update to latest lsp4e and lsp4j versions, incorporating changes to symbol parts of the LSP protocol, but not yet complete (symbol views in Eclipse broken at the moment)
This commit is contained in:
@@ -5,9 +5,9 @@ Bundle-SymbolicName: org.springframework.tooling.ls.eclipse.gotosymbol;singleton
|
||||
Bundle-Version: 4.15.0.qualifier
|
||||
Require-Bundle: org.eclipse.ui,
|
||||
org.eclipse.ui.workbench.texteditor,
|
||||
org.eclipse.lsp4e;bundle-version="0.13.7",
|
||||
org.eclipse.lsp4j;bundle-version="0.6.0",
|
||||
org.eclipse.lsp4j.jsonrpc;bundle-version="0.6.0",
|
||||
org.eclipse.lsp4e;bundle-version="0.13.12",
|
||||
org.eclipse.lsp4j;bundle-version="0.14.0",
|
||||
org.eclipse.lsp4j.jsonrpc;bundle-version="0.14.0",
|
||||
org.eclipse.jface.text;bundle-version="3.12.0",
|
||||
org.eclipse.core.resources;bundle-version="3.12.0",
|
||||
org.eclipse.core.filebuffers,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2017, 2019 Pivotal, Inc.
|
||||
* Copyright (c) 2017, 2022 Pivotal, Inc.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
@@ -19,10 +19,8 @@ import java.util.stream.Collectors;
|
||||
|
||||
import org.eclipse.core.runtime.Assert;
|
||||
import org.eclipse.lsp4e.LSPEclipseUtils;
|
||||
import org.eclipse.lsp4j.DocumentSymbol;
|
||||
import org.eclipse.lsp4j.Location;
|
||||
import org.eclipse.lsp4j.SymbolInformation;
|
||||
import org.eclipse.lsp4j.jsonrpc.messages.Either;
|
||||
import org.eclipse.ui.IWorkbenchPage;
|
||||
import org.eclipse.ui.PlatformUI;
|
||||
import org.springframework.tooling.ls.eclipse.gotosymbol.GotoSymbolPlugin;
|
||||
@@ -70,12 +68,12 @@ public class GotoSymbolDialogModel {
|
||||
|
||||
}
|
||||
|
||||
public static Comparator<Match<Either<SymbolInformation, DocumentSymbol>>> MATCH_COMPARATOR = (m1, m2) -> {
|
||||
public static Comparator<Match<SymbolContainer>> MATCH_COMPARATOR = (m1, m2) -> {
|
||||
int comp = Double.compare(m2.score, m1.score);
|
||||
if (comp!=0) return comp;
|
||||
if (comp != 0) return comp;
|
||||
|
||||
String m1Name = m1.value.isLeft() ? m1.value.getLeft().getName() : m1.value.getRight().getName();
|
||||
String m2Name = m2.value.isLeft() ? m2.value.getLeft().getName() : m2.value.getRight().getName();
|
||||
String m1Name = m1.value.getName();
|
||||
String m2Name = m2.value.getName();
|
||||
|
||||
return m1Name.compareTo(m2Name);
|
||||
};
|
||||
@@ -113,7 +111,7 @@ public class GotoSymbolDialogModel {
|
||||
private int currentSymbolsProviderIndex;
|
||||
public final LiveVariable<SymbolsProvider> currentSymbolsProvider = new LiveVariable<>(null);
|
||||
private final LiveVariable<String> searchBox = new LiveVariable<>("");
|
||||
public final ObservableSet<Either<SymbolInformation, DocumentSymbol>> unfilteredSymbols = new ObservableSet<Either<SymbolInformation, DocumentSymbol>>(ImmutableSet.of(), AsyncMode.ASYNC, AsyncMode.SYNC) {
|
||||
public final ObservableSet<SymbolContainer> unfilteredSymbols = new ObservableSet<SymbolContainer>(ImmutableSet.of(), AsyncMode.ASYNC, AsyncMode.SYNC) {
|
||||
//Note: fetching is 'slow' so is done asynchronously
|
||||
{
|
||||
setRefreshDelay(100);
|
||||
@@ -122,7 +120,7 @@ public class GotoSymbolDialogModel {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ImmutableSet<Either<SymbolInformation, DocumentSymbol>> compute() {
|
||||
protected ImmutableSet<SymbolContainer> compute() {
|
||||
status.setValue(HighlightedText.plain("Fetching symbols..."));
|
||||
try {
|
||||
SymbolsProvider sp = currentSymbolsProvider.getValue();
|
||||
@@ -131,7 +129,7 @@ public class GotoSymbolDialogModel {
|
||||
debug("Fetching "+currentProviderName);
|
||||
String query = searchBox.getValue();
|
||||
debug("Fetching symbols... from symbol provider, for '"+query+"'");
|
||||
Collection<Either<SymbolInformation, DocumentSymbol>> fetched = sp.fetchFor(query);
|
||||
Collection<SymbolContainer> fetched = sp.fetchFor(query);
|
||||
if (keyBindings==null) {
|
||||
status.setValue(HighlightedText.plain(currentProviderName));
|
||||
} else {
|
||||
@@ -160,7 +158,7 @@ public class GotoSymbolDialogModel {
|
||||
}
|
||||
};
|
||||
|
||||
private LiveExpression<Collection<Match<Either<SymbolInformation, DocumentSymbol>>>> filteredSymbols = new LiveExpression<Collection<Match<Either<SymbolInformation, DocumentSymbol>>>>() {
|
||||
private LiveExpression<Collection<Match<SymbolContainer>>> filteredSymbols = new LiveExpression<Collection<Match<SymbolContainer>>>() {
|
||||
//Note: filtering is 'fast' so is done synchronously
|
||||
{
|
||||
dependsOn(searchBox);
|
||||
@@ -168,25 +166,23 @@ public class GotoSymbolDialogModel {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Collection<Match<Either<SymbolInformation, DocumentSymbol>>> compute() {
|
||||
protected Collection<Match<SymbolContainer>> compute() {
|
||||
String query = searchBox.getValue();
|
||||
if (!StringUtil.hasText(query)) {
|
||||
query = "";
|
||||
}
|
||||
query = query.toLowerCase();
|
||||
List<Match<Either<SymbolInformation, DocumentSymbol>>> matches = new ArrayList<>();
|
||||
for (Either<SymbolInformation, DocumentSymbol> symbol : unfilteredSymbols.getValues()) {
|
||||
String name = null;
|
||||
if (symbol.isLeft()) {
|
||||
name = symbol.getLeft().getName().toLowerCase();
|
||||
}
|
||||
else if (symbol.isRight()) {
|
||||
name = symbol.getRight().getName().toLowerCase();
|
||||
List<Match<SymbolContainer>> matches = new ArrayList<>();
|
||||
for (SymbolContainer symbol : unfilteredSymbols.getValues()) {
|
||||
String name = symbol.getName();
|
||||
|
||||
if (name != null) {
|
||||
name = name.toLowerCase();
|
||||
}
|
||||
|
||||
double score = FuzzyMatcher.matchScore(query, name);
|
||||
if (score!=0.0) {
|
||||
matches.add(new Match<Either<SymbolInformation, DocumentSymbol>>(score, query, symbol));
|
||||
if (score != 0.0) {
|
||||
matches.add(new Match<SymbolContainer>(score, query, symbol));
|
||||
}
|
||||
}
|
||||
Collections.sort(matches, MATCH_COMPARATOR);
|
||||
@@ -223,11 +219,11 @@ public class GotoSymbolDialogModel {
|
||||
return favourites;
|
||||
}
|
||||
|
||||
private List<String> summary(Collection<Match<Either<SymbolInformation, DocumentSymbol>>> collection) {
|
||||
return collection.stream().map(match -> match.value.isLeft() ? match.value.getLeft().getName() : match.value.getRight().getName()).collect(Collectors.toList());
|
||||
private List<String> summary(Collection<Match<SymbolContainer>> collection) {
|
||||
return collection.stream().map(match -> match.value.getName()).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public LiveExpression<Collection<Match<Either<SymbolInformation, DocumentSymbol>>>> getSymbols() {
|
||||
public LiveExpression<Collection<Match<SymbolContainer>>> getSymbols() {
|
||||
return filteredSymbols;
|
||||
}
|
||||
|
||||
@@ -270,7 +266,8 @@ public class GotoSymbolDialogModel {
|
||||
|
||||
public boolean fromFileProvider(SymbolInformation symbolInformation) {
|
||||
SymbolsProvider sp = currentSymbolsProvider.getValue();
|
||||
if (sp!=null) {
|
||||
|
||||
if (sp != null) {
|
||||
return sp.fromFile(symbolInformation);
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2016, 2021 Rogue Wave Software Inc. and others.
|
||||
* Copyright (c) 2016, 2022 Rogue Wave Software Inc. and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
@@ -464,7 +464,7 @@ public class GotoSymbolSection extends WizardPageSection {
|
||||
|
||||
private SymbolInformation getFirstElement(TreeViewer list) {
|
||||
TreeItem[] items = list.getTree().getItems();
|
||||
if (items != null && items.length>0) {
|
||||
if (items != null && items.length > 0) {
|
||||
TreeItem item = items[0];
|
||||
Object data = item.getData();
|
||||
if (data instanceof Match) {
|
||||
@@ -478,16 +478,11 @@ public class GotoSymbolSection extends WizardPageSection {
|
||||
}
|
||||
|
||||
private SymbolInformation getSymbolInformation(Match<?> element) {
|
||||
if (element.value instanceof SymbolInformation) {
|
||||
return (SymbolInformation) element.value;
|
||||
}
|
||||
if (element.value instanceof Either) {
|
||||
Either<?,?> either = (Either<?, ?>)element.value;
|
||||
if (either.isLeft()) {
|
||||
Object left = either.getLeft();
|
||||
if (left instanceof SymbolInformation) {
|
||||
return (SymbolInformation) left;
|
||||
}
|
||||
if (element.value instanceof SymbolContainer) {
|
||||
SymbolContainer symbolContainer = (SymbolContainer) element.value;
|
||||
|
||||
if (symbolContainer.isSymbolInformation()) {
|
||||
return symbolContainer.getSymbolInformation();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2017, 2021 Pivotal, Inc.
|
||||
* Copyright (c) 2017, 2022 Pivotal, Inc.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
@@ -14,6 +14,7 @@ import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.eclipse.jface.text.IDocument;
|
||||
import org.eclipse.lsp4e.LSPEclipseUtils;
|
||||
@@ -47,16 +48,21 @@ public class InFileSymbolsProvider implements SymbolsProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Either<SymbolInformation, DocumentSymbol>> fetchFor(String query) throws Exception {
|
||||
public List<SymbolContainer> fetchFor(String query) throws Exception {
|
||||
CompletableFuture<LanguageServer> server = getServer();
|
||||
String uri = getUri();
|
||||
|
||||
if (server != null && uri != null) {
|
||||
DocumentSymbolParams params = new DocumentSymbolParams(
|
||||
new TextDocumentIdentifier(uri));
|
||||
DocumentSymbolParams params = new DocumentSymbolParams(new TextDocumentIdentifier(uri));
|
||||
|
||||
CompletableFuture<List<Either<SymbolInformation, DocumentSymbol>>> symbolsFuture = server
|
||||
.get()
|
||||
.getTextDocumentService().documentSymbol(params);
|
||||
List<Either<SymbolInformation, DocumentSymbol>> symbols = symbolsFuture.get();
|
||||
|
||||
List<SymbolContainer> symbols = symbolsFuture.get().stream()
|
||||
.map(either -> either.isLeft() ? SymbolContainer.fromSymbolInformation(either.getLeft()) : SymbolContainer.fromDocumentSymbol(either.getRight()))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
return symbols == null ? ImmutableList.of() : ImmutableList.copyOf(symbols);
|
||||
}
|
||||
return ImmutableList.of();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2019, 2021 Pivotal, Inc.
|
||||
* Copyright (c) 2019, 2022 Pivotal, Inc.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
@@ -21,6 +21,7 @@ import org.eclipse.lsp4e.LSPEclipseUtils;
|
||||
import org.eclipse.lsp4e.LanguageServiceAccessor;
|
||||
import org.eclipse.lsp4j.DocumentSymbol;
|
||||
import org.eclipse.lsp4j.SymbolInformation;
|
||||
import org.eclipse.lsp4j.WorkspaceSymbol;
|
||||
import org.eclipse.lsp4j.WorkspaceSymbolParams;
|
||||
import org.eclipse.lsp4j.jsonrpc.messages.Either;
|
||||
import org.eclipse.lsp4j.services.LanguageServer;
|
||||
@@ -29,6 +30,7 @@ import org.springsource.ide.eclipse.commons.livexp.core.LiveExpression;
|
||||
import org.springsource.ide.eclipse.commons.livexp.util.ExceptionUtil;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
@@ -74,7 +76,7 @@ public class InProjectSymbolsProvider implements SymbolsProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Either<SymbolInformation, DocumentSymbol>> fetchFor(String query) throws Exception {
|
||||
public List<SymbolContainer> 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>>
|
||||
@@ -86,20 +88,27 @@ public class InProjectSymbolsProvider implements SymbolsProvider {
|
||||
// really use this with a single language server anyways.
|
||||
|
||||
IProject project = this.project.get();
|
||||
if (project!=null) {
|
||||
|
||||
if (project != null) {
|
||||
String projectLocationPrefix = LSPEclipseUtils.toUri(project).toString();
|
||||
query = "locationPrefix:" + projectLocationPrefix + "?" + query;
|
||||
|
||||
WorkspaceSymbolParams params = new WorkspaceSymbolParams(query);
|
||||
|
||||
Flux<Either<SymbolInformation, DocumentSymbol>> symbols = Flux.fromIterable(this.languageServers.get())
|
||||
.flatMap(server -> Mono.fromFuture(server.getWorkspaceService().symbol(params))
|
||||
.timeout(TIMEOUT)
|
||||
.doOnError(e -> log(e))
|
||||
.onErrorReturn(ImmutableList.of())
|
||||
.flatMapMany(Flux::fromIterable)
|
||||
.map(symbol -> Either.forLeft(symbol))
|
||||
);
|
||||
List<LanguageServer> servers = this.languageServers.get();
|
||||
|
||||
Flux<Either<List<? extends SymbolInformation>, List<? extends WorkspaceSymbol>>> first = Flux.fromIterable(servers)
|
||||
.flatMap(server -> Mono.fromFuture(server.getWorkspaceService().symbol(params)))
|
||||
.timeout(TIMEOUT);
|
||||
|
||||
Flux<SymbolContainer> symbols = first
|
||||
.doOnError(e -> log(e))
|
||||
.onErrorReturn(Either.forLeft(ImmutableList.of()))
|
||||
.map(eitherList -> (eitherList.isLeft()
|
||||
? SymbolsProvider.toSymbolContainerFromSymbolInformation(eitherList.getLeft())
|
||||
: SymbolsProvider.toSymbolContainerFromWorkspaceSymbols(eitherList.getRight())))
|
||||
.flatMap(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();
|
||||
}
|
||||
@@ -114,5 +123,5 @@ public class InProjectSymbolsProvider implements SymbolsProvider {
|
||||
private static void log(Throwable e) {
|
||||
GotoSymbolPlugin.getInstance().getLog().log(ExceptionUtil.status(e));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2017, 2021 Pivotal, Inc.
|
||||
* Copyright (c) 2017, 2022 Pivotal, Inc.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
@@ -23,16 +23,15 @@ import org.eclipse.core.runtime.IAdaptable;
|
||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||
import org.eclipse.lsp4e.LSPEclipseUtils;
|
||||
import org.eclipse.lsp4e.LanguageServiceAccessor;
|
||||
import org.eclipse.lsp4j.DocumentSymbol;
|
||||
import org.eclipse.lsp4j.ServerCapabilities;
|
||||
import org.eclipse.lsp4j.SymbolInformation;
|
||||
import org.eclipse.lsp4j.WorkspaceSymbol;
|
||||
import org.eclipse.lsp4j.WorkspaceSymbolParams;
|
||||
import org.eclipse.lsp4j.jsonrpc.messages.Either;
|
||||
import org.eclipse.lsp4j.services.LanguageServer;
|
||||
import org.eclipse.ui.IEditorPart;
|
||||
import org.eclipse.ui.handlers.HandlerUtil;
|
||||
import org.springframework.tooling.ls.eclipse.gotosymbol.GotoSymbolPlugin;
|
||||
import org.springsource.ide.eclipse.commons.livexp.ui.Ilabelable;
|
||||
import org.springsource.ide.eclipse.commons.livexp.util.ExceptionUtil;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
@@ -81,7 +80,7 @@ public class InWorkspaceSymbolsProvider implements SymbolsProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Either<SymbolInformation, DocumentSymbol>> fetchFor(String query) throws Exception {
|
||||
public List<SymbolContainer> 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>>
|
||||
@@ -93,14 +92,20 @@ public class InWorkspaceSymbolsProvider implements SymbolsProvider {
|
||||
// really use this with a single language server anyways.
|
||||
WorkspaceSymbolParams params = new WorkspaceSymbolParams(query);
|
||||
|
||||
Flux<Either<SymbolInformation, DocumentSymbol>> symbols = Flux.fromIterable(this.languageServers.get())
|
||||
.flatMap(server -> Mono.fromFuture(server.getWorkspaceService().symbol(params))
|
||||
.timeout(TIMEOUT)
|
||||
.doOnError(e -> log(e))
|
||||
.onErrorReturn(ImmutableList.of())
|
||||
.flatMapMany(Flux::fromIterable)
|
||||
.map(symbol -> Either.forLeft(symbol))
|
||||
);
|
||||
List<LanguageServer> servers = this.languageServers.get();
|
||||
|
||||
Flux<Either<List<? extends SymbolInformation>, List<? extends WorkspaceSymbol>>> first = Flux.fromIterable(servers)
|
||||
.flatMap(server -> Mono.fromFuture(server.getWorkspaceService().symbol(params)))
|
||||
.timeout(TIMEOUT);
|
||||
|
||||
Flux<SymbolContainer> symbols = first
|
||||
.doOnError(e -> log(e))
|
||||
.onErrorReturn(Either.forLeft(ImmutableList.of()))
|
||||
.map(eitherList -> (eitherList.isLeft()
|
||||
? SymbolsProvider.toSymbolContainerFromSymbolInformation(eitherList.getLeft())
|
||||
: SymbolsProvider.toSymbolContainerFromWorkspaceSymbols(eitherList.getRight())))
|
||||
.flatMap(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();
|
||||
}
|
||||
@@ -141,4 +146,5 @@ public class InWorkspaceSymbolsProvider implements SymbolsProvider {
|
||||
private static void log(Throwable e) {
|
||||
GotoSymbolPlugin.getInstance().getLog().log(ExceptionUtil.status(e));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2022 VMware Inc. and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* https://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Martin Lippert (VMware Inc.) - initial implementation
|
||||
*******************************************************************************/
|
||||
package org.springframework.tooling.ls.eclipse.gotosymbol.dialogs;
|
||||
|
||||
import org.eclipse.lsp4j.DocumentSymbol;
|
||||
import org.eclipse.lsp4j.SymbolInformation;
|
||||
import org.eclipse.lsp4j.WorkspaceSymbol;
|
||||
|
||||
public class SymbolContainer {
|
||||
|
||||
private SymbolInformation symbolInformation;
|
||||
private DocumentSymbol documentSymbol;
|
||||
private WorkspaceSymbol workspaceSymbol;
|
||||
|
||||
public static SymbolContainer fromSymbolInformation(SymbolInformation symbolInformation) {
|
||||
return new SymbolContainer(symbolInformation);
|
||||
}
|
||||
|
||||
public static SymbolContainer fromDocumentSymbol(DocumentSymbol documentSymbol) {
|
||||
return new SymbolContainer(documentSymbol);
|
||||
}
|
||||
|
||||
public static SymbolContainer fromWorkspaceSymbol(WorkspaceSymbol workspaceSymbol) {
|
||||
return new SymbolContainer(workspaceSymbol);
|
||||
}
|
||||
|
||||
private SymbolContainer(SymbolInformation symbolInformation) {
|
||||
this.symbolInformation = symbolInformation;
|
||||
}
|
||||
|
||||
private SymbolContainer(DocumentSymbol documentSymbol) {
|
||||
this.documentSymbol = documentSymbol;
|
||||
}
|
||||
|
||||
private SymbolContainer(WorkspaceSymbol workspaceSymbol) {
|
||||
this.workspaceSymbol = workspaceSymbol;
|
||||
}
|
||||
|
||||
public boolean isSymbolInformation() {
|
||||
return symbolInformation != null;
|
||||
}
|
||||
|
||||
public boolean isDocumentSymbol() {
|
||||
return documentSymbol != null;
|
||||
}
|
||||
|
||||
public boolean isWorkspaceSymbol() {
|
||||
return workspaceSymbol != null;
|
||||
}
|
||||
|
||||
public SymbolInformation getSymbolInformation() {
|
||||
return symbolInformation;
|
||||
}
|
||||
|
||||
public DocumentSymbol getDocumentSymbol() {
|
||||
return documentSymbol;
|
||||
}
|
||||
|
||||
public WorkspaceSymbol getWorkspaceSymbol() {
|
||||
return workspaceSymbol;
|
||||
}
|
||||
|
||||
/**
|
||||
* convenience method to get the name from the symbol, independent of which type of symbol it is
|
||||
*/
|
||||
public String getName() {
|
||||
|
||||
if (isSymbolInformation()) {
|
||||
return symbolInformation.getName();
|
||||
}
|
||||
else if (isDocumentSymbol()) {
|
||||
return documentSymbol.getName();
|
||||
}
|
||||
else if (isWorkspaceSymbol()) {
|
||||
return workspaceSymbol.getName();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2017 Pivotal, Inc.
|
||||
* Copyright (c) 2017, 2022 Pivotal, Inc.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
@@ -11,10 +11,10 @@
|
||||
package org.springframework.tooling.ls.eclipse.gotosymbol.dialogs;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.eclipse.lsp4j.DocumentSymbol;
|
||||
import org.eclipse.lsp4j.SymbolInformation;
|
||||
import org.eclipse.lsp4j.jsonrpc.messages.Either;
|
||||
import org.eclipse.lsp4j.WorkspaceSymbol;
|
||||
|
||||
/**
|
||||
* An SymbolsProvider can fetch symbols from a service (typically, a language server
|
||||
@@ -24,7 +24,7 @@ import org.eclipse.lsp4j.jsonrpc.messages.Either;
|
||||
public interface SymbolsProvider {
|
||||
String getName();
|
||||
|
||||
List<Either<SymbolInformation, DocumentSymbol>> fetchFor(String query) throws Exception;
|
||||
List<SymbolContainer> fetchFor(String query) throws Exception;
|
||||
/**
|
||||
* True if the symbol information is provided from a file provider (a file is the provider of the symbols). False otherwise
|
||||
* @param symbol
|
||||
@@ -32,4 +32,15 @@ public interface SymbolsProvider {
|
||||
|
||||
*/
|
||||
boolean fromFile(SymbolInformation symbol);
|
||||
|
||||
|
||||
// helper methods for symbol providers to convert lists
|
||||
static List<SymbolContainer> toSymbolContainerFromSymbolInformation(List<? extends SymbolInformation> symbols) {
|
||||
return symbols.stream().map(sym -> SymbolContainer.fromSymbolInformation(sym)).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
static List<SymbolContainer> toSymbolContainerFromWorkspaceSymbols(List<? extends WorkspaceSymbol> symbols) {
|
||||
return symbols.stream().map(sym -> SymbolContainer.fromWorkspaceSymbol(sym)).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user