use of org.graalvm.tools.lsp.server.types.Position in project graal by oracle.
the class SourceSectionReference method behind.
public boolean behind(Range range) {
Position end = range.getEnd();
int otherEndLine = end.getLine() + 1;
int otherEndColumn = end.getCharacter() + 1;
if (otherEndLine < this.startLine || otherEndLine == this.startLine && otherEndColumn < this.startColumn) {
// range is fully before us in the text
return true;
}
return false;
}
use of org.graalvm.tools.lsp.server.types.Position in project graal by oracle.
the class SourceSectionReference method before.
public boolean before(Range range) {
Position start = range.getStart();
int otherStartLine = start.getLine() + 1;
int otherStartColumn = start.getCharacter() + 1;
if (this.endLine < otherStartLine || this.endLine == otherStartLine && this.endColumn < otherStartColumn) {
// range is fully behind us in the text
return true;
}
return false;
}
use of org.graalvm.tools.lsp.server.types.Position in project graal by oracle.
the class SourceUtils method applyTextDocumentChanges.
public static String applyTextDocumentChanges(List<? extends TextDocumentContentChangeEvent> list, Source source, TextDocumentSurrogate surrogate, TruffleLogger logger) {
Source currentSource = null;
String text = source.getCharacters().toString();
StringBuilder sb = new StringBuilder(text);
for (TextDocumentContentChangeEvent event : list) {
if (currentSource == null) {
currentSource = source;
} else {
currentSource = Source.newBuilder(currentSource.getLanguage(), sb, currentSource.getName()).cached(false).build();
}
Range range = event.getRange();
if (range == null) {
// The whole file has changed
// Clear StringBuilder
sb.setLength(0);
sb.append(event.getText());
continue;
}
Position start = range.getStart();
Position end = range.getEnd();
int startLine = start.getLine() + 1;
int endLine = end.getLine() + 1;
int replaceBegin = currentSource.getLineStartOffset(startLine) + start.getCharacter();
int replaceEnd = currentSource.getLineStartOffset(endLine) + end.getCharacter();
sb.replace(replaceBegin, replaceEnd, event.getText());
if (surrogate != null && surrogate.hasCoverageData()) {
updateCoverageData(surrogate, currentSource, event.getText(), range, replaceBegin, replaceEnd, logger);
}
}
return sb.toString();
}
use of org.graalvm.tools.lsp.server.types.Position in project graal by oracle.
the class SourceSectionReference method includes.
public boolean includes(Range range) {
Position start = range.getStart();
Position end = range.getEnd();
int otherStartLine = start.getLine() + 1;
int otherEndLine = end.getLine() + 1;
if (this.startLine < otherStartLine && otherEndLine < this.endLine) {
// range is fully included and we do not have to check the columns
return true;
}
int otherStartColumn = start.getCharacter() + 1;
int otherEndColumn = end.getCharacter() + 1;
return (startLine < otherStartLine || startLine == otherStartLine && startColumn <= otherStartColumn) && (otherEndLine < endLine || otherEndLine == endLine && otherEndColumn <= endColumn);
}
Aggregations