@Override public int getLineStartOffset(Object impl, int lineNumber) { com.oracle.truffle.api.source.Source source = (com.oracle.truffle.api.source.Source) impl; return source.getLineStartOffset(lineNumber); }
@Override public int getLineStartOffset(Object impl, int lineNumber) { com.oracle.truffle.api.source.Source source = (com.oracle.truffle.api.source.Source) impl; return source.getLineStartOffset(lineNumber); }
/** * Creates a representation of a contiguous region of text in the source. Computes the * {@code (startLine, startColumn)} values by building a {@linkplain TextMap map} of lines in * the source. * <p> * Checks the position arguments for consistency with the source. * <p> * The resulting representation defines hash/equality around equivalent location, presuming that * {@link Source} representations are canonical. * * * @param identifier terse description of the region * @param charIndex 0-based position of the first character in the section * @param length the number of characters in the section * @return newly created object representing the specified region * @throws IllegalArgumentException if either of the arguments are outside the text of the * source * @throws IllegalStateException if the source is one of the "null" instances */ public final SourceSection createSection(String identifier, int charIndex, int length) throws IllegalArgumentException { checkRange(charIndex, length); checkTextMap(); final int startLine = getLineNumber(charIndex); final int startColumn = charIndex - getLineStartOffset(startLine) + 1; return new DefaultSourceSection(this, identifier, startLine, startColumn, charIndex, length); }
private static SourceSection findNearestBound(Source source, Set<Class<? extends Tag>> elementTags, int line, int column, SuspendAnchor anchor, TruffleInstrument.Env env) { int offset = source.getLineStartOffset(line); if (column > 0) { offset += column - 1;
private static SourceSection findNearestBound(Source source, Set<Class<? extends Tag>> elementTags, int line, int column, SuspendAnchor anchor, TruffleInstrument.Env env) { int offset = source.getLineStartOffset(line); if (column > 0) { offset += column - 1;