Search in sources :

Example 1 with DocumentSymbolService

use of org.eclipse.xtext.ide.server.symbol.DocumentSymbolService in project xtext-core by eclipse.

the class LanguageServerImpl method definition.

protected List<? extends Location> definition(final CancelIndicator cancelIndicator, final TextDocumentPositionParams params) {
    final URI uri = this._uriExtensions.toUri(params.getTextDocument().getUri());
    final IResourceServiceProvider resourceServiceProvider = this.languagesRegistry.getResourceServiceProvider(uri);
    DocumentSymbolService _get = null;
    if (resourceServiceProvider != null) {
        _get = resourceServiceProvider.<DocumentSymbolService>get(DocumentSymbolService.class);
    }
    final DocumentSymbolService documentSymbolService = _get;
    if ((documentSymbolService == null)) {
        return CollectionLiterals.<Location>emptyList();
    }
    final Function2<Document, XtextResource, List<? extends Location>> _function = (Document document, XtextResource resource) -> {
        return documentSymbolService.getDefinitions(document, resource, params, this.resourceAccess, cancelIndicator);
    };
    return this.workspaceManager.<List<? extends Location>>doRead(uri, _function);
}
Also used : IResourceServiceProvider(org.eclipse.xtext.resource.IResourceServiceProvider) DocumentSymbolService(org.eclipse.xtext.ide.server.symbol.DocumentSymbolService) XtextResource(org.eclipse.xtext.resource.XtextResource) ArrayList(java.util.ArrayList) List(java.util.List) CompletionList(org.eclipse.lsp4j.CompletionList) Document(org.eclipse.xtext.ide.server.Document) URI(org.eclipse.emf.common.util.URI) Location(org.eclipse.lsp4j.Location)

Example 2 with DocumentSymbolService

use of org.eclipse.xtext.ide.server.symbol.DocumentSymbolService in project xtext-core by eclipse.

the class LanguageServerImpl method definition.

/**
 * Compute the definition.
 */
protected List<? extends Location> definition(CancelIndicator cancelIndicator, DefinitionParams params) {
    URI uri = getURI(params);
    DocumentSymbolService documentSymbolService = getService(uri, DocumentSymbolService.class);
    if (documentSymbolService == null) {
        return Collections.emptyList();
    }
    return workspaceManager.doRead(uri, (doc, res) -> documentSymbolService.getDefinitions(doc, res, params, resourceAccess, cancelIndicator));
}
Also used : HierarchicalDocumentSymbolService(org.eclipse.xtext.ide.server.symbol.HierarchicalDocumentSymbolService) DocumentSymbolService(org.eclipse.xtext.ide.server.symbol.DocumentSymbolService) IDocumentSymbolService(org.eclipse.xtext.ide.server.symbol.IDocumentSymbolService) URI(org.eclipse.emf.common.util.URI)

Example 3 with DocumentSymbolService

use of org.eclipse.xtext.ide.server.symbol.DocumentSymbolService in project xtext-core by eclipse.

the class WorkspaceSymbolService method getSymbols.

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;
}
Also used : IResourceServiceProvider(org.eclipse.xtext.resource.IResourceServiceProvider) IResourceDescription(org.eclipse.xtext.resource.IResourceDescription) DocumentSymbolService(org.eclipse.xtext.ide.server.symbol.DocumentSymbolService) List(java.util.List) LinkedList(java.util.LinkedList) SymbolInformation(org.eclipse.lsp4j.SymbolInformation)

Example 4 with DocumentSymbolService

use of org.eclipse.xtext.ide.server.symbol.DocumentSymbolService in project xtext-core by eclipse.

the class LanguageServerImpl method references.

/**
 * Compute the references. Executed in read request.
 * @since 2.20
 */
protected List<? extends Location> references(ReferenceParams params, CancelIndicator cancelIndicator) {
    URI uri = getURI(params);
    DocumentSymbolService documentSymbolService = getService(uri, DocumentSymbolService.class);
    if (documentSymbolService == null) {
        return Collections.emptyList();
    }
    return workspaceManager.doRead(uri, (document, resource) -> documentSymbolService.getReferences(document, resource, params, resourceAccess, workspaceManager.getIndex(), cancelIndicator));
}
Also used : HierarchicalDocumentSymbolService(org.eclipse.xtext.ide.server.symbol.HierarchicalDocumentSymbolService) DocumentSymbolService(org.eclipse.xtext.ide.server.symbol.DocumentSymbolService) IDocumentSymbolService(org.eclipse.xtext.ide.server.symbol.IDocumentSymbolService) URI(org.eclipse.emf.common.util.URI)

Aggregations

DocumentSymbolService (org.eclipse.xtext.ide.server.symbol.DocumentSymbolService)4 URI (org.eclipse.emf.common.util.URI)3 List (java.util.List)2 HierarchicalDocumentSymbolService (org.eclipse.xtext.ide.server.symbol.HierarchicalDocumentSymbolService)2 IDocumentSymbolService (org.eclipse.xtext.ide.server.symbol.IDocumentSymbolService)2 IResourceServiceProvider (org.eclipse.xtext.resource.IResourceServiceProvider)2 ArrayList (java.util.ArrayList)1 LinkedList (java.util.LinkedList)1 CompletionList (org.eclipse.lsp4j.CompletionList)1 Location (org.eclipse.lsp4j.Location)1 SymbolInformation (org.eclipse.lsp4j.SymbolInformation)1 Document (org.eclipse.xtext.ide.server.Document)1 IResourceDescription (org.eclipse.xtext.resource.IResourceDescription)1 XtextResource (org.eclipse.xtext.resource.XtextResource)1