Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed changes in comments while renaming #7724

Merged
merged 1 commit into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1473,7 +1473,6 @@ public boolean cancel(boolean mayInterruptIfRunning) {
refactoring[0] = new RenameRefactoring(Lookups.fixed(lookupContent.toArray(new Object[0])));
refactoring[0].getContext().add(JavaRefactoringUtils.getClasspathInfoFor(cc.getFileObject()));
refactoring[0].setNewName(params.getNewName());
refactoring[0].setSearchInComments(true); //TODO?
}
}, true);
if (cancel.get()) return ;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3794,6 +3794,13 @@ public void testRenameDocumentChangesCapabilitiesRenameOp() throws Exception {
Set<String> actual = edit.getDocumentChanges().stream().map(this::toString).collect(Collectors.toSet());
Set<String> expected = new HashSet<>(Arrays.asList("Test2.java:[0:27-0:31=>TestNew, 1:4-1:8=>TestNew, 2:11-2:15=>TestNew]", "Test.java:[0:13-0:17=>TestNew]", "Test.java=>TestNew.java"));
assertEquals(expected, actual);
},
cf -> {
WorkspaceEdit edit = cf.get();
assertTrue(edit.getChanges().isEmpty());
Set<String> actual = edit.getDocumentChanges().stream().map(this::toString).collect(Collectors.toSet());
Set<String> expected = new HashSet<>(Arrays.asList("Test3.java:[3:14-3:22=>arg, 6:36-6:44=>arg, 7:27-7:35=>arg]"));
assertEquals(expected, actual);
});
}

Expand All @@ -3818,12 +3825,20 @@ public void testRenameDocumentChangesCapabilitiesNoRenameOp() throws Exception {
Set<String> actual = edit.getDocumentChanges().stream().map(this::toString).collect(Collectors.toSet());
Set<String> expected = new HashSet<>(Arrays.asList("Test2.java:[0:27-0:31=>TestNew, 1:4-1:8=>TestNew, 2:11-2:15=>TestNew]", "Test.java:[0:13-0:17=>TestNew]", "Test.java=>TestNew.java"));
assertEquals(expected, actual);
},
cf -> {
WorkspaceEdit edit = cf.get();
assertTrue(edit.getChanges().isEmpty());
Set<String> actual = edit.getDocumentChanges().stream().map(this::toString).collect(Collectors.toSet());
Set<String> expected = new HashSet<>(Arrays.asList("Test3.java:[3:14-3:22=>arg, 6:36-6:44=>arg, 7:27-7:35=>arg]"));
assertEquals(expected, actual);
});
}

private void doTestRename(Consumer<InitializeParams> settings,
Validator<CompletableFuture<WorkspaceEdit>> validateFieldRename,
Validator<CompletableFuture<WorkspaceEdit>> validateClassRename) throws Exception {
Validator<CompletableFuture<WorkspaceEdit>> validateClassRename,
Validator<CompletableFuture<WorkspaceEdit>> validateArgumentRename) throws Exception {
File src = new File(getWorkDir(), "Test.java");
src.getParentFile().mkdirs();
try (Writer w = new FileWriter(new File(src.getParentFile(), ".test-project"))) {}
Expand All @@ -3842,6 +3857,20 @@ private void doTestRename(Consumer<InitializeParams> settings,
try (Writer w = new FileWriter(src2)) {
w.write(code2);
}
File src3 = new File(getWorkDir(), "Test3.java");
String code3 = "public class Test3 {\n" +
" /**\n" +
" * They had an argument\n" +
" * @param argument\n" +
" *\n" +
" */\n" +
" public static void greet(String argument){\n" +
" System.out.println(argument);\n" +
" }\n" +
"}";
try (Writer w = new FileWriter(src3)) {
w.write(code3);
}
List<Diagnostic>[] diags = new List[1];
CountDownLatch indexingComplete = new CountDownLatch(1);
Launcher<LanguageServer> serverLauncher = createClientLauncherWithLogging(new LspClient() {
Expand Down Expand Up @@ -3899,6 +3928,14 @@ public void logMessage(MessageParams arg0) {

validateClassRename.validate(server.getTextDocumentService().rename(params));
}
server.getTextDocumentService().didOpen(new DidOpenTextDocumentParams(new TextDocumentItem(toURI(src3), "java", 0, code3)));
{
RenameParams params = new RenameParams(new TextDocumentIdentifier(src3.toURI().toString()),
new Position(6, 37),
"arg");

validateArgumentRename.validate(server.getTextDocumentService().rename(params));
}
}

public void testMoveClass() throws Exception {
Expand Down
Loading