mirror of
https://github.com/sigmasternchen/xtext-core
synced 2025-03-15 08:18:55 +00:00
Merge pull request #1436 from eclipse/cd_evenMoreXtend2Java
[eclipse/xtext#1679] ported code from xtend to java
This commit is contained in:
commit
9158b09e19
27 changed files with 253 additions and 692 deletions
|
@ -1,25 +1,23 @@
|
|||
/*******************************************************************************
|
||||
* 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.contentassist
|
||||
|
||||
import org.eclipse.xtext.ide.editor.contentassist.ContentAssistEntry
|
||||
package org.eclipse.xtext.ide.editor.contentassist;
|
||||
|
||||
/**
|
||||
* @noreference
|
||||
*/
|
||||
interface IIdeContentProposalAcceptor {
|
||||
public interface IIdeContentProposalAcceptor {
|
||||
|
||||
/**
|
||||
* Handle the given content assist entry. The entry may be {@code null}.
|
||||
*/
|
||||
def void accept(ContentAssistEntry entry, int priority)
|
||||
void accept(ContentAssistEntry entry, int priority);
|
||||
|
||||
def boolean canAcceptMoreProposals()
|
||||
boolean canAcceptMoreProposals();
|
||||
|
||||
}
|
|
@ -1,36 +1,37 @@
|
|||
/*******************************************************************************
|
||||
* 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.contentassist
|
||||
package org.eclipse.xtext.ide.editor.contentassist;
|
||||
|
||||
import com.google.inject.ImplementedBy
|
||||
import com.google.inject.ImplementedBy;
|
||||
|
||||
/**
|
||||
* Prefix matchers are used to reject content assist proposals that do not match the prefix at
|
||||
* the current cursor position.
|
||||
/**
|
||||
* Prefix matchers are used to reject content assist proposals that do not match the prefix at the current cursor
|
||||
* position.
|
||||
*
|
||||
* @since 2.10
|
||||
* @noreference
|
||||
*/
|
||||
@ImplementedBy(IPrefixMatcher.IgnoreCase)
|
||||
interface IPrefixMatcher {
|
||||
|
||||
def boolean isCandidateMatchingPrefix(String name, String prefix)
|
||||
|
||||
/**
|
||||
@ImplementedBy(IPrefixMatcher.IgnoreCase.class)
|
||||
public interface IPrefixMatcher {
|
||||
|
||||
boolean isCandidateMatchingPrefix(String name, String prefix);
|
||||
|
||||
/**
|
||||
* Default prefix matcher that compares the prefix of the candidate ignoring case.
|
||||
*/
|
||||
static class IgnoreCase implements IPrefixMatcher {
|
||||
|
||||
override boolean isCandidateMatchingPrefix(String name, String prefix) {
|
||||
return name.regionMatches(true, 0, prefix, 0, prefix.length)
|
||||
|
||||
@Override
|
||||
public boolean isCandidateMatchingPrefix(String name, String prefix) {
|
||||
return name.regionMatches(true, 0, prefix, 0, prefix.length());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -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.hierarchy
|
||||
package org.eclipse.xtext.ide.editor.hierarchy;
|
||||
|
||||
/**
|
||||
* It is used to build a call hierarchy structure.
|
||||
|
@ -14,15 +14,13 @@ package org.eclipse.xtext.ide.editor.hierarchy
|
|||
* @author kosyakov - Initial contribution and API
|
||||
* @since 2.10
|
||||
*/
|
||||
interface ICallHierarchyBuilder extends IHierarchyBuilder {
|
||||
public interface ICallHierarchyBuilder extends IHierarchyBuilder {
|
||||
|
||||
static enum CallHierarchyType {
|
||||
CALLER,
|
||||
CALLEE
|
||||
enum CallHierarchyType {
|
||||
CALLER, CALLEE;
|
||||
}
|
||||
|
||||
def CallHierarchyType getHierarchyType();
|
||||
|
||||
def void setHierarchyType(CallHierarchyType hierarchyType);
|
||||
ICallHierarchyBuilder.CallHierarchyType getHierarchyType();
|
||||
|
||||
void setHierarchyType(ICallHierarchyBuilder.CallHierarchyType hierarchyType);
|
||||
}
|
|
@ -1,16 +1,16 @@
|
|||
/*******************************************************************************
|
||||
* 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.hierarchy
|
||||
package org.eclipse.xtext.ide.editor.hierarchy;
|
||||
|
||||
import java.util.Collection
|
||||
import org.eclipse.core.runtime.IProgressMonitor
|
||||
import org.eclipse.emf.common.util.URI
|
||||
import java.util.Collection;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.emf.common.util.URI;
|
||||
|
||||
/**
|
||||
* This class is used to build a hierarchy structure.
|
||||
|
@ -18,16 +18,16 @@ import org.eclipse.emf.common.util.URI
|
|||
* @author kosyakov - Initial contribution and API
|
||||
* @since 2.10
|
||||
*/
|
||||
interface IHierarchyBuilder {
|
||||
public interface IHierarchyBuilder {
|
||||
|
||||
/**
|
||||
* @return root hierarchy nodes for the given URI; empty if the hierarchy cannot be built for the given URI
|
||||
*/
|
||||
def Collection<IHierarchyNode> buildRoots(URI rootURI, IProgressMonitor monitor)
|
||||
Collection<IHierarchyNode> buildRoots(URI rootURI, IProgressMonitor monitor);
|
||||
|
||||
/**
|
||||
* @return child nodes for the given parent node; empty if {@link IHierarchyNode#mayHaveChildren} returns <code>false</code> for the parent
|
||||
*/
|
||||
def Collection<IHierarchyNode> buildChildren(IHierarchyNode parent, IProgressMonitor monitor)
|
||||
Collection<IHierarchyNode> buildChildren(IHierarchyNode parent, IProgressMonitor monitor);
|
||||
|
||||
}
|
|
@ -1,47 +1,47 @@
|
|||
/*******************************************************************************
|
||||
* 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.hierarchy
|
||||
package org.eclipse.xtext.ide.editor.hierarchy;
|
||||
|
||||
import java.util.Collection
|
||||
import org.eclipse.xtext.ide.editor.navigation.INavigatable
|
||||
import org.eclipse.xtext.resource.IEObjectDescription
|
||||
import java.util.Collection;
|
||||
|
||||
import org.eclipse.xtext.ide.editor.navigation.INavigatable;
|
||||
import org.eclipse.xtext.resource.IEObjectDescription;
|
||||
|
||||
/**
|
||||
* Represents a hierarchy node.
|
||||
* Represents a hierarchy node.
|
||||
*
|
||||
* @author kosyakov - Initial contribution and API
|
||||
* @since 2.10
|
||||
*/
|
||||
interface IHierarchyNode extends INavigatable {
|
||||
|
||||
public interface IHierarchyNode extends INavigatable {
|
||||
/**
|
||||
* @return an associated element that is used to build child nodes
|
||||
*/
|
||||
def IEObjectDescription getElement()
|
||||
IEObjectDescription getElement();
|
||||
|
||||
/**
|
||||
* @return a parent; <code>null</code> if the node is a root
|
||||
*/
|
||||
def IHierarchyNode getParent()
|
||||
IHierarchyNode getParent();
|
||||
|
||||
/**
|
||||
* @return references used to reach the node from a parent; empty if the node is a root
|
||||
* @return references used to reach the node from a parent; empty if the node is a root
|
||||
*/
|
||||
def Collection<IHierarchyNodeReference> getReferences()
|
||||
Collection<IHierarchyNodeReference> getReferences();
|
||||
|
||||
/**
|
||||
* @return whether there is a parent (can be transitive) containing the same element as the node
|
||||
*/
|
||||
def boolean isRecursive()
|
||||
boolean isRecursive();
|
||||
|
||||
/**
|
||||
* @return whether the node may have children; e.g. a recursive node cannot have children
|
||||
* @return whether the node may have children; e.g. a recursive node cannot have children
|
||||
*/
|
||||
def boolean mayHaveChildren()
|
||||
boolean mayHaveChildren();
|
||||
}
|
|
@ -1,17 +1,16 @@
|
|||
/**
|
||||
* 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.hierarchy;
|
||||
|
||||
import com.google.inject.ImplementedBy;
|
||||
import org.eclipse.emf.ecore.EObject;
|
||||
import org.eclipse.emf.ecore.EStructuralFeature;
|
||||
import org.eclipse.xtext.ide.editor.hierarchy.DefaultHierarchyNodeLocationProvider;
|
||||
import org.eclipse.xtext.util.ITextRegionWithLineInformation;
|
||||
|
||||
/**
|
||||
|
@ -21,9 +20,8 @@ import org.eclipse.xtext.util.ITextRegionWithLineInformation;
|
|||
* @since 2.10
|
||||
*/
|
||||
@ImplementedBy(DefaultHierarchyNodeLocationProvider.class)
|
||||
@SuppressWarnings("all")
|
||||
public interface IHierarchyNodeLocationProvider {
|
||||
ITextRegionWithLineInformation getTextRegion(final EObject obj);
|
||||
|
||||
ITextRegionWithLineInformation getTextRegion(final EObject owner, final EStructuralFeature feature, final int indexInList);
|
||||
ITextRegionWithLineInformation getTextRegion(EObject obj);
|
||||
|
||||
ITextRegionWithLineInformation getTextRegion(EObject owner, EStructuralFeature feature, int indexInList);
|
||||
}
|
|
@ -1,27 +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.hierarchy
|
||||
|
||||
import com.google.inject.ImplementedBy
|
||||
import org.eclipse.emf.ecore.EObject
|
||||
import org.eclipse.emf.ecore.EStructuralFeature
|
||||
import org.eclipse.xtext.util.ITextRegionWithLineInformation
|
||||
|
||||
/**
|
||||
* This class is used to identify a region for {@link IHierarchyNode} and {@link IHierarchyNodeReference}.
|
||||
*
|
||||
* @author kosyakov - Initial contribution and API
|
||||
* @since 2.10
|
||||
*/
|
||||
@ImplementedBy(DefaultHierarchyNodeLocationProvider)
|
||||
interface IHierarchyNodeLocationProvider {
|
||||
def ITextRegionWithLineInformation getTextRegion(EObject obj)
|
||||
|
||||
def ITextRegionWithLineInformation getTextRegion(EObject owner, EStructuralFeature feature, int indexInList)
|
||||
}
|
|
@ -1,23 +1,22 @@
|
|||
/**
|
||||
* 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.hierarchy;
|
||||
|
||||
import org.eclipse.xtext.ide.editor.navigation.INavigatable;
|
||||
import org.eclipse.xtext.util.ITextRegionWithLineInformation;
|
||||
|
||||
/**
|
||||
* Represents a reference between parent and child nodes. Each reference is backed up with a region and a text.
|
||||
* Represents a reference between parent and child nodes. Each reference is backed up with a region and a text.
|
||||
*
|
||||
* @author kosyakov - Initial contribution and API
|
||||
* @since 2.10
|
||||
*/
|
||||
@SuppressWarnings("all")
|
||||
public interface IHierarchyNodeReference extends INavigatable, ITextRegionWithLineInformation {
|
||||
String getText();
|
||||
String getText();
|
||||
}
|
|
@ -1,22 +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.hierarchy
|
||||
|
||||
import org.eclipse.xtext.ide.editor.navigation.INavigatable
|
||||
import org.eclipse.xtext.util.ITextRegionWithLineInformation
|
||||
|
||||
/**
|
||||
* Represents a reference between parent and child nodes. Each reference is backed up with a region and a text.
|
||||
*
|
||||
* @author kosyakov - Initial contribution and API
|
||||
* @since 2.10
|
||||
*/
|
||||
interface IHierarchyNodeReference extends INavigatable, ITextRegionWithLineInformation {
|
||||
def String getText()
|
||||
}
|
|
@ -1,14 +1,15 @@
|
|||
/*******************************************************************************
|
||||
* 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.hierarchy
|
||||
package org.eclipse.xtext.ide.editor.hierarchy;
|
||||
|
||||
import java.util.Collection
|
||||
import java.util.Collection;
|
||||
import static java.util.Collections.*;
|
||||
|
||||
/**
|
||||
* Represents a hierarchy root.
|
||||
|
@ -16,16 +17,13 @@ import java.util.Collection
|
|||
* @author kosyakov - Initial contribution and API
|
||||
* @since 2.10
|
||||
*/
|
||||
interface IHierarchyRoot {
|
||||
public interface IHierarchyRoot {
|
||||
Collection<IHierarchyNode> getRoots();
|
||||
|
||||
def Collection<IHierarchyNode> getRoots()
|
||||
|
||||
val EMPTY = new IHierarchyRoot() {
|
||||
|
||||
override getRoots() {
|
||||
emptyList
|
||||
static final IHierarchyRoot EMPTY = new IHierarchyRoot() {
|
||||
@Override
|
||||
public Collection<IHierarchyNode> getRoots() {
|
||||
return emptyList();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
/**
|
||||
* Copyright (c) 2014, 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.model;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.name.Named;
|
||||
import java.util.Map;
|
||||
import org.antlr.runtime.Token;
|
||||
import org.eclipse.xtext.ide.LexerIdeBindings;
|
||||
import org.eclipse.xtext.ide.editor.syntaxcoloring.HighlightingStyles;
|
||||
import org.eclipse.xtext.parser.antlr.ITokenDefProvider;
|
||||
|
||||
/**
|
||||
* @author Anton Kosyakov
|
||||
*
|
||||
* @since 2.9
|
||||
*/
|
||||
public abstract class TokenTypeToStringMapper {
|
||||
|
||||
private String[] mappedValues;
|
||||
|
||||
@Inject
|
||||
public void setTokenDefProvider(@Named(LexerIdeBindings.HIGHLIGHTING) ITokenDefProvider tokenDefProvider) {
|
||||
initIds(tokenDefProvider.getTokenDefMap());
|
||||
}
|
||||
|
||||
protected void initIds(Map<Integer, String> tokenDefMap) {
|
||||
mappedValues = new String[tokenDefMap.size()];
|
||||
for (Map.Entry<Integer, String> entry : tokenDefMap.entrySet()) {
|
||||
if (entry.getKey() >= Token.MIN_TOKEN_TYPE) {
|
||||
mappedValues[entry.getKey() - Token.MIN_TOKEN_TYPE] = calculateId(entry.getValue(), entry.getKey());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract String calculateId(String tokenName, int tokenType);
|
||||
|
||||
protected String getMappedValue(int tokenType) {
|
||||
if (tokenType == Token.INVALID_TOKEN_TYPE) {
|
||||
return HighlightingStyles.INVALID_TOKEN_ID;
|
||||
} else {
|
||||
return mappedValues[tokenType - Token.MIN_TOKEN_TYPE];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,52 +0,0 @@
|
|||
/**
|
||||
* Copyright (c) 2014 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.model
|
||||
|
||||
import com.google.inject.Inject
|
||||
import com.google.inject.name.Named
|
||||
import java.util.Map
|
||||
import org.antlr.runtime.Token
|
||||
import org.eclipse.xtext.ide.LexerIdeBindings
|
||||
import org.eclipse.xtext.ide.editor.syntaxcoloring.HighlightingStyles
|
||||
import org.eclipse.xtext.parser.antlr.ITokenDefProvider
|
||||
|
||||
/**
|
||||
* @author Anton Kosyakov
|
||||
*
|
||||
* @since 2.9
|
||||
*/
|
||||
abstract class TokenTypeToStringMapper {
|
||||
|
||||
String[] mappedValues
|
||||
|
||||
@Inject
|
||||
def void setTokenDefProvider(@Named(LexerIdeBindings.HIGHLIGHTING) ITokenDefProvider tokenDefProvider) {
|
||||
initIds(tokenDefProvider.tokenDefMap)
|
||||
}
|
||||
|
||||
def protected void initIds(Map<Integer, String> tokenDefMap) {
|
||||
mappedValues = newArrayOfSize(tokenDefMap.size)
|
||||
for (entry : tokenDefMap.entrySet) {
|
||||
if (entry.key >= Token.MIN_TOKEN_TYPE) {
|
||||
mappedValues.set(entry.key - Token.MIN_TOKEN_TYPE, calculateId(entry.value, entry.key))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def protected abstract String calculateId(String tokenName, int tokenType)
|
||||
|
||||
def protected String getMappedValue(int tokenType) {
|
||||
if (tokenType == Token.INVALID_TOKEN_TYPE) {
|
||||
HighlightingStyles.INVALID_TOKEN_ID
|
||||
} else {
|
||||
mappedValues.get(tokenType - Token.MIN_TOKEN_TYPE)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,26 +1,26 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2014 itemis AG (http://www.itemis.eu) and others.
|
||||
* Copyright (c) 2014, 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.syntaxcoloring
|
||||
package org.eclipse.xtext.ide.editor.syntaxcoloring;
|
||||
|
||||
/**
|
||||
* @author Anton Kosyakov - Initial contribution and API
|
||||
* @since 2.9
|
||||
*/
|
||||
interface HighlightingStyles {
|
||||
public interface HighlightingStyles {
|
||||
|
||||
val KEYWORD_ID = "keyword"
|
||||
val PUNCTUATION_ID = "punctuation"
|
||||
val COMMENT_ID = "comment"
|
||||
val STRING_ID = "string"
|
||||
val NUMBER_ID = "number"
|
||||
val DEFAULT_ID = "default"
|
||||
val INVALID_TOKEN_ID = "error"
|
||||
val TASK_ID = "task"
|
||||
String KEYWORD_ID = "keyword";
|
||||
String PUNCTUATION_ID = "punctuation";
|
||||
String COMMENT_ID = "comment";
|
||||
String STRING_ID = "string";
|
||||
String NUMBER_ID = "number";
|
||||
String DEFAULT_ID = "default";
|
||||
String INVALID_TOKEN_ID = "error";
|
||||
String TASK_ID = "task";
|
||||
|
||||
}
|
|
@ -0,0 +1,57 @@
|
|||
/*******************************************************************************
|
||||
* 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.symbol;
|
||||
|
||||
import static java.util.Collections.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.lsp4j.DocumentSymbol;
|
||||
import org.eclipse.lsp4j.DocumentSymbolParams;
|
||||
import org.eclipse.lsp4j.SymbolInformation;
|
||||
import org.eclipse.lsp4j.jsonrpc.messages.Either;
|
||||
import org.eclipse.xtext.ide.server.Document;
|
||||
import org.eclipse.xtext.ide.server.symbol.IDocumentSymbolService.Noop;
|
||||
import org.eclipse.xtext.resource.XtextResource;
|
||||
import org.eclipse.xtext.util.CancelIndicator;
|
||||
|
||||
import com.google.common.annotations.Beta;
|
||||
import com.google.inject.ImplementedBy;
|
||||
|
||||
/**
|
||||
* Common service interface for providing document symbol information for text documents.
|
||||
*
|
||||
* <p>
|
||||
* For more details, see the <a href=
|
||||
* "https://microsoft.github.io/language-server-protocol/specification#textDocument_documentSymbol">{@code textDocument/documentSymbol}</a>
|
||||
* LSP method.
|
||||
*
|
||||
* <p>
|
||||
* This interface is not meant to be injected. Use the {@link DocumentSymbolService} and the
|
||||
* {@link HierarchicalDocumentSymbolService} directly instead.
|
||||
*/
|
||||
@Beta
|
||||
@ImplementedBy(Noop.class)
|
||||
public interface IDocumentSymbolService {
|
||||
|
||||
List<Either<SymbolInformation, DocumentSymbol>> getSymbols(Document document, XtextResource resource,
|
||||
DocumentSymbolParams params, CancelIndicator cancelIndicator);
|
||||
|
||||
public static class Noop implements IDocumentSymbolService {
|
||||
|
||||
@Override
|
||||
public List<Either<SymbolInformation, DocumentSymbol>> getSymbols(Document document, XtextResource resource,
|
||||
DocumentSymbolParams params, CancelIndicator cancelIndicator) {
|
||||
|
||||
return emptyList();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -1,48 +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.symbol
|
||||
|
||||
import com.google.common.annotations.Beta
|
||||
import com.google.inject.ImplementedBy
|
||||
import java.util.List
|
||||
import org.eclipse.lsp4j.DocumentSymbol
|
||||
import org.eclipse.lsp4j.DocumentSymbolParams
|
||||
import org.eclipse.lsp4j.SymbolInformation
|
||||
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
|
||||
|
||||
/**
|
||||
* Common service interface for providing document symbol information for text documents.
|
||||
*
|
||||
* <p>
|
||||
* For more details, see the <a href="https://microsoft.github.io/language-server-protocol/specification#textDocument_documentSymbol">{@code textDocument/documentSymbol}</a> LSP method.
|
||||
*
|
||||
* <p>
|
||||
* This interface is not meant to be injected. Use the {@link DocumentSymbolService} and the {@link HierarchicalDocumentSymbolService} directly instead.
|
||||
*/
|
||||
@Beta
|
||||
@ImplementedBy(Noop)
|
||||
interface IDocumentSymbolService {
|
||||
|
||||
def List<Either<SymbolInformation, DocumentSymbol>> getSymbols(Document document, XtextResource resource,
|
||||
DocumentSymbolParams params, CancelIndicator cancelIndicator);
|
||||
|
||||
static class Noop implements IDocumentSymbolService {
|
||||
|
||||
override getSymbols(Document document, XtextResource resource, DocumentSymbolParams params,
|
||||
CancelIndicator cancelIndicator) {
|
||||
|
||||
return emptyList;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,57 @@
|
|||
/*******************************************************************************
|
||||
* 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.symbol;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import org.eclipse.lsp4j.SymbolInformation;
|
||||
import org.eclipse.xtext.findReferences.IReferenceFinder.IResourceAccess;
|
||||
import org.eclipse.xtext.resource.IResourceDescription;
|
||||
import org.eclipse.xtext.resource.IResourceDescriptions;
|
||||
import org.eclipse.xtext.resource.IResourceServiceProvider;
|
||||
import org.eclipse.xtext.service.OperationCanceledManager;
|
||||
import org.eclipse.xtext.util.CancelIndicator;
|
||||
|
||||
/**
|
||||
* @author kosyakov - Initial contribution and API
|
||||
* @since 2.11
|
||||
*/
|
||||
@Singleton
|
||||
public class WorkspaceSymbolService {
|
||||
|
||||
@Inject
|
||||
private IResourceServiceProvider.Registry registry;
|
||||
|
||||
@Inject
|
||||
private OperationCanceledManager operationCanceledManager;
|
||||
|
||||
public List<? extends SymbolInformation> getSymbols(
|
||||
String query,
|
||||
IResourceAccess resourceAccess,
|
||||
IResourceDescriptions indexData,
|
||||
CancelIndicator cancelIndicator
|
||||
) {
|
||||
List<SymbolInformation> result = new LinkedList<>();
|
||||
for (IResourceDescription resourceDescription : indexData.getAllResourceDescriptions()) {
|
||||
operationCanceledManager.checkCanceled(cancelIndicator);
|
||||
IResourceServiceProvider resourceServiceProvider = registry.getResourceServiceProvider(resourceDescription.getURI());
|
||||
if (resourceServiceProvider != null) {
|
||||
DocumentSymbolService documentSymbolService = resourceServiceProvider.get(DocumentSymbolService.class);
|
||||
if (documentSymbolService != null) {
|
||||
result.addAll(documentSymbolService.getSymbols(resourceDescription, query, resourceAccess, cancelIndicator));
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
|
@ -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.server.symbol
|
||||
|
||||
import com.google.inject.Inject
|
||||
import com.google.inject.Singleton
|
||||
import java.util.List
|
||||
import org.eclipse.lsp4j.SymbolInformation
|
||||
import org.eclipse.xtext.findReferences.IReferenceFinder.IResourceAccess
|
||||
import org.eclipse.xtext.resource.IResourceDescriptions
|
||||
import org.eclipse.xtext.resource.IResourceServiceProvider
|
||||
import org.eclipse.xtext.service.OperationCanceledManager
|
||||
import org.eclipse.xtext.util.CancelIndicator
|
||||
|
||||
/**
|
||||
* @author kosyakov - Initial contribution and API
|
||||
* @since 2.11
|
||||
*/
|
||||
@Singleton
|
||||
class WorkspaceSymbolService {
|
||||
|
||||
@Inject
|
||||
extension IResourceServiceProvider.Registry
|
||||
|
||||
@Inject
|
||||
OperationCanceledManager operationCanceledManager
|
||||
|
||||
def List<? extends SymbolInformation> getSymbols(
|
||||
String query,
|
||||
IResourceAccess resourceAccess,
|
||||
IResourceDescriptions indexData,
|
||||
CancelIndicator cancelIndicator
|
||||
) {
|
||||
val result = newLinkedList
|
||||
for (resourceDescription : indexData.allResourceDescriptions) {
|
||||
operationCanceledManager.checkCanceled(cancelIndicator)
|
||||
val resourceServiceProvider = resourceDescription.URI.resourceServiceProvider
|
||||
val documentSymbolService = resourceServiceProvider?.get(DocumentSymbolService)
|
||||
if (documentSymbolService !== null) {
|
||||
result += documentSymbolService.getSymbols(resourceDescription, query, resourceAccess, cancelIndicator)
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
}
|
|
@ -1,24 +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.contentassist;
|
||||
|
||||
import org.eclipse.xtext.ide.editor.contentassist.ContentAssistEntry;
|
||||
|
||||
/**
|
||||
* @noreference
|
||||
*/
|
||||
@SuppressWarnings("all")
|
||||
public interface IIdeContentProposalAcceptor {
|
||||
/**
|
||||
* Handle the given content assist entry. The entry may be {@code null}.
|
||||
*/
|
||||
void accept(final ContentAssistEntry entry, final int priority);
|
||||
|
||||
boolean canAcceptMoreProposals();
|
||||
}
|
|
@ -1,34 +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.contentassist;
|
||||
|
||||
import com.google.inject.ImplementedBy;
|
||||
|
||||
/**
|
||||
* Prefix matchers are used to reject content assist proposals that do not match the prefix at
|
||||
* the current cursor position.
|
||||
*
|
||||
* @since 2.10
|
||||
* @noreference
|
||||
*/
|
||||
@ImplementedBy(IPrefixMatcher.IgnoreCase.class)
|
||||
@SuppressWarnings("all")
|
||||
public interface IPrefixMatcher {
|
||||
/**
|
||||
* Default prefix matcher that compares the prefix of the candidate ignoring case.
|
||||
*/
|
||||
class IgnoreCase implements IPrefixMatcher {
|
||||
@Override
|
||||
public boolean isCandidateMatchingPrefix(final String name, final String prefix) {
|
||||
return name.regionMatches(true, 0, prefix, 0, prefix.length());
|
||||
}
|
||||
}
|
||||
|
||||
boolean isCandidateMatchingPrefix(final String name, final String prefix);
|
||||
}
|
|
@ -1,30 +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.hierarchy;
|
||||
|
||||
import org.eclipse.xtext.ide.editor.hierarchy.IHierarchyBuilder;
|
||||
|
||||
/**
|
||||
* It is used to build a call hierarchy structure.
|
||||
*
|
||||
* @author kosyakov - Initial contribution and API
|
||||
* @since 2.10
|
||||
*/
|
||||
@SuppressWarnings("all")
|
||||
public interface ICallHierarchyBuilder extends IHierarchyBuilder {
|
||||
enum CallHierarchyType {
|
||||
CALLER,
|
||||
|
||||
CALLEE;
|
||||
}
|
||||
|
||||
ICallHierarchyBuilder.CallHierarchyType getHierarchyType();
|
||||
|
||||
void setHierarchyType(final ICallHierarchyBuilder.CallHierarchyType hierarchyType);
|
||||
}
|
|
@ -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.editor.hierarchy;
|
||||
|
||||
import java.util.Collection;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.emf.common.util.URI;
|
||||
import org.eclipse.xtext.ide.editor.hierarchy.IHierarchyNode;
|
||||
|
||||
/**
|
||||
* This class is used to build a hierarchy structure.
|
||||
*
|
||||
* @author kosyakov - Initial contribution and API
|
||||
* @since 2.10
|
||||
*/
|
||||
@SuppressWarnings("all")
|
||||
public interface IHierarchyBuilder {
|
||||
/**
|
||||
* @return root hierarchy nodes for the given URI; empty if the hierarchy cannot be built for the given URI
|
||||
*/
|
||||
Collection<IHierarchyNode> buildRoots(final URI rootURI, final IProgressMonitor monitor);
|
||||
|
||||
/**
|
||||
* @return child nodes for the given parent node; empty if {@link IHierarchyNode#mayHaveChildren} returns <code>false</code> for the parent
|
||||
*/
|
||||
Collection<IHierarchyNode> buildChildren(final IHierarchyNode parent, final IProgressMonitor monitor);
|
||||
}
|
|
@ -1,48 +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.hierarchy;
|
||||
|
||||
import java.util.Collection;
|
||||
import org.eclipse.xtext.ide.editor.hierarchy.IHierarchyNodeReference;
|
||||
import org.eclipse.xtext.ide.editor.navigation.INavigatable;
|
||||
import org.eclipse.xtext.resource.IEObjectDescription;
|
||||
|
||||
/**
|
||||
* Represents a hierarchy node.
|
||||
*
|
||||
* @author kosyakov - Initial contribution and API
|
||||
* @since 2.10
|
||||
*/
|
||||
@SuppressWarnings("all")
|
||||
public interface IHierarchyNode extends INavigatable {
|
||||
/**
|
||||
* @return an associated element that is used to build child nodes
|
||||
*/
|
||||
IEObjectDescription getElement();
|
||||
|
||||
/**
|
||||
* @return a parent; <code>null</code> if the node is a root
|
||||
*/
|
||||
IHierarchyNode getParent();
|
||||
|
||||
/**
|
||||
* @return references used to reach the node from a parent; empty if the node is a root
|
||||
*/
|
||||
Collection<IHierarchyNodeReference> getReferences();
|
||||
|
||||
/**
|
||||
* @return whether there is a parent (can be transitive) containing the same element as the node
|
||||
*/
|
||||
boolean isRecursive();
|
||||
|
||||
/**
|
||||
* @return whether the node may have children; e.g. a recursive node cannot have children
|
||||
*/
|
||||
boolean mayHaveChildren();
|
||||
}
|
|
@ -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.hierarchy;
|
||||
|
||||
import java.util.Collection;
|
||||
import org.eclipse.xtext.ide.editor.hierarchy.IHierarchyNode;
|
||||
import org.eclipse.xtext.xbase.lib.CollectionLiterals;
|
||||
|
||||
/**
|
||||
* Represents a hierarchy root.
|
||||
*
|
||||
* @author kosyakov - Initial contribution and API
|
||||
* @since 2.10
|
||||
*/
|
||||
@SuppressWarnings("all")
|
||||
public interface IHierarchyRoot {
|
||||
Collection<IHierarchyNode> getRoots();
|
||||
|
||||
static final IHierarchyRoot EMPTY = new IHierarchyRoot() {
|
||||
@Override
|
||||
public Collection<IHierarchyNode> getRoots() {
|
||||
return CollectionLiterals.<IHierarchyNode>emptyList();
|
||||
}
|
||||
};
|
||||
}
|
|
@ -1,59 +0,0 @@
|
|||
/**
|
||||
* Copyright (c) 2014 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.model;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.name.Named;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import org.antlr.runtime.Token;
|
||||
import org.eclipse.xtext.ide.LexerIdeBindings;
|
||||
import org.eclipse.xtext.ide.editor.syntaxcoloring.HighlightingStyles;
|
||||
import org.eclipse.xtext.parser.antlr.ITokenDefProvider;
|
||||
|
||||
/**
|
||||
* @author Anton Kosyakov
|
||||
*
|
||||
* @since 2.9
|
||||
*/
|
||||
@SuppressWarnings("all")
|
||||
public abstract class TokenTypeToStringMapper {
|
||||
private String[] mappedValues;
|
||||
|
||||
@Inject
|
||||
public void setTokenDefProvider(@Named(LexerIdeBindings.HIGHLIGHTING) final ITokenDefProvider tokenDefProvider) {
|
||||
this.initIds(tokenDefProvider.getTokenDefMap());
|
||||
}
|
||||
|
||||
protected void initIds(final Map<Integer, String> tokenDefMap) {
|
||||
this.mappedValues = new String[tokenDefMap.size()];
|
||||
Set<Map.Entry<Integer, String>> _entrySet = tokenDefMap.entrySet();
|
||||
for (final Map.Entry<Integer, String> entry : _entrySet) {
|
||||
Integer _key = entry.getKey();
|
||||
boolean _greaterEqualsThan = ((_key).intValue() >= Token.MIN_TOKEN_TYPE);
|
||||
if (_greaterEqualsThan) {
|
||||
Integer _key_1 = entry.getKey();
|
||||
int _minus = ((_key_1).intValue() - Token.MIN_TOKEN_TYPE);
|
||||
this.mappedValues[_minus] = this.calculateId(entry.getValue(), (entry.getKey()).intValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract String calculateId(final String tokenName, final int tokenType);
|
||||
|
||||
protected String getMappedValue(final int tokenType) {
|
||||
String _xifexpression = null;
|
||||
if ((tokenType == Token.INVALID_TOKEN_TYPE)) {
|
||||
_xifexpression = HighlightingStyles.INVALID_TOKEN_ID;
|
||||
} else {
|
||||
_xifexpression = this.mappedValues[(tokenType - Token.MIN_TOKEN_TYPE)];
|
||||
}
|
||||
return _xifexpression;
|
||||
}
|
||||
}
|
|
@ -1,32 +0,0 @@
|
|||
/**
|
||||
* Copyright (c) 2014 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.syntaxcoloring;
|
||||
|
||||
/**
|
||||
* @author Anton Kosyakov - Initial contribution and API
|
||||
* @since 2.9
|
||||
*/
|
||||
@SuppressWarnings("all")
|
||||
public interface HighlightingStyles {
|
||||
static final String KEYWORD_ID = "keyword";
|
||||
|
||||
static final String PUNCTUATION_ID = "punctuation";
|
||||
|
||||
static final String COMMENT_ID = "comment";
|
||||
|
||||
static final String STRING_ID = "string";
|
||||
|
||||
static final String NUMBER_ID = "number";
|
||||
|
||||
static final String DEFAULT_ID = "default";
|
||||
|
||||
static final String INVALID_TOKEN_ID = "error";
|
||||
|
||||
static final String TASK_ID = "task";
|
||||
}
|
|
@ -1,44 +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.symbol;
|
||||
|
||||
import com.google.common.annotations.Beta;
|
||||
import com.google.inject.ImplementedBy;
|
||||
import java.util.List;
|
||||
import org.eclipse.lsp4j.DocumentSymbol;
|
||||
import org.eclipse.lsp4j.DocumentSymbolParams;
|
||||
import org.eclipse.lsp4j.SymbolInformation;
|
||||
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;
|
||||
import org.eclipse.xtext.xbase.lib.CollectionLiterals;
|
||||
|
||||
/**
|
||||
* Common service interface for providing document symbol information for text documents.
|
||||
*
|
||||
* <p>
|
||||
* For more details, see the <a href="https://microsoft.github.io/language-server-protocol/specification#textDocument_documentSymbol">{@code textDocument/documentSymbol}</a> LSP method.
|
||||
*
|
||||
* <p>
|
||||
* This interface is not meant to be injected. Use the {@link DocumentSymbolService} and the {@link HierarchicalDocumentSymbolService} directly instead.
|
||||
*/
|
||||
@Beta
|
||||
@ImplementedBy(IDocumentSymbolService.Noop.class)
|
||||
@SuppressWarnings("all")
|
||||
public interface IDocumentSymbolService {
|
||||
class Noop implements IDocumentSymbolService {
|
||||
@Override
|
||||
public List<Either<SymbolInformation, DocumentSymbol>> getSymbols(final Document document, final XtextResource resource, final DocumentSymbolParams params, final CancelIndicator cancelIndicator) {
|
||||
return CollectionLiterals.<Either<SymbolInformation, DocumentSymbol>>emptyList();
|
||||
}
|
||||
}
|
||||
|
||||
List<Either<SymbolInformation, DocumentSymbol>> getSymbols(final Document document, final XtextResource resource, final DocumentSymbolParams params, final CancelIndicator cancelIndicator);
|
||||
}
|
|
@ -1,61 +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.symbol;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import org.eclipse.lsp4j.SymbolInformation;
|
||||
import org.eclipse.xtext.findReferences.IReferenceFinder;
|
||||
import org.eclipse.xtext.ide.server.symbol.DocumentSymbolService;
|
||||
import org.eclipse.xtext.resource.IResourceDescription;
|
||||
import org.eclipse.xtext.resource.IResourceDescriptions;
|
||||
import org.eclipse.xtext.resource.IResourceServiceProvider;
|
||||
import org.eclipse.xtext.service.OperationCanceledManager;
|
||||
import org.eclipse.xtext.util.CancelIndicator;
|
||||
import org.eclipse.xtext.xbase.lib.CollectionLiterals;
|
||||
import org.eclipse.xtext.xbase.lib.Extension;
|
||||
|
||||
/**
|
||||
* @author kosyakov - Initial contribution and API
|
||||
* @since 2.11
|
||||
*/
|
||||
@Singleton
|
||||
@SuppressWarnings("all")
|
||||
public class WorkspaceSymbolService {
|
||||
@Inject
|
||||
@Extension
|
||||
private IResourceServiceProvider.Registry _registry;
|
||||
|
||||
@Inject
|
||||
private OperationCanceledManager operationCanceledManager;
|
||||
|
||||
public List<? extends SymbolInformation> getSymbols(final String query, final IReferenceFinder.IResourceAccess resourceAccess, final IResourceDescriptions indexData, final CancelIndicator cancelIndicator) {
|
||||
final LinkedList<SymbolInformation> result = CollectionLiterals.<SymbolInformation>newLinkedList();
|
||||
Iterable<IResourceDescription> _allResourceDescriptions = indexData.getAllResourceDescriptions();
|
||||
for (final IResourceDescription resourceDescription : _allResourceDescriptions) {
|
||||
{
|
||||
this.operationCanceledManager.checkCanceled(cancelIndicator);
|
||||
final IResourceServiceProvider resourceServiceProvider = this._registry.getResourceServiceProvider(resourceDescription.getURI());
|
||||
DocumentSymbolService _get = null;
|
||||
if (resourceServiceProvider!=null) {
|
||||
_get=resourceServiceProvider.<DocumentSymbolService>get(DocumentSymbolService.class);
|
||||
}
|
||||
final DocumentSymbolService documentSymbolService = _get;
|
||||
if ((documentSymbolService != null)) {
|
||||
List<? extends SymbolInformation> _symbols = documentSymbolService.getSymbols(resourceDescription, query, resourceAccess, cancelIndicator);
|
||||
Iterables.<SymbolInformation>addAll(result, _symbols);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue