public static void addSpan(LexNameToken name, LexToken upto) { LexLocation span = new LexLocation(name.location.getFile(), name.location.getModule(), name.location.getStartLine(), name.location.getStartPos(), upto.location.getEndLine(), upto.location.getEndPos(), upto.location.getStartOffset(), upto.location.getEndOffset()); nameSpans.put(name, span); }
private static void initStatement(PStm result, ILexLocation token) { result.setLocation(token); if (token != null) { token.executable(true); } }
public static ASubclassResponsibilityExp newASubclassResponsibilityExp( ILexLocation location) { ASubclassResponsibilityExp result = new ASubclassResponsibilityExp(); initExpression(result, location); location.hit(); return result; }
public boolean within(ILexLocation span) { return (startLine > span.getStartLine() || startLine == span.getStartLine() && startPos >= span.getStartPos()) && (startLine <= span.getEndLine() || startLine == span.getEndLine() && startPos < span.getEndPos()) && file.equals(span.getFile()); }
@Override public String toString() { return "[Violation in module " + location.getModule() + ": '" + description + "'. Location: line " + location.getStartLine() + " at position: " + location.getStartPos() + " in " + location.getFile().getName() + "]"; }
protected StringBuilder stackResponse(ILexLocation location, int level) { StringBuilder sb = new StringBuilder(); sb.append("<stack level=\"" + level + "\""); sb.append(" type=\"file\""); sb.append(" filename=\"" + location.getFile().toURI() + "\""); sb.append(" lineno=\"" + location.getStartLine() + "\""); sb.append(" cmdbegin=\"" + location.getStartLine() + ":" + location.getStartPos() + "\""); sb.append("/>"); return sb; }
public List<Integer> getMissList(File file) { List<Integer> misses = new Vector<Integer>(); synchronized (allLocations) { for (ILexLocation l : allLocations) { if (l.getHits() == 0 && l.getFile().equals(file)) { misses.add(l.getStartLine()); } } } return misses; }
/** * Get a line of a source file. * * @param src * @return */ public String getSourceLine(ILexLocation src) { return getSourceLine(src.getFile(), src.getStartLine()); }
private String handleLocation(ILexLocation location) { if (location != null) { return location.getModule(); } else { return null; } } }
public int compareLocations(ILexLocation firstLoc, ILexLocation secondLoc) { String firstModule = firstLoc.getModule(); String secondModule = secondLoc.getModule(); if (!firstModule.equals(secondModule)) { return firstModule.compareTo(secondModule); } int firstLine = firstLoc.getStartLine(); int secondLine = secondLoc.getStartLine(); if (firstLine == secondLine) { int firstPos = firstLoc.getStartPos(); int secondPos = secondLoc.getStartPos(); return firstPos - secondPos; } else { return firstLine - secondLine; } }
public Map<Integer, List<ILexLocation>> getMissLocations(File file) { Map<Integer, List<ILexLocation>> map = new HashMap<Integer, List<ILexLocation>>(); synchronized (allLocations) { for (ILexLocation l : allLocations) { if (l.getExecutable() && l.getHits() == 0 && l.getFile().equals(file)) { List<ILexLocation> list = map.get(l.getStartLine()); if (list == null) { list = new Vector<ILexLocation>(); map.put(l.getStartLine(), list); } list.add(l); } } } return map; }
public Set<File> getSourceFiles() { Set<File> files = new HashSet<File>(); for (SClassDefinition def : this) { if (!(def instanceof ACpuClassDefinition || def instanceof ABusClassDefinition)) { files.add(def.getLocation().getFile()); } } return files; }
if (l.getStartLine() == lnum && l.getStartPos() == from && l.getEndPos() == to) l.setHits(l.getHits() + hits);
public static List<Integer> getSourceList(File file) { List<Integer> lines = new Vector<Integer>(); int last = 0; synchronized (allLocations) { for (ILexLocation l : allLocations) { if (l.getExecutable() && l.getStartLine() != last && l.getFile().equals(file)) { lines.add(l.getStartLine()); last = l.getStartLine(); } } } return lines; }
@Override public int compareTo(Renaming other) { if (loc.getModule() != null && other.loc.getModule() != null) { if (!loc.getModule().equals(other.loc.getModule())) { return other.loc.getModule().compareTo(loc.getModule()); } } ILexLocation otherLoc = other.getLoc(); return otherLoc.getStartOffset() - loc.getStartOffset(); } }
public static List<ILexLocation> getSourceLocations(File file) { List<ILexLocation> locations = new Vector<ILexLocation>(); synchronized (allLocations) { for (ILexLocation l : allLocations) { if (l.getExecutable() && l.getFile().equals(file)) { locations.add(l); } } } return locations; }
public static PStm findStatementBaseCase(PStm stm, int lineno) { return stm.getLocation().getStartLine() == lineno ? stm : null; } }
private ALocalDefinition pattern2DummyDef(PPattern pat) { ALocalDefinition r = AstFactory.newALocalDefinition(null, new LexNameToken("", "", pat.getLocation().clone()), NameScope.LOCAL, new AUnknownType()); return r; }
@Override public boolean equals(Object other) { if (other instanceof ILexLocation) { ILexLocation lother = (ILexLocation) other; return startPos == lother.getStartPos() && startLine == lother.getStartLine() && module.equals(lother.getModule()) && file.equals(lother.getFile()); } return false; }
public static void clearAfter(File file, int linecount, int charpos) { // Called from the LexTokenReader's pop method, to remove any // locations "popped". We assume any pushes are on the end of // the vector. synchronized (allLocations) { ListIterator<ILexLocation> it = allLocations.listIterator(allLocations.size()); while (it.hasPrevious()) { ILexLocation l = it.previous(); if (!l.getFile().equals(file) || l.getStartLine() < linecount || l.getStartLine() == linecount && l.getStartPos() < charpos) { break; } else { it.remove(); } } } }