@Override public CharSequence getCharacters() { if (!isValid()) { return ""; } return source.getCharacters().subSequence(getCharIndex(), getCharEndIndex()); }
@Override public int getEndLine() { if (!isValid()) { return 1; } return source.getLineNumber(getCharIndex() + Math.max(0, getCharLength() - 1)); }
/** * Returns whether the source section is in bounds of the {@link #getSource() source} * {@link Source#getCharacters() code}. Please note that calling this method causes the * {@link Source#getCharacters() code} of the {@link #getSource() source} to be loaded if it was * not yet loaded. */ @Override boolean isValid() { return charIndex + charLength <= getSource().getCharacters().length(); }
@Override public int getCharEndIndex() { return getCharIndex() + getCharLength(); }
@Override public int getStartLine() { if (!isValid()) { return 1; } return source.getLineNumber(getCharIndex()); }
section = new SourceSectionLoaded(this, charIndex, length); assert assertValid(section); } else {
@Override public int hashCode() { if (!isAvailable()) { return System.identityHashCode(this); } final int prime = 31; int result = 1; result = prime * result + charIndex; result = prime * result + charLength; result = prime * result + source.hashCode(); return result; }
@Override public int getStartColumn() { if (!isValid()) { return 1; } return source.getColumnNumber(getCharIndex()); }
throw new IllegalArgumentException("charIndex out of range"); SourceSection section = new SourceSectionLoaded(this, charIndex, length); assert assertValid(section); return section;
@Override public int getEndColumn() { if (!isValid()) { return 1; } return source.getColumnNumber(getCharIndex() + Math.max(0, getCharLength() - 1)); }
throw new IllegalArgumentException("end position out of range"); SourceSection section = new SourceSectionLoaded(this, charIndex, length); assert assertValid(section); return section;
final int charIndex = getTextMap().lineStartOffset(lineNumber); final int length = getTextMap().lineLength(lineNumber); section = new SourceSectionLoaded(this, charIndex, length); assert assertValid(section); } else {