Search in sources :

Example 46 with Position

use of org.eclipse.lsp4j.Position 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 47 with Position

use of org.eclipse.lsp4j.Position 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 48 with Position

use of org.eclipse.lsp4j.Position 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 49 with Position

use of org.eclipse.lsp4j.Position 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)

Example 50 with Position

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

the class RenamePositionTest method testBeyondEndOfFile.

@Test
public void testBeyondEndOfFile() {
    String model = "type Test";
    renameAndFail(model, new Position(0, model.length() + 1), "Invalid document position");
}
Also used : Position(org.eclipse.lsp4j.Position) Test(org.junit.Test) AbstractLanguageServerTest(org.eclipse.xtext.testing.AbstractLanguageServerTest)

Aggregations

Position (org.eclipse.lsp4j.Position)240 Test (org.junit.Test)149 Range (org.eclipse.lsp4j.Range)103 TextDocumentIdentifier (org.eclipse.lsp4j.TextDocumentIdentifier)95 AbstractProjectsManagerBasedTest (org.eclipse.jdt.ls.core.internal.managers.AbstractProjectsManagerBasedTest)73 ICompilationUnit (org.eclipse.jdt.core.ICompilationUnit)70 IPackageFragment (org.eclipse.jdt.core.IPackageFragment)50 TextDocumentPositionParams (org.eclipse.lsp4j.TextDocumentPositionParams)36 Location (org.eclipse.lsp4j.Location)34 List (java.util.List)29 WorkspaceEdit (org.eclipse.lsp4j.WorkspaceEdit)29 URI (java.net.URI)27 Either (org.eclipse.lsp4j.jsonrpc.messages.Either)23 ArrayList (java.util.ArrayList)21 PrepareRenameParams (org.eclipse.lsp4j.PrepareRenameParams)18 TextEdit (org.eclipse.lsp4j.TextEdit)15 CompletionList (org.eclipse.lsp4j.CompletionList)14 Document (org.eclipse.xtext.ide.server.Document)14 VersionedTextDocumentIdentifier (org.eclipse.lsp4j.VersionedTextDocumentIdentifier)13 Command (org.eclipse.lsp4j.Command)12