# HG changeset patch # User Michael Van De Vanter # Date 1425431506 28800 # Node ID 33bdafbf285dbe92f836e85b1974313621cfcb82 # Parent 787b5aa53401e8d94cf7bc920771fb2407e86a11 Truffle: SourceSection can now produce the line/column coordinates of its final character diff -r 787b5aa53401 -r 33bdafbf285d graal/com.oracle.truffle.api/src/com/oracle/truffle/api/source/NullSourceSection.java --- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/source/NullSourceSection.java Tue Mar 03 16:54:43 2015 -0800 +++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/source/NullSourceSection.java Tue Mar 03 17:11:46 2015 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -73,6 +73,14 @@ throw new UnsupportedOperationException(this.toString()); } + public int getEndLine() { + throw new UnsupportedOperationException(this.toString()); + } + + public int getEndColumn() { + throw new UnsupportedOperationException(this.toString()); + } + public final int getCharIndex() { throw new UnsupportedOperationException(this.toString()); } @@ -101,5 +109,4 @@ public String toString() { return getShortDescription(); } - } diff -r 787b5aa53401 -r 33bdafbf285d graal/com.oracle.truffle.api/src/com/oracle/truffle/api/source/Source.java --- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/source/Source.java Tue Mar 03 16:54:43 2015 -0800 +++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/source/Source.java Tue Mar 03 17:11:46 2015 -0800 @@ -851,6 +851,14 @@ return startColumn; } + public int getEndLine() { + return source.getLineNumber(charIndex + charLength - 1); + } + + public int getEndColumn() { + return source.getColumnNumber(charIndex + charLength - 1); + } + @Override public int getCharIndex() { return charIndex; @@ -939,7 +947,6 @@ } return true; } - } private static final class LineLocationImpl implements LineLocation { diff -r 787b5aa53401 -r 33bdafbf285d graal/com.oracle.truffle.api/src/com/oracle/truffle/api/source/SourceSection.java --- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/source/SourceSection.java Tue Mar 03 16:54:43 2015 -0800 +++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/source/SourceSection.java Tue Mar 03 17:11:46 2015 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -66,6 +66,20 @@ int getStartColumn(); /** + * Returns 1-based line number of the last character in this section (inclusive). + * + * @return the starting line number + */ + int getEndLine(); + + /** + * Returns the 1-based column number of the last character in this section (inclusive). + * + * @return the starting column number + */ + int getEndColumn(); + + /** * Returns the 0-based index of the first character in this section. * * @return the starting character index