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; }
@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; } }
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(); } } } }
@Override public String toString() { return "[Violation in module " + location.getModule() + ": '" + description + "'. Location: line " + location.getStartLine() + " at position: " + location.getStartPos() + " in " + location.getFile().getName() + "]"; }
private String markup(String line, List<ILexLocation> list) { if (list == null) { return line; } else { StringBuilder sb = new StringBuilder(); int p = 0; for (ILexLocation m : list) { int start = m.getStartPos() - 1; int end = m.getStartLine() == m.getEndLine() ? m.getEndPos() - 1 : line.length(); if (start >= p) // Backtracker produces duplicate tokens { sb.append(line.substring(p, start)); sb.append(LST_ESCAPE_BEGIN + "\\vdmnotcovered{"); sb.append(latexQuote(line.substring(start, end))); sb.append("}" + LST_ESCAPE_END); // \u00A3"); p = end; } } sb.append(line.substring(p)); return sb.toString(); } }
if (l.getStartLine() == lnum && l.getStartPos() == from && l.getEndPos() == to)
private String markupHTML(String line, List<ILexLocation> list) { if (line.isEmpty()) { return htmlLine(); } StringBuilder sb = new StringBuilder(HTMLSTART); int p = 0; if (list != null) { for (ILexLocation m : list) { int start = m.getStartPos() - 1; int end = m.getStartLine() == m.getEndLine() ? m.getEndPos() - 1 : line.length(); if (start >= p) // Backtracker produces duplicate tokens { sb.append(htmlQuote(line.substring(p, start))); sb.append("<span style='color:red'>"); sb.append(htmlQuote(line.substring(start, end))); sb.append("</span>"); p = end; } } } sb.append(htmlQuote(line.substring(p))); sb.append(HTMLEND); return sb.toString(); }
((ILexLocation)loc).getStartLine() + "p" + ((ILexLocation)loc).getStartPos(), loc -> new Vector<ILexLocation>(Arrays.asList(loc)), merge)
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()); }
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); }
public static void printUnsupportedIrNodes( Set<VdmNodeInfo> unsupportedNodes) { AssistantManager assistantManager = new AssistantManager(); LocationAssistantIR locationAssistant = assistantManager.getLocationAssistant(); List<VdmNodeInfo> nodesSorted = locationAssistant.getVdmNodeInfoLocationSorted(unsupportedNodes); for (VdmNodeInfo vdmNodeInfo : nodesSorted) { MsgPrinter.getPrinter().print(vdmNodeInfo.getNode().toString() + " (" + vdmNodeInfo.getNode().getClass().getSimpleName() + ")"); ILexLocation location = locationAssistant.findLocation(vdmNodeInfo.getNode()); MsgPrinter.getPrinter().print(location != null ? " at [line, pos] = [" + location.getStartLine() + ", " + location.getStartPos() + "] in " + location.getFile().getName() : ""); String reason = vdmNodeInfo.getReason(); if (reason != null) { MsgPrinter.getPrinter().print(". Reason: " + reason); } MsgPrinter.getPrinter().println(""); } }
+ location.getStartPos() + "] in " + location.getFile() : "");
tuple.add(new NaturalOneValue(ctxt.location.getStartPos())); tuple.add(new SeqValue(ctxt.location.getModule()));
if (storage != null) storage.StartTrace(mtd.getName().getName(), mtd.getLocation().getFile().getName(), mtd.getLocation().getStartLine(), mtd.getLocation().getStartPos(), size, new Float(subset), TraceReductionType.valueOf(traceReductionType.toString()), new Long(seed));