comparison graal/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/DefaultSourceSection.java @ 15371:c54f5fa05fd5

Truffle: add getShortName and getShortDescription to Source and SourceSection for when we don't need full paths.
author Chris Seaton <chris.seaton@oracle.com>
date Thu, 24 Apr 2014 23:29:04 +0100
parents 5f532ea846fb
children
comparison
equal deleted inserted replaced
15365:0aed1c2d0caa 15371:c54f5fa05fd5
51 * </ul> 51 * </ul>
52 * The <b>newline</b> that terminates each line counts as a single character for the purpose of 52 * The <b>newline</b> that terminates each line counts as a single character for the purpose of
53 * a character index. The (row,column) coordinates of a newline character should never appear in 53 * a character index. The (row,column) coordinates of a newline character should never appear in
54 * a text section. 54 * a text section.
55 * <p> 55 * <p>
56 * 56 *
57 * @param source object representing the complete source program that contains this section 57 * @param source object representing the complete source program that contains this section
58 * @param identifier an identifier used when printing the section 58 * @param identifier an identifier used when printing the section
59 * @param startLine the 1-based number of the start line of the section 59 * @param startLine the 1-based number of the start line of the section
60 * @param startColumn the 1-based number of the start column of the section 60 * @param startColumn the 1-based number of the start column of the section
61 * @param charIndex the 0-based index of the first character of the section 61 * @param charIndex the 0-based index of the first character of the section
98 return identifier; 98 return identifier;
99 } 99 }
100 100
101 public final String getCode() { 101 public final String getCode() {
102 return getSource().getCode().substring(charIndex, charIndex + charLength); 102 return getSource().getCode().substring(charIndex, charIndex + charLength);
103 }
104
105 public final String getShortDescription() {
106 return String.format("%s:%d", source.getShortName(), startLine);
103 } 107 }
104 108
105 @Override 109 @Override
106 public String toString() { 110 public String toString() {
107 return String.format("%s:%d", source.getName(), startLine); 111 return String.format("%s:%d", source.getName(), startLine);