Java Code Examples for com.oracle.truffle.api.source.SourceSection#getStartLine()
The following examples show how to use
com.oracle.truffle.api.source.SourceSection#getStartLine() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HashemStatementNode.java From mr-hashemi with Universal Permissive License v1.0 | 6 votes |
/** * Formats a source section of a node in human readable form. If no source section could be * found it looks up the parent hierarchy until it finds a source section. Nodes where this was * required append a <code>'~'</code> at the end. * * @param node the node to format. * @return a formatted source section string */ public static String formatSourceSection(Node node) { if (node == null) { return "<unknown>"; } SourceSection section = node.getSourceSection(); boolean estimated = false; if (section == null) { section = node.getEncapsulatingSourceSection(); estimated = true; } if (section == null || section.getSource() == null) { return "<unknown source>"; } else { String sourceName = section.getSource().getName(); int startLine = section.getStartLine(); return String.format("%s:%d%s", sourceName, startLine, estimated ? "~" : ""); } }
Example 2
Source File: MumblerReadException.java From mumbler with GNU General Public License v3.0 | 6 votes |
@Override public Throwable fillInStackTrace() { SourceSection sourceSection = this.getSourceSection(); Source source = sourceSection != null ? sourceSection.getSource() : null; String sourceName = source != null ? source.getName() : null; int lineNumber; try { lineNumber = sourceSection != null ? sourceSection.getStartLine() : -1; } catch (UnsupportedOperationException e) { /* * SourceSection#getLineLocation() may throw an UnsupportedOperationException. */ lineNumber = -1; } StackTraceElement[] traces = new StackTraceElement[] { new StackTraceElement(filename(sourceName), this.getMethodName(), sourceName, lineNumber) }; this.setStackTrace(traces); return this; }
Example 3
Source File: DebuggerVisualizer.java From netbeans with Apache License 2.0 | 5 votes |
/** <File name>:<line number> */ static String getSourceLocation(SourceSection ss) { if (ss == null) { //System.err.println("No source section for node "+n); return "unknown"; } return ss.getSource().getName() + ":" + ss.getStartLine(); }
Example 4
Source File: SourcePosition.java From netbeans with Apache License 2.0 | 5 votes |
public SourcePosition(SourceSection sourceSection) { Source source = sourceSection.getSource(); this.id = getId(source); this.name = source.getName(); String sourcePath = source.getPath(); if (sourcePath == null) { sourcePath = name; } this.path = sourcePath; this.sourceSection = sourceSection.getStartLine() + "," + sourceSection.getStartColumn() + "," + sourceSection.getEndLine() + "," + sourceSection.getEndColumn(); this.code = source.getCharacters().toString(); this.uri = source.getURI(); }