mirror of
https://github.com/sigmasternchen/xtext-core
synced 2025-03-15 08:18:55 +00:00
Merge pull request #1393 from eclipse/cd_lsp4j090_part2b
[#1244]Update to LSP4J 0.9.0 Part 2
This commit is contained in:
commit
b0cb8a8397
28 changed files with 367 additions and 332 deletions
|
@ -17,7 +17,6 @@ import org.eclipse.lsp4j.RenameCapabilities
|
|||
import org.eclipse.lsp4j.RenameParams
|
||||
import org.eclipse.lsp4j.TextDocumentClientCapabilities
|
||||
import org.eclipse.lsp4j.TextDocumentIdentifier
|
||||
import org.eclipse.lsp4j.TextDocumentPositionParams
|
||||
import org.eclipse.lsp4j.jsonrpc.ResponseErrorException
|
||||
import org.eclipse.xtext.ide.server.Document
|
||||
import org.eclipse.xtext.ide.server.UriExtensions
|
||||
|
@ -25,6 +24,7 @@ import org.junit.Test
|
|||
|
||||
import static org.junit.Assert.*
|
||||
import java.io.FileNotFoundException
|
||||
import org.eclipse.lsp4j.PrepareRenameParams
|
||||
|
||||
class PrepareRenameTest extends AbstractTestLangLanguageServerTest {
|
||||
|
||||
|
@ -45,7 +45,7 @@ class PrepareRenameTest extends AbstractTestLangLanguageServerTest {
|
|||
val uri = new File('''missing.«fileExtension»''').toURI.normalize.toUriString
|
||||
initializeWithPrepareSupport()
|
||||
|
||||
val params = new TextDocumentPositionParams(new TextDocumentIdentifier(uri), new Position(2, 5))
|
||||
val params = new PrepareRenameParams(new TextDocumentIdentifier(uri), new Position(2, 5))
|
||||
assertNull(languageServer.prepareRename(params).get)
|
||||
}
|
||||
|
||||
|
@ -54,7 +54,7 @@ class PrepareRenameTest extends AbstractTestLangLanguageServerTest {
|
|||
val uri = new File('''missing.«fileExtension»''').toURI.normalize.toUriString
|
||||
initialize()
|
||||
|
||||
val params = new TextDocumentPositionParams(new TextDocumentIdentifier(uri), new Position(2, 5))
|
||||
val params = new PrepareRenameParams(new TextDocumentIdentifier(uri), new Position(2, 5))
|
||||
try {
|
||||
assertNull(languageServer.prepareRename(params).get)
|
||||
fail('Expected an error.')
|
||||
|
@ -140,7 +140,7 @@ class PrepareRenameTest extends AbstractTestLangLanguageServerTest {
|
|||
|
||||
val uri = 'my-type-valid.testlang'.writeFile(model)
|
||||
|
||||
val params = new TextDocumentPositionParams(new TextDocumentIdentifier(uri), new Position(2, 11))
|
||||
val params = new PrepareRenameParams(new TextDocumentIdentifier(uri), new Position(2, 11))
|
||||
assertNull(languageServer.prepareRename(params).get)
|
||||
}
|
||||
|
||||
|
@ -158,7 +158,7 @@ class PrepareRenameTest extends AbstractTestLangLanguageServerTest {
|
|||
|
||||
val uri = 'my-type-valid.testlang'.writeFile(model)
|
||||
|
||||
val params = new TextDocumentPositionParams(new TextDocumentIdentifier(uri), new Position(2, 12))
|
||||
val params = new PrepareRenameParams(new TextDocumentIdentifier(uri), new Position(2, 12))
|
||||
val range = languageServer.prepareRename(params).get.getLeft
|
||||
assertEquals('MyType', new Document(0, model).getSubstring(range))
|
||||
}
|
||||
|
@ -177,7 +177,7 @@ class PrepareRenameTest extends AbstractTestLangLanguageServerTest {
|
|||
|
||||
val uri = 'my-type-valid.testlang'.writeFile(model)
|
||||
|
||||
val params = new TextDocumentPositionParams(new TextDocumentIdentifier(uri), new Position(2, 14))
|
||||
val params = new PrepareRenameParams(new TextDocumentIdentifier(uri), new Position(2, 14))
|
||||
val range = languageServer.prepareRename(params).get.getLeft
|
||||
assertEquals('MyType', new Document(0, model).getSubstring(range))
|
||||
}
|
||||
|
@ -196,7 +196,7 @@ class PrepareRenameTest extends AbstractTestLangLanguageServerTest {
|
|||
|
||||
val uri = 'my-type-valid.testlang'.writeFile(model)
|
||||
|
||||
val params = new TextDocumentPositionParams(new TextDocumentIdentifier(uri), new Position(2, 18))
|
||||
val params = new PrepareRenameParams(new TextDocumentIdentifier(uri), new Position(2, 18))
|
||||
val range = languageServer.prepareRename(params).get.getLeft
|
||||
assertEquals('MyType', new Document(0, model).getSubstring(range))
|
||||
}
|
||||
|
@ -215,7 +215,7 @@ class PrepareRenameTest extends AbstractTestLangLanguageServerTest {
|
|||
|
||||
val uri = 'my-type-valid.testlang'.writeFile(model)
|
||||
|
||||
val params = new TextDocumentPositionParams(new TextDocumentIdentifier(uri), new Position(2, 18))
|
||||
val params = new PrepareRenameParams(new TextDocumentIdentifier(uri), new Position(2, 18))
|
||||
assertNull(languageServer.prepareRename(params).get)
|
||||
}
|
||||
|
||||
|
|
|
@ -11,11 +11,11 @@ package org.eclipse.xtext.ide.tests.server
|
|||
import com.google.common.base.Throwables
|
||||
import org.eclipse.lsp4j.ClientCapabilities
|
||||
import org.eclipse.lsp4j.Position
|
||||
import org.eclipse.lsp4j.PrepareRenameParams
|
||||
import org.eclipse.lsp4j.RenameCapabilities
|
||||
import org.eclipse.lsp4j.RenameParams
|
||||
import org.eclipse.lsp4j.TextDocumentClientCapabilities
|
||||
import org.eclipse.lsp4j.TextDocumentIdentifier
|
||||
import org.eclipse.lsp4j.TextDocumentPositionParams
|
||||
import org.eclipse.lsp4j.jsonrpc.ResponseErrorException
|
||||
import org.eclipse.xtext.ide.server.Document
|
||||
import org.eclipse.xtext.testing.AbstractLanguageServerTest
|
||||
|
@ -79,7 +79,7 @@ class RenamePositionTest extends AbstractLanguageServerTest {
|
|||
initialize
|
||||
try {
|
||||
val identifier = new TextDocumentIdentifier(modelFile)
|
||||
val prepareRenameResult = languageServer.prepareRename(new TextDocumentPositionParams(identifier, position)).get
|
||||
val prepareRenameResult = languageServer.prepareRename(new PrepareRenameParams(identifier, position)).get
|
||||
assertNull('''expected null result got «prepareRenameResult» instead''', prepareRenameResult)
|
||||
val renameParams = new RenameParams(new TextDocumentIdentifier(modelFile), position, 'Tescht')
|
||||
languageServer.rename(renameParams).get
|
||||
|
@ -104,7 +104,7 @@ class RenamePositionTest extends AbstractLanguageServerTest {
|
|||
]
|
||||
]
|
||||
val identifier = new TextDocumentIdentifier(modelFile)
|
||||
val range = languageServer.prepareRename(new TextDocumentPositionParams(identifier, position)).get.getLeft
|
||||
val range = languageServer.prepareRename(new PrepareRenameParams(identifier, position)).get.getLeft
|
||||
assertNotNull(range)
|
||||
assertEquals(new Document(0, model).getSubstring(range), 'Test')
|
||||
val params = new RenameParams(identifier, position, 'Tescht')
|
||||
|
|
|
@ -10,11 +10,11 @@ package org.eclipse.xtext.ide.tests.server
|
|||
|
||||
import org.eclipse.lsp4j.ClientCapabilities
|
||||
import org.eclipse.lsp4j.Position
|
||||
import org.eclipse.lsp4j.PrepareRenameParams
|
||||
import org.eclipse.lsp4j.RenameCapabilities
|
||||
import org.eclipse.lsp4j.RenameParams
|
||||
import org.eclipse.lsp4j.TextDocumentClientCapabilities
|
||||
import org.eclipse.lsp4j.TextDocumentIdentifier
|
||||
import org.eclipse.lsp4j.TextDocumentPositionParams
|
||||
import org.eclipse.lsp4j.WorkspaceClientCapabilities
|
||||
import org.eclipse.lsp4j.WorkspaceEditCapabilities
|
||||
import org.eclipse.xtext.ide.server.Document
|
||||
|
@ -43,7 +43,7 @@ class RenameTest2 extends AbstractLanguageServerTest {
|
|||
initialize
|
||||
val identifier = new TextDocumentIdentifier(file)
|
||||
val position = new Position(2, 9)
|
||||
val range = languageServer.prepareRename(new TextDocumentPositionParams(identifier, position)).get.getLeft
|
||||
val range = languageServer.prepareRename(new PrepareRenameParams(identifier, position)).get.getLeft
|
||||
assertEquals('Foo', new Document(0, model).getSubstring(range))
|
||||
val params = new RenameParams(identifier, position, 'Bar')
|
||||
val workspaceEdit = languageServer.rename(params).get
|
||||
|
@ -73,7 +73,7 @@ class RenameTest2 extends AbstractLanguageServerTest {
|
|||
|
||||
val identifier = new TextDocumentIdentifier(file)
|
||||
val position = new Position(2, 9)
|
||||
val range = languageServer.prepareRename(new TextDocumentPositionParams(identifier, position)).get.getLeft
|
||||
val range = languageServer.prepareRename(new PrepareRenameParams(identifier, position)).get.getLeft
|
||||
assertEquals('Foo', new Document(0, model).getSubstring(range))
|
||||
val params = new RenameParams(identifier, position, 'Baz')
|
||||
val workspaceEdit = languageServer.rename(params).get
|
||||
|
|
|
@ -13,13 +13,13 @@ import org.eclipse.lsp4j.DidChangeWatchedFilesParams
|
|||
import org.eclipse.lsp4j.FileChangeType
|
||||
import org.eclipse.lsp4j.FileEvent
|
||||
import org.eclipse.lsp4j.TextDocumentIdentifier
|
||||
import org.eclipse.lsp4j.TextDocumentPositionParams
|
||||
import org.eclipse.lsp4j.jsonrpc.ResponseErrorException
|
||||
import org.eclipse.lsp4j.jsonrpc.messages.ResponseErrorCode
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
|
||||
import static org.junit.Assert.*
|
||||
import org.eclipse.lsp4j.DefinitionParams
|
||||
|
||||
/**
|
||||
* @author Sven Efftinge - Initial contribution and API
|
||||
|
@ -132,7 +132,7 @@ class ServerTest extends AbstractTestLangLanguageServerTest {
|
|||
@Test
|
||||
def void testMissingInitialize() {
|
||||
try {
|
||||
languageServer.definition(new TextDocumentPositionParams => [
|
||||
languageServer.definition(new DefinitionParams => [
|
||||
textDocument = new TextDocumentIdentifier => [
|
||||
uri = 'file:/home/test/workspace/mydoc.testlang'
|
||||
]
|
||||
|
|
|
@ -16,12 +16,12 @@ import org.eclipse.lsp4j.ClientCapabilities;
|
|||
import org.eclipse.lsp4j.InitializeParams;
|
||||
import org.eclipse.lsp4j.InitializeResult;
|
||||
import org.eclipse.lsp4j.Position;
|
||||
import org.eclipse.lsp4j.PrepareRenameParams;
|
||||
import org.eclipse.lsp4j.Range;
|
||||
import org.eclipse.lsp4j.RenameCapabilities;
|
||||
import org.eclipse.lsp4j.RenameParams;
|
||||
import org.eclipse.lsp4j.TextDocumentClientCapabilities;
|
||||
import org.eclipse.lsp4j.TextDocumentIdentifier;
|
||||
import org.eclipse.lsp4j.TextDocumentPositionParams;
|
||||
import org.eclipse.lsp4j.WorkspaceEdit;
|
||||
import org.eclipse.lsp4j.jsonrpc.ResponseErrorException;
|
||||
import org.eclipse.lsp4j.jsonrpc.messages.ResponseError;
|
||||
|
@ -69,7 +69,7 @@ public class PrepareRenameTest extends AbstractTestLangLanguageServerTest {
|
|||
this.initializeWithPrepareSupport();
|
||||
TextDocumentIdentifier _textDocumentIdentifier = new TextDocumentIdentifier(uri);
|
||||
Position _position = new Position(2, 5);
|
||||
final TextDocumentPositionParams params = new TextDocumentPositionParams(_textDocumentIdentifier, _position);
|
||||
final PrepareRenameParams params = new PrepareRenameParams(_textDocumentIdentifier, _position);
|
||||
Assert.assertNull(this.languageServer.prepareRename(params).get());
|
||||
} catch (Throwable _e) {
|
||||
throw Exceptions.sneakyThrow(_e);
|
||||
|
@ -85,7 +85,7 @@ public class PrepareRenameTest extends AbstractTestLangLanguageServerTest {
|
|||
this.initialize();
|
||||
TextDocumentIdentifier _textDocumentIdentifier = new TextDocumentIdentifier(uri);
|
||||
Position _position = new Position(2, 5);
|
||||
final TextDocumentPositionParams params = new TextDocumentPositionParams(_textDocumentIdentifier, _position);
|
||||
final PrepareRenameParams params = new PrepareRenameParams(_textDocumentIdentifier, _position);
|
||||
try {
|
||||
Assert.assertNull(this.languageServer.prepareRename(params).get());
|
||||
Assert.fail("Expected an error.");
|
||||
|
@ -242,7 +242,7 @@ public class PrepareRenameTest extends AbstractTestLangLanguageServerTest {
|
|||
final String uri = this.writeFile("my-type-valid.testlang", model);
|
||||
TextDocumentIdentifier _textDocumentIdentifier = new TextDocumentIdentifier(uri);
|
||||
Position _position = new Position(2, 11);
|
||||
final TextDocumentPositionParams params = new TextDocumentPositionParams(_textDocumentIdentifier, _position);
|
||||
final PrepareRenameParams params = new PrepareRenameParams(_textDocumentIdentifier, _position);
|
||||
Assert.assertNull(this.languageServer.prepareRename(params).get());
|
||||
} catch (Throwable _e) {
|
||||
throw Exceptions.sneakyThrow(_e);
|
||||
|
@ -274,7 +274,7 @@ public class PrepareRenameTest extends AbstractTestLangLanguageServerTest {
|
|||
final String uri = this.writeFile("my-type-valid.testlang", model);
|
||||
TextDocumentIdentifier _textDocumentIdentifier = new TextDocumentIdentifier(uri);
|
||||
Position _position = new Position(2, 12);
|
||||
final TextDocumentPositionParams params = new TextDocumentPositionParams(_textDocumentIdentifier, _position);
|
||||
final PrepareRenameParams params = new PrepareRenameParams(_textDocumentIdentifier, _position);
|
||||
final Range range = this.languageServer.prepareRename(params).get().getLeft();
|
||||
this.assertEquals("MyType", new Document(Integer.valueOf(0), model).getSubstring(range));
|
||||
} catch (Throwable _e) {
|
||||
|
@ -307,7 +307,7 @@ public class PrepareRenameTest extends AbstractTestLangLanguageServerTest {
|
|||
final String uri = this.writeFile("my-type-valid.testlang", model);
|
||||
TextDocumentIdentifier _textDocumentIdentifier = new TextDocumentIdentifier(uri);
|
||||
Position _position = new Position(2, 14);
|
||||
final TextDocumentPositionParams params = new TextDocumentPositionParams(_textDocumentIdentifier, _position);
|
||||
final PrepareRenameParams params = new PrepareRenameParams(_textDocumentIdentifier, _position);
|
||||
final Range range = this.languageServer.prepareRename(params).get().getLeft();
|
||||
this.assertEquals("MyType", new Document(Integer.valueOf(0), model).getSubstring(range));
|
||||
} catch (Throwable _e) {
|
||||
|
@ -340,7 +340,7 @@ public class PrepareRenameTest extends AbstractTestLangLanguageServerTest {
|
|||
final String uri = this.writeFile("my-type-valid.testlang", model);
|
||||
TextDocumentIdentifier _textDocumentIdentifier = new TextDocumentIdentifier(uri);
|
||||
Position _position = new Position(2, 18);
|
||||
final TextDocumentPositionParams params = new TextDocumentPositionParams(_textDocumentIdentifier, _position);
|
||||
final PrepareRenameParams params = new PrepareRenameParams(_textDocumentIdentifier, _position);
|
||||
final Range range = this.languageServer.prepareRename(params).get().getLeft();
|
||||
this.assertEquals("MyType", new Document(Integer.valueOf(0), model).getSubstring(range));
|
||||
} catch (Throwable _e) {
|
||||
|
@ -373,7 +373,7 @@ public class PrepareRenameTest extends AbstractTestLangLanguageServerTest {
|
|||
final String uri = this.writeFile("my-type-valid.testlang", model);
|
||||
TextDocumentIdentifier _textDocumentIdentifier = new TextDocumentIdentifier(uri);
|
||||
Position _position = new Position(2, 18);
|
||||
final TextDocumentPositionParams params = new TextDocumentPositionParams(_textDocumentIdentifier, _position);
|
||||
final PrepareRenameParams params = new PrepareRenameParams(_textDocumentIdentifier, _position);
|
||||
Assert.assertNull(this.languageServer.prepareRename(params).get());
|
||||
} catch (Throwable _e) {
|
||||
throw Exceptions.sneakyThrow(_e);
|
||||
|
|
|
@ -12,13 +12,13 @@ import com.google.common.base.Throwables;
|
|||
import org.eclipse.lsp4j.ClientCapabilities;
|
||||
import org.eclipse.lsp4j.InitializeParams;
|
||||
import org.eclipse.lsp4j.Position;
|
||||
import org.eclipse.lsp4j.PrepareRenameParams;
|
||||
import org.eclipse.lsp4j.PrepareRenameResult;
|
||||
import org.eclipse.lsp4j.Range;
|
||||
import org.eclipse.lsp4j.RenameCapabilities;
|
||||
import org.eclipse.lsp4j.RenameParams;
|
||||
import org.eclipse.lsp4j.TextDocumentClientCapabilities;
|
||||
import org.eclipse.lsp4j.TextDocumentIdentifier;
|
||||
import org.eclipse.lsp4j.TextDocumentPositionParams;
|
||||
import org.eclipse.lsp4j.WorkspaceEdit;
|
||||
import org.eclipse.lsp4j.jsonrpc.ResponseErrorException;
|
||||
import org.eclipse.lsp4j.jsonrpc.messages.Either;
|
||||
|
@ -102,8 +102,8 @@ public class RenamePositionTest extends AbstractLanguageServerTest {
|
|||
this.initialize();
|
||||
try {
|
||||
final TextDocumentIdentifier identifier = new TextDocumentIdentifier(modelFile);
|
||||
TextDocumentPositionParams _textDocumentPositionParams = new TextDocumentPositionParams(identifier, position);
|
||||
final Either<Range, PrepareRenameResult> prepareRenameResult = this.languageServer.prepareRename(_textDocumentPositionParams).get();
|
||||
PrepareRenameParams _prepareRenameParams = new PrepareRenameParams(identifier, position);
|
||||
final Either<Range, PrepareRenameResult> prepareRenameResult = this.languageServer.prepareRename(_prepareRenameParams).get();
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("expected null result got ");
|
||||
_builder.append(prepareRenameResult);
|
||||
|
@ -149,8 +149,8 @@ public class RenamePositionTest extends AbstractLanguageServerTest {
|
|||
};
|
||||
this.initialize(_function);
|
||||
final TextDocumentIdentifier identifier = new TextDocumentIdentifier(modelFile);
|
||||
TextDocumentPositionParams _textDocumentPositionParams = new TextDocumentPositionParams(identifier, position);
|
||||
final Range range = this.languageServer.prepareRename(_textDocumentPositionParams).get().getLeft();
|
||||
PrepareRenameParams _prepareRenameParams = new PrepareRenameParams(identifier, position);
|
||||
final Range range = this.languageServer.prepareRename(_prepareRenameParams).get().getLeft();
|
||||
Assert.assertNotNull(range);
|
||||
this.assertEquals(new Document(Integer.valueOf(0), model).getSubstring(range), "Test");
|
||||
final RenameParams params = new RenameParams(identifier, position, "Tescht");
|
||||
|
|
|
@ -12,12 +12,12 @@ import org.eclipse.lsp4j.ClientCapabilities;
|
|||
import org.eclipse.lsp4j.InitializeParams;
|
||||
import org.eclipse.lsp4j.InitializeResult;
|
||||
import org.eclipse.lsp4j.Position;
|
||||
import org.eclipse.lsp4j.PrepareRenameParams;
|
||||
import org.eclipse.lsp4j.Range;
|
||||
import org.eclipse.lsp4j.RenameCapabilities;
|
||||
import org.eclipse.lsp4j.RenameParams;
|
||||
import org.eclipse.lsp4j.TextDocumentClientCapabilities;
|
||||
import org.eclipse.lsp4j.TextDocumentIdentifier;
|
||||
import org.eclipse.lsp4j.TextDocumentPositionParams;
|
||||
import org.eclipse.lsp4j.WorkspaceClientCapabilities;
|
||||
import org.eclipse.lsp4j.WorkspaceEdit;
|
||||
import org.eclipse.lsp4j.WorkspaceEditCapabilities;
|
||||
|
@ -57,8 +57,8 @@ public class RenameTest2 extends AbstractLanguageServerTest {
|
|||
this.initialize();
|
||||
final TextDocumentIdentifier identifier = new TextDocumentIdentifier(file);
|
||||
final Position position = new Position(2, 9);
|
||||
TextDocumentPositionParams _textDocumentPositionParams = new TextDocumentPositionParams(identifier, position);
|
||||
final Range range = this.languageServer.prepareRename(_textDocumentPositionParams).get().getLeft();
|
||||
PrepareRenameParams _prepareRenameParams = new PrepareRenameParams(identifier, position);
|
||||
final Range range = this.languageServer.prepareRename(_prepareRenameParams).get().getLeft();
|
||||
this.assertEquals("Foo", new Document(Integer.valueOf(0), model).getSubstring(range));
|
||||
final RenameParams params = new RenameParams(identifier, position, "Bar");
|
||||
final WorkspaceEdit workspaceEdit = this.languageServer.rename(params).get();
|
||||
|
@ -110,8 +110,8 @@ public class RenameTest2 extends AbstractLanguageServerTest {
|
|||
this.initialize();
|
||||
final TextDocumentIdentifier identifier = new TextDocumentIdentifier(file);
|
||||
final Position position = new Position(2, 9);
|
||||
TextDocumentPositionParams _textDocumentPositionParams = new TextDocumentPositionParams(identifier, position);
|
||||
final Range range = this.languageServer.prepareRename(_textDocumentPositionParams).get().getLeft();
|
||||
PrepareRenameParams _prepareRenameParams = new PrepareRenameParams(identifier, position);
|
||||
final Range range = this.languageServer.prepareRename(_prepareRenameParams).get().getLeft();
|
||||
this.assertEquals("Foo", new Document(Integer.valueOf(0), model).getSubstring(range));
|
||||
final RenameParams params = new RenameParams(identifier, position, "Baz");
|
||||
final WorkspaceEdit workspaceEdit = this.languageServer.rename(params).get();
|
||||
|
|
|
@ -11,12 +11,12 @@ package org.eclipse.xtext.ide.tests.server;
|
|||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import org.eclipse.lsp4j.DefinitionParams;
|
||||
import org.eclipse.lsp4j.Diagnostic;
|
||||
import org.eclipse.lsp4j.DidChangeWatchedFilesParams;
|
||||
import org.eclipse.lsp4j.FileChangeType;
|
||||
import org.eclipse.lsp4j.FileEvent;
|
||||
import org.eclipse.lsp4j.TextDocumentIdentifier;
|
||||
import org.eclipse.lsp4j.TextDocumentPositionParams;
|
||||
import org.eclipse.lsp4j.jsonrpc.ResponseErrorException;
|
||||
import org.eclipse.lsp4j.jsonrpc.messages.ResponseErrorCode;
|
||||
import org.eclipse.lsp4j.services.WorkspaceService;
|
||||
|
@ -175,8 +175,8 @@ public class ServerTest extends AbstractTestLangLanguageServerTest {
|
|||
public void testMissingInitialize() {
|
||||
try {
|
||||
try {
|
||||
TextDocumentPositionParams _textDocumentPositionParams = new TextDocumentPositionParams();
|
||||
final Procedure1<TextDocumentPositionParams> _function = (TextDocumentPositionParams it) -> {
|
||||
DefinitionParams _definitionParams = new DefinitionParams();
|
||||
final Procedure1<DefinitionParams> _function = (DefinitionParams it) -> {
|
||||
TextDocumentIdentifier _textDocumentIdentifier = new TextDocumentIdentifier();
|
||||
final Procedure1<TextDocumentIdentifier> _function_1 = (TextDocumentIdentifier it_1) -> {
|
||||
it_1.setUri("file:/home/test/workspace/mydoc.testlang");
|
||||
|
@ -184,7 +184,7 @@ public class ServerTest extends AbstractTestLangLanguageServerTest {
|
|||
TextDocumentIdentifier _doubleArrow = ObjectExtensions.<TextDocumentIdentifier>operator_doubleArrow(_textDocumentIdentifier, _function_1);
|
||||
it.setTextDocument(_doubleArrow);
|
||||
};
|
||||
TextDocumentPositionParams _doubleArrow = ObjectExtensions.<TextDocumentPositionParams>operator_doubleArrow(_textDocumentPositionParams, _function);
|
||||
DefinitionParams _doubleArrow = ObjectExtensions.<DefinitionParams>operator_doubleArrow(_definitionParams, _function);
|
||||
this.languageServer.definition(_doubleArrow).get();
|
||||
Assert.fail("Expected a ResponseErrorException");
|
||||
} catch (final Throwable _t) {
|
||||
|
|
|
@ -36,6 +36,7 @@ import org.eclipse.lsp4j.CompletionItem;
|
|||
import org.eclipse.lsp4j.CompletionList;
|
||||
import org.eclipse.lsp4j.CompletionOptions;
|
||||
import org.eclipse.lsp4j.CompletionParams;
|
||||
import org.eclipse.lsp4j.DefinitionParams;
|
||||
import org.eclipse.lsp4j.Diagnostic;
|
||||
import org.eclipse.lsp4j.DiagnosticSeverity;
|
||||
import org.eclipse.lsp4j.DidChangeConfigurationParams;
|
||||
|
@ -47,6 +48,7 @@ import org.eclipse.lsp4j.DidOpenTextDocumentParams;
|
|||
import org.eclipse.lsp4j.DidSaveTextDocumentParams;
|
||||
import org.eclipse.lsp4j.DocumentFormattingParams;
|
||||
import org.eclipse.lsp4j.DocumentHighlight;
|
||||
import org.eclipse.lsp4j.DocumentHighlightParams;
|
||||
import org.eclipse.lsp4j.DocumentOnTypeFormattingParams;
|
||||
import org.eclipse.lsp4j.DocumentRangeFormattingParams;
|
||||
import org.eclipse.lsp4j.DocumentSymbol;
|
||||
|
@ -57,12 +59,14 @@ import org.eclipse.lsp4j.ExecuteCommandOptions;
|
|||
import org.eclipse.lsp4j.ExecuteCommandParams;
|
||||
import org.eclipse.lsp4j.FileChangeType;
|
||||
import org.eclipse.lsp4j.Hover;
|
||||
import org.eclipse.lsp4j.HoverParams;
|
||||
import org.eclipse.lsp4j.InitializeParams;
|
||||
import org.eclipse.lsp4j.InitializeResult;
|
||||
import org.eclipse.lsp4j.InitializedParams;
|
||||
import org.eclipse.lsp4j.Location;
|
||||
import org.eclipse.lsp4j.LocationLink;
|
||||
import org.eclipse.lsp4j.Position;
|
||||
import org.eclipse.lsp4j.PrepareRenameParams;
|
||||
import org.eclipse.lsp4j.PrepareRenameResult;
|
||||
import org.eclipse.lsp4j.PublishDiagnosticsParams;
|
||||
import org.eclipse.lsp4j.Range;
|
||||
|
@ -555,7 +559,7 @@ public class LanguageServerImpl implements LanguageServer, WorkspaceService, Tex
|
|||
}
|
||||
BufferedCancelIndicator cancelIndicator = new BufferedCancelIndicator(originalCancelIndicator);
|
||||
return Either.forRight(workspaceManager.doRead(uri,
|
||||
(doc, res) -> contentAssistService.createCompletionList(doc, res, params, cancelIndicator)));
|
||||
(doc, res) -> contentAssistService.createCompletionList(doc, res, (TextDocumentPositionParams) params, cancelIndicator)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -584,7 +588,7 @@ public class LanguageServerImpl implements LanguageServer, WorkspaceService, Tex
|
|||
|
||||
@Override
|
||||
public CompletableFuture<Either<List<? extends Location>, List<? extends LocationLink>>> definition(
|
||||
TextDocumentPositionParams params) {
|
||||
DefinitionParams params) {
|
||||
return requestManager.runRead(cancelIndicator -> definition(params, cancelIndicator));
|
||||
}
|
||||
|
||||
|
@ -593,21 +597,21 @@ public class LanguageServerImpl implements LanguageServer, WorkspaceService, Tex
|
|||
* @since 2.20
|
||||
*/
|
||||
protected Either<List<? extends Location>, List<? extends LocationLink>> definition(
|
||||
TextDocumentPositionParams params, CancelIndicator cancelIndicator) {
|
||||
DefinitionParams params, CancelIndicator cancelIndicator) {
|
||||
return Either.forLeft(definition(cancelIndicator, params));
|
||||
}
|
||||
|
||||
/**
|
||||
* Compute the definition.
|
||||
*/
|
||||
protected List<? extends Location> definition(CancelIndicator cancelIndicator, TextDocumentPositionParams params) {
|
||||
protected List<? extends Location> definition(CancelIndicator cancelIndicator, DefinitionParams params) {
|
||||
URI uri = getURI(params);
|
||||
DocumentSymbolService documentSymbolService = getService(uri, DocumentSymbolService.class);
|
||||
if (documentSymbolService == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return workspaceManager.doRead(uri,
|
||||
(doc, res) -> documentSymbolService.getDefinitions(doc, res, params, resourceAccess, cancelIndicator));
|
||||
(doc, res) -> documentSymbolService.getDefinitions(doc, res, (TextDocumentPositionParams) params, resourceAccess, cancelIndicator));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -703,7 +707,7 @@ public class LanguageServerImpl implements LanguageServer, WorkspaceService, Tex
|
|||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Hover> hover(TextDocumentPositionParams params) {
|
||||
public CompletableFuture<Hover> hover(HoverParams params) {
|
||||
return requestManager.runRead((cancelIndicator) -> hover(params, cancelIndicator));
|
||||
}
|
||||
|
||||
|
@ -711,14 +715,14 @@ public class LanguageServerImpl implements LanguageServer, WorkspaceService, Tex
|
|||
* Compute the hover. Executed in a read request.
|
||||
* @since 2.20
|
||||
*/
|
||||
protected Hover hover(TextDocumentPositionParams params, CancelIndicator cancelIndicator) {
|
||||
protected Hover hover(HoverParams params, CancelIndicator cancelIndicator) {
|
||||
URI uri = getURI(params);
|
||||
IHoverService hoverService = getService(uri, IHoverService.class);
|
||||
if (hoverService == null) {
|
||||
return IHoverService.EMPTY_HOVER;
|
||||
}
|
||||
return workspaceManager.<Hover>doRead(uri,
|
||||
(document, resource) -> hoverService.hover(document, resource, params, cancelIndicator));
|
||||
(document, resource) -> hoverService.hover(document, resource, (TextDocumentPositionParams) params, cancelIndicator));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -746,7 +750,7 @@ public class LanguageServerImpl implements LanguageServer, WorkspaceService, Tex
|
|||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<List<? extends DocumentHighlight>> documentHighlight(TextDocumentPositionParams params) {
|
||||
public CompletableFuture<List<? extends DocumentHighlight>> documentHighlight(DocumentHighlightParams params) {
|
||||
return requestManager.runRead((cancelIndicator) -> documentHighlight(params, cancelIndicator));
|
||||
}
|
||||
|
||||
|
@ -754,7 +758,7 @@ public class LanguageServerImpl implements LanguageServer, WorkspaceService, Tex
|
|||
* Compute the document highlights. Executed in a read request.
|
||||
* @since 2.20
|
||||
*/
|
||||
protected List<? extends DocumentHighlight> documentHighlight(TextDocumentPositionParams params,
|
||||
protected List<? extends DocumentHighlight> documentHighlight(DocumentHighlightParams params,
|
||||
CancelIndicator cancelIndicator) {
|
||||
URI uri = getURI(params);
|
||||
IDocumentHighlightService service = getService(uri, IDocumentHighlightService.class);
|
||||
|
@ -762,7 +766,7 @@ public class LanguageServerImpl implements LanguageServer, WorkspaceService, Tex
|
|||
return Collections.emptyList();
|
||||
}
|
||||
return workspaceManager.doRead(uri,
|
||||
(doc, resource) -> service.getDocumentHighlights(doc, resource, params, cancelIndicator));
|
||||
(doc, resource) -> service.getDocumentHighlights(doc, resource, (TextDocumentPositionParams) params, cancelIndicator));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1012,7 +1016,7 @@ public class LanguageServerImpl implements LanguageServer, WorkspaceService, Tex
|
|||
* @since 2.18
|
||||
*/
|
||||
@Override
|
||||
public CompletableFuture<Either<Range, PrepareRenameResult>> prepareRename(TextDocumentPositionParams params) {
|
||||
public CompletableFuture<Either<Range, PrepareRenameResult>> prepareRename(PrepareRenameParams params) {
|
||||
return requestManager.runRead(cancelIndicator -> prepareRename(params, cancelIndicator));
|
||||
}
|
||||
|
||||
|
@ -1020,7 +1024,7 @@ public class LanguageServerImpl implements LanguageServer, WorkspaceService, Tex
|
|||
* Prepare the rename operation. Executed in a read request.
|
||||
* @since 2.20
|
||||
*/
|
||||
protected Either<Range, PrepareRenameResult> prepareRename(TextDocumentPositionParams params,
|
||||
protected Either<Range, PrepareRenameResult> prepareRename(PrepareRenameParams params,
|
||||
CancelIndicator cancelIndicator) {
|
||||
URI uri = getURI(params);
|
||||
IRenameService2 renameService = getService(uri, IRenameService2.class);
|
||||
|
|
|
@ -17,6 +17,8 @@ import java.util.concurrent.ExecutorService
|
|||
import org.eclipse.lsp4j.CompletionItem
|
||||
import org.eclipse.lsp4j.CompletionItemKind
|
||||
import org.eclipse.lsp4j.CompletionList
|
||||
import org.eclipse.lsp4j.CompletionParams
|
||||
import org.eclipse.lsp4j.InsertTextFormat
|
||||
import org.eclipse.lsp4j.Position
|
||||
import org.eclipse.lsp4j.Range
|
||||
import org.eclipse.lsp4j.TextDocumentPositionParams
|
||||
|
@ -32,7 +34,6 @@ import org.eclipse.xtext.service.OperationCanceledManager
|
|||
import org.eclipse.xtext.util.CancelIndicator
|
||||
import org.eclipse.xtext.util.ReplaceRegion
|
||||
import org.eclipse.xtext.util.TextRegion
|
||||
import org.eclipse.lsp4j.InsertTextFormat
|
||||
|
||||
/**
|
||||
* @author kosyakov - Initial contribution and API
|
||||
|
@ -55,8 +56,21 @@ class ContentAssistService {
|
|||
|
||||
@Inject OperationCanceledManager operationCanceledManager
|
||||
|
||||
def CompletionList createCompletionList(Document document, XtextResource resource,
|
||||
/**
|
||||
* @deprecated please override/call {@link #createCompletionList(Document, XtextResource, CompletionParams, CancelIndicator)} instead.
|
||||
* This method is scheduled to be removed with 2.22.
|
||||
*/
|
||||
@Deprecated//(since="2.21",forRemoval=true)
|
||||
def CompletionList createCompletionList(Document document, XtextResource resource,
|
||||
TextDocumentPositionParams params, CancelIndicator cancelIndicator) {
|
||||
if (params instanceof CompletionParams) {
|
||||
return createCompletionList(document, resource, params as CompletionParams, cancelIndicator)
|
||||
}
|
||||
throw new IllegalArgumentException("params is not a CompletionParams");
|
||||
}
|
||||
|
||||
def CompletionList createCompletionList(Document document, XtextResource resource,
|
||||
CompletionParams params, CancelIndicator cancelIndicator) {
|
||||
val result = new CompletionList
|
||||
// we set isInComplete to true, so we get asked always, which is the best match to the expected behavior in Xtext
|
||||
result.setIsIncomplete(true);
|
||||
|
|
|
@ -15,7 +15,6 @@ import org.eclipse.emf.ecore.EObject
|
|||
import org.eclipse.lsp4j.Hover
|
||||
import org.eclipse.lsp4j.MarkupContent
|
||||
import org.eclipse.lsp4j.Range
|
||||
import org.eclipse.lsp4j.TextDocumentPositionParams
|
||||
import org.eclipse.xtend.lib.annotations.Accessors
|
||||
import org.eclipse.xtend.lib.annotations.FinalFieldsConstructor
|
||||
import org.eclipse.xtext.documentation.IEObjectDocumentationProvider
|
||||
|
@ -28,6 +27,7 @@ import org.eclipse.xtext.util.CancelIndicator
|
|||
import org.eclipse.xtext.util.ITextRegion
|
||||
|
||||
import static extension org.eclipse.xtext.nodemodel.util.NodeModelUtils.*
|
||||
import org.eclipse.lsp4j.HoverParams
|
||||
|
||||
/**
|
||||
* @author kosyakov - Initial contribution and API
|
||||
|
@ -52,7 +52,7 @@ class HoverService implements IHoverService {
|
|||
override Hover hover(
|
||||
Document document,
|
||||
XtextResource resource,
|
||||
TextDocumentPositionParams params,
|
||||
HoverParams params,
|
||||
CancelIndicator cancelIndicator
|
||||
) {
|
||||
val offset = document.getOffSet(params.position)
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
/**
|
||||
* Copyright (c) 2017, 2020 TypeFox GmbH (http://www.typefox.io) and others.
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0.
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.eclipse.xtext.ide.server.hover;
|
||||
|
||||
import org.eclipse.lsp4j.Hover;
|
||||
import org.eclipse.lsp4j.HoverParams;
|
||||
import org.eclipse.lsp4j.MarkupContent;
|
||||
import org.eclipse.lsp4j.TextDocumentPositionParams;
|
||||
import org.eclipse.xtext.ide.server.Document;
|
||||
import org.eclipse.xtext.resource.XtextResource;
|
||||
import org.eclipse.xtext.util.CancelIndicator;
|
||||
|
||||
import com.google.inject.ImplementedBy;
|
||||
|
||||
/**
|
||||
* @author Sven Efftinge - Initial contribution and API
|
||||
*/
|
||||
@ImplementedBy(HoverService.class)
|
||||
public interface IHoverService {
|
||||
static final Hover EMPTY_HOVER = new Hover(new MarkupContent("markdown", ""), null);
|
||||
|
||||
/**
|
||||
* callback for 'textDocument/hover' requests.
|
||||
*
|
||||
* @deprecated please override/call {@link #hover(Document, XtextResource, HoverParams, CancelIndicator)} instead.
|
||||
* This method is scheduled to be removed with 2.22.
|
||||
*/
|
||||
@Deprecated//(since="2.21",forRemoval=true)
|
||||
default Hover hover(Document document, XtextResource resource, TextDocumentPositionParams params,
|
||||
CancelIndicator cancelIndicator) {
|
||||
if (params instanceof HoverParams) {
|
||||
return hover(document, resource, (HoverParams) params, cancelIndicator);
|
||||
}
|
||||
throw new IllegalArgumentException("params is not a HoverParams");
|
||||
}
|
||||
|
||||
/**
|
||||
* callback for 'textDocument/hover' requests.
|
||||
* @since 2.21
|
||||
*/
|
||||
Hover hover(Document document, XtextResource resource, HoverParams params,
|
||||
CancelIndicator cancelIndicator);
|
||||
}
|
|
@ -1,31 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2017, 2020 TypeFox GmbH (http://www.typefox.io) and others.
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0.
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*******************************************************************************/
|
||||
package org.eclipse.xtext.ide.server.hover
|
||||
|
||||
import org.eclipse.lsp4j.Hover
|
||||
import org.eclipse.lsp4j.TextDocumentPositionParams
|
||||
import org.eclipse.xtext.ide.server.Document
|
||||
import org.eclipse.xtext.resource.XtextResource
|
||||
import org.eclipse.xtext.util.CancelIndicator
|
||||
import com.google.inject.ImplementedBy
|
||||
import org.eclipse.lsp4j.MarkupContent
|
||||
|
||||
/**
|
||||
* @author Sven Efftinge - Initial contribution and API
|
||||
*/
|
||||
@ImplementedBy(HoverService)
|
||||
interface IHoverService {
|
||||
|
||||
public static val EMPTY_HOVER = new Hover(new MarkupContent("markdown", ""), null)
|
||||
|
||||
/**
|
||||
* callback for 'textDocument/hover' requests.
|
||||
*/
|
||||
def Hover hover(Document document, XtextResource resource, TextDocumentPositionParams params, CancelIndicator cancelIndicator);
|
||||
}
|
|
@ -19,7 +19,7 @@ import org.eclipse.emf.common.util.URI;
|
|||
import org.eclipse.emf.ecore.EObject;
|
||||
import org.eclipse.lsp4j.DocumentHighlight;
|
||||
import org.eclipse.lsp4j.DocumentHighlightKind;
|
||||
import org.eclipse.lsp4j.TextDocumentPositionParams;
|
||||
import org.eclipse.lsp4j.DocumentHighlightParams;
|
||||
import org.eclipse.xtext.findReferences.IReferenceFinder;
|
||||
import org.eclipse.xtext.findReferences.IReferenceFinder.Acceptor;
|
||||
import org.eclipse.xtext.findReferences.TargetURICollector;
|
||||
|
@ -92,7 +92,7 @@ public class DefaultDocumentHighlightService implements IDocumentHighlightServic
|
|||
private DocumentHighlightComparator comparator;
|
||||
|
||||
@Override
|
||||
public List<? extends DocumentHighlight> getDocumentHighlights(Document document, XtextResource resource, TextDocumentPositionParams params, CancelIndicator cancelIndicator) {
|
||||
public List<? extends DocumentHighlight> getDocumentHighlights(Document document, XtextResource resource, DocumentHighlightParams params, CancelIndicator cancelIndicator) {
|
||||
int offset = document.getOffSet(params.getPosition());
|
||||
return getDocumentHighlights(resource, offset);
|
||||
}
|
||||
|
@ -274,4 +274,6 @@ public class DefaultDocumentHighlightService implements IDocumentHighlightServic
|
|||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ package org.eclipse.xtext.ide.server.occurrences;
|
|||
import java.util.List;
|
||||
|
||||
import org.eclipse.lsp4j.DocumentHighlight;
|
||||
import org.eclipse.lsp4j.DocumentHighlightParams;
|
||||
import org.eclipse.lsp4j.TextDocumentPositionParams;
|
||||
import org.eclipse.xtext.ide.server.Document;
|
||||
import org.eclipse.xtext.resource.XtextResource;
|
||||
|
@ -33,8 +34,23 @@ import com.google.inject.ImplementedBy;
|
|||
@ImplementedBy(DefaultDocumentHighlightService.class)
|
||||
public interface IDocumentHighlightService {
|
||||
|
||||
List<? extends DocumentHighlight> getDocumentHighlights(Document document, XtextResource resource, TextDocumentPositionParams params, CancelIndicator cancelIndicator);
|
||||
/**
|
||||
* @deprecated please override/call {@link #getDocumentHighlights(Document, XtextResource, DocumentHighlightParams, CancelIndicator)} instead.
|
||||
* This method is scheduled to be removed with 2.22.
|
||||
*/
|
||||
@Deprecated//(since="2.21",forRemoval=true)
|
||||
default List<? extends DocumentHighlight> getDocumentHighlights(Document document, XtextResource resource, TextDocumentPositionParams params, CancelIndicator cancelIndicator) {
|
||||
if (params instanceof DocumentHighlightParams) {
|
||||
return getDocumentHighlights(document, resource, (DocumentHighlightParams) params, cancelIndicator);
|
||||
}
|
||||
throw new IllegalArgumentException("params is not a DocumentHighlightParams");
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 2.21
|
||||
*/
|
||||
List<? extends DocumentHighlight> getDocumentHighlights(Document document, XtextResource resource, DocumentHighlightParams params, CancelIndicator cancelIndicator);
|
||||
|
||||
/**
|
||||
* Returns with a list of {@link DocumentHighlight document highlight}
|
||||
* instances that matches with the given text from the resource at the given
|
||||
|
@ -50,6 +66,7 @@ public interface IDocumentHighlightService {
|
|||
* @return a list of document highlight instances that matches with the
|
||||
* selected text based on an arbitrary logic. Might return with an
|
||||
* empty list but never returns with {@code null}.
|
||||
* @deprecated This method is scheduled to be removed with 2.22.
|
||||
*/
|
||||
@Deprecated
|
||||
List<? extends DocumentHighlight> getDocumentHighlights(final XtextResource resource, final int offset);
|
||||
|
|
|
@ -0,0 +1,112 @@
|
|||
/**
|
||||
* Copyright (c) 2017 TypeFox GmbH (http://www.typefox.io) and others.
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0.
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.eclipse.xtext.ide.server.rename;
|
||||
|
||||
import org.eclipse.lsp4j.PrepareRenameParams;
|
||||
import org.eclipse.lsp4j.PrepareRenameResult;
|
||||
import org.eclipse.lsp4j.Range;
|
||||
import org.eclipse.lsp4j.RenameParams;
|
||||
import org.eclipse.lsp4j.WorkspaceEdit;
|
||||
import org.eclipse.lsp4j.jsonrpc.messages.Either;
|
||||
import org.eclipse.xtext.ide.server.ILanguageServerAccess;
|
||||
import org.eclipse.xtext.util.CancelIndicator;
|
||||
|
||||
/**
|
||||
* Service called for rename refactoring.
|
||||
*
|
||||
* @author koehnlein - Initial contribution and API
|
||||
* @since 2.18
|
||||
*/
|
||||
public interface IRenameService2 {
|
||||
class Options {
|
||||
private ILanguageServerAccess languageServerAccess;
|
||||
|
||||
private RenameParams renameParams;
|
||||
|
||||
private CancelIndicator cancelIndicator;
|
||||
|
||||
public ILanguageServerAccess getLanguageServerAccess() {
|
||||
return languageServerAccess;
|
||||
}
|
||||
|
||||
public void setLanguageServerAccess(ILanguageServerAccess languageServerAccess) {
|
||||
this.languageServerAccess = languageServerAccess;
|
||||
}
|
||||
|
||||
public RenameParams getRenameParams() {
|
||||
return renameParams;
|
||||
}
|
||||
|
||||
public void setRenameParams(RenameParams renameParams) {
|
||||
this.renameParams = renameParams;
|
||||
}
|
||||
|
||||
public CancelIndicator getCancelIndicator() {
|
||||
return cancelIndicator;
|
||||
}
|
||||
|
||||
public void setCancelIndicator(CancelIndicator cancelIndicator) {
|
||||
this.cancelIndicator = cancelIndicator;
|
||||
}
|
||||
}
|
||||
|
||||
class PrepareRenameOptions {
|
||||
private ILanguageServerAccess languageServerAccess;
|
||||
|
||||
private PrepareRenameParams params;
|
||||
|
||||
private CancelIndicator cancelIndicator;
|
||||
|
||||
public ILanguageServerAccess getLanguageServerAccess() {
|
||||
return languageServerAccess;
|
||||
}
|
||||
|
||||
public void setLanguageServerAccess(final ILanguageServerAccess languageServerAccess) {
|
||||
this.languageServerAccess = languageServerAccess;
|
||||
}
|
||||
|
||||
public PrepareRenameParams getParams() {
|
||||
return params;
|
||||
}
|
||||
|
||||
public void setParams(PrepareRenameParams params) {
|
||||
this.params = params;
|
||||
}
|
||||
|
||||
public CancelIndicator getCancelIndicator() {
|
||||
return cancelIndicator;
|
||||
}
|
||||
|
||||
public void setCancelIndicator(CancelIndicator cancelIndicator) {
|
||||
this.cancelIndicator = cancelIndicator;
|
||||
}
|
||||
}
|
||||
|
||||
WorkspaceEdit rename(IRenameService2.Options options);
|
||||
|
||||
/**
|
||||
* Returns a {@link Range range} describing the range of the string to rename and optionally a placeholder text of
|
||||
* the string content to be renamed.
|
||||
*
|
||||
* <p>
|
||||
* If {@code null} is returned then it is deemed that invoking {@link #rename rename} with the same text document
|
||||
* position will not result in a valid {@link WorkspaceEdit workspace edit}.
|
||||
*
|
||||
* <p>
|
||||
* The default implementation only checks whether there is an identifier under the give text document position or
|
||||
* not.
|
||||
*
|
||||
* <p>
|
||||
* This method should be used to set up and to test the validity of a rename operation at a given location.</br>
|
||||
* See <a href=
|
||||
* "https://microsoft.github.io/language-server-protocol/specification#textDocument_prepareRename">{@code textDocument/prepareRename}</a>
|
||||
* for more details.
|
||||
*/
|
||||
Either<Range, PrepareRenameResult> prepareRename(IRenameService2.PrepareRenameOptions options);
|
||||
}
|
|
@ -1,63 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2017 TypeFox GmbH (http://www.typefox.io) and others.
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0.
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*******************************************************************************/
|
||||
package org.eclipse.xtext.ide.server.rename
|
||||
|
||||
import org.eclipse.lsp4j.PrepareRenameResult
|
||||
import org.eclipse.lsp4j.Range
|
||||
import org.eclipse.lsp4j.RenameParams
|
||||
import org.eclipse.lsp4j.TextDocumentPositionParams
|
||||
import org.eclipse.lsp4j.WorkspaceEdit
|
||||
import org.eclipse.lsp4j.jsonrpc.messages.Either
|
||||
import org.eclipse.xtend.lib.annotations.Accessors
|
||||
import org.eclipse.xtext.ide.server.ILanguageServerAccess
|
||||
import org.eclipse.xtext.util.CancelIndicator
|
||||
|
||||
/**
|
||||
* Service called for rename refactoring.
|
||||
*
|
||||
* @author koehnlein - Initial contribution and API
|
||||
* @since 2.18
|
||||
*/
|
||||
interface IRenameService2 {
|
||||
|
||||
def WorkspaceEdit rename(Options options)
|
||||
|
||||
/**
|
||||
* Returns a {@link Range range} describing the range of the string to rename and optionally a placeholder text of
|
||||
* the string content to be renamed.
|
||||
*
|
||||
* <p>
|
||||
* If {@code null} is returned then it is deemed that invoking {@link #rename rename} with the same text document
|
||||
* position will not result in a valid {@link WorkspaceEdit workspace edit}.
|
||||
*
|
||||
* <p>
|
||||
* The default implementation only checks whether there is an identifier under the give text document position or not.
|
||||
*
|
||||
* <p>
|
||||
* This method should be used to set up and to test the validity of a rename operation at a given location.</br>
|
||||
* See <a href="https://microsoft.github.io/language-server-protocol/specification#textDocument_prepareRename">{@code textDocument/prepareRename}</a> for more details.
|
||||
*
|
||||
*/
|
||||
def Either<Range, PrepareRenameResult> prepareRename(PrepareRenameOptions options)
|
||||
|
||||
@Accessors
|
||||
class Options {
|
||||
ILanguageServerAccess languageServerAccess
|
||||
RenameParams renameParams
|
||||
CancelIndicator cancelIndicator
|
||||
}
|
||||
|
||||
@Accessors
|
||||
class PrepareRenameOptions {
|
||||
ILanguageServerAccess languageServerAccess
|
||||
TextDocumentPositionParams params
|
||||
CancelIndicator cancelIndicator
|
||||
}
|
||||
|
||||
}
|
|
@ -18,6 +18,7 @@ import org.eclipse.emf.ecore.EObject
|
|||
import org.eclipse.emf.ecore.resource.Resource
|
||||
import org.eclipse.emf.ecore.util.EcoreUtil
|
||||
import org.eclipse.lsp4j.Position
|
||||
import org.eclipse.lsp4j.PrepareRenameParams
|
||||
import org.eclipse.lsp4j.PrepareRenameResult
|
||||
import org.eclipse.lsp4j.Range
|
||||
import org.eclipse.lsp4j.RenameParams
|
||||
|
@ -77,12 +78,12 @@ class RenameService2 implements IRenameService2 {
|
|||
if (shouldPrepareRename) {
|
||||
val identifier = new TextDocumentIdentifier(textDocument.uri)
|
||||
val position = options.renameParams.position
|
||||
val positionParams = new TextDocumentPositionParams(identifier, position)
|
||||
val positionParams = new PrepareRenameParams(identifier, position)
|
||||
val resource = context.resource
|
||||
val document = context.document
|
||||
val cancelIndicator = options.cancelIndicator
|
||||
|
||||
val prepareRenameResult = doPrepareRename(resource, document, positionParams, cancelIndicator)
|
||||
val prepareRenameResult = doPrepareRename(resource, document, positionParams as TextDocumentPositionParams, cancelIndicator)
|
||||
if (!mayPerformRename(prepareRenameResult, options.renameParams)) {
|
||||
return null
|
||||
}
|
||||
|
@ -165,7 +166,7 @@ class RenameService2 implements IRenameService2 {
|
|||
val document = context.document
|
||||
val params = options.params
|
||||
val cancelIndicator = options.cancelIndicator
|
||||
return doPrepareRename(resource, document, params, cancelIndicator)
|
||||
return doPrepareRename(resource, document, params as TextDocumentPositionParams, cancelIndicator)
|
||||
].exceptionally [ exception |
|
||||
val rootCause = Throwables.getRootCause(exception)
|
||||
if (rootCause instanceof FileNotFoundException) {
|
||||
|
@ -176,9 +177,21 @@ class RenameService2 implements IRenameService2 {
|
|||
throw exception
|
||||
].get
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @deprecated please override/call {@link #doPrepareRename(Resource, Document, PrepareRenameParams, CancelIndicator)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
protected def Either<Range, PrepareRenameResult> doPrepareRename(Resource resource, Document document,
|
||||
TextDocumentPositionParams params, CancelIndicator cancelIndicator) {
|
||||
if (params instanceof PrepareRenameParams) {
|
||||
return doPrepareRename(resource, document, params as PrepareRenameParams, cancelIndicator)
|
||||
}
|
||||
throw new IllegalArgumentException("params is not a PrepareRenameParams");
|
||||
}
|
||||
|
||||
protected def Either<Range, PrepareRenameResult> doPrepareRename(Resource resource, Document document,
|
||||
PrepareRenameParams params, CancelIndicator cancelIndicator) {
|
||||
|
||||
val uri = params.textDocument.uri
|
||||
if (resource instanceof XtextResource) {
|
||||
|
|
|
@ -36,8 +36,9 @@ public interface ISignatureHelpService {
|
|||
|
||||
/**
|
||||
* @deprecated please override/call {@link #getSignatureHelp(Document, XtextResource, SignatureHelpParams, CancelIndicator)} instead.
|
||||
* This method is scheduled to be removed with 2.22.
|
||||
*/
|
||||
@Deprecated
|
||||
@Deprecated//(since="2.21",forRemoval=true)
|
||||
default SignatureHelp getSignatureHelp(Document document, XtextResource resource, TextDocumentPositionParams params, CancelIndicator cancelIndicator) {
|
||||
if (params instanceof SignatureHelpParams) {
|
||||
return getSignatureHelp(document, resource, (SignatureHelpParams) params, cancelIndicator);
|
||||
|
@ -58,6 +59,8 @@ public interface ISignatureHelpService {
|
|||
* the offset of the cursor in the resource.
|
||||
*
|
||||
* @return a signature help instance.
|
||||
*
|
||||
* @deprecated This method is scheduled to be removed with 2.22.
|
||||
*/
|
||||
@Deprecated
|
||||
default SignatureHelp getSignatureHelp(final XtextResource resource, final int offset) {
|
||||
|
|
|
@ -16,6 +16,7 @@ import java.util.List
|
|||
import org.eclipse.emf.common.util.URI
|
||||
import org.eclipse.emf.ecore.EClass
|
||||
import org.eclipse.emf.ecore.EObject
|
||||
import org.eclipse.lsp4j.DefinitionParams
|
||||
import org.eclipse.lsp4j.DocumentSymbol
|
||||
import org.eclipse.lsp4j.DocumentSymbolParams
|
||||
import org.eclipse.lsp4j.Location
|
||||
|
@ -80,13 +81,34 @@ class DocumentSymbolService implements IDocumentSymbolService {
|
|||
|
||||
@Inject
|
||||
HierarchicalDocumentSymbolService hierarchicalDocumentSymbolService
|
||||
|
||||
|
||||
/**
|
||||
* @deprecated please override/call {@link #getDefinitions(Document,XtextResource,DefinitionParams,IReferenceFinder.IResourceAccess,CancelIndicator)} instead.
|
||||
* This method is scheduled to be removed with 2.22.
|
||||
*/
|
||||
@Deprecated//(since="2.21",forRemoval=true)
|
||||
def List<? extends Location> getDefinitions(
|
||||
Document document,
|
||||
XtextResource resource,
|
||||
TextDocumentPositionParams params,
|
||||
IResourceAccess resourceAccess,
|
||||
CancelIndicator cancelIndicator
|
||||
) {
|
||||
if (params instanceof DefinitionParams) {
|
||||
return getDefinitions(document, resource, params as DefinitionParams, resourceAccess, cancelIndicator)
|
||||
}
|
||||
throw new IllegalArgumentException("params is not a DefinitionParams");
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 2.21
|
||||
*/
|
||||
def List<? extends Location> getDefinitions(
|
||||
Document document,
|
||||
XtextResource resource,
|
||||
DefinitionParams params,
|
||||
IResourceAccess resourceAccess,
|
||||
CancelIndicator cancelIndicator
|
||||
) {
|
||||
val offset = document.getOffSet(params.position)
|
||||
return getDefinitions(resource, offset, resourceAccess, cancelIndicator)
|
||||
|
|
|
@ -21,6 +21,7 @@ import java.util.function.Consumer;
|
|||
import org.eclipse.lsp4j.CompletionItem;
|
||||
import org.eclipse.lsp4j.CompletionItemKind;
|
||||
import org.eclipse.lsp4j.CompletionList;
|
||||
import org.eclipse.lsp4j.CompletionParams;
|
||||
import org.eclipse.lsp4j.InsertTextFormat;
|
||||
import org.eclipse.lsp4j.Position;
|
||||
import org.eclipse.lsp4j.Range;
|
||||
|
@ -69,7 +70,19 @@ public class ContentAssistService {
|
|||
@Inject
|
||||
private OperationCanceledManager operationCanceledManager;
|
||||
|
||||
/**
|
||||
* @deprecated please override/call {@link #createCompletionList(Document, XtextResource, CompletionParams, CancelIndicator)} instead.
|
||||
* This method is scheduled to be removed with 2.22.
|
||||
*/
|
||||
@Deprecated
|
||||
public CompletionList createCompletionList(final Document document, final XtextResource resource, final TextDocumentPositionParams params, final CancelIndicator cancelIndicator) {
|
||||
if ((params instanceof CompletionParams)) {
|
||||
return this.createCompletionList(document, resource, ((CompletionParams) params), cancelIndicator);
|
||||
}
|
||||
throw new IllegalArgumentException("params is not a CompletionParams");
|
||||
}
|
||||
|
||||
public CompletionList createCompletionList(final Document document, final XtextResource resource, final CompletionParams params, final CancelIndicator cancelIndicator) {
|
||||
try {
|
||||
final CompletionList result = new CompletionList();
|
||||
result.setIsIncomplete(true);
|
||||
|
|
|
@ -13,9 +13,9 @@ import com.google.inject.Inject;
|
|||
import com.google.inject.Singleton;
|
||||
import org.eclipse.emf.ecore.EObject;
|
||||
import org.eclipse.lsp4j.Hover;
|
||||
import org.eclipse.lsp4j.HoverParams;
|
||||
import org.eclipse.lsp4j.MarkupContent;
|
||||
import org.eclipse.lsp4j.Range;
|
||||
import org.eclipse.lsp4j.TextDocumentPositionParams;
|
||||
import org.eclipse.xtext.documentation.IEObjectDocumentationProvider;
|
||||
import org.eclipse.xtext.ide.server.Document;
|
||||
import org.eclipse.xtext.ide.server.DocumentExtensions;
|
||||
|
@ -56,7 +56,7 @@ public class HoverService implements IHoverService {
|
|||
private IEObjectDocumentationProvider _iEObjectDocumentationProvider;
|
||||
|
||||
@Override
|
||||
public Hover hover(final Document document, final XtextResource resource, final TextDocumentPositionParams params, final CancelIndicator cancelIndicator) {
|
||||
public Hover hover(final Document document, final XtextResource resource, final HoverParams params, final CancelIndicator cancelIndicator) {
|
||||
final int offset = document.getOffSet(params.getPosition());
|
||||
final HoverContext context = this.createContext(document, resource, offset);
|
||||
return this.hover(context);
|
||||
|
|
|
@ -1,32 +0,0 @@
|
|||
/**
|
||||
* Copyright (c) 2017, 2020 TypeFox GmbH (http://www.typefox.io) and others.
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0.
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.eclipse.xtext.ide.server.hover;
|
||||
|
||||
import com.google.inject.ImplementedBy;
|
||||
import org.eclipse.lsp4j.Hover;
|
||||
import org.eclipse.lsp4j.MarkupContent;
|
||||
import org.eclipse.lsp4j.TextDocumentPositionParams;
|
||||
import org.eclipse.xtext.ide.server.Document;
|
||||
import org.eclipse.xtext.ide.server.hover.HoverService;
|
||||
import org.eclipse.xtext.resource.XtextResource;
|
||||
import org.eclipse.xtext.util.CancelIndicator;
|
||||
|
||||
/**
|
||||
* @author Sven Efftinge - Initial contribution and API
|
||||
*/
|
||||
@ImplementedBy(HoverService.class)
|
||||
@SuppressWarnings("all")
|
||||
public interface IHoverService {
|
||||
static final Hover EMPTY_HOVER = new Hover(new MarkupContent("markdown", ""), null);
|
||||
|
||||
/**
|
||||
* callback for 'textDocument/hover' requests.
|
||||
*/
|
||||
Hover hover(final Document document, final XtextResource resource, final TextDocumentPositionParams params, final CancelIndicator cancelIndicator);
|
||||
}
|
|
@ -1,120 +0,0 @@
|
|||
/**
|
||||
* Copyright (c) 2017 TypeFox GmbH (http://www.typefox.io) and others.
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0.
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.eclipse.xtext.ide.server.rename;
|
||||
|
||||
import org.eclipse.lsp4j.PrepareRenameResult;
|
||||
import org.eclipse.lsp4j.Range;
|
||||
import org.eclipse.lsp4j.RenameParams;
|
||||
import org.eclipse.lsp4j.TextDocumentPositionParams;
|
||||
import org.eclipse.lsp4j.WorkspaceEdit;
|
||||
import org.eclipse.lsp4j.jsonrpc.messages.Either;
|
||||
import org.eclipse.xtend.lib.annotations.Accessors;
|
||||
import org.eclipse.xtext.ide.server.ILanguageServerAccess;
|
||||
import org.eclipse.xtext.util.CancelIndicator;
|
||||
import org.eclipse.xtext.xbase.lib.Pure;
|
||||
|
||||
/**
|
||||
* Service called for rename refactoring.
|
||||
*
|
||||
* @author koehnlein - Initial contribution and API
|
||||
* @since 2.18
|
||||
*/
|
||||
@SuppressWarnings("all")
|
||||
public interface IRenameService2 {
|
||||
@Accessors
|
||||
class Options {
|
||||
private ILanguageServerAccess languageServerAccess;
|
||||
|
||||
private RenameParams renameParams;
|
||||
|
||||
private CancelIndicator cancelIndicator;
|
||||
|
||||
@Pure
|
||||
public ILanguageServerAccess getLanguageServerAccess() {
|
||||
return this.languageServerAccess;
|
||||
}
|
||||
|
||||
public void setLanguageServerAccess(final ILanguageServerAccess languageServerAccess) {
|
||||
this.languageServerAccess = languageServerAccess;
|
||||
}
|
||||
|
||||
@Pure
|
||||
public RenameParams getRenameParams() {
|
||||
return this.renameParams;
|
||||
}
|
||||
|
||||
public void setRenameParams(final RenameParams renameParams) {
|
||||
this.renameParams = renameParams;
|
||||
}
|
||||
|
||||
@Pure
|
||||
public CancelIndicator getCancelIndicator() {
|
||||
return this.cancelIndicator;
|
||||
}
|
||||
|
||||
public void setCancelIndicator(final CancelIndicator cancelIndicator) {
|
||||
this.cancelIndicator = cancelIndicator;
|
||||
}
|
||||
}
|
||||
|
||||
@Accessors
|
||||
class PrepareRenameOptions {
|
||||
private ILanguageServerAccess languageServerAccess;
|
||||
|
||||
private TextDocumentPositionParams params;
|
||||
|
||||
private CancelIndicator cancelIndicator;
|
||||
|
||||
@Pure
|
||||
public ILanguageServerAccess getLanguageServerAccess() {
|
||||
return this.languageServerAccess;
|
||||
}
|
||||
|
||||
public void setLanguageServerAccess(final ILanguageServerAccess languageServerAccess) {
|
||||
this.languageServerAccess = languageServerAccess;
|
||||
}
|
||||
|
||||
@Pure
|
||||
public TextDocumentPositionParams getParams() {
|
||||
return this.params;
|
||||
}
|
||||
|
||||
public void setParams(final TextDocumentPositionParams params) {
|
||||
this.params = params;
|
||||
}
|
||||
|
||||
@Pure
|
||||
public CancelIndicator getCancelIndicator() {
|
||||
return this.cancelIndicator;
|
||||
}
|
||||
|
||||
public void setCancelIndicator(final CancelIndicator cancelIndicator) {
|
||||
this.cancelIndicator = cancelIndicator;
|
||||
}
|
||||
}
|
||||
|
||||
WorkspaceEdit rename(final IRenameService2.Options options);
|
||||
|
||||
/**
|
||||
* Returns a {@link Range range} describing the range of the string to rename and optionally a placeholder text of
|
||||
* the string content to be renamed.
|
||||
*
|
||||
* <p>
|
||||
* If {@code null} is returned then it is deemed that invoking {@link #rename rename} with the same text document
|
||||
* position will not result in a valid {@link WorkspaceEdit workspace edit}.
|
||||
*
|
||||
* <p>
|
||||
* The default implementation only checks whether there is an identifier under the give text document position or not.
|
||||
*
|
||||
* <p>
|
||||
* This method should be used to set up and to test the validity of a rename operation at a given location.</br>
|
||||
* See <a href="https://microsoft.github.io/language-server-protocol/specification#textDocument_prepareRename">{@code textDocument/prepareRename}</a> for more details.
|
||||
*/
|
||||
Either<Range, PrepareRenameResult> prepareRename(final IRenameService2.PrepareRenameOptions options);
|
||||
}
|
|
@ -24,6 +24,7 @@ import org.eclipse.emf.ecore.resource.ResourceSet;
|
|||
import org.eclipse.emf.ecore.util.EcoreUtil;
|
||||
import org.eclipse.lsp4j.InitializeResult;
|
||||
import org.eclipse.lsp4j.Position;
|
||||
import org.eclipse.lsp4j.PrepareRenameParams;
|
||||
import org.eclipse.lsp4j.PrepareRenameResult;
|
||||
import org.eclipse.lsp4j.Range;
|
||||
import org.eclipse.lsp4j.RenameOptions;
|
||||
|
@ -102,11 +103,11 @@ public class RenameService2 implements IRenameService2 {
|
|||
String _uri = textDocument.getUri();
|
||||
final TextDocumentIdentifier identifier = new TextDocumentIdentifier(_uri);
|
||||
final Position position = options.getRenameParams().getPosition();
|
||||
final TextDocumentPositionParams positionParams = new TextDocumentPositionParams(identifier, position);
|
||||
final PrepareRenameParams positionParams = new PrepareRenameParams(identifier, position);
|
||||
final Resource resource = context.getResource();
|
||||
final Document document = context.getDocument();
|
||||
final CancelIndicator cancelIndicator = options.getCancelIndicator();
|
||||
final Either<Range, PrepareRenameResult> prepareRenameResult = this.doPrepareRename(resource, document, positionParams, cancelIndicator);
|
||||
final Either<Range, PrepareRenameResult> prepareRenameResult = this.doPrepareRename(resource, document, ((TextDocumentPositionParams) positionParams), cancelIndicator);
|
||||
boolean _mayPerformRename = this.mayPerformRename(prepareRenameResult, options.getRenameParams());
|
||||
boolean _not = (!_mayPerformRename);
|
||||
if (_not) {
|
||||
|
@ -225,9 +226,9 @@ public class RenameService2 implements IRenameService2 {
|
|||
}
|
||||
final Resource resource = context.getResource();
|
||||
final Document document = context.getDocument();
|
||||
final TextDocumentPositionParams params = options.getParams();
|
||||
final PrepareRenameParams params = options.getParams();
|
||||
final CancelIndicator cancelIndicator = options.getCancelIndicator();
|
||||
return this.doPrepareRename(resource, document, params, cancelIndicator);
|
||||
return this.doPrepareRename(resource, document, ((TextDocumentPositionParams) params), cancelIndicator);
|
||||
};
|
||||
final java.util.function.Function<Throwable, Either<Range, PrepareRenameResult>> _function_1 = (Throwable exception) -> {
|
||||
try {
|
||||
|
@ -248,7 +249,18 @@ public class RenameService2 implements IRenameService2 {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated please override/call {@link #doPrepareRename(Resource, Document, PrepareRenameParams, CancelIndicator)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
protected Either<Range, PrepareRenameResult> doPrepareRename(final Resource resource, final Document document, final TextDocumentPositionParams params, final CancelIndicator cancelIndicator) {
|
||||
if ((params instanceof PrepareRenameParams)) {
|
||||
return this.doPrepareRename(resource, document, ((PrepareRenameParams) params), cancelIndicator);
|
||||
}
|
||||
throw new IllegalArgumentException("params is not a PrepareRenameParams");
|
||||
}
|
||||
|
||||
protected Either<Range, PrepareRenameResult> doPrepareRename(final Resource resource, final Document document, final PrepareRenameParams params, final CancelIndicator cancelIndicator) {
|
||||
final String uri = params.getTextDocument().getUri();
|
||||
if ((resource instanceof XtextResource)) {
|
||||
IParseResult _parseResult = null;
|
||||
|
|
|
@ -22,6 +22,7 @@ import org.eclipse.emf.common.util.URI;
|
|||
import org.eclipse.emf.ecore.EClass;
|
||||
import org.eclipse.emf.ecore.EObject;
|
||||
import org.eclipse.emf.ecore.resource.ResourceSet;
|
||||
import org.eclipse.lsp4j.DefinitionParams;
|
||||
import org.eclipse.lsp4j.DocumentSymbol;
|
||||
import org.eclipse.lsp4j.DocumentSymbolParams;
|
||||
import org.eclipse.lsp4j.Location;
|
||||
|
@ -102,7 +103,22 @@ public class DocumentSymbolService implements IDocumentSymbolService {
|
|||
@Inject
|
||||
private HierarchicalDocumentSymbolService hierarchicalDocumentSymbolService;
|
||||
|
||||
/**
|
||||
* @deprecated please override/call {@link #getDefinitions(Document,XtextResource,DefinitionParams,IReferenceFinder.IResourceAccess,CancelIndicator)} instead.
|
||||
* This method is scheduled to be removed with 2.22.
|
||||
*/
|
||||
@Deprecated
|
||||
public List<? extends Location> getDefinitions(final Document document, final XtextResource resource, final TextDocumentPositionParams params, final IReferenceFinder.IResourceAccess resourceAccess, final CancelIndicator cancelIndicator) {
|
||||
if ((params instanceof DefinitionParams)) {
|
||||
return this.getDefinitions(document, resource, ((DefinitionParams) params), resourceAccess, cancelIndicator);
|
||||
}
|
||||
throw new IllegalArgumentException("params is not a DefinitionParams");
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 2.21
|
||||
*/
|
||||
public List<? extends Location> getDefinitions(final Document document, final XtextResource resource, final DefinitionParams params, final IReferenceFinder.IResourceAccess resourceAccess, final CancelIndicator cancelIndicator) {
|
||||
final int offset = document.getOffSet(params.getPosition());
|
||||
return this.getDefinitions(resource, offset, resourceAccess, cancelIndicator);
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ import org.eclipse.lsp4j.CodeLensParams
|
|||
import org.eclipse.lsp4j.Command
|
||||
import org.eclipse.lsp4j.CompletionItem
|
||||
import org.eclipse.lsp4j.CompletionParams
|
||||
import org.eclipse.lsp4j.DefinitionParams
|
||||
import org.eclipse.lsp4j.Diagnostic
|
||||
import org.eclipse.lsp4j.DidChangeWatchedFilesParams
|
||||
import org.eclipse.lsp4j.DidCloseTextDocumentParams
|
||||
|
@ -34,15 +35,18 @@ import org.eclipse.lsp4j.DidOpenTextDocumentParams
|
|||
import org.eclipse.lsp4j.DocumentFormattingParams
|
||||
import org.eclipse.lsp4j.DocumentHighlight
|
||||
import org.eclipse.lsp4j.DocumentHighlightKind
|
||||
import org.eclipse.lsp4j.DocumentHighlightParams
|
||||
import org.eclipse.lsp4j.DocumentRangeFormattingParams
|
||||
import org.eclipse.lsp4j.DocumentSymbol
|
||||
import org.eclipse.lsp4j.DocumentSymbolParams
|
||||
import org.eclipse.lsp4j.FileChangeType
|
||||
import org.eclipse.lsp4j.FileEvent
|
||||
import org.eclipse.lsp4j.Hover
|
||||
import org.eclipse.lsp4j.HoverParams
|
||||
import org.eclipse.lsp4j.InitializeParams
|
||||
import org.eclipse.lsp4j.InitializeResult
|
||||
import org.eclipse.lsp4j.Location
|
||||
import org.eclipse.lsp4j.MarkupContent
|
||||
import org.eclipse.lsp4j.Position
|
||||
import org.eclipse.lsp4j.PublishDiagnosticsParams
|
||||
import org.eclipse.lsp4j.Range
|
||||
|
@ -51,11 +55,11 @@ import org.eclipse.lsp4j.ReferenceParams
|
|||
import org.eclipse.lsp4j.SemanticHighlightingInformation
|
||||
import org.eclipse.lsp4j.SemanticHighlightingParams
|
||||
import org.eclipse.lsp4j.SignatureHelp
|
||||
import org.eclipse.lsp4j.SignatureHelpParams
|
||||
import org.eclipse.lsp4j.SymbolInformation
|
||||
import org.eclipse.lsp4j.TextDocumentEdit
|
||||
import org.eclipse.lsp4j.TextDocumentIdentifier
|
||||
import org.eclipse.lsp4j.TextDocumentItem
|
||||
import org.eclipse.lsp4j.TextDocumentPositionParams
|
||||
import org.eclipse.lsp4j.TextEdit
|
||||
import org.eclipse.lsp4j.VersionedTextDocumentIdentifier
|
||||
import org.eclipse.lsp4j.WorkspaceEdit
|
||||
|
@ -85,8 +89,6 @@ import org.junit.jupiter.api.BeforeEach
|
|||
|
||||
import static extension org.eclipse.lsp4j.util.Ranges.containsRange
|
||||
import static extension org.eclipse.xtext.util.Strings.*
|
||||
import org.eclipse.lsp4j.SignatureHelpParams
|
||||
import org.eclipse.lsp4j.MarkupContent
|
||||
import org.eclipse.lsp4j.WorkspaceFolder
|
||||
|
||||
/**
|
||||
|
@ -522,7 +524,7 @@ abstract class AbstractLanguageServerTest implements Endpoint {
|
|||
configuration.filePath = 'MyModel.' + fileExtension
|
||||
configurator.apply(configuration)
|
||||
val fileUri = initializeContext(configuration).uri
|
||||
val definitionsFuture = languageServer.definition(new TextDocumentPositionParams => [
|
||||
val definitionsFuture = languageServer.definition(new DefinitionParams => [
|
||||
textDocument = new TextDocumentIdentifier(fileUri)
|
||||
position = new Position(line, column)
|
||||
])
|
||||
|
@ -541,7 +543,7 @@ abstract class AbstractLanguageServerTest implements Endpoint {
|
|||
configurator.apply(configuration)
|
||||
val fileUri = initializeContext(configuration).uri
|
||||
|
||||
val hoverFuture = languageServer.hover(new TextDocumentPositionParams => [
|
||||
val hoverFuture = languageServer.hover(new HoverParams => [
|
||||
textDocument = new TextDocumentIdentifier(fileUri)
|
||||
position = new Position(line, column)
|
||||
])
|
||||
|
@ -581,7 +583,7 @@ abstract class AbstractLanguageServerTest implements Endpoint {
|
|||
configurator.apply(configuration);
|
||||
|
||||
val fileUri = initializeContext(configuration).uri;
|
||||
val highlights = languageServer.documentHighlight(new TextDocumentPositionParams => [
|
||||
val highlights = languageServer.documentHighlight(new DocumentHighlightParams => [
|
||||
textDocument = new TextDocumentIdentifier(fileUri)
|
||||
position = new Position(line, column)
|
||||
]);
|
||||
|
|
|
@ -40,6 +40,7 @@ import org.eclipse.lsp4j.Command;
|
|||
import org.eclipse.lsp4j.CompletionItem;
|
||||
import org.eclipse.lsp4j.CompletionList;
|
||||
import org.eclipse.lsp4j.CompletionParams;
|
||||
import org.eclipse.lsp4j.DefinitionParams;
|
||||
import org.eclipse.lsp4j.Diagnostic;
|
||||
import org.eclipse.lsp4j.DidChangeWatchedFilesParams;
|
||||
import org.eclipse.lsp4j.DidCloseTextDocumentParams;
|
||||
|
@ -47,6 +48,7 @@ import org.eclipse.lsp4j.DidOpenTextDocumentParams;
|
|||
import org.eclipse.lsp4j.DocumentFormattingParams;
|
||||
import org.eclipse.lsp4j.DocumentHighlight;
|
||||
import org.eclipse.lsp4j.DocumentHighlightKind;
|
||||
import org.eclipse.lsp4j.DocumentHighlightParams;
|
||||
import org.eclipse.lsp4j.DocumentRangeFormattingParams;
|
||||
import org.eclipse.lsp4j.DocumentSymbol;
|
||||
import org.eclipse.lsp4j.DocumentSymbolCapabilities;
|
||||
|
@ -54,6 +56,7 @@ import org.eclipse.lsp4j.DocumentSymbolParams;
|
|||
import org.eclipse.lsp4j.FileChangeType;
|
||||
import org.eclipse.lsp4j.FileEvent;
|
||||
import org.eclipse.lsp4j.Hover;
|
||||
import org.eclipse.lsp4j.HoverParams;
|
||||
import org.eclipse.lsp4j.InitializeParams;
|
||||
import org.eclipse.lsp4j.InitializeResult;
|
||||
import org.eclipse.lsp4j.Location;
|
||||
|
@ -74,7 +77,6 @@ import org.eclipse.lsp4j.TextDocumentClientCapabilities;
|
|||
import org.eclipse.lsp4j.TextDocumentEdit;
|
||||
import org.eclipse.lsp4j.TextDocumentIdentifier;
|
||||
import org.eclipse.lsp4j.TextDocumentItem;
|
||||
import org.eclipse.lsp4j.TextDocumentPositionParams;
|
||||
import org.eclipse.lsp4j.TextEdit;
|
||||
import org.eclipse.lsp4j.VersionedTextDocumentIdentifier;
|
||||
import org.eclipse.lsp4j.WorkspaceEdit;
|
||||
|
@ -1106,8 +1108,8 @@ public abstract class AbstractLanguageServerTest implements Endpoint {
|
|||
configuration.setFilePath(("MyModel." + this.fileExtension));
|
||||
configurator.apply(configuration);
|
||||
final String fileUri = this.initializeContext(configuration).getUri();
|
||||
TextDocumentPositionParams _textDocumentPositionParams = new TextDocumentPositionParams();
|
||||
final Procedure1<TextDocumentPositionParams> _function = (TextDocumentPositionParams it) -> {
|
||||
DefinitionParams _definitionParams = new DefinitionParams();
|
||||
final Procedure1<DefinitionParams> _function = (DefinitionParams it) -> {
|
||||
TextDocumentIdentifier _textDocumentIdentifier = new TextDocumentIdentifier(fileUri);
|
||||
it.setTextDocument(_textDocumentIdentifier);
|
||||
int _line = configuration.getLine();
|
||||
|
@ -1115,7 +1117,7 @@ public abstract class AbstractLanguageServerTest implements Endpoint {
|
|||
Position _position = new Position(_line, _column);
|
||||
it.setPosition(_position);
|
||||
};
|
||||
TextDocumentPositionParams _doubleArrow = ObjectExtensions.<TextDocumentPositionParams>operator_doubleArrow(_textDocumentPositionParams, _function);
|
||||
DefinitionParams _doubleArrow = ObjectExtensions.<DefinitionParams>operator_doubleArrow(_definitionParams, _function);
|
||||
final CompletableFuture<Either<List<? extends Location>, List<? extends LocationLink>>> definitionsFuture = this.languageServer.definition(_doubleArrow);
|
||||
final Either<List<? extends Location>, List<? extends LocationLink>> definitions = definitionsFuture.get();
|
||||
Procedure1<? super List<? extends Location>> _assertDefinitions = configuration.getAssertDefinitions();
|
||||
|
@ -1138,8 +1140,8 @@ public abstract class AbstractLanguageServerTest implements Endpoint {
|
|||
configuration.setFilePath(("MyModel." + this.fileExtension));
|
||||
configurator.apply(configuration);
|
||||
final String fileUri = this.initializeContext(configuration).getUri();
|
||||
TextDocumentPositionParams _textDocumentPositionParams = new TextDocumentPositionParams();
|
||||
final Procedure1<TextDocumentPositionParams> _function = (TextDocumentPositionParams it) -> {
|
||||
HoverParams _hoverParams = new HoverParams();
|
||||
final Procedure1<HoverParams> _function = (HoverParams it) -> {
|
||||
TextDocumentIdentifier _textDocumentIdentifier = new TextDocumentIdentifier(fileUri);
|
||||
it.setTextDocument(_textDocumentIdentifier);
|
||||
int _line = configuration.getLine();
|
||||
|
@ -1147,7 +1149,7 @@ public abstract class AbstractLanguageServerTest implements Endpoint {
|
|||
Position _position = new Position(_line, _column);
|
||||
it.setPosition(_position);
|
||||
};
|
||||
TextDocumentPositionParams _doubleArrow = ObjectExtensions.<TextDocumentPositionParams>operator_doubleArrow(_textDocumentPositionParams, _function);
|
||||
HoverParams _doubleArrow = ObjectExtensions.<HoverParams>operator_doubleArrow(_hoverParams, _function);
|
||||
final CompletableFuture<Hover> hoverFuture = this.languageServer.hover(_doubleArrow);
|
||||
final Hover hover = hoverFuture.get();
|
||||
Procedure1<? super Hover> _assertHover = configuration.getAssertHover();
|
||||
|
@ -1208,8 +1210,8 @@ public abstract class AbstractLanguageServerTest implements Endpoint {
|
|||
final DocumentHighlightConfiguration configuration = ObjectExtensions.<DocumentHighlightConfiguration>operator_doubleArrow(_documentHighlightConfiguration, _function);
|
||||
configurator.apply(configuration);
|
||||
final String fileUri = this.initializeContext(configuration).getUri();
|
||||
TextDocumentPositionParams _textDocumentPositionParams = new TextDocumentPositionParams();
|
||||
final Procedure1<TextDocumentPositionParams> _function_1 = (TextDocumentPositionParams it) -> {
|
||||
DocumentHighlightParams _documentHighlightParams = new DocumentHighlightParams();
|
||||
final Procedure1<DocumentHighlightParams> _function_1 = (DocumentHighlightParams it) -> {
|
||||
TextDocumentIdentifier _textDocumentIdentifier = new TextDocumentIdentifier(fileUri);
|
||||
it.setTextDocument(_textDocumentIdentifier);
|
||||
int _line = configuration.getLine();
|
||||
|
@ -1217,7 +1219,7 @@ public abstract class AbstractLanguageServerTest implements Endpoint {
|
|||
Position _position = new Position(_line, _column);
|
||||
it.setPosition(_position);
|
||||
};
|
||||
TextDocumentPositionParams _doubleArrow = ObjectExtensions.<TextDocumentPositionParams>operator_doubleArrow(_textDocumentPositionParams, _function_1);
|
||||
DocumentHighlightParams _doubleArrow = ObjectExtensions.<DocumentHighlightParams>operator_doubleArrow(_documentHighlightParams, _function_1);
|
||||
final CompletableFuture<List<? extends DocumentHighlight>> highlights = this.languageServer.documentHighlight(_doubleArrow);
|
||||
final Function1<DocumentHighlight, String> _function_2 = (DocumentHighlight it) -> {
|
||||
return this.toExpectation(it);
|
||||
|
|
Loading…
Reference in a new issue