Skip to content

Commit

Permalink
fixup! Calculate change length from range instead of rangeLength
Browse files Browse the repository at this point in the history
  • Loading branch information
mfussenegger committed Nov 5, 2021
1 parent 3948d0f commit 77911bd
Showing 1 changed file with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,7 @@ public void testNotExpectedPackage() throws Exception {
String source = cu.getSource();
int length = source.length();
source = source.replace("org", "org.eclipse");
changeDocument(cu, source, 2, JDTUtils.toRange(cu, 0, length), length);
changeDocument(cu, source, 2, JDTUtils.toRange(cu, 0, length));
FileUtils.writeStringToFile(file, source);
saveDocument(cu);
cu = JDTUtils.resolveCompilationUnit(uri);
Expand Down Expand Up @@ -725,7 +725,7 @@ public void testNotExpectedPackage2() throws Exception {
String source = cu.getSource();
int length = source.length();
source = source.replace("org", "org.eclipse");
changeDocument(cu, source, 2, JDTUtils.toRange(cu, 0, length), length);
changeDocument(cu, source, 2, JDTUtils.toRange(cu, 0, length));
FileUtils.writeStringToFile(file, source);
saveDocument(cu);
cu = JDTUtils.resolveCompilationUnit(uri);
Expand All @@ -736,7 +736,7 @@ public void testNotExpectedPackage2() throws Exception {
source = cu.getSource();
length = source.length();
source = source.replace("org.eclipse", "org.eclipse.toto");
changeDocument(cu, source, 3, JDTUtils.toRange(cu, 0, length), length);
changeDocument(cu, source, 3, JDTUtils.toRange(cu, 0, length));
FileUtils.writeStringToFile(file, source);
saveDocument(cu);
cu = JDTUtils.resolveCompilationUnit(uri);
Expand Down Expand Up @@ -852,14 +852,14 @@ private void openDocument(String uri, String content, int version) {

private void changeDocumentIncrementally(ICompilationUnit cu, String content, int version, int offset, int length) throws JavaModelException {
Range range = JDTUtils.toRange(cu, offset, length);
changeDocument(cu, content, version, range, length);
changeDocument(cu, content, version, range);
}

private void changeDocumentFull(ICompilationUnit cu, String content, int version) throws JavaModelException {
changeDocument(cu, content, version, null, 0);
changeDocument(cu, content, version, null);
}

private void changeDocument(ICompilationUnit cu, String content, int version, Range range, int length) throws JavaModelException {
private void changeDocument(ICompilationUnit cu, String content, int version, Range range) throws JavaModelException {
DidChangeTextDocumentParams changeParms = new DidChangeTextDocumentParams();
VersionedTextDocumentIdentifier textDocument = new VersionedTextDocumentIdentifier();
textDocument.setUri(JDTUtils.toURI(cu));
Expand All @@ -868,7 +868,6 @@ private void changeDocument(ICompilationUnit cu, String content, int version, Ra
TextDocumentContentChangeEvent event = new TextDocumentContentChangeEvent();
if (range != null) {
event.setRange(range);
event.setRangeLength(length);
}
event.setText(content);
List<TextDocumentContentChangeEvent> contentChanges = new ArrayList<>();
Expand Down

0 comments on commit 77911bd

Please sign in to comment.