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 static PStm findStatementBaseCase(PStm stm, int lineno) { return stm.getLocation().getStartLine() == lineno ? stm : null; } }
public static PExp findExpressionBaseCase(PExp exp, int lineno) { return exp.getLocation().getStartLine() == lineno ? exp : null; }
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; }
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; }
protected StringBuilder breakpointResponse(Breakpoint bp) { StringBuilder sb = new StringBuilder(); sb.append("<breakpoint id=\"" + bp.number + "\""); sb.append(" type=\"line\""); sb.append(" state=\"" + (bp.isEnabled() ? "enabled" : "disabled") + "\""); sb.append(" filename=\"" + bp.location.getFile().toURI() + "\""); sb.append(" lineno=\"" + bp.location.getStartLine() + "\""); sb.append(">"); if (bp.trace != null) { sb.append("<expression>" + quote(bp.trace) + "</expression>"); } sb.append("</breakpoint>"); return sb; }
public static 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; }
public static List<Integer> getHitList(File file) { List<Integer> hits = new Vector<Integer>(); synchronized (allLocations) { for (ILexLocation l : allLocations) { if (l.getHits() > 0 && l.getFile().equals(file)) { hits.add(l.getStartLine()); } } } return hits; }
public List<Integer> getHitList(File file) { //FIXME skip lex location in other files // idea: if !lextLocation.getFile().equals(file) then continue; List<Integer> hits = new Vector<Integer>(); synchronized (allLocations) { for (ILexLocation l : allLocations) { if (l.getHits() > 0 && l.getFile().equals(file)) { hits.add(l.getStartLine()); } } } return hits; }
/** * Get a line of a source file. * * @param src * @return */ public String getSourceLine(ILexLocation src) { return getSourceLine(src.getFile(), src.getStartLine()); }
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 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 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; } }
@Override public String toString() { return "[Violation in module " + location.getModule() + ": '" + description + "'. Location: line " + location.getStartLine() + " at position: " + location.getStartPos() + " in " + location.getFile().getName() + "]"; }
protected void processCurrentLine(DBGPCommand c) throws DBGPException, IOException { if (status != DBGPStatus.BREAK && status != DBGPStatus.STOPPING || breakpoint == null) { throw new DBGPException(DBGPErrorCode.NOT_AVAILABLE, c.toString()); } OutputStream out = new ByteArrayOutputStream(); PrintWriter pw = new PrintWriter(out); pw.println(breakpoint.stoppedAtString()); pw.println(interpreter.getSourceLine(breakpoint.location.getFile(), breakpoint.location.getStartLine(), ": ")); pw.close(); cdataResponse(out.toString()); }
@Override protected boolean doSource(String line) { File file = breakpoint.location.getFile(); int current = breakpoint.location.getStartLine(); int start = current - SOURCE_LINES; if (start < 1) { start = 1; } int end = start + SOURCE_LINES * 2 + 1; for (int src = start; src < end; src++) { println(interpreter.getSourceLine(file, src, src == current ? ":>>" : ": ")); } return true; }
public String formatVdmSource(PIR irNode) { if (getJavaSettings().printVdmLocations() && irNode != null) { org.overture.ast.node.INode vdmNode = LocationAssistantIR.getVdmNode(irNode); if (vdmNode != null) { ILexLocation loc = info.getLocationAssistant().findLocation(vdmNode); if (loc != null) { return String.format("/* %s %d:%d */\n", loc.getFile().getName(), loc.getStartLine(), loc.getStartPos()); } } } return ""; }
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); }
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); }
public ILexNameToken getClassName() { // We don't know the class name of the name of a class until we've // read the name. So create a new location with the right module. LexLocation loc = new LexLocation(location.getFile(), name, location.getStartLine(), location.getStartPos(), location.getEndLine(), location.getEndPos(), location.getStartOffset(), location.getEndOffset()); return new LexNameToken("CLASS", name, loc); }