mirror of
https://github.com/sigmasternchen/xtext-core
synced 2025-03-15 08:18:55 +00:00
Merge pull request #1409 from eclipse/cd_mx2j
[eclipse/xtext#1679] converted more Xtend code to Java
This commit is contained in:
commit
dd54880350
44 changed files with 681 additions and 1427 deletions
|
@ -26,6 +26,7 @@ import org.eclipse.lsp4j.jsonrpc.services.JsonRequest;
|
|||
import org.eclipse.lsp4j.jsonrpc.services.ServiceEndpoints;
|
||||
import org.eclipse.lsp4j.services.LanguageClient;
|
||||
import org.eclipse.xtend.lib.annotations.ToString;
|
||||
import org.eclipse.xtext.ide.server.Document;
|
||||
import org.eclipse.xtext.ide.server.ILanguageServerAccess;
|
||||
import org.eclipse.xtext.ide.server.ILanguageServerExtension;
|
||||
import org.eclipse.xtext.ide.tests.testlanguage.testLanguage.TestLanguagePackage;
|
||||
|
@ -82,10 +83,12 @@ public interface TestLangLSPExtension extends ILanguageServerExtension {
|
|||
@Override
|
||||
public CompletableFuture<TestLangLSPExtension.TextOfLineResult> getTextOfLine(final TestLangLSPExtension.TextOfLineParam param) {
|
||||
final Function<ILanguageServerAccess.Context, TestLangLSPExtension.TextOfLineResult> _function = (ILanguageServerAccess.Context ctx) -> {
|
||||
Document _document = ctx.getDocument();
|
||||
Position _position = new Position(param.line, 0);
|
||||
final int start = ctx.getDocument().getOffSet(_position);
|
||||
final int start = _document.getOffSet(_position);
|
||||
Document _document_1 = ctx.getDocument();
|
||||
Position _position_1 = new Position((param.line + 1), 0);
|
||||
int _offSet = ctx.getDocument().getOffSet(_position_1);
|
||||
int _offSet = _document_1.getOffSet(_position_1);
|
||||
int _length = System.lineSeparator().length();
|
||||
final int end = (_offSet - _length);
|
||||
TestLangLSPExtension.TextOfLineResult _textOfLineResult = new TestLangLSPExtension.TextOfLineResult();
|
||||
|
|
|
@ -1,17 +1,16 @@
|
|||
/**
|
||||
* Copyright (c) 2016, 2017 TypeFox GmbH (http://www.typefox.io) and others.
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2016, 2020 TypeFox GmbH (http://www.typefox.io) and others.
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0.
|
||||
*
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
*******************************************************************************/
|
||||
package org.eclipse.xtext.ide;
|
||||
|
||||
import com.google.inject.Binder;
|
||||
import com.google.inject.name.Names;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import org.eclipse.xtext.ide.ExecutorServiceProvider;
|
||||
import org.eclipse.xtext.resource.IResourceDescriptions;
|
||||
import org.eclipse.xtext.resource.impl.LiveShadowedChunkedResourceDescriptions;
|
||||
import org.eclipse.xtext.resource.impl.ResourceDescriptionsProvider;
|
||||
|
@ -22,17 +21,18 @@ import org.eclipse.xtext.workspace.ProjectConfigProvider;
|
|||
/**
|
||||
* Default Guice bindings for the generic IDE features of Xtext.
|
||||
*/
|
||||
@SuppressWarnings("all")
|
||||
public class DefaultIdeModule extends AbstractGenericModule {
|
||||
public void configureExecutorService(final Binder binder) {
|
||||
binder.<ExecutorService>bind(ExecutorService.class).toProvider(ExecutorServiceProvider.class);
|
||||
}
|
||||
|
||||
public void configureIResourceDescriptionsLiveScope(final Binder binder) {
|
||||
binder.<IResourceDescriptions>bind(IResourceDescriptions.class).annotatedWith(Names.named(ResourceDescriptionsProvider.LIVE_SCOPE)).to(LiveShadowedChunkedResourceDescriptions.class);
|
||||
}
|
||||
|
||||
public Class<? extends IProjectConfigProvider> bindIProjectConfigProvider() {
|
||||
return ProjectConfigProvider.class;
|
||||
}
|
||||
|
||||
public void configureExecutorService(Binder binder) {
|
||||
binder.bind(ExecutorService.class).toProvider(ExecutorServiceProvider.class);
|
||||
}
|
||||
|
||||
public void configureIResourceDescriptionsLiveScope(Binder binder) {
|
||||
binder.bind(IResourceDescriptions.class).annotatedWith(Names.named(ResourceDescriptionsProvider.LIVE_SCOPE))
|
||||
.to(LiveShadowedChunkedResourceDescriptions.class);
|
||||
}
|
||||
|
||||
public Class<? extends IProjectConfigProvider> bindIProjectConfigProvider() {
|
||||
return ProjectConfigProvider.class;
|
||||
}
|
||||
}
|
|
@ -1,39 +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
|
||||
|
||||
import com.google.inject.Binder
|
||||
import com.google.inject.name.Names
|
||||
import java.util.concurrent.ExecutorService
|
||||
import org.eclipse.xtext.resource.IResourceDescriptions
|
||||
import org.eclipse.xtext.resource.impl.LiveShadowedChunkedResourceDescriptions
|
||||
import org.eclipse.xtext.resource.impl.ResourceDescriptionsProvider
|
||||
import org.eclipse.xtext.service.AbstractGenericModule
|
||||
import org.eclipse.xtext.workspace.IProjectConfigProvider
|
||||
import org.eclipse.xtext.workspace.ProjectConfigProvider
|
||||
|
||||
/**
|
||||
* Default Guice bindings for the generic IDE features of Xtext.
|
||||
*/
|
||||
class DefaultIdeModule extends AbstractGenericModule {
|
||||
|
||||
def void configureExecutorService(Binder binder) {
|
||||
binder.bind(ExecutorService).toProvider(ExecutorServiceProvider)
|
||||
}
|
||||
|
||||
def void configureIResourceDescriptionsLiveScope(Binder binder) {
|
||||
binder.bind(IResourceDescriptions)
|
||||
.annotatedWith(Names.named(ResourceDescriptionsProvider.LIVE_SCOPE))
|
||||
.to(LiveShadowedChunkedResourceDescriptions);
|
||||
}
|
||||
|
||||
def Class<? extends IProjectConfigProvider> bindIProjectConfigProvider() {
|
||||
ProjectConfigProvider
|
||||
}
|
||||
}
|
|
@ -0,0 +1,103 @@
|
|||
/**
|
||||
* Copyright (c) 2015, 2020 itemis AG (http://www.itemis.eu) 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.editor.bracketmatching;
|
||||
|
||||
import org.eclipse.xtext.xbase.lib.util.ToStringBuilder;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
|
||||
/**
|
||||
* Defines a single pair of braces which need to be matched when editing code.
|
||||
*
|
||||
* @author kosyakov - Initial contribution and API
|
||||
*/
|
||||
public class BracePair {
|
||||
/**
|
||||
* The length of a left brace should be one character for Eclipse.
|
||||
*/
|
||||
private final String leftBrace;
|
||||
|
||||
/**
|
||||
* The length of a right brace should be one character for Eclipse.
|
||||
*/
|
||||
private final String rightBrace;
|
||||
|
||||
/**
|
||||
* True if the brace is structural. Structural braces have higher priority than regular braces: they are matched
|
||||
* with each other even if there are unmatched braces of other types between them. An opening non-structural
|
||||
* brace is not matched with a closing one if one of them is outside a pair of matched structural braces and another
|
||||
* is inside. In Java code, the curly braces are structural.
|
||||
*
|
||||
* It is ignored by Eclipse.
|
||||
*/
|
||||
private final boolean structural;
|
||||
|
||||
public BracePair(String leftBrace, String rightBrace, boolean structural) {
|
||||
Preconditions.checkArgument(leftBrace.length() == 1);
|
||||
Preconditions.checkArgument(rightBrace.length() == 1);
|
||||
this.leftBrace = leftBrace;
|
||||
this.rightBrace = rightBrace;
|
||||
this.structural = structural;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + (leftBrace == null ? 0 : leftBrace.hashCode());
|
||||
result = prime * result + (rightBrace == null ? 0 : rightBrace.hashCode());
|
||||
result = prime * result + (structural ? 1231 : 1237);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
BracePair other = (BracePair) obj;
|
||||
if (leftBrace == null) {
|
||||
if (other.leftBrace != null)
|
||||
return false;
|
||||
} else if (!leftBrace.equals(other.leftBrace))
|
||||
return false;
|
||||
if (rightBrace == null) {
|
||||
if (other.rightBrace != null)
|
||||
return false;
|
||||
} else if (!rightBrace.equals(other.rightBrace))
|
||||
return false;
|
||||
if (structural != other.structural)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
ToStringBuilder b = new ToStringBuilder(this);
|
||||
b.add("leftBrace", this.leftBrace);
|
||||
b.add("rightBrace", this.rightBrace);
|
||||
b.add("structural", this.structural);
|
||||
return b.toString();
|
||||
}
|
||||
|
||||
public String getLeftBrace() {
|
||||
return leftBrace;
|
||||
}
|
||||
|
||||
public String getRightBrace() {
|
||||
return rightBrace;
|
||||
}
|
||||
|
||||
public boolean isStructural() {
|
||||
return structural;
|
||||
}
|
||||
}
|
|
@ -1,37 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2015 itemis AG (http://www.itemis.eu) 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.editor.bracketmatching
|
||||
|
||||
import org.eclipse.xtend.lib.annotations.Data
|
||||
|
||||
/**
|
||||
* Defines a single pair of braces which need to be matched when editing code.
|
||||
*
|
||||
* @author kosyakov - Initial contribution and API
|
||||
*/
|
||||
@Data
|
||||
class BracePair {
|
||||
/**
|
||||
* The length of a left brace should be one character for Eclipse.
|
||||
*/
|
||||
val String leftBrace
|
||||
/**
|
||||
* The length of a right brace should be one character for Eclipse.
|
||||
*/
|
||||
val String rightBrace
|
||||
/**
|
||||
* True if the brace is structural. Structural braces have higher priority than regular braces:
|
||||
* they are matched with each other even if there are unmatched braces of other types between them,
|
||||
* and an opening non-structural brace is not matched with a closing one if one of them is outside a pair
|
||||
* of matched structural braces and another is outside. In Java code, the curly braces are structural.
|
||||
*
|
||||
* It is ignored by Eclipse.
|
||||
*/
|
||||
val boolean structural
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
/**
|
||||
* Copyright (c) 2015, 2020 itemis AG (http://www.itemis.eu) 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.editor.bracketmatching;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
import org.eclipse.xtext.xbase.lib.CollectionLiterals;
|
||||
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
/**
|
||||
* @author kosyakov - Initial contribution and API
|
||||
*/
|
||||
@Singleton
|
||||
public class DefaultBracePairProvider implements IBracePairProvider {
|
||||
private final Set<BracePair> pairs;
|
||||
|
||||
public DefaultBracePairProvider() {
|
||||
this(Collections.unmodifiableSet(CollectionLiterals.newHashSet(new BracePair("(", ")", true),
|
||||
new BracePair("{", "}", true), new BracePair("[", "]", true))));
|
||||
}
|
||||
|
||||
public DefaultBracePairProvider(Set<BracePair> pairs) {
|
||||
this.pairs = pairs;
|
||||
}
|
||||
|
||||
public Set<BracePair> getPairs() {
|
||||
return pairs;
|
||||
}
|
||||
}
|
|
@ -1,34 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2015 itemis AG (http://www.itemis.eu) 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.editor.bracketmatching
|
||||
|
||||
import com.google.inject.Singleton
|
||||
import java.util.Set
|
||||
import org.eclipse.xtend.lib.annotations.Accessors
|
||||
import org.eclipse.xtend.lib.annotations.FinalFieldsConstructor
|
||||
|
||||
/**
|
||||
* @author kosyakov - Initial contribution and API
|
||||
*/
|
||||
@Singleton
|
||||
@Accessors
|
||||
@FinalFieldsConstructor
|
||||
class DefaultBracePairProvider implements IBracePairProvider {
|
||||
|
||||
val Set<BracePair> pairs
|
||||
|
||||
new() {
|
||||
this(#{
|
||||
new BracePair("(", ")", true),
|
||||
new BracePair("{", "}", true),
|
||||
new BracePair("[", "]", true)
|
||||
})
|
||||
}
|
||||
|
||||
}
|
|
@ -1,14 +1,14 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2015 itemis AG (http://www.itemis.eu) and others.
|
||||
* Copyright (c) 2015, 2020 itemis AG (http://www.itemis.eu) 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.editor.bracketmatching
|
||||
package org.eclipse.xtext.ide.editor.bracketmatching;
|
||||
|
||||
import java.util.Set
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
|
@ -18,12 +18,12 @@ import java.util.Set
|
|||
*
|
||||
* @author kosyakov - Initial contribution and API
|
||||
*/
|
||||
interface IBracePairProvider {
|
||||
public interface IBracePairProvider {
|
||||
|
||||
/**
|
||||
* Returns a set of definitions for brace pairs that need to be matched when
|
||||
* editing code.
|
||||
*/
|
||||
def Set<BracePair> getPairs()
|
||||
Set<BracePair> getPairs();
|
||||
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright (c) 2015 itemis AG (http://www.itemis.eu) and others.
|
||||
* Copyright (c) 2015, 2020 itemis AG (http://www.itemis.eu) 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.
|
||||
|
@ -18,10 +18,9 @@ import org.eclipse.xtext.xbase.lib.CollectionLiterals;
|
|||
* @author kosyakov - Initial contribution and API
|
||||
*/
|
||||
@Singleton
|
||||
@SuppressWarnings("all")
|
||||
public class XtextBracePairProvider extends DefaultBracePairProvider {
|
||||
public XtextBracePairProvider() {
|
||||
super(
|
||||
Collections.<BracePair>unmodifiableSet(CollectionLiterals.<BracePair>newHashSet(new BracePair(":", ";", true), new BracePair("(", ")", false), new BracePair("{", "}", true), new BracePair("[", "]", false))));
|
||||
}
|
||||
public XtextBracePairProvider() {
|
||||
super(Collections.unmodifiableSet(CollectionLiterals.newHashSet(new BracePair(":", ";", true),
|
||||
new BracePair("(", ")", false), new BracePair("{", "}", true), new BracePair("[", "]", false))));
|
||||
}
|
||||
}
|
|
@ -1,26 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2015 itemis AG (http://www.itemis.eu) 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.editor.bracketmatching
|
||||
|
||||
import com.google.inject.Singleton
|
||||
|
||||
/**
|
||||
* @author kosyakov - Initial contribution and API
|
||||
*/
|
||||
@Singleton
|
||||
class XtextBracePairProvider extends DefaultBracePairProvider {
|
||||
new() {
|
||||
super(#{
|
||||
new BracePair(":", ";", true),
|
||||
new BracePair("(", ")", false),
|
||||
new BracePair("{", "}", true),
|
||||
new BracePair("[", "]", false)
|
||||
})
|
||||
}
|
||||
}
|
|
@ -1,12 +1,12 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2016 TypeFox GmbH (http://www.typefox.io) and others.
|
||||
/**
|
||||
* Copyright (c) 2016, 2020 TypeFox GmbH (http://www.typefox.io) and others.
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0.
|
||||
*
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*******************************************************************************/
|
||||
package org.eclipse.xtext.ide.editor.navigation
|
||||
*/
|
||||
package org.eclipse.xtext.ide.editor.navigation;
|
||||
|
||||
/**
|
||||
* Represents an instance that can be opened in an editor.
|
||||
|
@ -14,18 +14,18 @@ package org.eclipse.xtext.ide.editor.navigation
|
|||
* @author kosyakov - Initial contribution and API
|
||||
* @since 2.10
|
||||
*/
|
||||
interface INavigatable {
|
||||
|
||||
public interface INavigatable {
|
||||
/**
|
||||
* <p>
|
||||
* Returns an instance containing enough information to identify an editor that should be opened and a region that should be revealed.
|
||||
* Returns an instance containing enough information to identify an editor that should be opened and a region that
|
||||
* should be revealed.
|
||||
* </p>
|
||||
* <p>
|
||||
* Typical navigation elements are resource, object and reference descriptions as well as another navigatable element.
|
||||
* Typical navigation elements are resource, object and reference descriptions.
|
||||
* </p>
|
||||
* <p>
|
||||
* Avoid usage of resource sets, resources and eobjects as navigation elements, since it can lead to memory leaks.
|
||||
* </p>
|
||||
* </p>
|
||||
*/
|
||||
def Object getNavigationElement()
|
||||
Object getNavigationElement();
|
||||
}
|
|
@ -1,23 +1,23 @@
|
|||
/*******************************************************************************
|
||||
* 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.
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*******************************************************************************/
|
||||
package org.eclipse.xtext.ide.server
|
||||
package org.eclipse.xtext.ide.server;
|
||||
|
||||
import org.eclipse.lsp4j.ServerCapabilities
|
||||
import org.eclipse.lsp4j.InitializeParams
|
||||
import org.eclipse.lsp4j.ServerCapabilities;
|
||||
import org.eclipse.lsp4j.InitializeParams;
|
||||
|
||||
/**
|
||||
* @author Sven Efftinge - Initial contribution and API
|
||||
*/
|
||||
interface ICapabilitiesContributor {
|
||||
public interface ICapabilitiesContributor {
|
||||
|
||||
/**
|
||||
* Allows an individual language to contribute to and overwrite properties in the server's capabilities.
|
||||
*/
|
||||
def ServerCapabilities contribute(ServerCapabilities capabilities, InitializeParams params);
|
||||
ServerCapabilities contribute(ServerCapabilities capabilities, InitializeParams params);
|
||||
}
|
|
@ -0,0 +1,166 @@
|
|||
/**
|
||||
* Copyright (c) 2016, 2020 TypeFox GmbH (http://www.typefox.io) and others.
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0.
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.eclipse.xtext.ide.server;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.function.Function;
|
||||
|
||||
import org.eclipse.emf.common.util.URI;
|
||||
import org.eclipse.emf.ecore.resource.Resource;
|
||||
import org.eclipse.emf.ecore.resource.ResourceSet;
|
||||
import org.eclipse.lsp4j.InitializeParams;
|
||||
import org.eclipse.lsp4j.InitializeResult;
|
||||
import org.eclipse.lsp4j.jsonrpc.Endpoint;
|
||||
import org.eclipse.lsp4j.services.LanguageClient;
|
||||
import org.eclipse.xtext.ide.serializer.IChangeSerializer;
|
||||
import org.eclipse.xtext.resource.IResourceDescription;
|
||||
import org.eclipse.xtext.resource.IResourceDescriptions;
|
||||
import org.eclipse.xtext.resource.impl.ResourceDescriptionsProvider;
|
||||
import org.eclipse.xtext.util.CancelIndicator;
|
||||
import org.eclipse.xtext.xbase.lib.util.ToStringBuilder;
|
||||
|
||||
/**
|
||||
* API for interacting with a running language server.
|
||||
*
|
||||
* @author Sven Efftinge - Initial contribution and API
|
||||
*/
|
||||
public interface ILanguageServerAccess {
|
||||
class Context {
|
||||
private final Resource resource;
|
||||
|
||||
private final Document document;
|
||||
|
||||
private final boolean isDocumentOpen;
|
||||
|
||||
private final CancelIndicator cancelChecker;
|
||||
|
||||
public Context(Resource resource, Document document, boolean isDocumentOpen, CancelIndicator cancelChecker) {
|
||||
this.resource = resource;
|
||||
this.document = document;
|
||||
this.isDocumentOpen = isDocumentOpen;
|
||||
this.cancelChecker = cancelChecker;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
ToStringBuilder b = new ToStringBuilder(this);
|
||||
b.add("resource", resource);
|
||||
b.add("document", document);
|
||||
b.add("isDocumentOpen", isDocumentOpen);
|
||||
b.add("cancelChecker", cancelChecker);
|
||||
return b.toString();
|
||||
}
|
||||
|
||||
public Resource getResource() {
|
||||
return resource;
|
||||
}
|
||||
|
||||
public Document getDocument() {
|
||||
return document;
|
||||
}
|
||||
|
||||
public boolean isDocumentOpen() {
|
||||
return isDocumentOpen;
|
||||
}
|
||||
|
||||
public CancelIndicator getCancelChecker() {
|
||||
return cancelChecker;
|
||||
}
|
||||
}
|
||||
|
||||
class IndexContext {
|
||||
private final IResourceDescriptions index;
|
||||
|
||||
private final CancelIndicator cancelChecker;
|
||||
|
||||
public IndexContext(IResourceDescriptions index, CancelIndicator cancelChecker) {
|
||||
this.index = index;
|
||||
this.cancelChecker = cancelChecker;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
ToStringBuilder b = new ToStringBuilder(this);
|
||||
b.add("index", index);
|
||||
b.add("cancelChecker", cancelChecker);
|
||||
return b.toString();
|
||||
}
|
||||
|
||||
public IResourceDescriptions getIndex() {
|
||||
return index;
|
||||
}
|
||||
|
||||
public CancelIndicator getCancelChecker() {
|
||||
return cancelChecker;
|
||||
}
|
||||
}
|
||||
|
||||
interface IBuildListener {
|
||||
void afterBuild(List<IResourceDescription.Delta> deltas);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides read access to a fully resolved resource and document.
|
||||
*/
|
||||
<T extends Object> CompletableFuture<T> doRead(String uri, Function<ILanguageServerAccess.Context, T> function);
|
||||
|
||||
/**
|
||||
* Provides read access to the Xtext index.
|
||||
*
|
||||
* @since 2.18
|
||||
*/
|
||||
<T extends Object> CompletableFuture<T> doReadIndex(
|
||||
Function<? super ILanguageServerAccess.IndexContext, ? extends T> function);
|
||||
|
||||
/**
|
||||
* Registers a build listener on this language server
|
||||
*/
|
||||
void addBuildListener(ILanguageServerAccess.IBuildListener listener);
|
||||
|
||||
/**
|
||||
* Removes a build listener on this language server
|
||||
*/
|
||||
default void removeBuildListener(ILanguageServerAccess.IBuildListener listener) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the language client facade. It usually also implements {@link Endpoint}, which can be used to call non-standard
|
||||
* extensions to LSP.
|
||||
*/
|
||||
LanguageClient getLanguageClient();
|
||||
|
||||
/**
|
||||
* Creates a new {@link ResourceSet} to be used with the {@link IChangeSerializer} API.
|
||||
*
|
||||
* The {@link IChangeSerializer} allows to calculate text edits from model changes. In order not to mess up the
|
||||
* originals, the respective models should be loaded into a new resource set which this method provides.
|
||||
*
|
||||
* @param uri
|
||||
* a file {@link URI} used to detect the project to configure the scope of the resource set.
|
||||
* @return a new empty resource set, configured with the project the <code>uri</code> belongs to and the
|
||||
* {@link ResourceDescriptionsProvider#LIVE_SCOPE} in order to reflect model changes immediately.
|
||||
* @since 2.18
|
||||
*/
|
||||
ResourceSet newLiveScopeResourceSet(URI uri);
|
||||
|
||||
/**
|
||||
* @return the parameters as negotiated during client and server on initialization.
|
||||
* @since 2.18
|
||||
*/
|
||||
InitializeParams getInitializeParams();
|
||||
|
||||
/**
|
||||
* Returns the {@link InitializeResult} of the language server.
|
||||
*
|
||||
* @since 2.18
|
||||
*/
|
||||
InitializeResult getInitializeResult();
|
||||
}
|
|
@ -1,104 +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
|
||||
|
||||
import java.util.List
|
||||
import java.util.concurrent.CompletableFuture
|
||||
import java.util.function.Function
|
||||
import org.eclipse.emf.common.util.URI
|
||||
import org.eclipse.emf.ecore.resource.Resource
|
||||
import org.eclipse.emf.ecore.resource.ResourceSet
|
||||
import org.eclipse.lsp4j.InitializeParams
|
||||
import org.eclipse.lsp4j.InitializeResult
|
||||
import org.eclipse.lsp4j.services.LanguageClient
|
||||
import org.eclipse.xtend.lib.annotations.Data
|
||||
import org.eclipse.xtext.ide.serializer.IChangeSerializer
|
||||
import org.eclipse.xtext.resource.IResourceDescription
|
||||
import org.eclipse.xtext.resource.IResourceDescriptions
|
||||
import org.eclipse.xtext.resource.impl.ResourceDescriptionsProvider
|
||||
import org.eclipse.xtext.util.CancelIndicator
|
||||
|
||||
/**
|
||||
* API for interacting with a running language server.
|
||||
*
|
||||
* @author Sven Efftinge - Initial contribution and API
|
||||
*/
|
||||
interface ILanguageServerAccess {
|
||||
|
||||
@Data
|
||||
static class Context {
|
||||
Resource resource
|
||||
Document document
|
||||
boolean isDocumentOpen
|
||||
CancelIndicator cancelChecker
|
||||
}
|
||||
|
||||
@Data
|
||||
static class IndexContext {
|
||||
IResourceDescriptions index
|
||||
CancelIndicator cancelChecker
|
||||
}
|
||||
|
||||
/**
|
||||
* provides read access to a fully resolved resource and Document.
|
||||
*/
|
||||
def <T> CompletableFuture<T> doRead(String uri, Function<Context, T> function)
|
||||
|
||||
/**
|
||||
* Provides read access to the Xtext index.
|
||||
*
|
||||
* @since 2.18
|
||||
*/
|
||||
def <T> CompletableFuture<T> doReadIndex(Function<? super IndexContext, ? extends T> function)
|
||||
|
||||
static interface IBuildListener {
|
||||
def void afterBuild(List<IResourceDescription.Delta> deltas)
|
||||
}
|
||||
|
||||
/**
|
||||
* registers a build listener on the this language server
|
||||
*/
|
||||
def void addBuildListener(IBuildListener listener)
|
||||
|
||||
/**
|
||||
* @return the language client facade. It usually also implements Endpoint, which can be used to
|
||||
* call non-standard extensions to the LSP.
|
||||
*/
|
||||
def LanguageClient getLanguageClient();
|
||||
|
||||
/**
|
||||
* Creates a new {@link ResourceSet} to be used with the {@link IChangeSerializer} API.
|
||||
*
|
||||
* The {@link IChangeSerializer} allows to calculate text edits from model changes.
|
||||
* In order not to mess up the originals, the resp. models should be loaded into a
|
||||
* new resource set which this method provides.
|
||||
*
|
||||
* @param uri a file URI used to detect the project to configure the scope of the resource set.
|
||||
* @return a new empty resource set, configured with the project the <code>uri</code>
|
||||
* belongs to and the {@link ResourceDescriptionsProvider#LIVE_SCOPE} in order to
|
||||
* reflect model changes immediately.
|
||||
* @since 2.18
|
||||
*/
|
||||
def ResourceSet newLiveScopeResourceSet(URI uri);
|
||||
|
||||
/**
|
||||
* @return the parameters as negotiated during client and server on initialization.
|
||||
* @since 2.18
|
||||
*/
|
||||
def InitializeParams getInitializeParams();
|
||||
|
||||
/**
|
||||
* Returns with the {@link InitializeResult} of the LS.
|
||||
*
|
||||
* @since 2.18
|
||||
*/
|
||||
def InitializeResult getInitializeResult();
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
/**
|
||||
* 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;
|
||||
|
||||
import org.eclipse.xtext.ide.server.ILanguageServerAccess;
|
||||
|
||||
/**
|
||||
* Interface for language specific extensions to LSP. Implementors should use {@link JsonRpcNotification} and {@link
|
||||
* JsonRpcRequest} annotations.
|
||||
*
|
||||
* @author Sven Efftinge - Initial contribution and API
|
||||
*/
|
||||
public interface ILanguageServerExtension {
|
||||
/**
|
||||
* The same jsonrpc method might be supported by multiple languages and only the actual invocation might reveal is a
|
||||
* language wants to handle it, based on e.g. a uri in the parameter.
|
||||
*
|
||||
* To indicate that a request is not handled, this exception should be thrown by the service.
|
||||
*/
|
||||
static final RuntimeException NOT_HANDLED_EXCEPTION = new UnsupportedOperationException("not handled");
|
||||
|
||||
/**
|
||||
* Initialize the extension.
|
||||
* @param access Provides access to language server documents, resource and build events.
|
||||
*/
|
||||
void initialize(ILanguageServerAccess access);
|
||||
}
|
|
@ -1,31 +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
|
||||
|
||||
/**
|
||||
* Interface for language specific extensions to the LSP.
|
||||
* Implementors should use {link JsonRpcNotification} and {link JsonRpcRequest} annotations.
|
||||
*
|
||||
* @author Sven Efftinge - Initial contribution and API
|
||||
*/
|
||||
interface ILanguageServerExtension {
|
||||
|
||||
/**
|
||||
* The same jsonrpc method might be supported by multiple languages and only the actual invocation
|
||||
* might reveal is a language wants to handle it, based on e.g. a uri in the parameter.
|
||||
*
|
||||
* To indicate that a request is not handled, this exception should be thrown by the service.
|
||||
*/
|
||||
static RuntimeException NOT_HANDLED_EXCEPTION = new UnsupportedOperationException("not handled");
|
||||
|
||||
/**
|
||||
* the language server provides a access to language server documents, resources and build events.
|
||||
*/
|
||||
def void initialize(ILanguageServerAccess access);
|
||||
}
|
|
@ -1099,6 +1099,11 @@ public class LanguageServerImpl implements LanguageServer, WorkspaceService, Tex
|
|||
public void addBuildListener(ILanguageServerAccess.IBuildListener listener) {
|
||||
workspaceManager.addBuildListener(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeBuildListener(ILanguageServerAccess.IBuildListener listener) {
|
||||
workspaceManager.removeBuildListener(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LanguageClient getLanguageClient() {
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
/*******************************************************************************
|
||||
* 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;
|
||||
|
||||
import com.google.inject.AbstractModule;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import org.eclipse.lsp4j.services.LanguageServer;
|
||||
import org.eclipse.xtext.ide.ExecutorServiceProvider;
|
||||
import org.eclipse.xtext.resource.IContainer;
|
||||
import org.eclipse.xtext.resource.IResourceServiceProvider;
|
||||
import org.eclipse.xtext.resource.ResourceServiceProviderServiceLoader;
|
||||
import org.eclipse.xtext.resource.containers.ProjectDescriptionBasedContainerManager;
|
||||
|
||||
/**
|
||||
* @author Sven Efftinge - Initial contribution and API
|
||||
* @since 2.11
|
||||
*/
|
||||
public class ServerModule extends AbstractModule {
|
||||
|
||||
@Override
|
||||
protected void configure() {
|
||||
binder().bind(ExecutorService.class).toProvider(ExecutorServiceProvider.class);
|
||||
|
||||
bind(LanguageServer.class).to(LanguageServerImpl.class);
|
||||
bind(IResourceServiceProvider.Registry.class).toProvider(ResourceServiceProviderServiceLoader.class);
|
||||
bind(IWorkspaceConfigFactory.class).to(ProjectWorkspaceConfigFactory.class);
|
||||
bind(ProjectWorkspaceConfigFactory.class).to(MultiRootWorkspaceConfigFactory.class);
|
||||
bind(IProjectDescriptionFactory.class).to(DefaultProjectDescriptionFactory.class);
|
||||
bind(IContainer.Manager.class).to(ProjectDescriptionBasedContainerManager.class);
|
||||
}
|
||||
}
|
|
@ -1,36 +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
|
||||
|
||||
import com.google.inject.AbstractModule
|
||||
import java.util.concurrent.ExecutorService
|
||||
import org.eclipse.lsp4j.services.LanguageServer
|
||||
import org.eclipse.xtext.ide.ExecutorServiceProvider
|
||||
import org.eclipse.xtext.resource.IContainer
|
||||
import org.eclipse.xtext.resource.IResourceServiceProvider
|
||||
import org.eclipse.xtext.resource.ResourceServiceProviderServiceLoader
|
||||
import org.eclipse.xtext.resource.containers.ProjectDescriptionBasedContainerManager
|
||||
|
||||
/**
|
||||
* @author Sven Efftinge - Initial contribution and API
|
||||
* @since 2.11
|
||||
*/
|
||||
class ServerModule extends AbstractModule {
|
||||
|
||||
override protected configure() {
|
||||
binder.bind(ExecutorService).toProvider(ExecutorServiceProvider)
|
||||
|
||||
bind(LanguageServer).to(LanguageServerImpl)
|
||||
bind(IResourceServiceProvider.Registry).toProvider(ResourceServiceProviderServiceLoader)
|
||||
bind(IWorkspaceConfigFactory).to(ProjectWorkspaceConfigFactory)
|
||||
bind(ProjectWorkspaceConfigFactory).to(MultiRootWorkspaceConfigFactory)
|
||||
bind(IProjectDescriptionFactory).to(DefaultProjectDescriptionFactory)
|
||||
bind(IContainer.Manager).to(ProjectDescriptionBasedContainerManager)
|
||||
}
|
||||
}
|
|
@ -0,0 +1,80 @@
|
|||
/**
|
||||
* Copyright (c) 2017, 2020 TypeFox GmbH (http://www.typefox.io) and others.
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0.
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.eclipse.xtext.ide.server.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.ide.server.ILanguageServerAccess;
|
||||
import org.eclipse.xtext.resource.XtextResource;
|
||||
import org.eclipse.xtext.util.CancelIndicator;
|
||||
|
||||
/**
|
||||
* @author Jan Koehnlein
|
||||
* @since 2.18
|
||||
*/
|
||||
public interface ICodeActionService2 {
|
||||
class Options {
|
||||
private Document document;
|
||||
|
||||
private XtextResource resource;
|
||||
|
||||
private ILanguageServerAccess languageServerAccess;
|
||||
|
||||
private CodeActionParams codeActionParams;
|
||||
|
||||
private CancelIndicator cancelIndicator;
|
||||
|
||||
public Document getDocument() {
|
||||
return document;
|
||||
}
|
||||
|
||||
public void setDocument(Document document) {
|
||||
this.document = document;
|
||||
}
|
||||
|
||||
public XtextResource getResource() {
|
||||
return resource;
|
||||
}
|
||||
|
||||
public void setResource(XtextResource resource) {
|
||||
this.resource = resource;
|
||||
}
|
||||
|
||||
public ILanguageServerAccess getLanguageServerAccess() {
|
||||
return languageServerAccess;
|
||||
}
|
||||
|
||||
public void setLanguageServerAccess(ILanguageServerAccess languageServerAccess) {
|
||||
this.languageServerAccess = languageServerAccess;
|
||||
}
|
||||
|
||||
public CodeActionParams getCodeActionParams() {
|
||||
return codeActionParams;
|
||||
}
|
||||
|
||||
public void setCodeActionParams(CodeActionParams codeActionParams) {
|
||||
this.codeActionParams = codeActionParams;
|
||||
}
|
||||
|
||||
public CancelIndicator getCancelIndicator() {
|
||||
return this.cancelIndicator;
|
||||
}
|
||||
|
||||
public void setCancelIndicator(CancelIndicator cancelIndicator) {
|
||||
this.cancelIndicator = cancelIndicator;
|
||||
}
|
||||
}
|
||||
|
||||
List<Either<Command, CodeAction>> getCodeActions(ICodeActionService2.Options options);
|
||||
}
|
|
@ -1,39 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2017, 2020 TypeFox GmbH (http://www.typefox.io) and others.
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0.
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*******************************************************************************/
|
||||
package org.eclipse.xtext.ide.server.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.xtend.lib.annotations.Accessors
|
||||
import org.eclipse.xtext.ide.server.Document
|
||||
import org.eclipse.xtext.ide.server.ILanguageServerAccess
|
||||
import org.eclipse.xtext.resource.XtextResource
|
||||
import org.eclipse.xtext.util.CancelIndicator
|
||||
|
||||
/**
|
||||
* @author Jan Koehnlein
|
||||
* @since 2.18
|
||||
*/
|
||||
interface ICodeActionService2 {
|
||||
|
||||
def List<Either<Command, CodeAction>> getCodeActions(Options options)
|
||||
|
||||
@Accessors
|
||||
class Options {
|
||||
Document document
|
||||
XtextResource resource
|
||||
ILanguageServerAccess languageServerAccess
|
||||
CodeActionParams codeActionParams
|
||||
CancelIndicator cancelIndicator
|
||||
}
|
||||
}
|
||||
|
|
@ -1,11 +1,11 @@
|
|||
/**
|
||||
* 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.
|
||||
*
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
*******************************************************************************/
|
||||
package org.eclipse.xtext.ide.server.codelens;
|
||||
|
||||
import org.eclipse.lsp4j.CodeLens;
|
||||
|
@ -16,10 +16,10 @@ import org.eclipse.xtext.util.CancelIndicator;
|
|||
/**
|
||||
* @author Sven Efftinge - Initial contribution and API
|
||||
*/
|
||||
@SuppressWarnings("all")
|
||||
public interface ICodeLensResolver {
|
||||
/**
|
||||
* Resolve the given code lens.
|
||||
*/
|
||||
CodeLens resolveCodeLens(final Document document, final XtextResource resource, final CodeLens codeLens, final CancelIndicator indicator);
|
||||
|
||||
/**
|
||||
* Resolve the given code lens.
|
||||
*/
|
||||
CodeLens resolveCodeLens(Document document, XtextResource resource, CodeLens codeLens, CancelIndicator indicator);
|
||||
}
|
|
@ -1,25 +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.codelens
|
||||
|
||||
import org.eclipse.lsp4j.CodeLens
|
||||
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
|
||||
*/
|
||||
interface ICodeLensResolver {
|
||||
|
||||
/**
|
||||
* Resolve the given code lens.
|
||||
*/
|
||||
def CodeLens resolveCodeLens(Document document, XtextResource resource, CodeLens codeLens, CancelIndicator indicator);
|
||||
}
|
|
@ -1,11 +1,11 @@
|
|||
/**
|
||||
* 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.
|
||||
*
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
*******************************************************************************/
|
||||
package org.eclipse.xtext.ide.server.codelens;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -18,10 +18,11 @@ import org.eclipse.xtext.util.CancelIndicator;
|
|||
/**
|
||||
* @author Sven Efftinge - Initial contribution and API
|
||||
*/
|
||||
@SuppressWarnings("all")
|
||||
public interface ICodeLensService {
|
||||
/**
|
||||
* compute code lenses for the given context.
|
||||
*/
|
||||
List<? extends CodeLens> computeCodeLenses(final Document document, final XtextResource resource, final CodeLensParams params, final CancelIndicator indicator);
|
||||
}
|
||||
|
||||
/**
|
||||
* Compute code lenses for the given context.
|
||||
*/
|
||||
List<? extends CodeLens> computeCodeLenses(Document document, XtextResource resource, CodeLensParams params, CancelIndicator indicator);
|
||||
|
||||
}
|
|
@ -1,28 +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.codelens
|
||||
|
||||
import java.util.List
|
||||
import org.eclipse.lsp4j.CodeLens
|
||||
import org.eclipse.lsp4j.CodeLensParams
|
||||
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
|
||||
*/
|
||||
interface ICodeLensService {
|
||||
|
||||
/**
|
||||
* compute code lenses for the given context.
|
||||
*/
|
||||
def List<? extends CodeLens> computeCodeLenses(Document document, XtextResource resource, CodeLensParams params, CancelIndicator indicator);
|
||||
|
||||
}
|
|
@ -18,7 +18,6 @@ import org.eclipse.xtext.xbase.lib.Functions.Function1;
|
|||
/**
|
||||
* @author Sven Efftinge - Initial contribution and API
|
||||
*/
|
||||
@SuppressWarnings("all")
|
||||
public interface IExecutableCommandService {
|
||||
/**
|
||||
* Called on server initialize.
|
||||
|
@ -29,11 +28,11 @@ public interface IExecutableCommandService {
|
|||
/**
|
||||
* Called on server initialize, only if the client supported dynamicRegistration of commands.
|
||||
*/
|
||||
default void initializeDynamicRegistration(final Function1<? super String, ? extends IDisposable> register) {
|
||||
default void initializeDynamicRegistration(Function1<? super String, ? extends IDisposable> register) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the client wants to execute a registered command.
|
||||
*/
|
||||
Object execute(final ExecuteCommandParams params, final ILanguageServerAccess access, final CancelIndicator cancelIndicator);
|
||||
Object execute(ExecuteCommandParams params, ILanguageServerAccess access, CancelIndicator cancelIndicator);
|
||||
}
|
|
@ -1,37 +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.commands
|
||||
|
||||
import java.util.List
|
||||
import org.eclipse.lsp4j.ExecuteCommandParams
|
||||
import org.eclipse.xtext.ide.server.ILanguageServerAccess
|
||||
import org.eclipse.xtext.util.IDisposable
|
||||
import org.eclipse.xtext.util.CancelIndicator
|
||||
|
||||
/**
|
||||
* @author Sven Efftinge - Initial contribution and API
|
||||
*/
|
||||
interface IExecutableCommandService {
|
||||
|
||||
/**
|
||||
* Called on server initialize.
|
||||
* @return the supported commands
|
||||
*/
|
||||
def List<String> initialize()
|
||||
|
||||
/**
|
||||
* Called on server initialize, only if the client supported dynamicRegistration of commands.
|
||||
*/
|
||||
def void initializeDynamicRegistration((String)=>IDisposable register) {}
|
||||
|
||||
/**
|
||||
* Called when the client wants to execute a registered command.
|
||||
*/
|
||||
def Object execute(ExecuteCommandParams params, ILanguageServerAccess access, CancelIndicator cancelIndicator)
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
/**
|
||||
* Copyright (c) 2016, 2020 TypeFox GmbH (http://www.typefox.io) and others.
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0.
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.eclipse.xtext.ide.server.hover;
|
||||
|
||||
import org.eclipse.emf.ecore.EObject;
|
||||
import org.eclipse.emf.ecore.util.EcoreUtil;
|
||||
import org.eclipse.xtext.ide.server.Document;
|
||||
import org.eclipse.xtext.resource.XtextResource;
|
||||
import org.eclipse.xtext.util.ITextRegion;
|
||||
|
||||
public class HoverContext {
|
||||
private final Document document;
|
||||
|
||||
private final XtextResource resource;
|
||||
|
||||
private final int offset;
|
||||
|
||||
private final ITextRegion region;
|
||||
|
||||
private final EObject element;
|
||||
|
||||
public HoverContext(Document document, XtextResource resource, int offset, ITextRegion region, EObject element) {
|
||||
this.document = document;
|
||||
this.resource = resource;
|
||||
this.offset = offset;
|
||||
this.region = region;
|
||||
this.element = element;
|
||||
}
|
||||
|
||||
public Document getDocument() {
|
||||
return document;
|
||||
}
|
||||
|
||||
public XtextResource getResource() {
|
||||
return resource;
|
||||
}
|
||||
|
||||
public int getOffset() {
|
||||
return offset;
|
||||
}
|
||||
|
||||
public ITextRegion getRegion() {
|
||||
return region;
|
||||
}
|
||||
|
||||
public EObject getElement() {
|
||||
return element;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "HoverContext [document=" + document + ", resource=" + (resource == null ? "null" : resource.getURI())
|
||||
+ ", offset=" + offset + ", region=" + region + ", element="
|
||||
+ (element == null ? "null" : EcoreUtil.getURI(element)) + "]";
|
||||
}
|
||||
|
||||
}
|
|
@ -13,10 +13,9 @@ import com.google.inject.Inject
|
|||
import com.google.inject.Singleton
|
||||
import org.eclipse.emf.ecore.EObject
|
||||
import org.eclipse.lsp4j.Hover
|
||||
import org.eclipse.lsp4j.HoverParams
|
||||
import org.eclipse.lsp4j.MarkupContent
|
||||
import org.eclipse.lsp4j.Range
|
||||
import org.eclipse.xtend.lib.annotations.Accessors
|
||||
import org.eclipse.xtend.lib.annotations.FinalFieldsConstructor
|
||||
import org.eclipse.xtext.documentation.IEObjectDocumentationProvider
|
||||
import org.eclipse.xtext.ide.server.Document
|
||||
import org.eclipse.xtext.ide.server.DocumentExtensions
|
||||
|
@ -24,10 +23,8 @@ import org.eclipse.xtext.resource.EObjectAtOffsetHelper
|
|||
import org.eclipse.xtext.resource.ILocationInFileProvider
|
||||
import org.eclipse.xtext.resource.XtextResource
|
||||
import org.eclipse.xtext.util.CancelIndicator
|
||||
import org.eclipse.xtext.util.ITextRegion
|
||||
|
||||
import static extension org.eclipse.xtext.nodemodel.util.NodeModelUtils.*
|
||||
import org.eclipse.lsp4j.HoverParams
|
||||
|
||||
/**
|
||||
* @author kosyakov - Initial contribution and API
|
||||
|
@ -124,13 +121,3 @@ class HoverService implements IHoverService {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
@Accessors
|
||||
@FinalFieldsConstructor
|
||||
class HoverContext {
|
||||
val Document document
|
||||
val XtextResource resource
|
||||
val int offset
|
||||
val ITextRegion region
|
||||
val EObject element
|
||||
}
|
||||
|
|
|
@ -1,46 +1,50 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2018 TypeFox and others.
|
||||
* Copyright (c) 2018, 2020 TypeFox 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.semanticHighlight
|
||||
package org.eclipse.xtext.ide.server.semanticHighlight;
|
||||
|
||||
import com.google.inject.ImplementedBy
|
||||
import com.google.inject.Singleton
|
||||
import java.util.List
|
||||
import java.util.Set
|
||||
import org.eclipse.xtext.ide.editor.syntaxcoloring.IHighlightedPositionAcceptor
|
||||
import org.eclipse.xtext.ide.editor.syntaxcoloring.ISemanticHighlightingCalculator
|
||||
import org.eclipse.xtext.ide.editor.syntaxcoloring.LightweightPosition
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.eclipse.xtext.ide.editor.syntaxcoloring.IHighlightedPositionAcceptor;
|
||||
import org.eclipse.xtext.ide.editor.syntaxcoloring.ISemanticHighlightingCalculator;
|
||||
import org.eclipse.xtext.ide.editor.syntaxcoloring.LightweightPosition;
|
||||
|
||||
import com.google.inject.ImplementedBy;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
/**
|
||||
* Service for mapping the IDs of the highlighting styles to a list of <a href="https://manual.macromates.com/en/language_grammars">TextMate scopes</a>.
|
||||
* Service for mapping the IDs of the highlighting styles to a list of
|
||||
* <a href="https://manual.macromates.com/en/language_grammars">TextMate scopes</a>.
|
||||
*
|
||||
* @see IHighlightedPositionAcceptor#addPosition
|
||||
* @see LightweightPosition#getIds
|
||||
*
|
||||
*/
|
||||
@ImplementedBy(Noop)
|
||||
interface ISemanticHighlightingStyleToTokenMapper {
|
||||
@ImplementedBy(ISemanticHighlightingStyleToTokenMapper.Noop.class)
|
||||
public interface ISemanticHighlightingStyleToTokenMapper {
|
||||
|
||||
/**
|
||||
* Maps the highlighting style ID to the corresponding TextMate scopes.
|
||||
*/
|
||||
def List<String> toScopes(String styleId);
|
||||
List<String> toScopes(String styleId);
|
||||
|
||||
/**
|
||||
* Returns with a set of distinct style identifiers that are used by the {@link IHighlightedPositionAcceptor} when calculating
|
||||
* the highlighted positions with the {@link ISemanticHighlightingCalculator}.
|
||||
* Returns a set of distinct style identifiers that are used by the {@link IHighlightedPositionAcceptor} when
|
||||
* calculating the highlighted positions with the {@link ISemanticHighlightingCalculator}.
|
||||
*
|
||||
* <p>
|
||||
* Must not return with {@code null} but an empty set instead.
|
||||
*
|
||||
* @see IHighlightedPositionAcceptor#addPosition
|
||||
*/
|
||||
def Set<String> getAllStyleIds();
|
||||
Set<String> getAllStyleIds();
|
||||
|
||||
/**
|
||||
* The shared, default NOOP implementation of the semantic style ID to TextMate token mapper.
|
||||
|
@ -48,12 +52,14 @@ interface ISemanticHighlightingStyleToTokenMapper {
|
|||
@Singleton
|
||||
static final class Noop implements ISemanticHighlightingStyleToTokenMapper {
|
||||
|
||||
override toScopes(String styleId) {
|
||||
@Override
|
||||
public List<String> toScopes(String styleId) {
|
||||
return SemanticHighlightingRegistry.UNKNOWN_SCOPES;
|
||||
}
|
||||
|
||||
override getAllStyleIds() {
|
||||
return emptySet;
|
||||
@Override
|
||||
public Set<String> getAllStyleIds() {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
/**
|
||||
* Copyright (c) 2016, 2020 TypeFox GmbH (http://www.typefox.io) and others.
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0.
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.eclipse.xtext.ide.util;
|
||||
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.xtext.util.CancelIndicator;
|
||||
|
||||
/**
|
||||
* @author kosyakov - Initial contribution and API
|
||||
* @since 2.11
|
||||
*/
|
||||
public class CancelIndicatorProgressMonitor implements IProgressMonitor {
|
||||
private final CancelIndicator delegate;
|
||||
|
||||
private volatile boolean canceled;
|
||||
|
||||
@Override
|
||||
public boolean isCanceled() {
|
||||
return canceled || delegate.isCanceled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCanceled(boolean value) {
|
||||
this.canceled = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beginTask(String name, int totalWork) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTaskName(String name) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void subTask(String name) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void internalWorked(double work) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void worked(int work) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void done() {
|
||||
}
|
||||
|
||||
public CancelIndicatorProgressMonitor(CancelIndicator delegate) {
|
||||
this.delegate = delegate;
|
||||
}
|
||||
}
|
|
@ -1,52 +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.util
|
||||
|
||||
import org.eclipse.core.runtime.IProgressMonitor
|
||||
import org.eclipse.xtend.lib.annotations.FinalFieldsConstructor
|
||||
import org.eclipse.xtext.util.CancelIndicator
|
||||
|
||||
/**
|
||||
* @author kosyakov - Initial contribution and API
|
||||
* @since 2.11
|
||||
*/
|
||||
@FinalFieldsConstructor
|
||||
class CancelIndicatorProgressMonitor implements IProgressMonitor {
|
||||
|
||||
val CancelIndicator delegate
|
||||
|
||||
boolean canceled
|
||||
|
||||
override isCanceled() {
|
||||
canceled || delegate.isCanceled
|
||||
}
|
||||
|
||||
override setCanceled(boolean value) {
|
||||
canceled = value
|
||||
}
|
||||
|
||||
override beginTask(String name, int totalWork) {
|
||||
}
|
||||
|
||||
override setTaskName(String name) {
|
||||
}
|
||||
|
||||
override subTask(String name) {
|
||||
}
|
||||
|
||||
override internalWorked(double work) {
|
||||
}
|
||||
|
||||
override worked(int work) {
|
||||
}
|
||||
|
||||
override done() {
|
||||
}
|
||||
|
||||
}
|
|
@ -1,109 +0,0 @@
|
|||
/**
|
||||
* Copyright (c) 2015 itemis AG (http://www.itemis.eu) 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.editor.bracketmatching;
|
||||
|
||||
import org.eclipse.xtend.lib.annotations.Data;
|
||||
import org.eclipse.xtext.xbase.lib.Pure;
|
||||
import org.eclipse.xtext.xbase.lib.util.ToStringBuilder;
|
||||
|
||||
/**
|
||||
* Defines a single pair of braces which need to be matched when editing code.
|
||||
*
|
||||
* @author kosyakov - Initial contribution and API
|
||||
*/
|
||||
@Data
|
||||
@SuppressWarnings("all")
|
||||
public class BracePair {
|
||||
/**
|
||||
* The length of a left brace should be one character for Eclipse.
|
||||
*/
|
||||
private final String leftBrace;
|
||||
|
||||
/**
|
||||
* The length of a right brace should be one character for Eclipse.
|
||||
*/
|
||||
private final String rightBrace;
|
||||
|
||||
/**
|
||||
* True if the brace is structural. Structural braces have higher priority than regular braces:
|
||||
* they are matched with each other even if there are unmatched braces of other types between them,
|
||||
* and an opening non-structural brace is not matched with a closing one if one of them is outside a pair
|
||||
* of matched structural braces and another is outside. In Java code, the curly braces are structural.
|
||||
*
|
||||
* It is ignored by Eclipse.
|
||||
*/
|
||||
private final boolean structural;
|
||||
|
||||
public BracePair(final String leftBrace, final String rightBrace, final boolean structural) {
|
||||
super();
|
||||
this.leftBrace = leftBrace;
|
||||
this.rightBrace = rightBrace;
|
||||
this.structural = structural;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Pure
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((this.leftBrace== null) ? 0 : this.leftBrace.hashCode());
|
||||
result = prime * result + ((this.rightBrace== null) ? 0 : this.rightBrace.hashCode());
|
||||
return prime * result + (this.structural ? 1231 : 1237);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Pure
|
||||
public boolean equals(final Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
BracePair other = (BracePair) obj;
|
||||
if (this.leftBrace == null) {
|
||||
if (other.leftBrace != null)
|
||||
return false;
|
||||
} else if (!this.leftBrace.equals(other.leftBrace))
|
||||
return false;
|
||||
if (this.rightBrace == null) {
|
||||
if (other.rightBrace != null)
|
||||
return false;
|
||||
} else if (!this.rightBrace.equals(other.rightBrace))
|
||||
return false;
|
||||
if (other.structural != this.structural)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Pure
|
||||
public String toString() {
|
||||
ToStringBuilder b = new ToStringBuilder(this);
|
||||
b.add("leftBrace", this.leftBrace);
|
||||
b.add("rightBrace", this.rightBrace);
|
||||
b.add("structural", this.structural);
|
||||
return b.toString();
|
||||
}
|
||||
|
||||
@Pure
|
||||
public String getLeftBrace() {
|
||||
return this.leftBrace;
|
||||
}
|
||||
|
||||
@Pure
|
||||
public String getRightBrace() {
|
||||
return this.rightBrace;
|
||||
}
|
||||
|
||||
@Pure
|
||||
public boolean isStructural() {
|
||||
return this.structural;
|
||||
}
|
||||
}
|
|
@ -1,45 +0,0 @@
|
|||
/**
|
||||
* Copyright (c) 2015 itemis AG (http://www.itemis.eu) 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.editor.bracketmatching;
|
||||
|
||||
import com.google.inject.Singleton;
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
import org.eclipse.xtend.lib.annotations.Accessors;
|
||||
import org.eclipse.xtend.lib.annotations.FinalFieldsConstructor;
|
||||
import org.eclipse.xtext.ide.editor.bracketmatching.BracePair;
|
||||
import org.eclipse.xtext.ide.editor.bracketmatching.IBracePairProvider;
|
||||
import org.eclipse.xtext.xbase.lib.CollectionLiterals;
|
||||
import org.eclipse.xtext.xbase.lib.Pure;
|
||||
|
||||
/**
|
||||
* @author kosyakov - Initial contribution and API
|
||||
*/
|
||||
@Singleton
|
||||
@Accessors
|
||||
@FinalFieldsConstructor
|
||||
@SuppressWarnings("all")
|
||||
public class DefaultBracePairProvider implements IBracePairProvider {
|
||||
private final Set<BracePair> pairs;
|
||||
|
||||
public DefaultBracePairProvider() {
|
||||
this(
|
||||
Collections.<BracePair>unmodifiableSet(CollectionLiterals.<BracePair>newHashSet(new BracePair("(", ")", true), new BracePair("{", "}", true), new BracePair("[", "]", true))));
|
||||
}
|
||||
|
||||
public DefaultBracePairProvider(final Set<BracePair> pairs) {
|
||||
super();
|
||||
this.pairs = pairs;
|
||||
}
|
||||
|
||||
@Pure
|
||||
public Set<BracePair> getPairs() {
|
||||
return this.pairs;
|
||||
}
|
||||
}
|
|
@ -1,29 +0,0 @@
|
|||
/**
|
||||
* Copyright (c) 2015 itemis AG (http://www.itemis.eu) 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.editor.bracketmatching;
|
||||
|
||||
import java.util.Set;
|
||||
import org.eclipse.xtext.ide.editor.bracketmatching.BracePair;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Provides a set of definitions for brace pairs that need to be matched when
|
||||
* editing code.
|
||||
* </p>
|
||||
*
|
||||
* @author kosyakov - Initial contribution and API
|
||||
*/
|
||||
@SuppressWarnings("all")
|
||||
public interface IBracePairProvider {
|
||||
/**
|
||||
* Returns a set of definitions for brace pairs that need to be matched when
|
||||
* editing code.
|
||||
*/
|
||||
Set<BracePair> getPairs();
|
||||
}
|
|
@ -1,31 +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.editor.navigation;
|
||||
|
||||
/**
|
||||
* Represents an instance that can be opened in an editor.
|
||||
*
|
||||
* @author kosyakov - Initial contribution and API
|
||||
* @since 2.10
|
||||
*/
|
||||
@SuppressWarnings("all")
|
||||
public interface INavigatable {
|
||||
/**
|
||||
* <p>
|
||||
* Returns an instance containing enough information to identify an editor that should be opened and a region that should be revealed.
|
||||
* </p>
|
||||
* <p>
|
||||
* Typical navigation elements are resource, object and reference descriptions as well as another navigatable element.
|
||||
* </p>
|
||||
* <p>
|
||||
* Avoid usage of resource sets, resources and eobjects as navigation elements, since it can lead to memory leaks.
|
||||
* </p>
|
||||
*/
|
||||
Object getNavigationElement();
|
||||
}
|
|
@ -1,23 +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;
|
||||
|
||||
import org.eclipse.lsp4j.InitializeParams;
|
||||
import org.eclipse.lsp4j.ServerCapabilities;
|
||||
|
||||
/**
|
||||
* @author Sven Efftinge - Initial contribution and API
|
||||
*/
|
||||
@SuppressWarnings("all")
|
||||
public interface ICapabilitiesContributor {
|
||||
/**
|
||||
* Allows an individual language to contribute to and overwrite properties in the server's capabilities.
|
||||
*/
|
||||
ServerCapabilities contribute(final ServerCapabilities capabilities, final InitializeParams params);
|
||||
}
|
|
@ -1,246 +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;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.function.Function;
|
||||
import org.eclipse.emf.common.util.URI;
|
||||
import org.eclipse.emf.ecore.resource.Resource;
|
||||
import org.eclipse.emf.ecore.resource.ResourceSet;
|
||||
import org.eclipse.lsp4j.InitializeParams;
|
||||
import org.eclipse.lsp4j.InitializeResult;
|
||||
import org.eclipse.lsp4j.services.LanguageClient;
|
||||
import org.eclipse.xtend.lib.annotations.Data;
|
||||
import org.eclipse.xtext.ide.serializer.IChangeSerializer;
|
||||
import org.eclipse.xtext.ide.server.Document;
|
||||
import org.eclipse.xtext.resource.IResourceDescription;
|
||||
import org.eclipse.xtext.resource.IResourceDescriptions;
|
||||
import org.eclipse.xtext.resource.impl.ResourceDescriptionsProvider;
|
||||
import org.eclipse.xtext.util.CancelIndicator;
|
||||
import org.eclipse.xtext.xbase.lib.Pure;
|
||||
import org.eclipse.xtext.xbase.lib.util.ToStringBuilder;
|
||||
|
||||
/**
|
||||
* API for interacting with a running language server.
|
||||
*
|
||||
* @author Sven Efftinge - Initial contribution and API
|
||||
*/
|
||||
@SuppressWarnings("all")
|
||||
public interface ILanguageServerAccess {
|
||||
@Data
|
||||
class Context {
|
||||
private final Resource resource;
|
||||
|
||||
private final Document document;
|
||||
|
||||
private final boolean isDocumentOpen;
|
||||
|
||||
private final CancelIndicator cancelChecker;
|
||||
|
||||
public Context(final Resource resource, final Document document, final boolean isDocumentOpen, final CancelIndicator cancelChecker) {
|
||||
super();
|
||||
this.resource = resource;
|
||||
this.document = document;
|
||||
this.isDocumentOpen = isDocumentOpen;
|
||||
this.cancelChecker = cancelChecker;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Pure
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((this.resource== null) ? 0 : this.resource.hashCode());
|
||||
result = prime * result + ((this.document== null) ? 0 : this.document.hashCode());
|
||||
result = prime * result + (this.isDocumentOpen ? 1231 : 1237);
|
||||
return prime * result + ((this.cancelChecker== null) ? 0 : this.cancelChecker.hashCode());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Pure
|
||||
public boolean equals(final Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
ILanguageServerAccess.Context other = (ILanguageServerAccess.Context) obj;
|
||||
if (this.resource == null) {
|
||||
if (other.resource != null)
|
||||
return false;
|
||||
} else if (!this.resource.equals(other.resource))
|
||||
return false;
|
||||
if (this.document == null) {
|
||||
if (other.document != null)
|
||||
return false;
|
||||
} else if (!this.document.equals(other.document))
|
||||
return false;
|
||||
if (other.isDocumentOpen != this.isDocumentOpen)
|
||||
return false;
|
||||
if (this.cancelChecker == null) {
|
||||
if (other.cancelChecker != null)
|
||||
return false;
|
||||
} else if (!this.cancelChecker.equals(other.cancelChecker))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Pure
|
||||
public String toString() {
|
||||
ToStringBuilder b = new ToStringBuilder(this);
|
||||
b.add("resource", this.resource);
|
||||
b.add("document", this.document);
|
||||
b.add("isDocumentOpen", this.isDocumentOpen);
|
||||
b.add("cancelChecker", this.cancelChecker);
|
||||
return b.toString();
|
||||
}
|
||||
|
||||
@Pure
|
||||
public Resource getResource() {
|
||||
return this.resource;
|
||||
}
|
||||
|
||||
@Pure
|
||||
public Document getDocument() {
|
||||
return this.document;
|
||||
}
|
||||
|
||||
@Pure
|
||||
public boolean isDocumentOpen() {
|
||||
return this.isDocumentOpen;
|
||||
}
|
||||
|
||||
@Pure
|
||||
public CancelIndicator getCancelChecker() {
|
||||
return this.cancelChecker;
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
class IndexContext {
|
||||
private final IResourceDescriptions index;
|
||||
|
||||
private final CancelIndicator cancelChecker;
|
||||
|
||||
public IndexContext(final IResourceDescriptions index, final CancelIndicator cancelChecker) {
|
||||
super();
|
||||
this.index = index;
|
||||
this.cancelChecker = cancelChecker;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Pure
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((this.index== null) ? 0 : this.index.hashCode());
|
||||
return prime * result + ((this.cancelChecker== null) ? 0 : this.cancelChecker.hashCode());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Pure
|
||||
public boolean equals(final Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
ILanguageServerAccess.IndexContext other = (ILanguageServerAccess.IndexContext) obj;
|
||||
if (this.index == null) {
|
||||
if (other.index != null)
|
||||
return false;
|
||||
} else if (!this.index.equals(other.index))
|
||||
return false;
|
||||
if (this.cancelChecker == null) {
|
||||
if (other.cancelChecker != null)
|
||||
return false;
|
||||
} else if (!this.cancelChecker.equals(other.cancelChecker))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Pure
|
||||
public String toString() {
|
||||
ToStringBuilder b = new ToStringBuilder(this);
|
||||
b.add("index", this.index);
|
||||
b.add("cancelChecker", this.cancelChecker);
|
||||
return b.toString();
|
||||
}
|
||||
|
||||
@Pure
|
||||
public IResourceDescriptions getIndex() {
|
||||
return this.index;
|
||||
}
|
||||
|
||||
@Pure
|
||||
public CancelIndicator getCancelChecker() {
|
||||
return this.cancelChecker;
|
||||
}
|
||||
}
|
||||
|
||||
interface IBuildListener {
|
||||
void afterBuild(final List<IResourceDescription.Delta> deltas);
|
||||
}
|
||||
|
||||
/**
|
||||
* provides read access to a fully resolved resource and Document.
|
||||
*/
|
||||
<T extends Object> CompletableFuture<T> doRead(final String uri, final Function<ILanguageServerAccess.Context, T> function);
|
||||
|
||||
/**
|
||||
* Provides read access to the Xtext index.
|
||||
*
|
||||
* @since 2.18
|
||||
*/
|
||||
<T extends Object> CompletableFuture<T> doReadIndex(final Function<? super ILanguageServerAccess.IndexContext, ? extends T> function);
|
||||
|
||||
/**
|
||||
* registers a build listener on the this language server
|
||||
*/
|
||||
void addBuildListener(final ILanguageServerAccess.IBuildListener listener);
|
||||
|
||||
/**
|
||||
* @return the language client facade. It usually also implements Endpoint, which can be used to
|
||||
* call non-standard extensions to the LSP.
|
||||
*/
|
||||
LanguageClient getLanguageClient();
|
||||
|
||||
/**
|
||||
* Creates a new {@link ResourceSet} to be used with the {@link IChangeSerializer} API.
|
||||
*
|
||||
* The {@link IChangeSerializer} allows to calculate text edits from model changes.
|
||||
* In order not to mess up the originals, the resp. models should be loaded into a
|
||||
* new resource set which this method provides.
|
||||
*
|
||||
* @param uri a file URI used to detect the project to configure the scope of the resource set.
|
||||
* @return a new empty resource set, configured with the project the <code>uri</code>
|
||||
* belongs to and the {@link ResourceDescriptionsProvider#LIVE_SCOPE} in order to
|
||||
* reflect model changes immediately.
|
||||
* @since 2.18
|
||||
*/
|
||||
ResourceSet newLiveScopeResourceSet(final URI uri);
|
||||
|
||||
/**
|
||||
* @return the parameters as negotiated during client and server on initialization.
|
||||
* @since 2.18
|
||||
*/
|
||||
InitializeParams getInitializeParams();
|
||||
|
||||
/**
|
||||
* Returns with the {@link InitializeResult} of the LS.
|
||||
*
|
||||
* @since 2.18
|
||||
*/
|
||||
InitializeResult getInitializeResult();
|
||||
}
|
|
@ -1,33 +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;
|
||||
|
||||
import org.eclipse.xtext.ide.server.ILanguageServerAccess;
|
||||
|
||||
/**
|
||||
* Interface for language specific extensions to the LSP.
|
||||
* Implementors should use {link JsonRpcNotification} and {link JsonRpcRequest} annotations.
|
||||
*
|
||||
* @author Sven Efftinge - Initial contribution and API
|
||||
*/
|
||||
@SuppressWarnings("all")
|
||||
public interface ILanguageServerExtension {
|
||||
/**
|
||||
* The same jsonrpc method might be supported by multiple languages and only the actual invocation
|
||||
* might reveal is a language wants to handle it, based on e.g. a uri in the parameter.
|
||||
*
|
||||
* To indicate that a request is not handled, this exception should be thrown by the service.
|
||||
*/
|
||||
static final RuntimeException NOT_HANDLED_EXCEPTION = new UnsupportedOperationException("not handled");
|
||||
|
||||
/**
|
||||
* the language server provides a access to language server documents, resources and build events.
|
||||
*/
|
||||
void initialize(final ILanguageServerAccess access);
|
||||
}
|
|
@ -1,42 +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;
|
||||
|
||||
import com.google.inject.AbstractModule;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import org.eclipse.lsp4j.services.LanguageServer;
|
||||
import org.eclipse.xtext.ide.ExecutorServiceProvider;
|
||||
import org.eclipse.xtext.ide.server.DefaultProjectDescriptionFactory;
|
||||
import org.eclipse.xtext.ide.server.IProjectDescriptionFactory;
|
||||
import org.eclipse.xtext.ide.server.IWorkspaceConfigFactory;
|
||||
import org.eclipse.xtext.ide.server.LanguageServerImpl;
|
||||
import org.eclipse.xtext.ide.server.MultiRootWorkspaceConfigFactory;
|
||||
import org.eclipse.xtext.ide.server.ProjectWorkspaceConfigFactory;
|
||||
import org.eclipse.xtext.resource.IContainer;
|
||||
import org.eclipse.xtext.resource.IResourceServiceProvider;
|
||||
import org.eclipse.xtext.resource.ResourceServiceProviderServiceLoader;
|
||||
import org.eclipse.xtext.resource.containers.ProjectDescriptionBasedContainerManager;
|
||||
|
||||
/**
|
||||
* @author Sven Efftinge - Initial contribution and API
|
||||
* @since 2.11
|
||||
*/
|
||||
@SuppressWarnings("all")
|
||||
public class ServerModule extends AbstractModule {
|
||||
@Override
|
||||
protected void configure() {
|
||||
this.binder().<ExecutorService>bind(ExecutorService.class).toProvider(ExecutorServiceProvider.class);
|
||||
this.<LanguageServer>bind(LanguageServer.class).to(LanguageServerImpl.class);
|
||||
this.<IResourceServiceProvider.Registry>bind(IResourceServiceProvider.Registry.class).toProvider(ResourceServiceProviderServiceLoader.class);
|
||||
this.<IWorkspaceConfigFactory>bind(IWorkspaceConfigFactory.class).to(ProjectWorkspaceConfigFactory.class);
|
||||
this.<ProjectWorkspaceConfigFactory>bind(ProjectWorkspaceConfigFactory.class).to(MultiRootWorkspaceConfigFactory.class);
|
||||
this.<IProjectDescriptionFactory>bind(IProjectDescriptionFactory.class).to(DefaultProjectDescriptionFactory.class);
|
||||
this.<IContainer.Manager>bind(IContainer.Manager.class).to(ProjectDescriptionBasedContainerManager.class);
|
||||
}
|
||||
}
|
|
@ -1,88 +0,0 @@
|
|||
/**
|
||||
* Copyright (c) 2017, 2020 TypeFox GmbH (http://www.typefox.io) and others.
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0.
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.eclipse.xtext.ide.server.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.xtend.lib.annotations.Accessors;
|
||||
import org.eclipse.xtext.ide.server.Document;
|
||||
import org.eclipse.xtext.ide.server.ILanguageServerAccess;
|
||||
import org.eclipse.xtext.resource.XtextResource;
|
||||
import org.eclipse.xtext.util.CancelIndicator;
|
||||
import org.eclipse.xtext.xbase.lib.Pure;
|
||||
|
||||
/**
|
||||
* @author Jan Koehnlein
|
||||
* @since 2.18
|
||||
*/
|
||||
@SuppressWarnings("all")
|
||||
public interface ICodeActionService2 {
|
||||
@Accessors
|
||||
class Options {
|
||||
private Document document;
|
||||
|
||||
private XtextResource resource;
|
||||
|
||||
private ILanguageServerAccess languageServerAccess;
|
||||
|
||||
private CodeActionParams codeActionParams;
|
||||
|
||||
private CancelIndicator cancelIndicator;
|
||||
|
||||
@Pure
|
||||
public Document getDocument() {
|
||||
return this.document;
|
||||
}
|
||||
|
||||
public void setDocument(final Document document) {
|
||||
this.document = document;
|
||||
}
|
||||
|
||||
@Pure
|
||||
public XtextResource getResource() {
|
||||
return this.resource;
|
||||
}
|
||||
|
||||
public void setResource(final XtextResource resource) {
|
||||
this.resource = resource;
|
||||
}
|
||||
|
||||
@Pure
|
||||
public ILanguageServerAccess getLanguageServerAccess() {
|
||||
return this.languageServerAccess;
|
||||
}
|
||||
|
||||
public void setLanguageServerAccess(final ILanguageServerAccess languageServerAccess) {
|
||||
this.languageServerAccess = languageServerAccess;
|
||||
}
|
||||
|
||||
@Pure
|
||||
public CodeActionParams getCodeActionParams() {
|
||||
return this.codeActionParams;
|
||||
}
|
||||
|
||||
public void setCodeActionParams(final CodeActionParams codeActionParams) {
|
||||
this.codeActionParams = codeActionParams;
|
||||
}
|
||||
|
||||
@Pure
|
||||
public CancelIndicator getCancelIndicator() {
|
||||
return this.cancelIndicator;
|
||||
}
|
||||
|
||||
public void setCancelIndicator(final CancelIndicator cancelIndicator) {
|
||||
this.cancelIndicator = cancelIndicator;
|
||||
}
|
||||
}
|
||||
|
||||
List<Either<Command, CodeAction>> getCodeActions(final ICodeActionService2.Options options);
|
||||
}
|
|
@ -1,66 +0,0 @@
|
|||
/**
|
||||
* Copyright (c) 2016, 2020 TypeFox GmbH (http://www.typefox.io) and others.
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0.
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.eclipse.xtext.ide.server.hover;
|
||||
|
||||
import org.eclipse.emf.ecore.EObject;
|
||||
import org.eclipse.xtend.lib.annotations.Accessors;
|
||||
import org.eclipse.xtend.lib.annotations.FinalFieldsConstructor;
|
||||
import org.eclipse.xtext.ide.server.Document;
|
||||
import org.eclipse.xtext.resource.XtextResource;
|
||||
import org.eclipse.xtext.util.ITextRegion;
|
||||
import org.eclipse.xtext.xbase.lib.Pure;
|
||||
|
||||
@Accessors
|
||||
@FinalFieldsConstructor
|
||||
@SuppressWarnings("all")
|
||||
public class HoverContext {
|
||||
private final Document document;
|
||||
|
||||
private final XtextResource resource;
|
||||
|
||||
private final int offset;
|
||||
|
||||
private final ITextRegion region;
|
||||
|
||||
private final EObject element;
|
||||
|
||||
public HoverContext(final Document document, final XtextResource resource, final int offset, final ITextRegion region, final EObject element) {
|
||||
super();
|
||||
this.document = document;
|
||||
this.resource = resource;
|
||||
this.offset = offset;
|
||||
this.region = region;
|
||||
this.element = element;
|
||||
}
|
||||
|
||||
@Pure
|
||||
public Document getDocument() {
|
||||
return this.document;
|
||||
}
|
||||
|
||||
@Pure
|
||||
public XtextResource getResource() {
|
||||
return this.resource;
|
||||
}
|
||||
|
||||
@Pure
|
||||
public int getOffset() {
|
||||
return this.offset;
|
||||
}
|
||||
|
||||
@Pure
|
||||
public ITextRegion getRegion() {
|
||||
return this.region;
|
||||
}
|
||||
|
||||
@Pure
|
||||
public EObject getElement() {
|
||||
return this.element;
|
||||
}
|
||||
}
|
|
@ -1,61 +0,0 @@
|
|||
/**
|
||||
* Copyright (c) 2018 TypeFox 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.semanticHighlight;
|
||||
|
||||
import com.google.inject.ImplementedBy;
|
||||
import com.google.inject.Singleton;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import org.eclipse.xtext.ide.editor.syntaxcoloring.IHighlightedPositionAcceptor;
|
||||
import org.eclipse.xtext.ide.editor.syntaxcoloring.ISemanticHighlightingCalculator;
|
||||
import org.eclipse.xtext.ide.editor.syntaxcoloring.LightweightPosition;
|
||||
import org.eclipse.xtext.ide.server.semanticHighlight.SemanticHighlightingRegistry;
|
||||
import org.eclipse.xtext.xbase.lib.CollectionLiterals;
|
||||
|
||||
/**
|
||||
* Service for mapping the IDs of the highlighting styles to a list of <a href="https://manual.macromates.com/en/language_grammars">TextMate scopes</a>.
|
||||
*
|
||||
* @see IHighlightedPositionAcceptor#addPosition
|
||||
* @see LightweightPosition#getIds
|
||||
*/
|
||||
@ImplementedBy(ISemanticHighlightingStyleToTokenMapper.Noop.class)
|
||||
@SuppressWarnings("all")
|
||||
public interface ISemanticHighlightingStyleToTokenMapper {
|
||||
/**
|
||||
* The shared, default NOOP implementation of the semantic style ID to TextMate token mapper.
|
||||
*/
|
||||
@Singleton
|
||||
final class Noop implements ISemanticHighlightingStyleToTokenMapper {
|
||||
@Override
|
||||
public List<String> toScopes(final String styleId) {
|
||||
return SemanticHighlightingRegistry.UNKNOWN_SCOPES;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getAllStyleIds() {
|
||||
return CollectionLiterals.<String>emptySet();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Maps the highlighting style ID to the corresponding TextMate scopes.
|
||||
*/
|
||||
List<String> toScopes(final String styleId);
|
||||
|
||||
/**
|
||||
* Returns with a set of distinct style identifiers that are used by the {@link IHighlightedPositionAcceptor} when calculating
|
||||
* the highlighted positions with the {@link ISemanticHighlightingCalculator}.
|
||||
*
|
||||
* <p>
|
||||
* Must not return with {@code null} but an empty set instead.
|
||||
*
|
||||
* @see IHighlightedPositionAcceptor#addPosition
|
||||
*/
|
||||
Set<String> getAllStyleIds();
|
||||
}
|
|
@ -1,64 +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.util;
|
||||
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.xtend.lib.annotations.FinalFieldsConstructor;
|
||||
import org.eclipse.xtext.util.CancelIndicator;
|
||||
|
||||
/**
|
||||
* @author kosyakov - Initial contribution and API
|
||||
* @since 2.11
|
||||
*/
|
||||
@FinalFieldsConstructor
|
||||
@SuppressWarnings("all")
|
||||
public class CancelIndicatorProgressMonitor implements IProgressMonitor {
|
||||
private final CancelIndicator delegate;
|
||||
|
||||
private boolean canceled;
|
||||
|
||||
@Override
|
||||
public boolean isCanceled() {
|
||||
return (this.canceled || this.delegate.isCanceled());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCanceled(final boolean value) {
|
||||
this.canceled = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beginTask(final String name, final int totalWork) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTaskName(final String name) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void subTask(final String name) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void internalWorked(final double work) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void worked(final int work) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void done() {
|
||||
}
|
||||
|
||||
public CancelIndicatorProgressMonitor(final CancelIndicator delegate) {
|
||||
super();
|
||||
this.delegate = delegate;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue