Skip to content

Commit

Permalink
Add SourceCoordinate.getLocationQualifier(int startIndex, Source source)
Browse files Browse the repository at this point in the history
This is a helper method, useful for use when a parser uses just a start index instead of a SourceCoordinate or SourceSection object.

Signed-off-by: Stefan Marr <[email protected]>
  • Loading branch information
smarr committed May 6, 2022
1 parent 470e40d commit 0e008d3
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/bd/source/SourceCoordinate.java
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,12 @@ public static String getLocationQualifier(final SourceSection section) {
return ":" + section.getStartLine() + ":" + section.getStartColumn();
}

public static String getLocationQualifier(final int startIndex, final Source source) {
int lineNumber = source.getLineNumber(startIndex);
int column = source.getColumnNumber(startIndex);
return ":" + lineNumber + ":" + column;
}

public static String getURI(final Source source) {
return source.getURI().toString();
}
Expand Down

0 comments on commit 0e008d3

Please sign in to comment.