Search in sources :

Example 26 with TextDocumentIdentifier

use of org.eclipse.lsp4j.TextDocumentIdentifier in project xtext-core by eclipse.

the class PrepareRenameTest method testPrepareRenameFqn_end_ok.

@Test
public void testPrepareRenameFqn_end_ok() throws Exception {
    String model = "package foo.bar {\n" + "  type A {\n" + "    foo.bar.MyType bar\n" + "  }\n" + "  type MyType { }\n" + "}\n";
    initializeWithPrepareSupport();
    String uri = writeFile("my-type-valid.testlang", model);
    PrepareRenameParams params = new PrepareRenameParams(new TextDocumentIdentifier(uri), new Position(2, 18));
    Range range = languageServer.prepareRename(params).get().getLeft();
    assertEquals("MyType", new Document(0, model).getSubstring(range));
}
Also used : TextDocumentIdentifier(org.eclipse.lsp4j.TextDocumentIdentifier) Position(org.eclipse.lsp4j.Position) PrepareRenameParams(org.eclipse.lsp4j.PrepareRenameParams) Range(org.eclipse.lsp4j.Range) Document(org.eclipse.xtext.ide.server.Document) Test(org.junit.Test)

Example 27 with TextDocumentIdentifier

use of org.eclipse.lsp4j.TextDocumentIdentifier in project xtext-core by eclipse.

the class PrepareRenameTest method testPrepareRenameFqn_missing_file_null.

@Test
public void testPrepareRenameFqn_missing_file_null() throws Exception {
    String uri = uriExtensions.toUriString(new File("missing." + fileExtension).toURI().normalize());
    initializeWithPrepareSupport();
    PrepareRenameParams params = new PrepareRenameParams(new TextDocumentIdentifier(uri), new Position(2, 5));
    Assert.assertNull(languageServer.prepareRename(params).get());
}
Also used : TextDocumentIdentifier(org.eclipse.lsp4j.TextDocumentIdentifier) Position(org.eclipse.lsp4j.Position) PrepareRenameParams(org.eclipse.lsp4j.PrepareRenameParams) File(java.io.File) Test(org.junit.Test)

Example 28 with TextDocumentIdentifier

use of org.eclipse.lsp4j.TextDocumentIdentifier in project xtext-core by eclipse.

the class PrepareRenameTest method testPrepareRenameFqn_end_null.

@Test
public void testPrepareRenameFqn_end_null() throws Exception {
    String model = "package foo.bar {\n" + "  type A {\n" + "    foo.bar.MyType bar\n" + "  }\n" + "  type MyType { }\n" + "}\n";
    initialize();
    String uri = writeFile("my-type-valid.testlang", model);
    PrepareRenameParams params = new PrepareRenameParams(new TextDocumentIdentifier(uri), new Position(2, 18));
    Assert.assertNull(languageServer.prepareRename(params).get());
}
Also used : TextDocumentIdentifier(org.eclipse.lsp4j.TextDocumentIdentifier) Position(org.eclipse.lsp4j.Position) PrepareRenameParams(org.eclipse.lsp4j.PrepareRenameParams) Test(org.junit.Test)

Example 29 with TextDocumentIdentifier

use of org.eclipse.lsp4j.TextDocumentIdentifier in project xtext-core by eclipse.

the class PrepareRenameTest method testPrepareRenameFqn_before_nok.

@Test
public void testPrepareRenameFqn_before_nok() throws Exception {
    String model = "package foo.bar {\n" + "  type A {\n" + "    foo.bar.MyType bar\n" + "  }\n" + "  type MyType { }\n" + "}\n";
    initializeWithPrepareSupport();
    String uri = writeFile("my-type-valid.testlang", model);
    PrepareRenameParams params = new PrepareRenameParams(new TextDocumentIdentifier(uri), new Position(2, 11));
    Assert.assertNull(languageServer.prepareRename(params).get());
}
Also used : TextDocumentIdentifier(org.eclipse.lsp4j.TextDocumentIdentifier) Position(org.eclipse.lsp4j.Position) PrepareRenameParams(org.eclipse.lsp4j.PrepareRenameParams) Test(org.junit.Test)

Example 30 with TextDocumentIdentifier

use of org.eclipse.lsp4j.TextDocumentIdentifier in project xtext-core by eclipse.

the class PrepareRenameTest method testRenameFqn_invalid_null.

@Test
public void testRenameFqn_invalid_null() throws Exception {
    String model = "package foo.bar {\n" + "  type A {\n" + "    foo.bar.MyType bar\n" + "  }\n" + "  type MyType { }\n" + "}\n";
    String uri = writeFile("my-type-invalid.testlang", model);
    initializeWithPrepareSupport();
    RenameParams params = new RenameParams(new TextDocumentIdentifier(uri), new Position(2, 5), "Does not matter");
    Assert.assertNull(languageServer.rename(params).get());
}
Also used : TextDocumentIdentifier(org.eclipse.lsp4j.TextDocumentIdentifier) Position(org.eclipse.lsp4j.Position) PrepareRenameParams(org.eclipse.lsp4j.PrepareRenameParams) RenameParams(org.eclipse.lsp4j.RenameParams) Test(org.junit.Test)

Aggregations

TextDocumentIdentifier (org.eclipse.lsp4j.TextDocumentIdentifier)172 Test (org.junit.Test)113 Position (org.eclipse.lsp4j.Position)102 ICompilationUnit (org.eclipse.jdt.core.ICompilationUnit)56 Range (org.eclipse.lsp4j.Range)47 TextDocumentPositionParams (org.eclipse.lsp4j.TextDocumentPositionParams)37 Either (org.eclipse.lsp4j.jsonrpc.messages.Either)35 URI (java.net.URI)34 AbstractProjectsManagerBasedTest (org.eclipse.jdt.ls.core.internal.managers.AbstractProjectsManagerBasedTest)33 CodeActionContext (org.eclipse.lsp4j.CodeActionContext)32 CodeActionParams (org.eclipse.lsp4j.CodeActionParams)32 List (java.util.List)26 VersionedTextDocumentIdentifier (org.eclipse.lsp4j.VersionedTextDocumentIdentifier)25 Location (org.eclipse.lsp4j.Location)23 AbstractQuickFixTest (org.eclipse.jdt.ls.core.internal.correction.AbstractQuickFixTest)22 Command (org.eclipse.lsp4j.Command)22 PrepareRenameParams (org.eclipse.lsp4j.PrepareRenameParams)20 FormattingOptions (org.eclipse.lsp4j.FormattingOptions)19 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)18 CodeAction (org.eclipse.lsp4j.CodeAction)18