use of org.eclipse.lsp4j.PrepareRenameResult in project eclipse.jdt.ls by eclipse.
the class PrepareRenameHandlerTest method testRenameJavadoc.
@Test
public void testRenameJavadoc() throws JavaModelException, BadLocationException {
IPackageFragment pack1 = sourceFolder.createPackageFragment("test1", false, null);
String[] codes = { "package test1;\n", "public class E {\n", " /**\n", " *@param i int\n", " */\n", " public int foo(int i|*) {\n", " E e = new E();\n", " e.foo();\n", " }\n", "}\n" };
StringBuilder builder = new StringBuilder();
Position pos = mergeCode(builder, codes);
ICompilationUnit cu = pack1.createCompilationUnit("E.java", builder.toString(), false, null);
Either<Range, PrepareRenameResult> result = prepareRename(cu, pos, "i2");
assertNotNull(result.getLeft());
assertTrue(result.getLeft().getStart().getLine() > 0);
}
use of org.eclipse.lsp4j.PrepareRenameResult in project eclipse.jdt.ls by eclipse.
the class PrepareRenameHandlerTest method testRenameLocalVariable.
@Test
public void testRenameLocalVariable() throws JavaModelException, BadLocationException {
IPackageFragment pack1 = sourceFolder.createPackageFragment("test1", false, null);
String[] codes = { "package test1;\n", "public class E {\n", " public int bar() {\n", " String str = new String();\n", " str.length();\n", " }\n", " public int foo() {\n", " String str = new String();\n", " str|*.length()\n", " }\n", "}\n" };
StringBuilder builder = new StringBuilder();
Position pos = mergeCode(builder, codes);
ICompilationUnit cu = pack1.createCompilationUnit("E.java", builder.toString(), false, null);
Either<Range, PrepareRenameResult> result = prepareRename(cu, pos, "newname");
assertNotNull(result.getLeft());
assertTrue(result.getLeft().getStart().getLine() > 0);
}
use of org.eclipse.lsp4j.PrepareRenameResult in project eclipse.jdt.ls by eclipse.
the class PrepareRenameHandlerTest method testRenameTypeWithResourceChanges.
@Test
public void testRenameTypeWithResourceChanges() throws JavaModelException, BadLocationException {
when(clientPreferences.isResourceOperationSupported()).thenReturn(true);
IPackageFragment pack1 = sourceFolder.createPackageFragment("test1", false, null);
String[] codes = { "package test1;\n", "public class E|* {\n", " public E() {\n", " }\n", " public int bar() {\n", " }\n", " public int foo() {\n", " this.bar();\n", " }\n", "}\n" };
StringBuilder builder = new StringBuilder();
Position pos = mergeCode(builder, codes);
ICompilationUnit cu = pack1.createCompilationUnit("E.java", builder.toString(), false, null);
Either<Range, PrepareRenameResult> result = prepareRename(cu, pos, "Newname");
assertNotNull(result.getLeft());
assertTrue(result.getLeft().getStart().getLine() > 0);
}
use of org.eclipse.lsp4j.PrepareRenameResult in project eclipse.jdt.ls by eclipse.
the class PrepareRenameHandlerTest method testRenameParameter.
@Test
public void testRenameParameter() throws JavaModelException, BadLocationException {
IPackageFragment pack1 = sourceFolder.createPackageFragment("test1", false, null);
String[] codes = { "package test1;\n", "public class E {\n", " public int foo(String str) {\n", " str|*.length();\n", " }\n", " public int bar(String str) {\n", " str.length();\n", " }\n", "}\n" };
StringBuilder builder = new StringBuilder();
Position pos = mergeCode(builder, codes);
ICompilationUnit cu = pack1.createCompilationUnit("E.java", builder.toString(), false, null);
Either<Range, PrepareRenameResult> result = prepareRename(cu, pos, "newname");
assertNotNull(result.getLeft());
assertTrue(result.getLeft().getStart().getLine() > 0);
}
use of org.eclipse.lsp4j.PrepareRenameResult in project eclipse.jdt.ls by eclipse.
the class PrepareRenameHandlerTest method testRenameField.
@Test
public void testRenameField() throws JavaModelException, BadLocationException {
IPackageFragment pack1 = sourceFolder.createPackageFragment("test1", false, null);
String[] codes = { "package test1;\n", "public class E {\n", " private int myValue = 2;\n", " public void bar() {\n", " myValue|* = 3;\n", " }\n", "}\n" };
StringBuilder builder = new StringBuilder();
Position pos = mergeCode(builder, codes);
ICompilationUnit cu = pack1.createCompilationUnit("E.java", builder.toString(), false, null);
Either<Range, PrepareRenameResult> result = prepareRename(cu, pos, "newname");
assertNotNull(result.getLeft());
assertTrue(result.getLeft().getStart().getLine() > 0);
}
Aggregations