mirror of
https://github.com/sigmasternchen/xtext-core
synced 2025-03-15 00:08:55 +00:00
Merge pull request #1406 from eclipse/cd_issue1394b
[#1394] remove lsp api methods that were scheduled for removal with 2.22
This commit is contained in:
commit
52166dd122
37 changed files with 19 additions and 1574 deletions
|
@ -1,68 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2016 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.tests.server
|
||||
|
||||
import org.eclipse.lsp4j.services.LanguageClientExtensions
|
||||
import org.junit.Test
|
||||
|
||||
/**
|
||||
* Test for checking the coloring service for the test language.
|
||||
*
|
||||
* @author akos.kitta - Initial contribution and API
|
||||
*/
|
||||
@Deprecated
|
||||
class ColoringTest extends AbstractTestLangLanguageServerTest {
|
||||
|
||||
static val MODEL = '''
|
||||
type A {
|
||||
int a
|
||||
op foo() { }
|
||||
op foo(a: A): string { }
|
||||
}
|
||||
type B {
|
||||
int b
|
||||
op foo(a: A, b: B): int { }
|
||||
}
|
||||
type C {
|
||||
int c
|
||||
op foo(a: A, b: B, c: C): void { }
|
||||
}
|
||||
type Test {
|
||||
boolean t
|
||||
op main() { }
|
||||
}
|
||||
''';
|
||||
|
||||
@Test
|
||||
def void checkColoring() {
|
||||
initialize();
|
||||
val file = root.toPath.resolve('''MyModel.«fileExtension»''').toFile;
|
||||
val uri = file.toURI.toString;
|
||||
uri.open(MODEL);
|
||||
|
||||
// Map the file URI to the file name.
|
||||
val expectation = coloringParams.entrySet.toMap([it.key.substring(it.key.lastIndexOf('/') + 1)], [it.value]).toExpectation;
|
||||
assertEquals('''
|
||||
«file.name» ->
|
||||
* [[1, 5] .. [1, 6]] -> [1]
|
||||
* [[2, 4] .. [2, 7]] -> [1]
|
||||
* [[3, 4] .. [3, 7]] -> [1]
|
||||
* [[6, 5] .. [6, 6]] -> [1]
|
||||
* [[7, 4] .. [7, 7]] -> [1]
|
||||
* [[10, 5] .. [10, 6]] -> [1]
|
||||
* [[11, 4] .. [11, 7]] -> [1]
|
||||
* [[14, 9] .. [14, 10]] -> [1]
|
||||
* [[15, 4] .. [15, 8]] -> [1]''', expectation);
|
||||
}
|
||||
|
||||
override protected getLanguageClientClass() {
|
||||
return LanguageClientExtensions;
|
||||
}
|
||||
|
||||
}
|
|
@ -8,20 +8,10 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.xtext.ide.tests.server
|
||||
|
||||
import com.google.inject.Inject
|
||||
import com.google.inject.Provider
|
||||
import org.eclipse.emf.common.util.URI
|
||||
import org.eclipse.lsp4j.DocumentFormattingParams
|
||||
import org.eclipse.lsp4j.FormattingOptions
|
||||
import org.eclipse.lsp4j.Position
|
||||
import org.eclipse.lsp4j.Range
|
||||
import org.eclipse.xtext.ide.server.Document
|
||||
import org.eclipse.xtext.ide.server.formatting.FormattingService
|
||||
import org.eclipse.xtext.resource.XtextResource
|
||||
import org.eclipse.xtext.resource.XtextResourceSet
|
||||
import org.eclipse.xtext.util.CancelIndicator
|
||||
import org.eclipse.xtext.util.StringInputStream
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
|
||||
/**
|
||||
|
@ -106,59 +96,5 @@ class FormattingTest extends AbstractTestLangLanguageServerTest {
|
|||
} type Bar{Foo foo}'''
|
||||
]
|
||||
}
|
||||
|
||||
@Inject
|
||||
Provider<XtextResourceSet> rsp
|
||||
|
||||
@Inject
|
||||
Provider<FormattingService2> fs2p
|
||||
|
||||
@Test def void testAPIMaintenance_01() {
|
||||
val FormattingService2 fs2 = fs2p.get
|
||||
doTestAPIMaintenanceLayer(fs2)
|
||||
}
|
||||
|
||||
@Inject
|
||||
Provider<FormattingService3> fs3p
|
||||
|
||||
@Test def void testAPIMaintenance_02() {
|
||||
val FormattingService3 fs3 = fs3p.get
|
||||
doTestAPIMaintenanceLayer(fs3)
|
||||
}
|
||||
|
||||
private def doTestAPIMaintenanceLayer(FormattingService fs) {
|
||||
val model = '''type Foo{int bar} type Bar{Foo foo}'''
|
||||
val rs = rsp.get
|
||||
val r = rs.createResource(URI.createURI("dummy.testlang")) as XtextResource
|
||||
r.load(new StringInputStream(model), null)
|
||||
try {
|
||||
fs.format(new Document(1,model), r, new DocumentFormattingParams, CancelIndicator.NullImpl)
|
||||
Assert.fail("IllegalStateException expected")
|
||||
} catch (IllegalStateException e) {
|
||||
if (e.message != "api maintenance layer broken") {
|
||||
throw e
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static class FormattingService2 extends FormattingService {
|
||||
|
||||
override format(XtextResource resource, Document document, int offset, int length) {
|
||||
throw new IllegalStateException("api maintenance layer broken")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static abstract class AbstractCustomFormattingService extends FormattingService {
|
||||
|
||||
override format(XtextResource resource, Document document, int offset, int length) {
|
||||
throw new IllegalStateException("api maintenance layer broken")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static class FormattingService3 extends AbstractCustomFormattingService {
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -32,11 +32,6 @@ public class TestLanguageRuntimeModule extends AbstractTestLanguageRuntimeModule
|
|||
return SignatureHelpServiceImpl.class;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public Class<? extends org.eclipse.xtext.ide.server.coloring.IColoringService> bindIColoringService() {
|
||||
return org.eclipse.xtext.ide.tests.testlanguage.coloring.ColoringServiceImpl.class;
|
||||
}
|
||||
|
||||
public Class<? extends ISemanticHighlightingCalculator> bindISemanticHighlightingCalculator() {
|
||||
return SemanticHighlightingCalculatorImpl.class;
|
||||
}
|
||||
|
|
|
@ -1,60 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2016, 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.tests.testlanguage.coloring
|
||||
|
||||
import com.google.common.collect.ImmutableList
|
||||
import java.util.Collections
|
||||
import org.eclipse.emf.ecore.util.EcoreUtil
|
||||
import org.eclipse.lsp4j.ColoringInformation
|
||||
import org.eclipse.lsp4j.ColoringStyle
|
||||
import org.eclipse.lsp4j.Range
|
||||
import org.eclipse.xtext.ide.server.Document
|
||||
import org.eclipse.xtext.ide.server.coloring.IColoringService
|
||||
import org.eclipse.xtext.ide.tests.testlanguage.testLanguage.Operation
|
||||
import org.eclipse.xtext.ide.tests.testlanguage.testLanguage.Property
|
||||
import org.eclipse.xtext.nodemodel.util.NodeModelUtils
|
||||
import org.eclipse.xtext.resource.XtextResource
|
||||
|
||||
import static org.eclipse.xtext.ide.tests.testlanguage.testLanguage.TestLanguagePackage.Literals.MEMBER__NAME
|
||||
|
||||
/**
|
||||
* Basic coloring service that highlights the method and variable declarations
|
||||
* for testing purposes.
|
||||
*
|
||||
* @author akos.kitta - Initial contribution and API
|
||||
*/
|
||||
@Deprecated
|
||||
class ColoringServiceImpl implements IColoringService {
|
||||
|
||||
static val STYLE_IDS = Collections.singletonList(ColoringStyle.Identifier);
|
||||
|
||||
override getColoring(XtextResource resource, Document document) {
|
||||
if (resource === null) {
|
||||
return emptyList;
|
||||
}
|
||||
val builder = ImmutableList.builder;
|
||||
EcoreUtil.getAllContents(resource, true).forEach [
|
||||
val nodes = if (it instanceof Property) {
|
||||
NodeModelUtils.findNodesForFeature(it, MEMBER__NAME);
|
||||
} else if (it instanceof Operation) {
|
||||
NodeModelUtils.findNodesForFeature(it, MEMBER__NAME);
|
||||
} else {
|
||||
emptyList;
|
||||
}
|
||||
nodes.forEach [
|
||||
val start = offset;
|
||||
val end = offset + length;
|
||||
val range = new Range(document.getPosition(start), document.getPosition(end));
|
||||
builder.add(new ColoringInformation(range, STYLE_IDS));
|
||||
]
|
||||
];
|
||||
return builder.build;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,142 +0,0 @@
|
|||
/**
|
||||
* Copyright (c) 2016 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.tests.server;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.file.Path;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.eclipse.lsp4j.ColoringInformation;
|
||||
import org.eclipse.lsp4j.services.LanguageClient;
|
||||
import org.eclipse.lsp4j.services.LanguageClientExtensions;
|
||||
import org.eclipse.xtend2.lib.StringConcatenation;
|
||||
import org.eclipse.xtext.ide.tests.server.AbstractTestLangLanguageServerTest;
|
||||
import org.eclipse.xtext.xbase.lib.Functions.Function0;
|
||||
import org.eclipse.xtext.xbase.lib.Functions.Function1;
|
||||
import org.eclipse.xtext.xbase.lib.IterableExtensions;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Test for checking the coloring service for the test language.
|
||||
*
|
||||
* @author akos.kitta - Initial contribution and API
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("all")
|
||||
public class ColoringTest extends AbstractTestLangLanguageServerTest {
|
||||
private static final String MODEL = new Function0<String>() {
|
||||
@Override
|
||||
public String apply() {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("type A {");
|
||||
_builder.newLine();
|
||||
_builder.append("\t");
|
||||
_builder.append("int a ");
|
||||
_builder.newLine();
|
||||
_builder.append("\t");
|
||||
_builder.append("op foo() { } ");
|
||||
_builder.newLine();
|
||||
_builder.append("\t");
|
||||
_builder.append("op foo(a: A): string { }");
|
||||
_builder.newLine();
|
||||
_builder.append("}");
|
||||
_builder.newLine();
|
||||
_builder.append("type B {");
|
||||
_builder.newLine();
|
||||
_builder.append("\t");
|
||||
_builder.append("int b");
|
||||
_builder.newLine();
|
||||
_builder.append("\t");
|
||||
_builder.append("op foo(a: A, b: B): int { }");
|
||||
_builder.newLine();
|
||||
_builder.append("}");
|
||||
_builder.newLine();
|
||||
_builder.append("type C {");
|
||||
_builder.newLine();
|
||||
_builder.append("\t");
|
||||
_builder.append("int c");
|
||||
_builder.newLine();
|
||||
_builder.append("\t");
|
||||
_builder.append("op foo(a: A, b: B, c: C): void { }");
|
||||
_builder.newLine();
|
||||
_builder.append("}");
|
||||
_builder.newLine();
|
||||
_builder.append("type Test {");
|
||||
_builder.newLine();
|
||||
_builder.append("\t");
|
||||
_builder.append("boolean t");
|
||||
_builder.newLine();
|
||||
_builder.append("\t");
|
||||
_builder.append("op main() { }");
|
||||
_builder.newLine();
|
||||
_builder.append("}");
|
||||
_builder.newLine();
|
||||
return _builder.toString();
|
||||
}
|
||||
}.apply();
|
||||
|
||||
@Test
|
||||
public void checkColoring() {
|
||||
this.initialize();
|
||||
Path _path = this.root.toPath();
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("MyModel.");
|
||||
_builder.append(this.fileExtension);
|
||||
final File file = _path.resolve(_builder.toString()).toFile();
|
||||
final String uri = file.toURI().toString();
|
||||
this.open(uri, ColoringTest.MODEL);
|
||||
final Function1<Map.Entry<String, List<? extends ColoringInformation>>, String> _function = (Map.Entry<String, List<? extends ColoringInformation>> it) -> {
|
||||
String _key = it.getKey();
|
||||
int _lastIndexOf = it.getKey().lastIndexOf("/");
|
||||
int _plus = (_lastIndexOf + 1);
|
||||
return _key.substring(_plus);
|
||||
};
|
||||
final Function1<Map.Entry<String, List<? extends ColoringInformation>>, List<? extends ColoringInformation>> _function_1 = (Map.Entry<String, List<? extends ColoringInformation>> it) -> {
|
||||
return it.getValue();
|
||||
};
|
||||
final String expectation = this.toExpectation(IterableExtensions.<Map.Entry<String, List<? extends ColoringInformation>>, String, List<? extends ColoringInformation>>toMap(this.getColoringParams().entrySet(), _function, _function_1));
|
||||
StringConcatenation _builder_1 = new StringConcatenation();
|
||||
String _name = file.getName();
|
||||
_builder_1.append(_name);
|
||||
_builder_1.append(" ->");
|
||||
_builder_1.newLineIfNotEmpty();
|
||||
_builder_1.append(" ");
|
||||
_builder_1.append("* [[1, 5] .. [1, 6]] -> [1]");
|
||||
_builder_1.newLine();
|
||||
_builder_1.append(" ");
|
||||
_builder_1.append("* [[2, 4] .. [2, 7]] -> [1]");
|
||||
_builder_1.newLine();
|
||||
_builder_1.append(" ");
|
||||
_builder_1.append("* [[3, 4] .. [3, 7]] -> [1]");
|
||||
_builder_1.newLine();
|
||||
_builder_1.append(" ");
|
||||
_builder_1.append("* [[6, 5] .. [6, 6]] -> [1]");
|
||||
_builder_1.newLine();
|
||||
_builder_1.append(" ");
|
||||
_builder_1.append("* [[7, 4] .. [7, 7]] -> [1]");
|
||||
_builder_1.newLine();
|
||||
_builder_1.append(" ");
|
||||
_builder_1.append("* [[10, 5] .. [10, 6]] -> [1]");
|
||||
_builder_1.newLine();
|
||||
_builder_1.append(" ");
|
||||
_builder_1.append("* [[11, 4] .. [11, 7]] -> [1]");
|
||||
_builder_1.newLine();
|
||||
_builder_1.append(" ");
|
||||
_builder_1.append("* [[14, 9] .. [14, 10]] -> [1]");
|
||||
_builder_1.newLine();
|
||||
_builder_1.append(" ");
|
||||
_builder_1.append("* [[15, 4] .. [15, 8]] -> [1]");
|
||||
this.assertEquals(_builder_1.toString(), expectation);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<? extends LanguageClient> getLanguageClientClass() {
|
||||
return LanguageClientExtensions.class;
|
||||
}
|
||||
}
|
|
@ -14,7 +14,6 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import org.eclipse.lsp4j.CodeAction;
|
||||
import org.eclipse.lsp4j.CodeLens;
|
||||
import org.eclipse.lsp4j.ColoringInformation;
|
||||
import org.eclipse.lsp4j.Command;
|
||||
import org.eclipse.lsp4j.CompletionItem;
|
||||
import org.eclipse.lsp4j.CompletionItemKind;
|
||||
|
@ -355,8 +354,6 @@ public class CompletionTest extends AbstractTestLangLanguageServerTest {
|
|||
return _toExpectation((CodeAction)it);
|
||||
} else if (it instanceof CodeLens) {
|
||||
return _toExpectation((CodeLens)it);
|
||||
} else if (it instanceof ColoringInformation) {
|
||||
return _toExpectation((ColoringInformation)it);
|
||||
} else if (it instanceof Command) {
|
||||
return _toExpectation((Command)it);
|
||||
} else if (it instanceof CompletionItem) {
|
||||
|
|
|
@ -8,35 +8,21 @@
|
|||
*/
|
||||
package org.eclipse.xtext.ide.tests.server;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import org.eclipse.emf.common.util.URI;
|
||||
import org.eclipse.emf.ecore.resource.Resource;
|
||||
import org.eclipse.lsp4j.DocumentFormattingParams;
|
||||
import org.eclipse.lsp4j.DocumentRangeFormattingParams;
|
||||
import org.eclipse.lsp4j.FormattingOptions;
|
||||
import org.eclipse.lsp4j.Position;
|
||||
import org.eclipse.lsp4j.Range;
|
||||
import org.eclipse.lsp4j.TextEdit;
|
||||
import org.eclipse.xtend2.lib.StringConcatenation;
|
||||
import org.eclipse.xtext.ide.server.Document;
|
||||
import org.eclipse.xtext.ide.server.formatting.FormattingService;
|
||||
import org.eclipse.xtext.ide.tests.server.AbstractTestLangLanguageServerTest;
|
||||
import org.eclipse.xtext.resource.XtextResource;
|
||||
import org.eclipse.xtext.resource.XtextResourceSet;
|
||||
import org.eclipse.xtext.testing.FormattingConfiguration;
|
||||
import org.eclipse.xtext.testing.RangeFormattingConfiguration;
|
||||
import org.eclipse.xtext.util.CancelIndicator;
|
||||
import org.eclipse.xtext.util.StringInputStream;
|
||||
import org.eclipse.xtext.xbase.lib.CollectionLiterals;
|
||||
import org.eclipse.xtext.xbase.lib.Exceptions;
|
||||
import org.eclipse.xtext.xbase.lib.ObjectExtensions;
|
||||
import org.eclipse.xtext.xbase.lib.Pair;
|
||||
import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
|
@ -46,23 +32,6 @@ import org.junit.Test;
|
|||
*/
|
||||
@SuppressWarnings("all")
|
||||
public class FormattingTest extends AbstractTestLangLanguageServerTest {
|
||||
public static class FormattingService2 extends FormattingService {
|
||||
@Override
|
||||
public List<TextEdit> format(final XtextResource resource, final Document document, final int offset, final int length) {
|
||||
throw new IllegalStateException("api maintenance layer broken");
|
||||
}
|
||||
}
|
||||
|
||||
public static abstract class AbstractCustomFormattingService extends FormattingService {
|
||||
@Override
|
||||
public List<TextEdit> format(final XtextResource resource, final Document document, final int offset, final int length) {
|
||||
throw new IllegalStateException("api maintenance layer broken");
|
||||
}
|
||||
}
|
||||
|
||||
public static class FormattingService3 extends FormattingTest.AbstractCustomFormattingService {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFormattingService() {
|
||||
final Procedure1<FormattingConfiguration> _function = (FormattingConfiguration it) -> {
|
||||
|
@ -203,57 +172,4 @@ public class FormattingTest extends AbstractTestLangLanguageServerTest {
|
|||
};
|
||||
this.testRangeFormatting(_function, _function_1);
|
||||
}
|
||||
|
||||
@Inject
|
||||
private Provider<XtextResourceSet> rsp;
|
||||
|
||||
@Inject
|
||||
private Provider<FormattingTest.FormattingService2> fs2p;
|
||||
|
||||
@Test
|
||||
public void testAPIMaintenance_01() {
|
||||
final FormattingTest.FormattingService2 fs2 = this.fs2p.get();
|
||||
this.doTestAPIMaintenanceLayer(fs2);
|
||||
}
|
||||
|
||||
@Inject
|
||||
private Provider<FormattingTest.FormattingService3> fs3p;
|
||||
|
||||
@Test
|
||||
public void testAPIMaintenance_02() {
|
||||
final FormattingTest.FormattingService3 fs3 = this.fs3p.get();
|
||||
this.doTestAPIMaintenanceLayer(fs3);
|
||||
}
|
||||
|
||||
private void doTestAPIMaintenanceLayer(final FormattingService fs) {
|
||||
try {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("type Foo{int bar} type Bar{Foo foo}");
|
||||
final String model = _builder.toString();
|
||||
final XtextResourceSet rs = this.rsp.get();
|
||||
Resource _createResource = rs.createResource(URI.createURI("dummy.testlang"));
|
||||
final XtextResource r = ((XtextResource) _createResource);
|
||||
StringInputStream _stringInputStream = new StringInputStream(model);
|
||||
r.load(_stringInputStream, null);
|
||||
try {
|
||||
Document _document = new Document(Integer.valueOf(1), model);
|
||||
DocumentFormattingParams _documentFormattingParams = new DocumentFormattingParams();
|
||||
fs.format(_document, r, _documentFormattingParams, CancelIndicator.NullImpl);
|
||||
Assert.fail("IllegalStateException expected");
|
||||
} catch (final Throwable _t) {
|
||||
if (_t instanceof IllegalStateException) {
|
||||
final IllegalStateException e = (IllegalStateException)_t;
|
||||
String _message = e.getMessage();
|
||||
boolean _notEquals = (!Objects.equal(_message, "api maintenance layer broken"));
|
||||
if (_notEquals) {
|
||||
throw e;
|
||||
}
|
||||
} else {
|
||||
throw Exceptions.sneakyThrow(_t);
|
||||
}
|
||||
}
|
||||
} catch (Throwable _e) {
|
||||
throw Exceptions.sneakyThrow(_e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,80 +0,0 @@
|
|||
/**
|
||||
* Copyright (c) 2016, 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.tests.testlanguage.coloring;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
import org.eclipse.emf.ecore.EObject;
|
||||
import org.eclipse.emf.ecore.util.EcoreUtil;
|
||||
import org.eclipse.lsp4j.ColoringInformation;
|
||||
import org.eclipse.lsp4j.ColoringStyle;
|
||||
import org.eclipse.lsp4j.Position;
|
||||
import org.eclipse.lsp4j.Range;
|
||||
import org.eclipse.xtext.ide.server.Document;
|
||||
import org.eclipse.xtext.ide.server.coloring.IColoringService;
|
||||
import org.eclipse.xtext.ide.tests.testlanguage.testLanguage.Operation;
|
||||
import org.eclipse.xtext.ide.tests.testlanguage.testLanguage.Property;
|
||||
import org.eclipse.xtext.ide.tests.testlanguage.testLanguage.TestLanguagePackage;
|
||||
import org.eclipse.xtext.nodemodel.INode;
|
||||
import org.eclipse.xtext.nodemodel.util.NodeModelUtils;
|
||||
import org.eclipse.xtext.resource.XtextResource;
|
||||
import org.eclipse.xtext.xbase.lib.CollectionLiterals;
|
||||
import org.eclipse.xtext.xbase.lib.IteratorExtensions;
|
||||
import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;
|
||||
|
||||
/**
|
||||
* Basic coloring service that highlights the method and variable declarations
|
||||
* for testing purposes.
|
||||
*
|
||||
* @author akos.kitta - Initial contribution and API
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("all")
|
||||
public class ColoringServiceImpl implements IColoringService {
|
||||
private static final List<Integer> STYLE_IDS = Collections.<Integer>singletonList(Integer.valueOf(ColoringStyle.Identifier));
|
||||
|
||||
@Override
|
||||
public List<? extends ColoringInformation> getColoring(final XtextResource resource, final Document document) {
|
||||
if ((resource == null)) {
|
||||
return CollectionLiterals.<ColoringInformation>emptyList();
|
||||
}
|
||||
final ImmutableList.Builder<ColoringInformation> builder = ImmutableList.<ColoringInformation>builder();
|
||||
final Procedure1<Object> _function = (Object it) -> {
|
||||
List<INode> _xifexpression = null;
|
||||
if ((it instanceof Property)) {
|
||||
_xifexpression = NodeModelUtils.findNodesForFeature(((EObject)it), TestLanguagePackage.Literals.MEMBER__NAME);
|
||||
} else {
|
||||
List<INode> _xifexpression_1 = null;
|
||||
if ((it instanceof Operation)) {
|
||||
_xifexpression_1 = NodeModelUtils.findNodesForFeature(((EObject)it), TestLanguagePackage.Literals.MEMBER__NAME);
|
||||
} else {
|
||||
_xifexpression_1 = CollectionLiterals.<INode>emptyList();
|
||||
}
|
||||
_xifexpression = _xifexpression_1;
|
||||
}
|
||||
final List<INode> nodes = _xifexpression;
|
||||
final Consumer<INode> _function_1 = (INode it_1) -> {
|
||||
final int start = it_1.getOffset();
|
||||
int _offset = it_1.getOffset();
|
||||
int _length = it_1.getLength();
|
||||
final int end = (_offset + _length);
|
||||
Position _position = document.getPosition(start);
|
||||
Position _position_1 = document.getPosition(end);
|
||||
final Range range = new Range(_position, _position_1);
|
||||
ColoringInformation _coloringInformation = new ColoringInformation(range, ColoringServiceImpl.STYLE_IDS);
|
||||
builder.add(_coloringInformation);
|
||||
};
|
||||
nodes.forEach(_function_1);
|
||||
};
|
||||
IteratorExtensions.<Object>forEach(EcoreUtil.<Object>getAllContents(resource, true), _function);
|
||||
return builder.build();
|
||||
}
|
||||
}
|
|
@ -52,7 +52,6 @@ Export-Package: org.eclipse.xtext.ide;x-friends:="org.eclipse.xtend.ide,
|
|||
org.eclipse.xtext.ide.server,
|
||||
org.eclipse.xtext.ide.server.codeActions;x-friends:="org.eclipse.xtext.ide.tests",
|
||||
org.eclipse.xtext.ide.server.codelens;x-friends:="org.eclipse.xtext.ide.tests",
|
||||
org.eclipse.xtext.ide.server.coloring,
|
||||
org.eclipse.xtext.ide.server.commands,
|
||||
org.eclipse.xtext.ide.server.concurrent,
|
||||
org.eclipse.xtext.ide.server.contentassist,
|
||||
|
|
|
@ -142,16 +142,6 @@ public class BuildManager {
|
|||
return this::internalBuild;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated this method is no longer used
|
||||
* This method is scheduled to be removed with 2.22.
|
||||
*/
|
||||
@Deprecated//(forRemoval=true)
|
||||
public List<IResourceDescription.Delta> doBuild(List<URI> dirtyFiles, List<URI> deletedFiles,
|
||||
CancelIndicator cancelIndicator) {
|
||||
return submit(dirtyFiles, deletedFiles).build(cancelIndicator);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the contents of the given set.
|
||||
*/
|
||||
|
|
|
@ -29,8 +29,6 @@ import org.eclipse.lsp4j.CodeActionParams;
|
|||
import org.eclipse.lsp4j.CodeLens;
|
||||
import org.eclipse.lsp4j.CodeLensOptions;
|
||||
import org.eclipse.lsp4j.CodeLensParams;
|
||||
import org.eclipse.lsp4j.ColoringInformation;
|
||||
import org.eclipse.lsp4j.ColoringParams;
|
||||
import org.eclipse.lsp4j.Command;
|
||||
import org.eclipse.lsp4j.CompletionItem;
|
||||
import org.eclipse.lsp4j.CompletionList;
|
||||
|
@ -100,18 +98,15 @@ import org.eclipse.lsp4j.jsonrpc.messages.Either;
|
|||
import org.eclipse.lsp4j.jsonrpc.services.ServiceEndpoints;
|
||||
import org.eclipse.lsp4j.services.LanguageClient;
|
||||
import org.eclipse.lsp4j.services.LanguageClientAware;
|
||||
import org.eclipse.lsp4j.services.LanguageClientExtensions;
|
||||
import org.eclipse.lsp4j.services.LanguageServer;
|
||||
import org.eclipse.lsp4j.services.TextDocumentService;
|
||||
import org.eclipse.lsp4j.services.WorkspaceService;
|
||||
import org.eclipse.xtext.diagnostics.Severity;
|
||||
import org.eclipse.xtext.findReferences.IReferenceFinder;
|
||||
import org.eclipse.xtext.ide.server.BuildManager.Buildable;
|
||||
import org.eclipse.xtext.ide.server.codeActions.ICodeActionService;
|
||||
import org.eclipse.xtext.ide.server.codeActions.ICodeActionService2;
|
||||
import org.eclipse.xtext.ide.server.codelens.ICodeLensResolver;
|
||||
import org.eclipse.xtext.ide.server.codelens.ICodeLensService;
|
||||
import org.eclipse.xtext.ide.server.coloring.IColoringService;
|
||||
import org.eclipse.xtext.ide.server.commands.ExecutableCommandRegistry;
|
||||
import org.eclipse.xtext.ide.server.concurrent.RequestManager;
|
||||
import org.eclipse.xtext.ide.server.contentassist.ContentAssistService;
|
||||
|
@ -119,7 +114,6 @@ import org.eclipse.xtext.ide.server.findReferences.WorkspaceResourceAccess;
|
|||
import org.eclipse.xtext.ide.server.formatting.FormattingService;
|
||||
import org.eclipse.xtext.ide.server.hover.IHoverService;
|
||||
import org.eclipse.xtext.ide.server.occurrences.IDocumentHighlightService;
|
||||
import org.eclipse.xtext.ide.server.rename.IRenameService;
|
||||
import org.eclipse.xtext.ide.server.rename.IRenameService2;
|
||||
import org.eclipse.xtext.ide.server.semanticHighlight.SemanticHighlightingRegistry;
|
||||
import org.eclipse.xtext.ide.server.signatureHelp.ISignatureHelpService;
|
||||
|
@ -129,13 +123,11 @@ import org.eclipse.xtext.ide.server.symbol.IDocumentSymbolService;
|
|||
import org.eclipse.xtext.ide.server.symbol.WorkspaceSymbolService;
|
||||
import org.eclipse.xtext.resource.IResourceDescription;
|
||||
import org.eclipse.xtext.resource.IResourceServiceProvider;
|
||||
import org.eclipse.xtext.resource.XtextResource;
|
||||
import org.eclipse.xtext.resource.XtextResourceSet;
|
||||
import org.eclipse.xtext.resource.impl.ResourceDescriptionsProvider;
|
||||
import org.eclipse.xtext.util.BufferedCancelIndicator;
|
||||
import org.eclipse.xtext.util.CancelIndicator;
|
||||
import org.eclipse.xtext.validation.Issue;
|
||||
import org.eclipse.xtext.xbase.lib.IterableExtensions;
|
||||
import org.eclipse.xtext.xbase.lib.Pair;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
|
@ -152,7 +144,6 @@ import com.google.inject.Inject;
|
|||
* @author Sven Efftinge - Initial contribution and API
|
||||
* @since 2.11
|
||||
*/
|
||||
@SuppressWarnings({ "deprecation" })
|
||||
public class LanguageServerImpl implements LanguageServer, WorkspaceService, TextDocumentService, LanguageClientAware,
|
||||
Endpoint, JsonRpcMethodProvider, ILanguageServerAccess.IBuildListener {
|
||||
|
||||
|
@ -262,8 +253,7 @@ public class LanguageServerImpl implements LanguageServer, WorkspaceService, Tex
|
|||
serverCapabilities.setCodeLensProvider(codeLensOptions);
|
||||
}
|
||||
serverCapabilities.setCodeActionProvider(allLanguages.stream()
|
||||
.anyMatch((serviceProvider) -> serviceProvider.get(ICodeActionService.class) != null
|
||||
|| serviceProvider.get(ICodeActionService2.class) != null));
|
||||
.anyMatch((serviceProvider) -> serviceProvider.get(ICodeActionService2.class) != null));
|
||||
|
||||
serverCapabilities.setSignatureHelpProvider(new SignatureHelpOptions(ImmutableList.of("(", ",")));
|
||||
serverCapabilities.setTextDocumentSync(TextDocumentSyncKind.Incremental);
|
||||
|
@ -298,8 +288,7 @@ public class LanguageServerImpl implements LanguageServer, WorkspaceService, Tex
|
|||
serverCapabilities.setRenameProvider(Either.<Boolean, RenameOptions>forRight(renameOptions));
|
||||
} else {
|
||||
serverCapabilities.setRenameProvider(Either.forLeft(allLanguages.stream()
|
||||
.anyMatch((serviceProvider) -> serviceProvider.get(IRenameService.class) != null
|
||||
|| serviceProvider.get(IRenameService2.class) != null)));
|
||||
.anyMatch((serviceProvider) -> serviceProvider.get(IRenameService2.class) != null)));
|
||||
}
|
||||
WorkspaceClientCapabilities workspace = null;
|
||||
if (clientCapabilities != null) {
|
||||
|
@ -559,7 +548,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, (TextDocumentPositionParams) params, cancelIndicator)));
|
||||
(doc, res) -> contentAssistService.createCompletionList(doc, res, params, cancelIndicator)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -611,7 +600,7 @@ public class LanguageServerImpl implements LanguageServer, WorkspaceService, Tex
|
|||
return Collections.emptyList();
|
||||
}
|
||||
return workspaceManager.doRead(uri,
|
||||
(doc, res) -> documentSymbolService.getDefinitions(doc, res, (TextDocumentPositionParams) params, resourceAccess, cancelIndicator));
|
||||
(doc, res) -> documentSymbolService.getDefinitions(doc, res, params, resourceAccess, cancelIndicator));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -722,7 +711,7 @@ public class LanguageServerImpl implements LanguageServer, WorkspaceService, Tex
|
|||
return IHoverService.EMPTY_HOVER;
|
||||
}
|
||||
return workspaceManager.<Hover>doRead(uri,
|
||||
(document, resource) -> hoverService.hover(document, resource, (TextDocumentPositionParams) params, cancelIndicator));
|
||||
(document, resource) -> hoverService.hover(document, resource, params, cancelIndicator));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -746,7 +735,7 @@ public class LanguageServerImpl implements LanguageServer, WorkspaceService, Tex
|
|||
return ISignatureHelpService.EMPTY;
|
||||
}
|
||||
return workspaceManager.doRead(uri,
|
||||
(doc, resource) -> helper.getSignatureHelp(doc, resource, (TextDocumentPositionParams) params, cancelIndicator));
|
||||
(doc, resource) -> helper.getSignatureHelp(doc, resource, params, cancelIndicator));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -766,7 +755,7 @@ public class LanguageServerImpl implements LanguageServer, WorkspaceService, Tex
|
|||
return Collections.emptyList();
|
||||
}
|
||||
return workspaceManager.doRead(uri,
|
||||
(doc, resource) -> service.getDocumentHighlights(doc, resource, (TextDocumentPositionParams) params, cancelIndicator));
|
||||
(doc, resource) -> service.getDocumentHighlights(doc, resource, params, cancelIndicator));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -781,20 +770,12 @@ public class LanguageServerImpl implements LanguageServer, WorkspaceService, Tex
|
|||
protected List<Either<Command, CodeAction>> codeAction(CodeActionParams params, CancelIndicator cancelIndicator) {
|
||||
URI uri = getURI(params.getTextDocument());
|
||||
IResourceServiceProvider serviceProvider = getResourceServiceProvider(uri);
|
||||
ICodeActionService service = getService(serviceProvider, ICodeActionService.class);
|
||||
ICodeActionService2 service2 = getService(serviceProvider, ICodeActionService2.class);
|
||||
if (service == null && service2 == null) {
|
||||
if (service2 == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return workspaceManager.doRead(uri, (doc, resource) -> {
|
||||
List<Either<Command, CodeAction>> result = new ArrayList<>();
|
||||
if (service != null) {
|
||||
List<Either<Command, CodeAction>> actions = service.getCodeActions(doc, resource, params,
|
||||
cancelIndicator);
|
||||
if (actions != null) {
|
||||
result.addAll(actions);
|
||||
}
|
||||
}
|
||||
if (service2 != null) {
|
||||
ICodeActionService2.Options options = new ICodeActionService2.Options();
|
||||
options.setDocument(doc);
|
||||
|
@ -988,10 +969,6 @@ public class LanguageServerImpl implements LanguageServer, WorkspaceService, Tex
|
|||
URI uri = getURI(renameParams.getTextDocument());
|
||||
|
||||
IResourceServiceProvider resourceServiceProvider = getResourceServiceProvider(uri);
|
||||
IRenameService renameServiceOld = getService(resourceServiceProvider, IRenameService.class);
|
||||
if (renameServiceOld != null) {
|
||||
return renameServiceOld.rename(workspaceManager, renameParams, cancelIndicator);
|
||||
}
|
||||
IRenameService2 renameService2 = getService(resourceServiceProvider, IRenameService2.class);
|
||||
if (renameService2 != null) {
|
||||
IRenameService2.Options options = new IRenameService2.Options();
|
||||
|
@ -1160,23 +1137,6 @@ public class LanguageServerImpl implements LanguageServer, WorkspaceService, Tex
|
|||
FluentIterable.from(deltas).filter(it -> it.getNew() != null).transform(it -> it.getUri().toString())
|
||||
.forEach(it -> {
|
||||
access.doRead(it, ctx -> {
|
||||
if (ctx.isDocumentOpen()) {
|
||||
if (ctx.getResource() instanceof XtextResource) {
|
||||
XtextResource resource = (XtextResource) ctx.getResource();
|
||||
IColoringService coloringService = resource.getResourceServiceProvider()
|
||||
.get(IColoringService.class);
|
||||
if (coloringService != null && client instanceof LanguageClientExtensions) {
|
||||
Document doc = ctx.getDocument();
|
||||
List<? extends ColoringInformation> coloringInfos = coloringService
|
||||
.getColoring(resource, doc);
|
||||
if (!IterableExtensions.isNullOrEmpty(coloringInfos)) {
|
||||
String uri = resource.getURI().toString();
|
||||
((LanguageClientExtensions) client)
|
||||
.updateColoring(new ColoringParams(uri, coloringInfos));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
semanticHighlightingRegistry.update(ctx);
|
||||
return null;
|
||||
});
|
||||
|
|
|
@ -33,25 +33,5 @@ class UriExtensions extends org.eclipse.xtext.util.UriExtensions {
|
|||
def String toUriString(java.net.URI uri) {
|
||||
return toUriString(URI.createURI(uri.normalize.toString))
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use #toUriString(URI)
|
||||
* This method is scheduled to be removed with 2.22.
|
||||
*/
|
||||
@Deprecated//(forRemoval=true)
|
||||
def String toPath(URI uri) {
|
||||
return toUriString(uri)
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use toUriString(URI)
|
||||
* This method is scheduled to be removed with 2.22.
|
||||
*/
|
||||
@Deprecated//(forRemoval=true)
|
||||
def String toPath(java.net.URI uri) {
|
||||
return toUriString(uri)
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -365,35 +365,6 @@ public class WorkspaceManager {
|
|||
return ImmutableList.copyOf(projectName2ProjectManager.values());
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated the server should not apply {@link TextEdit}s but {@link TextDocumentContentChangeEvent}s. Use
|
||||
* {@link #didChangeTextDocumentContent(URI, Integer, Iterable)} instead.
|
||||
* This method is scheduled to be removed with 2.22.
|
||||
*/
|
||||
@Deprecated//(forRemoval=true)
|
||||
public List<IResourceDescription.Delta> didChange(URI uri, Integer version, Iterable<TextEdit> changes,
|
||||
CancelIndicator cancelIndicator) {
|
||||
return didChange(uri, version, changes).build(cancelIndicator);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param version
|
||||
* unused
|
||||
* @deprecated the server should not apply {@link TextEdit}s but {@link TextDocumentContentChangeEvent}s. Use
|
||||
* {@link #didChangeTextDocumentContent(URI, Integer, Iterable)} instead.
|
||||
* This method is scheduled to be removed with 2.22.
|
||||
*/
|
||||
@Deprecated//(forRemoval=true)
|
||||
public BuildManager.Buildable didChange(URI uri, Integer version, Iterable<TextEdit> changes) {
|
||||
Document contents = openDocuments.get(uri);
|
||||
if (contents == null) {
|
||||
LOG.error("The document " + uri + " has not been opened.");
|
||||
return Buildable.NO_BUILD;
|
||||
}
|
||||
openDocuments.put(uri, contents.applyChanges(changes));
|
||||
return didChangeFiles(ImmutableList.of(uri), Collections.emptyList());
|
||||
}
|
||||
|
||||
/**
|
||||
* As opposed to {@link TextEdit}[] the positions in the edits of a {@link DidChangeTextDocumentParams} refer to the
|
||||
* state after applying the preceding edits. See
|
||||
|
@ -434,14 +405,6 @@ public class WorkspaceManager {
|
|||
return didChangeFiles(ImmutableList.of(uri), Collections.emptyList());
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated this method is no longer called. This method is scheduled to be removed with 2.22.
|
||||
*/
|
||||
@Deprecated//(forRemoval=true)
|
||||
public List<IResourceDescription.Delta> didClose(URI uri, CancelIndicator cancelIndicator) {
|
||||
return didClose(uri).build(cancelIndicator);
|
||||
}
|
||||
|
||||
/**
|
||||
* Mark the given document as cloded.
|
||||
*/
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2017 TypeFox GmbH (http://www.typefox.io) and others.
|
||||
* 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.
|
||||
|
@ -19,18 +19,6 @@ import org.eclipse.xtext.ide.server.ILanguageServerAccess
|
|||
import org.eclipse.xtext.resource.XtextResource
|
||||
import org.eclipse.xtext.util.CancelIndicator
|
||||
|
||||
/**
|
||||
* @author Sven Efftinge - Initial contribution and API
|
||||
* @deprecated use {@link ICodeActionService2} instead
|
||||
* This interface is scheduled to be removed with 2.22.
|
||||
*/
|
||||
@Deprecated//(forRemoval=true)
|
||||
interface ICodeActionService {
|
||||
|
||||
def List<Either<Command, CodeAction>> getCodeActions(Document document, XtextResource resource, CodeActionParams params, CancelIndicator indicator)
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @author Jan Koehnlein
|
||||
* @since 2.18
|
|
@ -1,65 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2016 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.coloring;
|
||||
|
||||
import static java.util.Collections.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.lsp4j.ColoringInformation;
|
||||
import org.eclipse.xtext.ide.editor.syntaxcoloring.ISemanticHighlightingCalculator;
|
||||
import org.eclipse.xtext.ide.server.Document;
|
||||
import org.eclipse.xtext.ide.server.semanticHighlight.ISemanticHighlightingStyleToTokenMapper;
|
||||
import org.eclipse.xtext.resource.XtextResource;
|
||||
|
||||
import com.google.inject.ImplementedBy;
|
||||
|
||||
/**
|
||||
* Representation of a generic, IDE independent coloring service. Provides
|
||||
* coloring and highlighting information for clients based on the underlying
|
||||
* model.
|
||||
*
|
||||
* @author akos.kitta - Initial contribution and API
|
||||
* @deprecated use the {@link ISemanticHighlightingCalculator} and the {@link ISemanticHighlightingStyleToTokenMapper} instead.
|
||||
* This interface is scheduled to be removed with 2.22.
|
||||
*/
|
||||
@Deprecated
|
||||
@ImplementedBy(IColoringService.Noop.class)
|
||||
public interface IColoringService {
|
||||
|
||||
/**
|
||||
* Provides a list of all available coloring information for the resource.
|
||||
*
|
||||
* @param resource
|
||||
* the resource that will be highlighted. May be {@code null} in
|
||||
* some rare cases.
|
||||
* @param document
|
||||
* the IDE and Xtext independent document that can be used to
|
||||
* convert the document based offsets to line based positions.
|
||||
* @return a list of all the coloring and highlighting information for the
|
||||
* resource. Must not return with {@code null}, but an empty list
|
||||
* instead.
|
||||
*/
|
||||
List<? extends ColoringInformation> getColoring(XtextResource resource, Document document);
|
||||
|
||||
/**
|
||||
* NOOP {@link IColoringService coloring service} implementation. Always
|
||||
* provides an empty list of coloring information.
|
||||
*
|
||||
* @author akos.kitta - Initial contribution and API
|
||||
*/
|
||||
public static class Noop implements IColoringService {
|
||||
|
||||
@Override
|
||||
public List<? extends ColoringInformation> getColoring(XtextResource resource, Document document) {
|
||||
return emptyList();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -21,7 +21,6 @@ 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
|
||||
import org.eclipse.lsp4j.TextEdit
|
||||
import org.eclipse.xtext.ide.editor.contentassist.ContentAssistEntry
|
||||
import org.eclipse.xtext.ide.editor.contentassist.IIdeContentProposalAcceptor
|
||||
|
@ -56,19 +55,6 @@ class ContentAssistService {
|
|||
|
||||
@Inject OperationCanceledManager operationCanceledManager
|
||||
|
||||
/**
|
||||
* @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
|
||||
|
|
|
@ -8,28 +8,26 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.xtext.ide.server.formatting
|
||||
|
||||
import com.google.common.base.Strings
|
||||
import com.google.inject.Inject
|
||||
import com.google.inject.Provider
|
||||
import java.util.List
|
||||
import org.eclipse.lsp4j.DocumentFormattingParams
|
||||
import org.eclipse.lsp4j.DocumentRangeFormattingParams
|
||||
import org.eclipse.lsp4j.FormattingOptions
|
||||
import org.eclipse.lsp4j.Range
|
||||
import org.eclipse.lsp4j.TextEdit
|
||||
import org.eclipse.xtext.formatting.IIndentationInformation
|
||||
import org.eclipse.xtext.formatting2.FormatterRequest
|
||||
import org.eclipse.xtext.formatting2.IFormatter2
|
||||
import org.eclipse.xtext.formatting2.regionaccess.TextRegionAccessBuilder
|
||||
import org.eclipse.xtext.ide.server.Document
|
||||
import org.eclipse.xtext.preferences.ITypedPreferenceValues
|
||||
import org.eclipse.xtext.preferences.MapBasedPreferenceValues
|
||||
import org.eclipse.xtext.resource.XtextResource
|
||||
import org.eclipse.xtext.util.CancelIndicator
|
||||
import org.eclipse.xtext.util.ITextRegion
|
||||
import org.eclipse.xtext.util.TextRegion
|
||||
import org.eclipse.xtext.preferences.MapBasedPreferenceValues
|
||||
import com.google.common.base.Strings
|
||||
import org.eclipse.lsp4j.FormattingOptions
|
||||
import java.util.Map
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
import org.eclipse.xtext.formatting.IIndentationInformation
|
||||
|
||||
/**
|
||||
* Language Service Implementation for Formatting and Range-Formatting
|
||||
|
@ -58,9 +56,6 @@ class FormattingService {
|
|||
if (length === 0 || resource.contents.isEmpty) {
|
||||
return emptyList
|
||||
}
|
||||
if (OverrideChecker.hasFormatOverride(class)) {
|
||||
return format(resource, document, offset, length)
|
||||
}
|
||||
return format(resource, document, offset, length, params.options)
|
||||
}
|
||||
|
||||
|
@ -72,20 +67,8 @@ class FormattingService {
|
|||
) {
|
||||
val offset = document.getOffSet(params.range.start)
|
||||
val length = document.getOffSet(params.range.end) - offset
|
||||
if (OverrideChecker.hasFormatOverride(class)) {
|
||||
return format(resource, document, offset, length)
|
||||
}
|
||||
return format(resource, document, offset, length, params.options)
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use {@link #format(XtextResource, Document, int, int, FormattingOptions)} instead.
|
||||
* This method is scheduled to be removed with 2.22.
|
||||
*/
|
||||
@Deprecated//(forRemoval=true)
|
||||
def List<TextEdit> format(XtextResource resource, Document document, int offset, int length) {
|
||||
format(resource, document, offset, length, null)
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 2.14
|
||||
|
@ -135,30 +118,5 @@ class FormattingService {
|
|||
val replacements = formatter2.format(request)
|
||||
return replacements
|
||||
}
|
||||
|
||||
private static class OverrideChecker {
|
||||
static val Map<Class<?>, Boolean> CLASSES_WITH_OVERRIDES = new ConcurrentHashMap<Class<?>, Boolean>()
|
||||
def static boolean hasFormatOverride(Class<? extends FormattingService> formattingServiceClass) {
|
||||
var Boolean result = CLASSES_WITH_OVERRIDES.get(formattingServiceClass)
|
||||
if (result === null) {
|
||||
try {
|
||||
result = Boolean.FALSE
|
||||
var Class<?> theClass = formattingServiceClass
|
||||
while (!result && theClass !== FormattingService) {
|
||||
try {
|
||||
theClass.getDeclaredMethod("format", XtextResource, Document, Integer.TYPE, Integer.TYPE)
|
||||
result = Boolean.TRUE
|
||||
} catch (NoSuchMethodException noSuchMethodException) {
|
||||
}
|
||||
theClass = theClass.getSuperclass()
|
||||
}
|
||||
} catch (Exception exception) {
|
||||
result = Boolean.TRUE
|
||||
}
|
||||
CLASSES_WITH_OVERRIDES.put(formattingServiceClass, result)
|
||||
}
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -11,7 +11,6 @@ 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;
|
||||
|
@ -25,21 +24,6 @@ import com.google.inject.ImplementedBy;
|
|||
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
|
||||
|
|
|
@ -97,7 +97,6 @@ public class DefaultDocumentHighlightService implements IDocumentHighlightServic
|
|||
return getDocumentHighlights(resource, offset);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DocumentHighlight> getDocumentHighlights(final XtextResource resource, final int offset) {
|
||||
if (resource == null) {
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
|
|
|
@ -12,7 +12,6 @@ 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;
|
||||
import org.eclipse.xtext.util.CancelIndicator;
|
||||
|
@ -33,42 +32,10 @@ import com.google.inject.ImplementedBy;
|
|||
*/
|
||||
@ImplementedBy(DefaultDocumentHighlightService.class)
|
||||
public interface IDocumentHighlightService {
|
||||
|
||||
/**
|
||||
* @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
|
||||
* offset.
|
||||
*
|
||||
* @param resource
|
||||
* the resource that represents the document where matching
|
||||
* highlights have to be collected.
|
||||
* @param offset
|
||||
* the offset used to identify the selected text from the
|
||||
* resource.
|
||||
*
|
||||
* @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//(forRemoval=true)
|
||||
List<? extends DocumentHighlight> getDocumentHighlights(final XtextResource resource, final int offset);
|
||||
|
||||
}
|
||||
|
|
|
@ -1,103 +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 com.google.inject.Inject
|
||||
import java.io.ByteArrayOutputStream
|
||||
import java.nio.charset.Charset
|
||||
import org.eclipse.emf.common.util.URI
|
||||
import org.eclipse.emf.ecore.resource.Resource
|
||||
import org.eclipse.emf.ecore.xmi.XMLResource
|
||||
import org.eclipse.lsp4j.Range
|
||||
import org.eclipse.lsp4j.TextEdit
|
||||
import org.eclipse.lsp4j.WorkspaceEdit
|
||||
import org.eclipse.xtext.ide.serializer.IEmfResourceChange
|
||||
import org.eclipse.xtext.ide.serializer.ITextDocumentChange
|
||||
import org.eclipse.xtext.ide.server.WorkspaceManager
|
||||
import org.eclipse.xtext.parser.IEncodingProvider
|
||||
import org.eclipse.xtext.resource.IResourceServiceProvider
|
||||
import org.eclipse.xtext.util.IAcceptor
|
||||
|
||||
/**
|
||||
* @author koehnlein - Initial contribution and API
|
||||
* @since 2.13
|
||||
* @deprecated use {@link ChangeConverter2} instead
|
||||
* This class is scheduled to be removed with 2.22.
|
||||
*/
|
||||
@Deprecated//(forRemoval=true)
|
||||
class ChangeConverter implements IAcceptor<IEmfResourceChange> {
|
||||
|
||||
static class Factory {
|
||||
|
||||
@Inject IResourceServiceProvider.Registry registry
|
||||
|
||||
def ChangeConverter create(WorkspaceManager workspaceManager, WorkspaceEdit edit) {
|
||||
new ChangeConverter(workspaceManager, registry, edit)
|
||||
}
|
||||
}
|
||||
|
||||
val WorkspaceManager workspaceManager
|
||||
val IResourceServiceProvider.Registry registry
|
||||
val WorkspaceEdit edit
|
||||
|
||||
protected new(WorkspaceManager workspaceManager, IResourceServiceProvider.Registry registry, WorkspaceEdit edit) {
|
||||
this.workspaceManager = workspaceManager
|
||||
this.registry = registry
|
||||
this.edit = edit
|
||||
}
|
||||
|
||||
override accept(IEmfResourceChange change) {
|
||||
handleReplacements(change)
|
||||
}
|
||||
|
||||
protected def dispatch void handleReplacements(IEmfResourceChange change) {
|
||||
val outputStream = new ByteArrayOutputStream
|
||||
try {
|
||||
val uri = change.resource.URI
|
||||
change.resource.save(outputStream, null)
|
||||
val newContent = new String(outputStream.toByteArray, change.resource.charset)
|
||||
workspaceManager.doRead(uri) [ document, resource |
|
||||
val range = new Range(document.getPosition(0), document.getPosition(document.contents.length))
|
||||
val textEdit = new TextEdit(range, newContent)
|
||||
addTextEdit(uri, textEdit)
|
||||
]
|
||||
} finally {
|
||||
outputStream.close
|
||||
}
|
||||
}
|
||||
|
||||
protected def String getCharset(Resource resource) {
|
||||
val xtextEncodingProvider = registry.getResourceServiceProvider(resource.URI).get(IEncodingProvider)
|
||||
if (xtextEncodingProvider !== null)
|
||||
return xtextEncodingProvider.getEncoding(resource.URI)
|
||||
else if (resource instanceof XMLResource)
|
||||
resource.encoding
|
||||
else
|
||||
Charset.defaultCharset.toString
|
||||
}
|
||||
|
||||
protected def dispatch void handleReplacements(ITextDocumentChange change) {
|
||||
if (change.replacements.size > 0) {
|
||||
val uri = change.newURI
|
||||
workspaceManager.doRead(uri) [ document, resource |
|
||||
val textEdits = change.replacements.map [ replacement |
|
||||
val start = document.getPosition(replacement.offset)
|
||||
val end = document.getPosition(replacement.offset + replacement.length)
|
||||
val range = new Range(start, end)
|
||||
new TextEdit(range, replacement.replacementText)
|
||||
]
|
||||
addTextEdit(uri, textEdits)
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
protected def addTextEdit(URI uri, TextEdit... textEdit) {
|
||||
edit.changes.put(uri.toString, textEdit)
|
||||
}
|
||||
}
|
|
@ -1,26 +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.RenameParams;
|
||||
import org.eclipse.lsp4j.WorkspaceEdit;
|
||||
import org.eclipse.xtext.ide.server.WorkspaceManager;
|
||||
import org.eclipse.xtext.util.CancelIndicator;
|
||||
|
||||
/**
|
||||
* @author koehnlein - Initial contribution and API
|
||||
* @since 2.13
|
||||
* @deprecated use {@link IRenameService2} instead.
|
||||
* This interface is scheduled to be removed with 2.22.
|
||||
*/
|
||||
@Deprecated//(forRemoval=true)
|
||||
public interface IRenameService {
|
||||
@Deprecated
|
||||
WorkspaceEdit rename(WorkspaceManager workspaceManager, RenameParams renameParams, CancelIndicator cancelIndicator);
|
||||
}
|
|
@ -1,77 +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 com.google.inject.Inject
|
||||
import com.google.inject.Provider
|
||||
import org.eclipse.emf.ecore.util.EcoreUtil
|
||||
import org.eclipse.lsp4j.RenameParams
|
||||
import org.eclipse.lsp4j.WorkspaceEdit
|
||||
import org.eclipse.xtext.ide.refactoring.RenameChange
|
||||
import org.eclipse.xtext.ide.refactoring.RenameContext
|
||||
import org.eclipse.xtext.ide.serializer.IChangeSerializer
|
||||
import org.eclipse.xtext.ide.server.UriExtensions
|
||||
import org.eclipse.xtext.ide.server.WorkspaceManager
|
||||
import org.eclipse.xtext.resource.EObjectAtOffsetHelper
|
||||
import org.eclipse.xtext.resource.XtextResource
|
||||
import org.eclipse.xtext.util.CancelIndicator
|
||||
import static org.eclipse.xtext.ide.refactoring.RefactoringIssueAcceptor.Severity.*
|
||||
import org.eclipse.xtext.ide.refactoring.IRenameStrategy2
|
||||
import org.eclipse.xtext.resource.impl.ResourceDescriptionsProvider
|
||||
|
||||
/**
|
||||
* @author koehnlein - Initial contribution and API
|
||||
* @since 2.13
|
||||
* @deprecated use {@link RenameService2} instead.
|
||||
* This class is scheduled to be removed with 2.22.
|
||||
*/
|
||||
@Deprecated//(forRemoval=true)
|
||||
class RenameService implements IRenameService {
|
||||
|
||||
@Inject extension EObjectAtOffsetHelper
|
||||
|
||||
@Inject IRenameStrategy2 renameStrategy
|
||||
|
||||
@Inject ChangeConverter.Factory converterFactory
|
||||
|
||||
@Inject extension UriExtensions
|
||||
|
||||
@Inject Provider<IChangeSerializer> changeSerializerProvider
|
||||
|
||||
@Inject Provider<ServerRefactoringIssueAcceptor> issueProvider
|
||||
|
||||
override rename(WorkspaceManager workspaceManager, RenameParams renameParams, CancelIndicator cancelIndicator) {
|
||||
val uri = renameParams.textDocument.uri.toUri
|
||||
val issueAcceptor = issueProvider.get
|
||||
workspaceManager.doRead(uri) [ document, resource |
|
||||
val projectManager = workspaceManager.getProjectManager(uri)
|
||||
val resourceSet = projectManager.createNewResourceSet(projectManager.indexState.resourceDescriptions)
|
||||
resourceSet.loadOptions.put(ResourceDescriptionsProvider.LIVE_SCOPE, true)
|
||||
val offset = document.getOffSet(renameParams.position)
|
||||
val workspaceEdit = new WorkspaceEdit
|
||||
val xtextResource = resourceSet.getResource(resource.URI, true)
|
||||
if (xtextResource instanceof XtextResource) {
|
||||
val element = xtextResource.resolveElementAt(offset)
|
||||
if (element === null || element.eIsProxy) {
|
||||
issueAcceptor.add(FATAL, '''No element found at position line:«renameParams.position.line» column:«renameParams.position.character»''')
|
||||
} else {
|
||||
val change = new RenameChange(renameParams.newName, EcoreUtil.getURI(element))
|
||||
val changeSerializer = changeSerializerProvider.get
|
||||
val context = new RenameContext(#[change], resourceSet, changeSerializer, issueAcceptor)
|
||||
renameStrategy.applyRename(context)
|
||||
val changeConverter = converterFactory.create(workspaceManager, workspaceEdit)
|
||||
changeSerializer.applyModifications(changeConverter)
|
||||
}
|
||||
} else {
|
||||
issueAcceptor.add(FATAL, 'Loaded resource is not an XtextResource', resource.URI)
|
||||
}
|
||||
return workspaceEdit
|
||||
]
|
||||
}
|
||||
}
|
|
@ -23,7 +23,6 @@ import org.eclipse.lsp4j.PrepareRenameResult
|
|||
import org.eclipse.lsp4j.Range
|
||||
import org.eclipse.lsp4j.RenameParams
|
||||
import org.eclipse.lsp4j.TextDocumentIdentifier
|
||||
import org.eclipse.lsp4j.TextDocumentPositionParams
|
||||
import org.eclipse.lsp4j.WorkspaceEdit
|
||||
import org.eclipse.lsp4j.jsonrpc.messages.Either
|
||||
import org.eclipse.xtend.lib.annotations.Accessors
|
||||
|
@ -83,7 +82,7 @@ class RenameService2 implements IRenameService2 {
|
|||
val document = context.document
|
||||
val cancelIndicator = options.cancelIndicator
|
||||
|
||||
val prepareRenameResult = doPrepareRename(resource, document, positionParams as TextDocumentPositionParams, cancelIndicator)
|
||||
val prepareRenameResult = doPrepareRename(resource, document, positionParams, cancelIndicator)
|
||||
if (!mayPerformRename(prepareRenameResult, options.renameParams)) {
|
||||
return null
|
||||
}
|
||||
|
@ -166,7 +165,7 @@ class RenameService2 implements IRenameService2 {
|
|||
val document = context.document
|
||||
val params = options.params
|
||||
val cancelIndicator = options.cancelIndicator
|
||||
return doPrepareRename(resource, document, params as TextDocumentPositionParams, cancelIndicator)
|
||||
return doPrepareRename(resource, document, params, cancelIndicator)
|
||||
].exceptionally [ exception |
|
||||
val rootCause = Throwables.getRootCause(exception)
|
||||
if (rootCause instanceof FileNotFoundException) {
|
||||
|
@ -177,19 +176,6 @@ class RenameService2 implements IRenameService2 {
|
|||
throw exception
|
||||
].get
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated please override/call {@link #doPrepareRename(Resource, Document, PrepareRenameParams, CancelIndicator)} instead.
|
||||
* This method is scheduled to be removed with 2.22.
|
||||
*/
|
||||
@Deprecated//(forRemoval=true)
|
||||
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) {
|
||||
|
|
|
@ -12,7 +12,6 @@ import static java.util.Collections.*;
|
|||
|
||||
import org.eclipse.lsp4j.SignatureHelp;
|
||||
import org.eclipse.lsp4j.SignatureHelpParams;
|
||||
import org.eclipse.lsp4j.TextDocumentPositionParams;
|
||||
import org.eclipse.xtext.ide.server.Document;
|
||||
import org.eclipse.xtext.resource.XtextResource;
|
||||
import org.eclipse.xtext.util.CancelIndicator;
|
||||
|
@ -34,38 +33,7 @@ public interface ISignatureHelpService {
|
|||
*/
|
||||
SignatureHelp EMPTY = new SignatureHelp(emptyList(), null, null);
|
||||
|
||||
/**
|
||||
* @deprecated please override/call {@link #getSignatureHelp(Document, XtextResource, SignatureHelpParams, CancelIndicator)} instead.
|
||||
* This method is scheduled to be removed with 2.22.
|
||||
*/
|
||||
@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);
|
||||
}
|
||||
throw new IllegalArgumentException("params is not a SignatureHelpParams");
|
||||
}
|
||||
|
||||
SignatureHelp getSignatureHelp(Document document, XtextResource resource, SignatureHelpParams params, CancelIndicator cancelIndicator);
|
||||
|
||||
/**
|
||||
* Returns with a {@link SignatureHelp signature help} instance for a
|
||||
* resource at a given offset. This method never returns with {@code null}.
|
||||
*
|
||||
* @param resource
|
||||
* the resource to extract the help for a method/operation
|
||||
* signature.
|
||||
* @param offset
|
||||
* 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) {
|
||||
return EMPTY;
|
||||
}
|
||||
|
||||
/**
|
||||
* NOOP {@link ISignatureHelpService signature help service} implementation.
|
||||
|
|
|
@ -23,7 +23,6 @@ import org.eclipse.lsp4j.Location
|
|||
import org.eclipse.lsp4j.ReferenceParams
|
||||
import org.eclipse.lsp4j.SymbolInformation
|
||||
import org.eclipse.lsp4j.SymbolKind
|
||||
import org.eclipse.lsp4j.TextDocumentPositionParams
|
||||
import org.eclipse.lsp4j.jsonrpc.messages.Either
|
||||
import org.eclipse.xtext.findReferences.IReferenceFinder
|
||||
import org.eclipse.xtext.findReferences.IReferenceFinder.IResourceAccess
|
||||
|
@ -81,24 +80,6 @@ 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
|
||||
|
|
|
@ -33,22 +33,4 @@ public class UriExtensions extends org.eclipse.xtext.util.UriExtensions {
|
|||
public String toUriString(final java.net.URI uri) {
|
||||
return this.toUriString(URI.createURI(uri.normalize().toString()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use #toUriString(URI)
|
||||
* This method is scheduled to be removed with 2.22.
|
||||
*/
|
||||
@Deprecated
|
||||
public String toPath(final URI uri) {
|
||||
return this.toUriString(uri);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use toUriString(URI)
|
||||
* This method is scheduled to be removed with 2.22.
|
||||
*/
|
||||
@Deprecated
|
||||
public String toPath(final java.net.URI uri) {
|
||||
return this.toUriString(uri);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,29 +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.codeActions;
|
||||
|
||||
import java.util.List;
|
||||
import org.eclipse.lsp4j.CodeAction;
|
||||
import org.eclipse.lsp4j.CodeActionParams;
|
||||
import org.eclipse.lsp4j.Command;
|
||||
import org.eclipse.lsp4j.jsonrpc.messages.Either;
|
||||
import org.eclipse.xtext.ide.server.Document;
|
||||
import org.eclipse.xtext.resource.XtextResource;
|
||||
import org.eclipse.xtext.util.CancelIndicator;
|
||||
|
||||
/**
|
||||
* @author Sven Efftinge - Initial contribution and API
|
||||
* @deprecated use {@link ICodeActionService2} instead
|
||||
* This interface is scheduled to be removed with 2.22.
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("all")
|
||||
public interface ICodeActionService {
|
||||
List<Either<Command, CodeAction>> getCodeActions(final Document document, final XtextResource resource, final CodeActionParams params, final CancelIndicator indicator);
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright (c) 2017 TypeFox GmbH (http://www.typefox.io) and others.
|
||||
* 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.
|
||||
|
|
|
@ -25,7 +25,6 @@ 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;
|
||||
import org.eclipse.lsp4j.TextEdit;
|
||||
import org.eclipse.xtext.ide.editor.contentassist.ContentAssistContext;
|
||||
import org.eclipse.xtext.ide.editor.contentassist.ContentAssistEntry;
|
||||
|
@ -70,18 +69,6 @@ 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();
|
||||
|
|
|
@ -13,8 +13,6 @@ import com.google.inject.Inject;
|
|||
import com.google.inject.Provider;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import org.eclipse.lsp4j.DocumentFormattingParams;
|
||||
import org.eclipse.lsp4j.DocumentRangeFormattingParams;
|
||||
import org.eclipse.lsp4j.FormattingOptions;
|
||||
|
@ -34,7 +32,6 @@ import org.eclipse.xtext.util.CancelIndicator;
|
|||
import org.eclipse.xtext.util.ITextRegion;
|
||||
import org.eclipse.xtext.util.TextRegion;
|
||||
import org.eclipse.xtext.xbase.lib.CollectionLiterals;
|
||||
import org.eclipse.xtext.xbase.lib.Exceptions;
|
||||
import org.eclipse.xtext.xbase.lib.Functions.Function1;
|
||||
import org.eclipse.xtext.xbase.lib.IterableExtensions;
|
||||
import org.eclipse.xtext.xbase.lib.ListExtensions;
|
||||
|
@ -49,42 +46,6 @@ import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;
|
|||
*/
|
||||
@SuppressWarnings("all")
|
||||
public class FormattingService {
|
||||
private static class OverrideChecker {
|
||||
private static final Map<Class<?>, Boolean> CLASSES_WITH_OVERRIDES = new ConcurrentHashMap<Class<?>, Boolean>();
|
||||
|
||||
public static boolean hasFormatOverride(final Class<? extends FormattingService> formattingServiceClass) {
|
||||
Boolean result = FormattingService.OverrideChecker.CLASSES_WITH_OVERRIDES.get(formattingServiceClass);
|
||||
if ((result == null)) {
|
||||
try {
|
||||
result = Boolean.FALSE;
|
||||
Class<?> theClass = formattingServiceClass;
|
||||
while (((!(result).booleanValue()) && (theClass != FormattingService.class))) {
|
||||
{
|
||||
try {
|
||||
theClass.getDeclaredMethod("format", XtextResource.class, Document.class, Integer.TYPE, Integer.TYPE);
|
||||
result = Boolean.TRUE;
|
||||
} catch (final Throwable _t) {
|
||||
if (_t instanceof NoSuchMethodException) {
|
||||
} else {
|
||||
throw Exceptions.sneakyThrow(_t);
|
||||
}
|
||||
}
|
||||
theClass = theClass.getSuperclass();
|
||||
}
|
||||
}
|
||||
} catch (final Throwable _t) {
|
||||
if (_t instanceof Exception) {
|
||||
result = Boolean.TRUE;
|
||||
} else {
|
||||
throw Exceptions.sneakyThrow(_t);
|
||||
}
|
||||
}
|
||||
FormattingService.OverrideChecker.CLASSES_WITH_OVERRIDES.put(formattingServiceClass, result);
|
||||
}
|
||||
return (result).booleanValue();
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(optional = true)
|
||||
private Provider<IFormatter2> formatter2Provider;
|
||||
|
||||
|
@ -103,10 +64,6 @@ public class FormattingService {
|
|||
if (((length == 0) || resource.getContents().isEmpty())) {
|
||||
return CollectionLiterals.<TextEdit>emptyList();
|
||||
}
|
||||
boolean _hasFormatOverride = FormattingService.OverrideChecker.hasFormatOverride(this.getClass());
|
||||
if (_hasFormatOverride) {
|
||||
return this.format(resource, document, offset, length);
|
||||
}
|
||||
return this.format(resource, document, offset, length, params.getOptions());
|
||||
}
|
||||
|
||||
|
@ -114,22 +71,9 @@ public class FormattingService {
|
|||
final int offset = document.getOffSet(params.getRange().getStart());
|
||||
int _offSet = document.getOffSet(params.getRange().getEnd());
|
||||
final int length = (_offSet - offset);
|
||||
boolean _hasFormatOverride = FormattingService.OverrideChecker.hasFormatOverride(this.getClass());
|
||||
if (_hasFormatOverride) {
|
||||
return this.format(resource, document, offset, length);
|
||||
}
|
||||
return this.format(resource, document, offset, length, params.getOptions());
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use {@link #format(XtextResource, Document, int, int, FormattingOptions)} instead.
|
||||
* This method is scheduled to be removed with 2.22.
|
||||
*/
|
||||
@Deprecated
|
||||
public List<TextEdit> format(final XtextResource resource, final Document document, final int offset, final int length) {
|
||||
return this.format(resource, document, offset, length, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 2.14
|
||||
*/
|
||||
|
|
|
@ -1,170 +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 com.google.inject.Inject;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import org.eclipse.emf.common.util.URI;
|
||||
import org.eclipse.emf.ecore.resource.Resource;
|
||||
import org.eclipse.emf.ecore.xmi.XMLResource;
|
||||
import org.eclipse.lsp4j.Position;
|
||||
import org.eclipse.lsp4j.Range;
|
||||
import org.eclipse.lsp4j.TextEdit;
|
||||
import org.eclipse.lsp4j.WorkspaceEdit;
|
||||
import org.eclipse.xtext.formatting2.regionaccess.ITextReplacement;
|
||||
import org.eclipse.xtext.ide.serializer.IEmfResourceChange;
|
||||
import org.eclipse.xtext.ide.serializer.ITextDocumentChange;
|
||||
import org.eclipse.xtext.ide.server.Document;
|
||||
import org.eclipse.xtext.ide.server.WorkspaceManager;
|
||||
import org.eclipse.xtext.parser.IEncodingProvider;
|
||||
import org.eclipse.xtext.resource.IResourceServiceProvider;
|
||||
import org.eclipse.xtext.resource.XtextResource;
|
||||
import org.eclipse.xtext.util.IAcceptor;
|
||||
import org.eclipse.xtext.xbase.lib.Conversions;
|
||||
import org.eclipse.xtext.xbase.lib.Exceptions;
|
||||
import org.eclipse.xtext.xbase.lib.Functions.Function1;
|
||||
import org.eclipse.xtext.xbase.lib.Functions.Function2;
|
||||
import org.eclipse.xtext.xbase.lib.ListExtensions;
|
||||
|
||||
/**
|
||||
* @author koehnlein - Initial contribution and API
|
||||
* @since 2.13
|
||||
* @deprecated use {@link ChangeConverter2} instead
|
||||
* This class is scheduled to be removed with 2.22.
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("all")
|
||||
public class ChangeConverter implements IAcceptor<IEmfResourceChange> {
|
||||
public static class Factory {
|
||||
@Inject
|
||||
private IResourceServiceProvider.Registry registry;
|
||||
|
||||
public ChangeConverter create(final WorkspaceManager workspaceManager, final WorkspaceEdit edit) {
|
||||
return new ChangeConverter(workspaceManager, this.registry, edit);
|
||||
}
|
||||
}
|
||||
|
||||
private final WorkspaceManager workspaceManager;
|
||||
|
||||
private final IResourceServiceProvider.Registry registry;
|
||||
|
||||
private final WorkspaceEdit edit;
|
||||
|
||||
protected ChangeConverter(final WorkspaceManager workspaceManager, final IResourceServiceProvider.Registry registry, final WorkspaceEdit edit) {
|
||||
this.workspaceManager = workspaceManager;
|
||||
this.registry = registry;
|
||||
this.edit = edit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accept(final IEmfResourceChange change) {
|
||||
this.handleReplacements(change);
|
||||
}
|
||||
|
||||
protected void _handleReplacements(final IEmfResourceChange change) {
|
||||
try {
|
||||
final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||
try {
|
||||
final URI uri = change.getResource().getURI();
|
||||
change.getResource().save(outputStream, null);
|
||||
byte[] _byteArray = outputStream.toByteArray();
|
||||
String _charset = this.getCharset(change.getResource());
|
||||
final String newContent = new String(_byteArray, _charset);
|
||||
final Function2<Document, XtextResource, List<TextEdit>> _function = (Document document, XtextResource resource) -> {
|
||||
List<TextEdit> _xblockexpression = null;
|
||||
{
|
||||
Position _position = document.getPosition(0);
|
||||
Position _position_1 = document.getPosition(document.getContents().length());
|
||||
final Range range = new Range(_position, _position_1);
|
||||
final TextEdit textEdit = new TextEdit(range, newContent);
|
||||
_xblockexpression = this.addTextEdit(uri, textEdit);
|
||||
}
|
||||
return _xblockexpression;
|
||||
};
|
||||
this.workspaceManager.<List<TextEdit>>doRead(uri, _function);
|
||||
} finally {
|
||||
outputStream.close();
|
||||
}
|
||||
} catch (Throwable _e) {
|
||||
throw Exceptions.sneakyThrow(_e);
|
||||
}
|
||||
}
|
||||
|
||||
protected String getCharset(final Resource resource) {
|
||||
String _xblockexpression = null;
|
||||
{
|
||||
final IEncodingProvider xtextEncodingProvider = this.registry.getResourceServiceProvider(resource.getURI()).<IEncodingProvider>get(IEncodingProvider.class);
|
||||
String _xifexpression = null;
|
||||
if ((xtextEncodingProvider != null)) {
|
||||
return xtextEncodingProvider.getEncoding(resource.getURI());
|
||||
} else {
|
||||
String _xifexpression_1 = null;
|
||||
if ((resource instanceof XMLResource)) {
|
||||
_xifexpression_1 = ((XMLResource)resource).getEncoding();
|
||||
} else {
|
||||
_xifexpression_1 = Charset.defaultCharset().toString();
|
||||
}
|
||||
_xifexpression = _xifexpression_1;
|
||||
}
|
||||
_xblockexpression = _xifexpression;
|
||||
}
|
||||
return _xblockexpression;
|
||||
}
|
||||
|
||||
protected void _handleReplacements(final ITextDocumentChange change) {
|
||||
int _size = change.getReplacements().size();
|
||||
boolean _greaterThan = (_size > 0);
|
||||
if (_greaterThan) {
|
||||
final URI uri = change.getNewURI();
|
||||
final Function2<Document, XtextResource, List<TextEdit>> _function = (Document document, XtextResource resource) -> {
|
||||
List<TextEdit> _xblockexpression = null;
|
||||
{
|
||||
final Function1<ITextReplacement, TextEdit> _function_1 = (ITextReplacement replacement) -> {
|
||||
TextEdit _xblockexpression_1 = null;
|
||||
{
|
||||
final Position start = document.getPosition(replacement.getOffset());
|
||||
int _offset = replacement.getOffset();
|
||||
int _length = replacement.getLength();
|
||||
int _plus = (_offset + _length);
|
||||
final Position end = document.getPosition(_plus);
|
||||
final Range range = new Range(start, end);
|
||||
String _replacementText = replacement.getReplacementText();
|
||||
_xblockexpression_1 = new TextEdit(range, _replacementText);
|
||||
}
|
||||
return _xblockexpression_1;
|
||||
};
|
||||
final List<TextEdit> textEdits = ListExtensions.<ITextReplacement, TextEdit>map(change.getReplacements(), _function_1);
|
||||
_xblockexpression = this.addTextEdit(uri, ((TextEdit[])Conversions.unwrapArray(textEdits, TextEdit.class)));
|
||||
}
|
||||
return _xblockexpression;
|
||||
};
|
||||
this.workspaceManager.<List<TextEdit>>doRead(uri, _function);
|
||||
}
|
||||
}
|
||||
|
||||
protected List<TextEdit> addTextEdit(final URI uri, final TextEdit... textEdit) {
|
||||
return this.edit.getChanges().put(uri.toString(), ((List<TextEdit>)Conversions.doWrapArray(textEdit)));
|
||||
}
|
||||
|
||||
protected void handleReplacements(final IEmfResourceChange change) {
|
||||
if (change instanceof ITextDocumentChange) {
|
||||
_handleReplacements((ITextDocumentChange)change);
|
||||
return;
|
||||
} else if (change != null) {
|
||||
_handleReplacements(change);
|
||||
return;
|
||||
} else {
|
||||
throw new IllegalArgumentException("Unhandled parameter types: " +
|
||||
Arrays.<Object>asList(change).toString());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,114 +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 com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import java.util.Collections;
|
||||
import org.eclipse.emf.common.util.URI;
|
||||
import org.eclipse.emf.ecore.EObject;
|
||||
import org.eclipse.emf.ecore.resource.Resource;
|
||||
import org.eclipse.emf.ecore.util.EcoreUtil;
|
||||
import org.eclipse.lsp4j.RenameParams;
|
||||
import org.eclipse.lsp4j.WorkspaceEdit;
|
||||
import org.eclipse.xtend2.lib.StringConcatenation;
|
||||
import org.eclipse.xtext.ide.refactoring.IRenameStrategy2;
|
||||
import org.eclipse.xtext.ide.refactoring.RefactoringIssueAcceptor;
|
||||
import org.eclipse.xtext.ide.refactoring.RenameChange;
|
||||
import org.eclipse.xtext.ide.refactoring.RenameContext;
|
||||
import org.eclipse.xtext.ide.serializer.IChangeSerializer;
|
||||
import org.eclipse.xtext.ide.server.Document;
|
||||
import org.eclipse.xtext.ide.server.ProjectManager;
|
||||
import org.eclipse.xtext.ide.server.UriExtensions;
|
||||
import org.eclipse.xtext.ide.server.WorkspaceManager;
|
||||
import org.eclipse.xtext.ide.server.rename.ChangeConverter;
|
||||
import org.eclipse.xtext.ide.server.rename.IRenameService;
|
||||
import org.eclipse.xtext.ide.server.rename.ServerRefactoringIssueAcceptor;
|
||||
import org.eclipse.xtext.resource.EObjectAtOffsetHelper;
|
||||
import org.eclipse.xtext.resource.XtextResource;
|
||||
import org.eclipse.xtext.resource.XtextResourceSet;
|
||||
import org.eclipse.xtext.resource.impl.ResourceDescriptionsProvider;
|
||||
import org.eclipse.xtext.util.CancelIndicator;
|
||||
import org.eclipse.xtext.xbase.lib.CollectionLiterals;
|
||||
import org.eclipse.xtext.xbase.lib.Extension;
|
||||
import org.eclipse.xtext.xbase.lib.Functions.Function2;
|
||||
|
||||
/**
|
||||
* @author koehnlein - Initial contribution and API
|
||||
* @since 2.13
|
||||
* @deprecated use {@link RenameService2} instead.
|
||||
* This class is scheduled to be removed with 2.22.
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("all")
|
||||
public class RenameService implements IRenameService {
|
||||
@Inject
|
||||
@Extension
|
||||
private EObjectAtOffsetHelper _eObjectAtOffsetHelper;
|
||||
|
||||
@Inject
|
||||
private IRenameStrategy2 renameStrategy;
|
||||
|
||||
@Inject
|
||||
private ChangeConverter.Factory converterFactory;
|
||||
|
||||
@Inject
|
||||
@Extension
|
||||
private UriExtensions _uriExtensions;
|
||||
|
||||
@Inject
|
||||
private Provider<IChangeSerializer> changeSerializerProvider;
|
||||
|
||||
@Inject
|
||||
private Provider<ServerRefactoringIssueAcceptor> issueProvider;
|
||||
|
||||
@Override
|
||||
public WorkspaceEdit rename(final WorkspaceManager workspaceManager, final RenameParams renameParams, final CancelIndicator cancelIndicator) {
|
||||
WorkspaceEdit _xblockexpression = null;
|
||||
{
|
||||
final URI uri = this._uriExtensions.toUri(renameParams.getTextDocument().getUri());
|
||||
final ServerRefactoringIssueAcceptor issueAcceptor = this.issueProvider.get();
|
||||
final Function2<Document, XtextResource, WorkspaceEdit> _function = (Document document, XtextResource resource) -> {
|
||||
final ProjectManager projectManager = workspaceManager.getProjectManager(uri);
|
||||
final XtextResourceSet resourceSet = projectManager.createNewResourceSet(projectManager.getIndexState().getResourceDescriptions());
|
||||
resourceSet.getLoadOptions().put(ResourceDescriptionsProvider.LIVE_SCOPE, Boolean.valueOf(true));
|
||||
final int offset = document.getOffSet(renameParams.getPosition());
|
||||
final WorkspaceEdit workspaceEdit = new WorkspaceEdit();
|
||||
final Resource xtextResource = resourceSet.getResource(resource.getURI(), true);
|
||||
if ((xtextResource instanceof XtextResource)) {
|
||||
final EObject element = this._eObjectAtOffsetHelper.resolveElementAt(((XtextResource)xtextResource), offset);
|
||||
if (((element == null) || element.eIsProxy())) {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
_builder.append("No element found at position line:");
|
||||
int _line = renameParams.getPosition().getLine();
|
||||
_builder.append(_line);
|
||||
_builder.append(" column:");
|
||||
int _character = renameParams.getPosition().getCharacter();
|
||||
_builder.append(_character);
|
||||
issueAcceptor.add(RefactoringIssueAcceptor.Severity.FATAL, _builder.toString());
|
||||
} else {
|
||||
String _newName = renameParams.getNewName();
|
||||
URI _uRI = EcoreUtil.getURI(element);
|
||||
final RenameChange change = new RenameChange(_newName, _uRI);
|
||||
final IChangeSerializer changeSerializer = this.changeSerializerProvider.get();
|
||||
final RenameContext context = new RenameContext(Collections.<RenameChange>unmodifiableList(CollectionLiterals.<RenameChange>newArrayList(change)), resourceSet, changeSerializer, issueAcceptor);
|
||||
this.renameStrategy.applyRename(context);
|
||||
final ChangeConverter changeConverter = this.converterFactory.create(workspaceManager, workspaceEdit);
|
||||
changeSerializer.applyModifications(changeConverter);
|
||||
}
|
||||
} else {
|
||||
issueAcceptor.add(RefactoringIssueAcceptor.Severity.FATAL, "Loaded resource is not an XtextResource", resource.getURI());
|
||||
}
|
||||
return workspaceEdit;
|
||||
};
|
||||
_xblockexpression = workspaceManager.<WorkspaceEdit>doRead(uri, _function);
|
||||
}
|
||||
return _xblockexpression;
|
||||
}
|
||||
}
|
|
@ -31,7 +31,6 @@ import org.eclipse.lsp4j.RenameOptions;
|
|||
import org.eclipse.lsp4j.RenameParams;
|
||||
import org.eclipse.lsp4j.ServerCapabilities;
|
||||
import org.eclipse.lsp4j.TextDocumentIdentifier;
|
||||
import org.eclipse.lsp4j.TextDocumentPositionParams;
|
||||
import org.eclipse.lsp4j.WorkspaceEdit;
|
||||
import org.eclipse.lsp4j.jsonrpc.messages.Either;
|
||||
import org.eclipse.lsp4j.util.Ranges;
|
||||
|
@ -107,7 +106,7 @@ public class RenameService2 implements IRenameService2 {
|
|||
final Resource resource = context.getResource();
|
||||
final Document document = context.getDocument();
|
||||
final CancelIndicator cancelIndicator = options.getCancelIndicator();
|
||||
final Either<Range, PrepareRenameResult> prepareRenameResult = this.doPrepareRename(resource, document, ((TextDocumentPositionParams) positionParams), cancelIndicator);
|
||||
final Either<Range, PrepareRenameResult> prepareRenameResult = this.doPrepareRename(resource, document, positionParams, cancelIndicator);
|
||||
boolean _mayPerformRename = this.mayPerformRename(prepareRenameResult, options.getRenameParams());
|
||||
boolean _not = (!_mayPerformRename);
|
||||
if (_not) {
|
||||
|
@ -228,7 +227,7 @@ public class RenameService2 implements IRenameService2 {
|
|||
final Document document = context.getDocument();
|
||||
final PrepareRenameParams params = options.getParams();
|
||||
final CancelIndicator cancelIndicator = options.getCancelIndicator();
|
||||
return this.doPrepareRename(resource, document, ((TextDocumentPositionParams) params), cancelIndicator);
|
||||
return this.doPrepareRename(resource, document, params, cancelIndicator);
|
||||
};
|
||||
final java.util.function.Function<Throwable, Either<Range, PrepareRenameResult>> _function_1 = (Throwable exception) -> {
|
||||
try {
|
||||
|
@ -249,18 +248,6 @@ public class RenameService2 implements IRenameService2 {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated please override/call {@link #doPrepareRename(Resource, Document, PrepareRenameParams, CancelIndicator)} instead.
|
||||
* This method is scheduled to be removed with 2.22.
|
||||
*/
|
||||
@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)) {
|
||||
|
|
|
@ -29,7 +29,6 @@ import org.eclipse.lsp4j.Location;
|
|||
import org.eclipse.lsp4j.ReferenceParams;
|
||||
import org.eclipse.lsp4j.SymbolInformation;
|
||||
import org.eclipse.lsp4j.SymbolKind;
|
||||
import org.eclipse.lsp4j.TextDocumentPositionParams;
|
||||
import org.eclipse.lsp4j.jsonrpc.messages.Either;
|
||||
import org.eclipse.xtext.findReferences.IReferenceFinder;
|
||||
import org.eclipse.xtext.findReferences.ReferenceAcceptor;
|
||||
|
@ -103,18 +102,6 @@ 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
|
||||
*/
|
||||
|
|
|
@ -393,14 +393,6 @@ abstract class AbstractLanguageServerTest implements Endpoint {
|
|||
return sb.toString;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated This method is scheduled to be removed with 2.22.
|
||||
*/
|
||||
@Deprecated//(forRemoval=true)
|
||||
protected dispatch def String toExpectation(org.eclipse.lsp4j.ColoringInformation it) {
|
||||
return '''«range.toExpectation» -> [«styles.join(', ')»]''';
|
||||
}
|
||||
|
||||
protected dispatch def String toExpectation(Pair<SemanticHighlightingInformation, List<List<String>>> it) {
|
||||
val sb = new StringBuilder()
|
||||
val tokens = SemanticHighlightingTokens.decode(key.tokens).sort;
|
||||
|
@ -754,16 +746,6 @@ abstract class AbstractLanguageServerTest implements Endpoint {
|
|||
].get
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated This method is scheduled to be removed with 2.22.
|
||||
*/
|
||||
@Deprecated//(forRemoval=true)
|
||||
protected def getColoringParams() {
|
||||
languageServer.requestManager.runRead[
|
||||
return notifications.map[value].filter(org.eclipse.lsp4j.ColoringParams).toMap([uri], [infos]);
|
||||
].get
|
||||
}
|
||||
|
||||
protected def getSemanticHighlightingParams() {
|
||||
languageServer.requestManager.runRead[
|
||||
return notifications.map[value].filter(SemanticHighlightingParams).toMap([textDocument], [lines]);
|
||||
|
|
|
@ -34,8 +34,6 @@ import org.eclipse.lsp4j.CodeActionContext;
|
|||
import org.eclipse.lsp4j.CodeActionParams;
|
||||
import org.eclipse.lsp4j.CodeLens;
|
||||
import org.eclipse.lsp4j.CodeLensParams;
|
||||
import org.eclipse.lsp4j.ColoringInformation;
|
||||
import org.eclipse.lsp4j.ColoringParams;
|
||||
import org.eclipse.lsp4j.Command;
|
||||
import org.eclipse.lsp4j.CompletionItem;
|
||||
import org.eclipse.lsp4j.CompletionList;
|
||||
|
@ -814,21 +812,6 @@ public abstract class AbstractLanguageServerTest implements Endpoint {
|
|||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated This method is scheduled to be removed with 2.22.
|
||||
*/
|
||||
@Deprecated
|
||||
protected String _toExpectation(final ColoringInformation it) {
|
||||
StringConcatenation _builder = new StringConcatenation();
|
||||
String _expectation = this.toExpectation(it.getRange());
|
||||
_builder.append(_expectation);
|
||||
_builder.append(" -> [");
|
||||
String _join = IterableExtensions.join(it.getStyles(), ", ");
|
||||
_builder.append(_join);
|
||||
_builder.append("]");
|
||||
return _builder.toString();
|
||||
}
|
||||
|
||||
protected String _toExpectation(final Pair<SemanticHighlightingInformation, List<List<String>>> it) {
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
final List<SemanticHighlightingTokens.Token> tokens = IterableExtensions.<SemanticHighlightingTokens.Token>sort(SemanticHighlightingTokens.decode(it.getKey().getTokens()));
|
||||
|
@ -1495,30 +1478,6 @@ public abstract class AbstractLanguageServerTest implements Endpoint {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated This method is scheduled to be removed with 2.22.
|
||||
*/
|
||||
@Deprecated
|
||||
protected Map<String, List<? extends ColoringInformation>> getColoringParams() {
|
||||
try {
|
||||
final Function1<CancelIndicator, Map<String, List<? extends ColoringInformation>>> _function = (CancelIndicator it) -> {
|
||||
final Function1<Pair<String, Object>, Object> _function_1 = (Pair<String, Object> it_1) -> {
|
||||
return it_1.getValue();
|
||||
};
|
||||
final Function1<ColoringParams, String> _function_2 = (ColoringParams it_1) -> {
|
||||
return it_1.getUri();
|
||||
};
|
||||
final Function1<ColoringParams, List<? extends ColoringInformation>> _function_3 = (ColoringParams it_1) -> {
|
||||
return it_1.getInfos();
|
||||
};
|
||||
return IterableExtensions.<ColoringParams, String, List<? extends ColoringInformation>>toMap(Iterables.<ColoringParams>filter(ListExtensions.<Pair<String, Object>, Object>map(this.notifications, _function_1), ColoringParams.class), _function_2, _function_3);
|
||||
};
|
||||
return this.languageServer.getRequestManager().<Map<String, List<? extends ColoringInformation>>>runRead(_function).get();
|
||||
} catch (Throwable _e) {
|
||||
throw Exceptions.sneakyThrow(_e);
|
||||
}
|
||||
}
|
||||
|
||||
protected Map<VersionedTextDocumentIdentifier, List<SemanticHighlightingInformation>> getSemanticHighlightingParams() {
|
||||
try {
|
||||
final Function1<CancelIndicator, Map<VersionedTextDocumentIdentifier, List<SemanticHighlightingInformation>>> _function = (CancelIndicator it) -> {
|
||||
|
@ -1560,8 +1519,6 @@ public abstract class AbstractLanguageServerTest implements Endpoint {
|
|||
return _toExpectation((CodeAction)it);
|
||||
} else if (it instanceof CodeLens) {
|
||||
return _toExpectation((CodeLens)it);
|
||||
} else if (it instanceof ColoringInformation) {
|
||||
return _toExpectation((ColoringInformation)it);
|
||||
} else if (it instanceof Command) {
|
||||
return _toExpectation((Command)it);
|
||||
} else if (it instanceof CompletionItem) {
|
||||
|
|
Loading…
Reference in a new issue