Search in sources :

Example 1 with WorkspaceSymbolParams

use of org.eclipse.lsp4j.WorkspaceSymbolParams in project xtext-core by eclipse.

the class AbstractLanguageServerTest method testSymbol.

protected void testSymbol(final Procedure1<? super WorkspaceSymbolConfiguration> configurator) {
    try {
        @Extension final WorkspaceSymbolConfiguration configuration = new WorkspaceSymbolConfiguration();
        configuration.setFilePath(("MyModel." + this.fileExtension));
        configurator.apply(configuration);
        this.initializeContext(configuration);
        String _query = configuration.getQuery();
        WorkspaceSymbolParams _workspaceSymbolParams = new WorkspaceSymbolParams(_query);
        final List<? extends SymbolInformation> symbols = this.languageServer.symbol(_workspaceSymbolParams).get();
        Procedure1<? super List<? extends SymbolInformation>> _assertSymbols = configuration.getAssertSymbols();
        boolean _tripleNotEquals = (_assertSymbols != null);
        if (_tripleNotEquals) {
            configuration.getAssertSymbols().apply(symbols);
        } else {
            final String actualSymbols = this.toExpectation(symbols);
            this.assertEquals(configuration.getExpectedSymbols(), actualSymbols);
        }
    } catch (Throwable _e) {
        throw Exceptions.sneakyThrow(_e);
    }
}
Also used : Extension(org.eclipse.xtext.xbase.lib.Extension) WorkspaceSymbolConfiguration(org.eclipse.xtext.testing.WorkspaceSymbolConfiguration) WorkspaceSymbolParams(org.eclipse.lsp4j.WorkspaceSymbolParams)

Example 2 with WorkspaceSymbolParams

use of org.eclipse.lsp4j.WorkspaceSymbolParams in project sts4 by spring-projects.

the class InWorkspaceSymbolsProvider method fetchFor.

@Override
public Collection<SymbolInformation> fetchFor(String query) throws Exception {
    // TODO: if we want decent support for multiple language servers...
    // consider changing SymbolsProvider api and turning the stuff in here into something producing a
    // Flux<Collection<SymbolInformation>>
    // This will help in
    // - supporting cancelation
    // - executing multiple requests to different servers in parallel.
    // - producing results per server so don't have to wait for one slow server to see the rest.
    // However it will also add complexity to the code that consumes this and at this time we only
    // really use this with a single language server anyways.
    WorkspaceSymbolParams params = new WorkspaceSymbolParams(query);
    Flux<SymbolInformation> symbols = Flux.fromIterable(this.languageServers).flatMap(server -> Mono.fromFuture(server.getWorkspaceService().symbol(params)).timeout(TIMEOUT).doOnError(e -> log(e)).onErrorReturn(ImmutableList.of()).flatMapMany(Flux::fromIterable));
    // Consider letting the Flux go out from here instead of blocking and collecting elements.
    return symbols.take(MAX_RESULTS).collect(Collectors.toList()).block();
}
Also used : ExecutionEvent(org.eclipse.core.commands.ExecutionEvent) IAdaptable(org.eclipse.core.runtime.IAdaptable) Collection(java.util.Collection) WorkspaceSymbolParams(org.eclipse.lsp4j.WorkspaceSymbolParams) Mono(reactor.core.publisher.Mono) LanguageServer(org.eclipse.lsp4j.services.LanguageServer) Collectors(java.util.stream.Collectors) SymbolInformation(org.eclipse.lsp4j.SymbolInformation) HandlerUtil(org.eclipse.ui.handlers.HandlerUtil) ExceptionUtil(org.springsource.ide.eclipse.commons.livexp.util.ExceptionUtil) Flux(reactor.core.publisher.Flux) List(java.util.List) IProject(org.eclipse.core.resources.IProject) ImmutableList(com.google.common.collect.ImmutableList) Duration(java.time.Duration) IResource(org.eclipse.core.resources.IResource) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) LanguageServiceAccessor(org.eclipse.lsp4e.LanguageServiceAccessor) IEditorPart(org.eclipse.ui.IEditorPart) GotoSymbolPlugin(org.springframework.tooling.ls.eclipse.gotosymbol.GotoSymbolPlugin) WorkspaceSymbolParams(org.eclipse.lsp4j.WorkspaceSymbolParams) SymbolInformation(org.eclipse.lsp4j.SymbolInformation)

Aggregations

WorkspaceSymbolParams (org.eclipse.lsp4j.WorkspaceSymbolParams)2 ImmutableList (com.google.common.collect.ImmutableList)1 Duration (java.time.Duration)1 Collection (java.util.Collection)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 ExecutionEvent (org.eclipse.core.commands.ExecutionEvent)1 IProject (org.eclipse.core.resources.IProject)1 IResource (org.eclipse.core.resources.IResource)1 IAdaptable (org.eclipse.core.runtime.IAdaptable)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 LanguageServiceAccessor (org.eclipse.lsp4e.LanguageServiceAccessor)1 SymbolInformation (org.eclipse.lsp4j.SymbolInformation)1 LanguageServer (org.eclipse.lsp4j.services.LanguageServer)1 IEditorPart (org.eclipse.ui.IEditorPart)1 HandlerUtil (org.eclipse.ui.handlers.HandlerUtil)1 WorkspaceSymbolConfiguration (org.eclipse.xtext.testing.WorkspaceSymbolConfiguration)1 Extension (org.eclipse.xtext.xbase.lib.Extension)1 GotoSymbolPlugin (org.springframework.tooling.ls.eclipse.gotosymbol.GotoSymbolPlugin)1 ExceptionUtil (org.springsource.ide.eclipse.commons.livexp.util.ExceptionUtil)1