LSP4J 0.14.0. SymbolInformation -> WorkspaceSymbol where possible
This commit is contained in:
@@ -13,7 +13,7 @@ package org.springframework.ide.vscode.commons.languageserver.util;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.lsp4j.DocumentSymbolParams;
|
||||
import org.eclipse.lsp4j.SymbolInformation;
|
||||
import org.eclipse.lsp4j.WorkspaceSymbol;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
@@ -22,6 +22,6 @@ public interface DocumentSymbolHandler {
|
||||
|
||||
DocumentSymbolHandler NO_SYMBOLS = (params) -> ImmutableList.of();
|
||||
|
||||
List<? extends SymbolInformation> handle(DocumentSymbolParams params);
|
||||
List<? extends WorkspaceSymbol> handle(DocumentSymbolParams params);
|
||||
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ import java.util.List;
|
||||
|
||||
import org.eclipse.lsp4j.DocumentSymbol;
|
||||
import org.eclipse.lsp4j.DocumentSymbolParams;
|
||||
import org.eclipse.lsp4j.SymbolInformation;
|
||||
import org.eclipse.lsp4j.WorkspaceSymbol;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
@@ -27,7 +27,7 @@ public interface HierarchicalDocumentSymbolHandler extends DocumentSymbolHandler
|
||||
|
||||
HierarchicalDocumentSymbolHandler NO_SYMBOLS = new HierarchicalDocumentSymbolHandler() {
|
||||
@Override
|
||||
public List<? extends SymbolInformation> handle(DocumentSymbolParams params) {
|
||||
public List<? extends WorkspaceSymbol> handle(DocumentSymbolParams params) {
|
||||
return ImmutableList.of();
|
||||
}
|
||||
|
||||
|
||||
@@ -67,6 +67,7 @@ import org.eclipse.lsp4j.TextDocumentPositionParams;
|
||||
import org.eclipse.lsp4j.TextEdit;
|
||||
import org.eclipse.lsp4j.VersionedTextDocumentIdentifier;
|
||||
import org.eclipse.lsp4j.WorkspaceEdit;
|
||||
import org.eclipse.lsp4j.WorkspaceSymbol;
|
||||
import org.eclipse.lsp4j.jsonrpc.CancelChecker;
|
||||
import org.eclipse.lsp4j.jsonrpc.CompletableFutures;
|
||||
import org.eclipse.lsp4j.jsonrpc.messages.Either;
|
||||
@@ -413,11 +414,11 @@ public class SimpleTextDocumentService implements TextDocumentService, DocumentE
|
||||
: r.stream().map(symbolInfo -> Either.<SymbolInformation, DocumentSymbol>forRight(symbolInfo))
|
||||
.collect(Collectors.toList());
|
||||
} else {
|
||||
List<? extends SymbolInformation> r = h.handle(params);
|
||||
List<? extends WorkspaceSymbol> r = h.handle(params);
|
||||
//handle it when symbolHandler is sloppy and returns null instead of empty list.
|
||||
return r == null
|
||||
? ImmutableList.of()
|
||||
: r.stream().map(symbolInfo -> Either.<SymbolInformation, DocumentSymbol>forLeft(symbolInfo))
|
||||
: r.stream().map(symbolInfo -> Either.<SymbolInformation, DocumentSymbol>forLeft(new SymbolInformation(symbolInfo.getName(), symbolInfo.getKind(), symbolInfo.getLocation().getLeft(), symbolInfo.getContainerName())))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
});
|
||||
|
||||
@@ -28,7 +28,9 @@ import org.eclipse.lsp4j.FileEvent;
|
||||
import org.eclipse.lsp4j.SymbolInformation;
|
||||
import org.eclipse.lsp4j.WorkspaceFolder;
|
||||
import org.eclipse.lsp4j.WorkspaceFoldersChangeEvent;
|
||||
import org.eclipse.lsp4j.WorkspaceSymbol;
|
||||
import org.eclipse.lsp4j.WorkspaceSymbolParams;
|
||||
import org.eclipse.lsp4j.jsonrpc.messages.Either;
|
||||
import org.eclipse.lsp4j.services.WorkspaceService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -62,15 +64,15 @@ public class SimpleWorkspaceService implements WorkspaceService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<List<? extends SymbolInformation>> symbol(WorkspaceSymbolParams params) {
|
||||
public CompletableFuture<Either<List<? extends SymbolInformation>, List<? extends WorkspaceSymbol>>> symbol(WorkspaceSymbolParams params) {
|
||||
return async.invoke(() -> {
|
||||
WorkspaceSymbolHandler workspaceSymbolHandler = this.workspaceSymbolHandler;
|
||||
if (workspaceSymbolHandler==null) {
|
||||
return ImmutableList.of();
|
||||
return Either.forRight(ImmutableList.of());
|
||||
}
|
||||
server.waitForReconcile();
|
||||
List<? extends SymbolInformation> symbols = workspaceSymbolHandler.handle(params);
|
||||
return symbols == null ? ImmutableList.of() : symbols;
|
||||
List<? extends WorkspaceSymbol> symbols = workspaceSymbolHandler.handle(params);
|
||||
return Either.forRight(symbols == null ? ImmutableList.<WorkspaceSymbol>of() : symbols);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ package org.springframework.ide.vscode.commons.languageserver.util;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.lsp4j.SymbolInformation;
|
||||
import org.eclipse.lsp4j.WorkspaceSymbol;
|
||||
import org.eclipse.lsp4j.WorkspaceSymbolParams;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
@@ -22,6 +22,6 @@ public interface WorkspaceSymbolHandler {
|
||||
|
||||
WorkspaceSymbolHandler NO_SYMBOLS = (params) -> ImmutableList.of();
|
||||
|
||||
List<? extends SymbolInformation> handle(WorkspaceSymbolParams params);
|
||||
List<? extends WorkspaceSymbol> handle(WorkspaceSymbolParams params);
|
||||
|
||||
}
|
||||
|
||||
@@ -18,8 +18,8 @@ import java.util.Stack;
|
||||
|
||||
import org.eclipse.lsp4j.DocumentSymbol;
|
||||
import org.eclipse.lsp4j.DocumentSymbolParams;
|
||||
import org.eclipse.lsp4j.SymbolInformation;
|
||||
import org.eclipse.lsp4j.SymbolKind;
|
||||
import org.eclipse.lsp4j.WorkspaceSymbol;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.ide.vscode.commons.languageserver.util.HierarchicalDocumentSymbolHandler;
|
||||
@@ -153,7 +153,7 @@ public class TypeBasedYamlHierarchicalSymbolHandler implements HierarchicalDocum
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<? extends SymbolInformation> handle(DocumentSymbolParams params) {
|
||||
public List<? extends WorkspaceSymbol> handle(DocumentSymbolParams params) {
|
||||
return baseHandler.handle(params);
|
||||
}
|
||||
|
||||
|
||||
@@ -17,8 +17,9 @@ import java.util.Set;
|
||||
|
||||
import org.eclipse.lsp4j.DocumentSymbolParams;
|
||||
import org.eclipse.lsp4j.Location;
|
||||
import org.eclipse.lsp4j.SymbolInformation;
|
||||
import org.eclipse.lsp4j.SymbolKind;
|
||||
import org.eclipse.lsp4j.WorkspaceSymbol;
|
||||
import org.eclipse.lsp4j.jsonrpc.messages.Either;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.ide.vscode.commons.languageserver.util.DocumentSymbolHandler;
|
||||
@@ -62,8 +63,8 @@ public class TypeBasedYamlSymbolHandler implements DocumentSymbolHandler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<? extends SymbolInformation> handle(DocumentSymbolParams params) {
|
||||
Builder<SymbolInformation> builder = ImmutableList.builder();
|
||||
public List<? extends WorkspaceSymbol> handle(DocumentSymbolParams params) {
|
||||
Builder<WorkspaceSymbol> builder = ImmutableList.builder();
|
||||
|
||||
TextDocument doc = documents.getLatestSnapshot(params.getTextDocument().getUri());
|
||||
if (doc != null) {
|
||||
@@ -80,13 +81,13 @@ public class TypeBasedYamlSymbolHandler implements DocumentSymbolHandler {
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
protected SymbolInformation createSymbol(TextDocument doc, Node node, YType type) throws BadLocationException {
|
||||
protected WorkspaceSymbol createSymbol(TextDocument doc, Node node, YType type) throws BadLocationException {
|
||||
DocumentRegion region = NodeUtil.region(doc, node);
|
||||
Location location = new Location(doc.getUri(), doc.toRange(region.getStart(), region.getLength()));
|
||||
SymbolInformation symbol = new SymbolInformation();
|
||||
WorkspaceSymbol symbol = new WorkspaceSymbol();
|
||||
symbol.setName(region.toString());
|
||||
symbol.setKind(symbolKind(type));
|
||||
symbol.setLocation(location);
|
||||
symbol.setLocation(Either.forLeft(location));
|
||||
symbol.setContainerName(containerName(type));
|
||||
return symbol;
|
||||
}
|
||||
|
||||
@@ -56,7 +56,6 @@ import org.junit.Assert;
|
||||
import org.springframework.ide.vscode.commons.protocol.HighlightParams;
|
||||
import org.springframework.ide.vscode.commons.util.StringUtil;
|
||||
import org.springframework.ide.vscode.commons.util.Unicodes;
|
||||
import org.springframework.ide.vscode.commons.util.text.DocumentRegion;
|
||||
import org.springframework.ide.vscode.commons.util.text.LanguageId;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
@@ -36,8 +36,6 @@ import java.util.Random;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.assertj.core.api.Condition;
|
||||
@@ -102,6 +100,7 @@ import org.eclipse.lsp4j.WorkDoneProgressCreateParams;
|
||||
import org.eclipse.lsp4j.WorkspaceClientCapabilities;
|
||||
import org.eclipse.lsp4j.WorkspaceEdit;
|
||||
import org.eclipse.lsp4j.WorkspaceEditCapabilities;
|
||||
import org.eclipse.lsp4j.WorkspaceSymbol;
|
||||
import org.eclipse.lsp4j.WorkspaceSymbolParams;
|
||||
import org.eclipse.lsp4j.jsonrpc.messages.Either;
|
||||
import org.eclipse.lsp4j.services.LanguageClientAware;
|
||||
@@ -111,11 +110,9 @@ import org.springframework.ide.vscode.commons.languageserver.completion.Document
|
||||
import org.springframework.ide.vscode.commons.languageserver.util.LanguageServerTestListener;
|
||||
import org.springframework.ide.vscode.commons.languageserver.util.Settings;
|
||||
import org.springframework.ide.vscode.commons.languageserver.util.SimpleLanguageServer;
|
||||
import org.springframework.ide.vscode.commons.languageserver.util.SimpleWorkspaceService;
|
||||
import org.springframework.ide.vscode.commons.protocol.CursorMovement;
|
||||
import org.springframework.ide.vscode.commons.protocol.HighlightParams;
|
||||
import org.springframework.ide.vscode.commons.protocol.LiveProcessSummary;
|
||||
import org.springframework.ide.vscode.commons.protocol.ProgressParams;
|
||||
import org.springframework.ide.vscode.commons.protocol.STS4LanguageClient;
|
||||
import org.springframework.ide.vscode.commons.protocol.java.ClasspathListenerParams;
|
||||
import org.springframework.ide.vscode.commons.protocol.java.JavaCodeCompleteData;
|
||||
@@ -949,9 +946,9 @@ public class LanguageServerHarness {
|
||||
this.enableHierarchicalDocumentSymbols = b;
|
||||
}
|
||||
|
||||
public Collection<SymbolInformation> getWorkspaceSymbols(String query) throws Exception {
|
||||
public Collection<WorkspaceSymbol> getWorkspaceSymbols(String query) throws Exception {
|
||||
WorkspaceSymbolParams params = new WorkspaceSymbolParams(query);
|
||||
List<? extends SymbolInformation> r = server.getWorkspaceService().symbol(params).get();
|
||||
List<? extends WorkspaceSymbol> r = server.getWorkspaceService().symbol(params).get().getRight();
|
||||
return ImmutableList.copyOf(r);
|
||||
}
|
||||
|
||||
|
||||
@@ -100,7 +100,7 @@
|
||||
<mockito-version>1.10.19</mockito-version>
|
||||
<jackson-2-version>2.5.0</jackson-2-version>
|
||||
<jersey-2-version>2.10</jersey-2-version>
|
||||
<lsp4j-version>0.12.0</lsp4j-version>
|
||||
<lsp4j-version>0.14.0</lsp4j-version>
|
||||
<!-- NOTE: Reactor version must match version used by the CF client -->
|
||||
<cloudfoundry-client-version>3.8.0.RELEASE</cloudfoundry-client-version>
|
||||
<reactor-version>3.1.5.RELEASE</reactor-version>
|
||||
|
||||
@@ -33,8 +33,11 @@ import java.util.function.Predicate;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.eclipse.lsp4j.SymbolInformation;
|
||||
import org.eclipse.lsp4j.Location;
|
||||
import org.eclipse.lsp4j.TextDocumentIdentifier;
|
||||
import org.eclipse.lsp4j.WorkspaceSymbol;
|
||||
import org.eclipse.lsp4j.WorkspaceSymbolLocation;
|
||||
import org.eclipse.lsp4j.jsonrpc.messages.Either;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
@@ -518,7 +521,7 @@ public class SpringSymbolIndex implements InitializingBean {
|
||||
}
|
||||
}
|
||||
|
||||
public List<SymbolInformation> getAllSymbols(String query) {
|
||||
public List<WorkspaceSymbol> getAllSymbols(String query) {
|
||||
if (query != null && query.length() > 0) {
|
||||
synchronized(this.symbols) {
|
||||
return searchMatchingSymbols(this.symbols, query, MAX_NUMBER_OF_SYMBOLS_IN_RESPONSE);
|
||||
@@ -530,7 +533,7 @@ public class SpringSymbolIndex implements InitializingBean {
|
||||
}
|
||||
}
|
||||
|
||||
public Stream<SymbolInformation> getSymbols(Predicate<EnhancedSymbolInformation> filter) {
|
||||
public Stream<WorkspaceSymbol> getSymbols(Predicate<EnhancedSymbolInformation> filter) {
|
||||
return symbols.parallelStream()
|
||||
.filter(filter)
|
||||
.map(enhanced -> enhanced.getSymbol());
|
||||
@@ -545,13 +548,13 @@ public class SpringSymbolIndex implements InitializingBean {
|
||||
}
|
||||
}
|
||||
|
||||
public List<? extends SymbolInformation> getSymbols(String docURI) {
|
||||
public List<? extends WorkspaceSymbol> getSymbols(String docURI) {
|
||||
try {
|
||||
TextDocument doc = server.getTextDocumentService().getLatestSnapshot(docURI);
|
||||
URI uri = URI.create(docURI);
|
||||
CompletableFuture<IJavaProject> projectInitialized = futureProjectFinder.findFuture(uri).thenCompose(project -> projectInitializedFuture(project));
|
||||
IJavaProject project = projectInitialized.get(15, TimeUnit.SECONDS);
|
||||
ImmutableList.Builder<SymbolInformation> builder = ImmutableList.builder();
|
||||
ImmutableList.Builder<WorkspaceSymbol> builder = ImmutableList.builder();
|
||||
if (project != null && doc != null) {
|
||||
// Collect symbols from the opened document
|
||||
for (SpringIndexer indexer : this.indexers) {
|
||||
@@ -633,7 +636,7 @@ public class SpringSymbolIndex implements InitializingBean {
|
||||
}, this.updateQueue);
|
||||
}
|
||||
|
||||
private List<SymbolInformation> searchMatchingSymbols(List<EnhancedSymbolInformation> allsymbols, String query, int maxNumberOfSymbolsInResponse) {
|
||||
private List<WorkspaceSymbol> searchMatchingSymbols(List<EnhancedSymbolInformation> allsymbols, String query, int maxNumberOfSymbolsInResponse) {
|
||||
long limit = maxNumberOfSymbolsInResponse;
|
||||
String locationPrefix = "";
|
||||
|
||||
@@ -660,7 +663,16 @@ public class SpringSymbolIndex implements InitializingBean {
|
||||
|
||||
return allsymbols.stream()
|
||||
.map(enhanced -> enhanced.getSymbol())
|
||||
.filter(symbol -> symbol.getLocation().getUri().startsWith(finalLocationPrefix))
|
||||
.filter(symbol -> {
|
||||
Either<Location, WorkspaceSymbolLocation> eitherLocation = symbol.getLocation();
|
||||
if (eitherLocation.isLeft()) {
|
||||
return eitherLocation.getLeft().getUri().startsWith(finalLocationPrefix);
|
||||
}
|
||||
if (eitherLocation.isRight()) {
|
||||
return symbol.getLocation().getRight().getUri().startsWith(finalLocationPrefix);
|
||||
}
|
||||
return false;
|
||||
})
|
||||
.filter(symbol -> StringUtil.containsCharactersCaseInsensitive(symbol.getName(), finalQuery))
|
||||
.limit(limit)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
@@ -24,8 +24,11 @@ import org.eclipse.jdt.core.dom.StringLiteral;
|
||||
import org.eclipse.jdt.core.dom.Type;
|
||||
import org.eclipse.jdt.core.dom.TypeDeclaration;
|
||||
import org.eclipse.lsp4j.Location;
|
||||
import org.eclipse.lsp4j.SymbolInformation;
|
||||
import org.eclipse.lsp4j.SymbolKind;
|
||||
import org.eclipse.lsp4j.WorkspaceSymbol;
|
||||
import org.eclipse.lsp4j.jsonrpc.messages.Either;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.ide.vscode.boot.java.Annotations;
|
||||
import org.springframework.ide.vscode.boot.java.handlers.AbstractSymbolProvider;
|
||||
import org.springframework.ide.vscode.boot.java.handlers.EnhancedSymbolInformation;
|
||||
@@ -35,7 +38,6 @@ import org.springframework.ide.vscode.boot.java.utils.CachedSymbol;
|
||||
import org.springframework.ide.vscode.boot.java.utils.FunctionUtils;
|
||||
import org.springframework.ide.vscode.boot.java.utils.SpringIndexerJavaContext;
|
||||
import org.springframework.ide.vscode.commons.util.BadLocationException;
|
||||
import org.springframework.ide.vscode.commons.util.Log;
|
||||
import org.springframework.ide.vscode.commons.util.text.DocumentRegion;
|
||||
import org.springframework.ide.vscode.commons.util.text.TextDocument;
|
||||
|
||||
@@ -50,6 +52,9 @@ import reactor.util.function.Tuples;
|
||||
* @author Kris De Volder
|
||||
*/
|
||||
public class BeansSymbolProvider extends AbstractSymbolProvider {
|
||||
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(BeansSymbolProvider.class);
|
||||
|
||||
private static final String[] NAME_ATTRIBUTES = {"value", "name"};
|
||||
|
||||
@@ -63,17 +68,17 @@ public class BeansSymbolProvider extends AbstractSymbolProvider {
|
||||
for (Tuple2<String, DocumentRegion> nameAndRegion : getBeanNames(node, doc)) {
|
||||
try {
|
||||
EnhancedSymbolInformation enhancedSymbol = new EnhancedSymbolInformation(
|
||||
new SymbolInformation(
|
||||
new WorkspaceSymbol(
|
||||
beanLabel(isFunction, nameAndRegion.getT1(), beanType, "@Bean" + markerString),
|
||||
SymbolKind.Interface,
|
||||
new Location(doc.getUri(), doc.toRange(nameAndRegion.getT2()))),
|
||||
Either.forLeft(new Location(doc.getUri(), doc.toRange(nameAndRegion.getT2())))),
|
||||
new SymbolAddOnInformation[] {new BeansSymbolAddOnInformation(nameAndRegion.getT1())}
|
||||
);
|
||||
|
||||
context.getGeneratedSymbols().add(new CachedSymbol(context.getDocURI(), context.getLastModified(), enhancedSymbol));
|
||||
|
||||
} catch (BadLocationException e) {
|
||||
Log.log(e);
|
||||
log.error("", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -84,16 +89,16 @@ public class BeansSymbolProvider extends AbstractSymbolProvider {
|
||||
Tuple3<String, String, DocumentRegion> functionBean = FunctionUtils.getFunctionBean(typeDeclaration, doc);
|
||||
if (functionBean != null) {
|
||||
try {
|
||||
SymbolInformation symbol = new SymbolInformation(
|
||||
WorkspaceSymbol symbol = new WorkspaceSymbol(
|
||||
beanLabel(true, functionBean.getT1(), functionBean.getT2(), null),
|
||||
SymbolKind.Interface,
|
||||
new Location(doc.getUri(), doc.toRange(functionBean.getT3())));
|
||||
Either.forLeft(new Location(doc.getUri(), doc.toRange(functionBean.getT3()))));
|
||||
|
||||
context.getGeneratedSymbols().add(new CachedSymbol(context.getDocURI(), context.getLastModified(),
|
||||
new EnhancedSymbolInformation(symbol, new SymbolAddOnInformation[] {new BeansSymbolAddOnInformation(functionBean.getT1())})));
|
||||
|
||||
} catch (BadLocationException e) {
|
||||
Log.log(e);
|
||||
log.error("", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,15 +18,17 @@ import org.eclipse.jdt.core.dom.Annotation;
|
||||
import org.eclipse.jdt.core.dom.ITypeBinding;
|
||||
import org.eclipse.jdt.core.dom.TypeDeclaration;
|
||||
import org.eclipse.lsp4j.Location;
|
||||
import org.eclipse.lsp4j.SymbolInformation;
|
||||
import org.eclipse.lsp4j.SymbolKind;
|
||||
import org.eclipse.lsp4j.WorkspaceSymbol;
|
||||
import org.eclipse.lsp4j.jsonrpc.messages.Either;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.ide.vscode.boot.java.handlers.AbstractSymbolProvider;
|
||||
import org.springframework.ide.vscode.boot.java.handlers.EnhancedSymbolInformation;
|
||||
import org.springframework.ide.vscode.boot.java.handlers.SymbolAddOnInformation;
|
||||
import org.springframework.ide.vscode.boot.java.utils.CachedSymbol;
|
||||
import org.springframework.ide.vscode.boot.java.utils.SpringIndexerJavaContext;
|
||||
import org.springframework.ide.vscode.commons.util.BadLocationException;
|
||||
import org.springframework.ide.vscode.commons.util.Log;
|
||||
import org.springframework.ide.vscode.commons.util.text.TextDocument;
|
||||
|
||||
/**
|
||||
@@ -34,6 +36,8 @@ import org.springframework.ide.vscode.commons.util.text.TextDocument;
|
||||
* @author Kris De Volder
|
||||
*/
|
||||
public class ComponentSymbolProvider extends AbstractSymbolProvider {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(ComponentSymbolProvider.class);
|
||||
|
||||
@Override
|
||||
protected void addSymbolsPass1(Annotation node, ITypeBinding annotationType, Collection<ITypeBinding> metaAnnotations, SpringIndexerJavaContext context, TextDocument doc) {
|
||||
@@ -42,7 +46,7 @@ public class ComponentSymbolProvider extends AbstractSymbolProvider {
|
||||
context.getGeneratedSymbols().add(new CachedSymbol(context.getDocURI(), context.getLastModified(), enhancedSymbol));
|
||||
}
|
||||
catch (Exception e) {
|
||||
Log.log(e);
|
||||
log.error("", e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,9 +58,9 @@ public class ComponentSymbolProvider extends AbstractSymbolProvider {
|
||||
String beanName = getBeanName(node);
|
||||
String beanType = getBeanType(node);
|
||||
|
||||
SymbolInformation symbol = new SymbolInformation(
|
||||
WorkspaceSymbol symbol = new WorkspaceSymbol(
|
||||
beanLabel("+", annotationTypeName, metaAnnotationNames, beanName, beanType), SymbolKind.Interface,
|
||||
new Location(doc.getUri(), doc.toRange(node.getStartPosition(), node.getLength())));
|
||||
Either.forLeft(new Location(doc.getUri(), doc.toRange(node.getStartPosition(), node.getLength()))));
|
||||
|
||||
SymbolAddOnInformation[] addon = new SymbolAddOnInformation[] {new BeansSymbolAddOnInformation(beanName)};
|
||||
|
||||
|
||||
@@ -13,8 +13,9 @@ package org.springframework.ide.vscode.boot.java.data;
|
||||
import org.eclipse.jdt.core.dom.ITypeBinding;
|
||||
import org.eclipse.jdt.core.dom.TypeDeclaration;
|
||||
import org.eclipse.lsp4j.Location;
|
||||
import org.eclipse.lsp4j.SymbolInformation;
|
||||
import org.eclipse.lsp4j.SymbolKind;
|
||||
import org.eclipse.lsp4j.WorkspaceSymbol;
|
||||
import org.eclipse.lsp4j.jsonrpc.messages.Either;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.ide.vscode.boot.java.beans.BeanUtils;
|
||||
@@ -45,10 +46,10 @@ public class DataRepositorySymbolProvider extends AbstractSymbolProvider {
|
||||
Tuple4<String, String, String, DocumentRegion> repositoryBean = getRepositoryBean(typeDeclaration, doc);
|
||||
if (repositoryBean != null) {
|
||||
try {
|
||||
SymbolInformation symbol = new SymbolInformation(
|
||||
WorkspaceSymbol symbol = new WorkspaceSymbol(
|
||||
beanLabel(true, repositoryBean.getT1(), repositoryBean.getT2(), repositoryBean.getT3()),
|
||||
SymbolKind.Interface,
|
||||
new Location(doc.getUri(), doc.toRange(repositoryBean.getT4())));
|
||||
Either.forLeft(new Location(doc.getUri(), doc.toRange(repositoryBean.getT4()))));
|
||||
|
||||
SymbolAddOnInformation[] addon = new SymbolAddOnInformation[] {new BeansSymbolAddOnInformation(repositoryBean.getT1())};
|
||||
EnhancedSymbolInformation enhancedSymbol = new EnhancedSymbolInformation(symbol, addon);
|
||||
|
||||
@@ -14,7 +14,7 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.lsp4j.DocumentSymbolParams;
|
||||
import org.eclipse.lsp4j.SymbolInformation;
|
||||
import org.eclipse.lsp4j.WorkspaceSymbol;
|
||||
import org.springframework.ide.vscode.boot.app.SpringSymbolIndex;
|
||||
import org.springframework.ide.vscode.boot.java.BootJavaLanguageServerComponents;
|
||||
import org.springframework.ide.vscode.commons.languageserver.util.DocumentSymbolHandler;
|
||||
@@ -35,7 +35,7 @@ public class BootJavaDocumentSymbolHandler implements DocumentSymbolHandler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<? extends SymbolInformation> handle(DocumentSymbolParams params) {
|
||||
public List<? extends WorkspaceSymbol> handle(DocumentSymbolParams params) {
|
||||
SimpleTextDocumentService documents = server.getTextDocumentService();
|
||||
TextDocument doc = documents.getLatestSnapshot(params.getTextDocument().getUri());
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ package org.springframework.ide.vscode.boot.java.handlers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.lsp4j.SymbolInformation;
|
||||
import org.eclipse.lsp4j.WorkspaceSymbol;
|
||||
import org.eclipse.lsp4j.WorkspaceSymbolParams;
|
||||
import org.springframework.ide.vscode.boot.app.SpringSymbolIndex;
|
||||
import org.springframework.ide.vscode.boot.java.requestmapping.LiveAppURLSymbolProvider;
|
||||
@@ -32,7 +32,7 @@ public class BootJavaWorkspaceSymbolHandler implements WorkspaceSymbolHandler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<? extends SymbolInformation> handle(WorkspaceSymbolParams params) {
|
||||
public List<? extends WorkspaceSymbol> handle(WorkspaceSymbolParams params) {
|
||||
if (params.getQuery() != null && params.getQuery().startsWith("//")) {
|
||||
return liveAppSymbolProvider.getSymbols(params.getQuery());
|
||||
}
|
||||
|
||||
@@ -10,22 +10,22 @@
|
||||
*******************************************************************************/
|
||||
package org.springframework.ide.vscode.boot.java.handlers;
|
||||
|
||||
import org.eclipse.lsp4j.SymbolInformation;
|
||||
import org.eclipse.lsp4j.WorkspaceSymbol;
|
||||
|
||||
/**
|
||||
* @author Martin Lippert
|
||||
*/
|
||||
public class EnhancedSymbolInformation {
|
||||
|
||||
private final SymbolInformation symbol;
|
||||
private final WorkspaceSymbol symbol;
|
||||
private final SymbolAddOnInformation[] additionalInformation;
|
||||
|
||||
public EnhancedSymbolInformation(SymbolInformation symbol, SymbolAddOnInformation[] additionalInformation) {
|
||||
public EnhancedSymbolInformation(WorkspaceSymbol symbol, SymbolAddOnInformation[] additionalInformation) {
|
||||
this.symbol = symbol;
|
||||
this.additionalInformation = additionalInformation;
|
||||
}
|
||||
|
||||
public SymbolInformation getSymbol() {
|
||||
public WorkspaceSymbol getSymbol() {
|
||||
return symbol;
|
||||
}
|
||||
|
||||
|
||||
@@ -16,8 +16,9 @@ import java.util.List;
|
||||
import org.eclipse.lsp4j.Location;
|
||||
import org.eclipse.lsp4j.Position;
|
||||
import org.eclipse.lsp4j.Range;
|
||||
import org.eclipse.lsp4j.SymbolInformation;
|
||||
import org.eclipse.lsp4j.SymbolKind;
|
||||
import org.eclipse.lsp4j.WorkspaceSymbol;
|
||||
import org.eclipse.lsp4j.jsonrpc.messages.Either;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.ide.vscode.boot.java.livehover.v2.LiveRequestMapping;
|
||||
@@ -37,8 +38,8 @@ public class LiveAppURLSymbolProvider {
|
||||
this.liveDataProvider = liveDataProvider;
|
||||
}
|
||||
|
||||
public List<? extends SymbolInformation> getSymbols(String query) {
|
||||
List<SymbolInformation> result = new ArrayList<>();
|
||||
public List<? extends WorkspaceSymbol> getSymbols(String query) {
|
||||
List<WorkspaceSymbol> result = new ArrayList<>();
|
||||
|
||||
try {
|
||||
SpringProcessLiveData[] liveData = liveDataProvider.getLatestLiveData();
|
||||
@@ -59,7 +60,7 @@ public class LiveAppURLSymbolProvider {
|
||||
}
|
||||
for (String path : paths) {
|
||||
String url = UrlUtil.createUrl(urlScheme, host, port, path, contextPath);
|
||||
result.add(new SymbolInformation(url, SymbolKind.Method, new Location(url, new Range(new Position(0, 0), new Position(0, 1)))));
|
||||
result.add(new WorkspaceSymbol(url, SymbolKind.Method, Either.forLeft(new Location(url, new Range(new Position(0, 0), new Position(0, 1))))));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,8 +11,9 @@
|
||||
package org.springframework.ide.vscode.boot.java.requestmapping;
|
||||
|
||||
import org.eclipse.lsp4j.Location;
|
||||
import org.eclipse.lsp4j.SymbolInformation;
|
||||
import org.eclipse.lsp4j.SymbolKind;
|
||||
import org.eclipse.lsp4j.WorkspaceSymbol;
|
||||
import org.eclipse.lsp4j.jsonrpc.messages.Either;
|
||||
import org.springframework.ide.vscode.boot.java.handlers.EnhancedSymbolInformation;
|
||||
import org.springframework.ide.vscode.boot.java.handlers.SymbolAddOnInformation;
|
||||
|
||||
@@ -34,7 +35,7 @@ public class RouteUtils {
|
||||
String contentType = WebfluxUtils.getStringRep(contentTypes, WebfluxUtils::getMediaType);
|
||||
label += contentType != null ? " - Content-Type: " + contentType : "";
|
||||
|
||||
return new EnhancedSymbolInformation(new SymbolInformation(label, SymbolKind.Interface, location), enhancedInformation);
|
||||
return new EnhancedSymbolInformation(new WorkspaceSymbol(label, SymbolKind.Interface, Either.forLeft(location)), enhancedInformation);
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
|
||||
@@ -12,8 +12,9 @@ package org.springframework.ide.vscode.boot.java.utils;
|
||||
|
||||
import org.eclipse.jdt.core.dom.Annotation;
|
||||
import org.eclipse.lsp4j.Location;
|
||||
import org.eclipse.lsp4j.SymbolInformation;
|
||||
import org.eclipse.lsp4j.SymbolKind;
|
||||
import org.eclipse.lsp4j.WorkspaceSymbol;
|
||||
import org.eclipse.lsp4j.jsonrpc.messages.Either;
|
||||
import org.springframework.ide.vscode.commons.util.text.TextDocument;
|
||||
|
||||
/**
|
||||
@@ -21,9 +22,9 @@ import org.springframework.ide.vscode.commons.util.text.TextDocument;
|
||||
*/
|
||||
public class DefaultSymbolProvider {
|
||||
|
||||
public static SymbolInformation provideDefaultSymbol(Annotation node, TextDocument doc) throws Exception {
|
||||
SymbolInformation symbol = new SymbolInformation(node.toString(), SymbolKind.Interface,
|
||||
new Location(doc.getUri(), doc.toRange(node.getStartPosition(), node.getLength())));
|
||||
public static WorkspaceSymbol provideDefaultSymbol(Annotation node, TextDocument doc) throws Exception {
|
||||
WorkspaceSymbol symbol = new WorkspaceSymbol(node.toString(), SymbolKind.Interface,
|
||||
Either.forLeft(new Location(doc.getUri(), doc.toRange(node.getStartPosition(), node.getLength()))));
|
||||
return symbol;
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ import org.eclipse.jdt.core.dom.MethodDeclaration;
|
||||
import org.eclipse.jdt.core.dom.NormalAnnotation;
|
||||
import org.eclipse.jdt.core.dom.SingleMemberAnnotation;
|
||||
import org.eclipse.jdt.core.dom.TypeDeclaration;
|
||||
import org.eclipse.lsp4j.SymbolInformation;
|
||||
import org.eclipse.lsp4j.WorkspaceSymbol;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.ide.vscode.boot.java.annotations.AnnotationHierarchies;
|
||||
@@ -513,7 +513,7 @@ public class SpringIndexerJava implements SpringIndexer {
|
||||
provider.addSymbols(node, typeBinding, metaAnnotations, context, doc);
|
||||
}
|
||||
} else {
|
||||
SymbolInformation symbol = provideDefaultSymbol(node, context);
|
||||
WorkspaceSymbol symbol = provideDefaultSymbol(node, context);
|
||||
if (symbol != null) {
|
||||
EnhancedSymbolInformation enhancedSymbol = new EnhancedSymbolInformation(symbol, null);
|
||||
context.getGeneratedSymbols().add(new CachedSymbol(context.getDocURI(), context.getLastModified(), enhancedSymbol));
|
||||
@@ -525,7 +525,7 @@ public class SpringIndexerJava implements SpringIndexer {
|
||||
}
|
||||
}
|
||||
|
||||
private SymbolInformation provideDefaultSymbol(Annotation node, final SpringIndexerJavaContext context) {
|
||||
private WorkspaceSymbol provideDefaultSymbol(Annotation node, final SpringIndexerJavaContext context) {
|
||||
try {
|
||||
ITypeBinding type = node.resolveTypeBinding();
|
||||
if (type != null) {
|
||||
|
||||
@@ -17,8 +17,9 @@ import org.eclipse.lemminx.dom.DOMNode;
|
||||
import org.eclipse.lsp4j.Location;
|
||||
import org.eclipse.lsp4j.Position;
|
||||
import org.eclipse.lsp4j.Range;
|
||||
import org.eclipse.lsp4j.SymbolInformation;
|
||||
import org.eclipse.lsp4j.SymbolKind;
|
||||
import org.eclipse.lsp4j.WorkspaceSymbol;
|
||||
import org.eclipse.lsp4j.jsonrpc.messages.Either;
|
||||
import org.springframework.ide.vscode.boot.java.beans.BeanUtils;
|
||||
import org.springframework.ide.vscode.boot.java.beans.BeansSymbolAddOnInformation;
|
||||
import org.springframework.ide.vscode.boot.java.handlers.EnhancedSymbolInformation;
|
||||
@@ -87,7 +88,7 @@ public class SpringIndexerXMLNamespaceHandlerBeans implements SpringIndexerXMLNa
|
||||
beanID = deriveBeanIDFromClass(beanClass);
|
||||
}
|
||||
|
||||
SymbolInformation symbol = new SymbolInformation("@+ '" + beanID + "' " + beanClass, SymbolKind.Interface, new Location(docURI, range));
|
||||
WorkspaceSymbol symbol = new WorkspaceSymbol("@+ '" + beanID + "' " + beanClass, SymbolKind.Interface, Either.forLeft(new Location(docURI, range)));
|
||||
SymbolAddOnInformation[] addon = new SymbolAddOnInformation[] {new BeansSymbolAddOnInformation(beanID)};
|
||||
|
||||
EnhancedSymbolInformation fullSymbol = new EnhancedSymbolInformation(symbol, addon);
|
||||
|
||||
@@ -17,7 +17,7 @@ import java.util.stream.Collectors;
|
||||
import org.eclipse.lemminx.dom.DOMAttr;
|
||||
import org.eclipse.lemminx.dom.DOMNode;
|
||||
import org.eclipse.lsp4j.Location;
|
||||
import org.eclipse.lsp4j.SymbolInformation;
|
||||
import org.eclipse.lsp4j.WorkspaceSymbol;
|
||||
import org.springframework.ide.vscode.boot.app.SpringSymbolIndex;
|
||||
import org.springframework.ide.vscode.boot.java.beans.BeansSymbolAddOnInformation;
|
||||
import org.springframework.ide.vscode.boot.java.handlers.EnhancedSymbolInformation;
|
||||
@@ -57,17 +57,24 @@ public class BeanRefHyperlinkProvider implements XMLHyperlinkProvider {
|
||||
projectLocation = projectLocation + "/";
|
||||
}
|
||||
|
||||
List<SymbolInformation> symbols = symbolIndex.getSymbols(data -> symbolsFilter(data, attributeAt.getValue())).collect(Collectors.toList());
|
||||
List<WorkspaceSymbol> symbols = symbolIndex.getSymbols(data -> symbolsFilter(data, attributeAt.getValue())).collect(Collectors.toList());
|
||||
if (!symbols.isEmpty()) {
|
||||
for (SymbolInformation symbol : symbols) {
|
||||
Location location = symbol.getLocation();
|
||||
String uri = location.getUri();
|
||||
|
||||
if (uri != null && uri.startsWith(projectLocation)) {
|
||||
return location;
|
||||
for (WorkspaceSymbol symbol : symbols) {
|
||||
if (symbol.getLocation().isLeft()) {
|
||||
Location location = symbol.getLocation().getLeft();
|
||||
String uri = location.getUri();
|
||||
|
||||
if (uri != null && uri.startsWith(projectLocation)) {
|
||||
return location;
|
||||
}
|
||||
}
|
||||
}
|
||||
// TODO: need better handling for the WorkspaceSymbolLocation case
|
||||
for (WorkspaceSymbol symbol : symbols) {
|
||||
if (symbol.getLocation().isLeft()) {
|
||||
return symbol.getLocation().getLeft();
|
||||
}
|
||||
}
|
||||
return symbols.get(0).getLocation();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
||||
@@ -21,7 +21,7 @@ import java.util.List;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.eclipse.lsp4j.Range;
|
||||
import org.eclipse.lsp4j.SymbolInformation;
|
||||
import org.eclipse.lsp4j.WorkspaceSymbol;
|
||||
import org.springframework.ide.vscode.boot.app.SpringSymbolIndex;
|
||||
import org.springframework.ide.vscode.commons.util.text.LanguageId;
|
||||
import org.springframework.ide.vscode.commons.util.text.TextDocument;
|
||||
@@ -82,14 +82,14 @@ public class SpringIndexerHarness {
|
||||
}
|
||||
|
||||
private static final Comparator<Range> RANGE_COMPARATOR = Editor.RANGE_COMPARATOR;
|
||||
private static final Comparator<SymbolInformation> SYMBOL_COMPARATOR = new Comparator<SymbolInformation>() {
|
||||
private static final Comparator<WorkspaceSymbol> SYMBOL_COMPARATOR = new Comparator<WorkspaceSymbol>() {
|
||||
|
||||
@Override
|
||||
public int compare(SymbolInformation o1, SymbolInformation o2) {
|
||||
int r = o1.getLocation().getUri().compareTo(o2.getLocation().getUri());
|
||||
public int compare(WorkspaceSymbol o1, WorkspaceSymbol o2) {
|
||||
int r = o1.getLocation().getLeft().getUri().compareTo(o2.getLocation().getLeft().getUri());
|
||||
if (r!=0) return r;
|
||||
|
||||
r = RANGE_COMPARATOR.compare(o1.getLocation().getRange(), o2.getLocation().getRange());
|
||||
r = RANGE_COMPARATOR.compare(o1.getLocation().getLeft().getRange(), o2.getLocation().getLeft().getRange());
|
||||
if (r!=0) return r;
|
||||
|
||||
return o1.getName().compareTo(o2.getName());
|
||||
@@ -115,15 +115,15 @@ public class SpringIndexerHarness {
|
||||
}
|
||||
|
||||
public static List<TestSymbolInfo> getSymbolsInFile(SpringSymbolIndex indexer, String docURI) throws Exception {
|
||||
List<? extends SymbolInformation> symbols = indexer.getSymbols(docURI);
|
||||
List<? extends WorkspaceSymbol> symbols = indexer.getSymbols(docURI);
|
||||
if (symbols!=null) {
|
||||
symbols = new ArrayList<>(symbols);
|
||||
Collections.sort(symbols, SYMBOL_COMPARATOR);
|
||||
TextDocument doc = new TextDocument(docURI, LanguageId.JAVA, 1, IOUtils.toString(new URI(docURI)));
|
||||
ImmutableList.Builder<TestSymbolInfo> symbolInfos = ImmutableList.builder();
|
||||
for (SymbolInformation s : symbols) {
|
||||
int start = doc.toOffset(s.getLocation().getRange().getStart());
|
||||
int end = doc.toOffset(s.getLocation().getRange().getEnd());
|
||||
for (WorkspaceSymbol s : symbols) {
|
||||
int start = doc.toOffset(s.getLocation().getLeft().getRange().getStart());
|
||||
int end = doc.toOffset(s.getLocation().getLeft().getRange().getEnd());
|
||||
symbolInfos.add(new TestSymbolInfo(doc.textBetween(start, end), s.getName()));
|
||||
}
|
||||
return symbolInfos.build();
|
||||
|
||||
@@ -19,8 +19,8 @@ import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.eclipse.lsp4j.SymbolInformation;
|
||||
import org.eclipse.lsp4j.TextDocumentIdentifier;
|
||||
import org.eclipse.lsp4j.WorkspaceSymbol;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -67,7 +67,7 @@ public class DataRepositorySymbolProviderTest {
|
||||
@Test
|
||||
public void testSimpleRepositorySymbol() throws Exception {
|
||||
String docUri = directory.toPath().resolve("src/main/java/org/test/CustomerRepository.java").toUri().toString();
|
||||
List<? extends SymbolInformation> symbols = indexer.getSymbols(docUri);
|
||||
List<? extends WorkspaceSymbol> symbols = indexer.getSymbols(docUri);
|
||||
assertEquals(1, symbols.size());
|
||||
assertTrue(containsSymbol(symbols, "@+ 'customerRepository' (Customer) Repository<Customer,Long>", docUri, 6, 17, 6, 35));
|
||||
|
||||
@@ -77,16 +77,16 @@ public class DataRepositorySymbolProviderTest {
|
||||
assertEquals("customerRepository", ((BeansSymbolAddOnInformation)addon.get(0)).getBeanID());
|
||||
}
|
||||
|
||||
private boolean containsSymbol(List<? extends SymbolInformation> symbols, String name, String uri, int startLine, int startCHaracter, int endLine, int endCharacter) {
|
||||
for (Iterator<? extends SymbolInformation> iterator = symbols.iterator(); iterator.hasNext();) {
|
||||
SymbolInformation symbol = iterator.next();
|
||||
private boolean containsSymbol(List<? extends WorkspaceSymbol> symbols, String name, String uri, int startLine, int startCHaracter, int endLine, int endCharacter) {
|
||||
for (Iterator<? extends WorkspaceSymbol> iterator = symbols.iterator(); iterator.hasNext();) {
|
||||
WorkspaceSymbol symbol = iterator.next();
|
||||
|
||||
if (symbol.getName().equals(name)
|
||||
&& symbol.getLocation().getUri().equals(uri)
|
||||
&& symbol.getLocation().getRange().getStart().getLine() == startLine
|
||||
&& symbol.getLocation().getRange().getStart().getCharacter() == startCHaracter
|
||||
&& symbol.getLocation().getRange().getEnd().getLine() == endLine
|
||||
&& symbol.getLocation().getRange().getEnd().getCharacter() == endCharacter) {
|
||||
&& symbol.getLocation().getLeft().getUri().equals(uri)
|
||||
&& symbol.getLocation().getLeft().getRange().getStart().getLine() == startLine
|
||||
&& symbol.getLocation().getLeft().getRange().getStart().getCharacter() == startCHaracter
|
||||
&& symbol.getLocation().getLeft().getRange().getEnd().getLine() == endLine
|
||||
&& symbol.getLocation().getLeft().getRange().getEnd().getCharacter() == endCharacter) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,8 +23,8 @@ import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.eclipse.lsp4j.Location;
|
||||
import org.eclipse.lsp4j.SymbolInformation;
|
||||
import org.eclipse.lsp4j.TextDocumentIdentifier;
|
||||
import org.eclipse.lsp4j.WorkspaceSymbol;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -81,7 +81,7 @@ public class RequestMappingDependentConstantChangedTest {
|
||||
public void testSimpleRequestMappingSymbolFromConstantInDifferentClass() throws Exception {
|
||||
String docUri = directory.resolve("src/main/java/org/test/SimpleMappingClassWithConstantInDifferentClass.java").toUri().toString();
|
||||
String constantsUri = directory.resolve("src/main/java/org/test/Constants.java").toUri().toString();
|
||||
List<? extends SymbolInformation> symbols = indexer.getSymbols(docUri);
|
||||
List<? extends WorkspaceSymbol> symbols = indexer.getSymbols(docUri);
|
||||
assertEquals(1, symbols.size());
|
||||
assertSymbol(docUri, "@/path/from/constant", "@RequestMapping(Constants.REQUEST_MAPPING_PATH)");
|
||||
|
||||
@@ -104,7 +104,7 @@ public class RequestMappingDependentConstantChangedTest {
|
||||
public void testSimpleRequestMappingSymbolFromConstantInDifferentClassViaMultipleFilesUpdate() throws Exception {
|
||||
String docUri = directory.resolve("src/main/java/org/test/SimpleMappingClassWithConstantInDifferentClass.java").toUri().toString();
|
||||
String constantsUri = directory.resolve("src/main/java/org/test/Constants.java").toUri().toString();
|
||||
List<? extends SymbolInformation> symbols = indexer.getSymbols(docUri);
|
||||
List<? extends WorkspaceSymbol> symbols = indexer.getSymbols(docUri);
|
||||
assertEquals(1, symbols.size());
|
||||
assertSymbol(docUri, "@/path/from/constant", "@RequestMapping(Constants.REQUEST_MAPPING_PATH)");
|
||||
|
||||
@@ -128,7 +128,7 @@ public class RequestMappingDependentConstantChangedTest {
|
||||
String docUri = directory.resolve("src/main/java/org/test/ChainedRequestMappingPathOverMultipleClasses.java").toUri().toString();
|
||||
String chainConstantsUri_2 = directory.resolve("src/main/java/org/test/ChainElement2.java").toUri().toString();
|
||||
|
||||
List<? extends SymbolInformation> symbols = indexer.getSymbols(docUri);
|
||||
List<? extends WorkspaceSymbol> symbols = indexer.getSymbols(docUri);
|
||||
assertEquals(1, symbols.size());
|
||||
assertSymbol(docUri, "@/path/from/chain", "@RequestMapping(ChainElement1.MAPPING_PATH_1)");
|
||||
|
||||
@@ -153,12 +153,12 @@ public class RequestMappingDependentConstantChangedTest {
|
||||
String pongUri = directory.resolve("src/main/java/org/test/PongConstantRequestMapping.java").toUri().toString();
|
||||
|
||||
{
|
||||
List<? extends SymbolInformation> symbols = indexer.getSymbols(pingUri);
|
||||
List<? extends WorkspaceSymbol> symbols = indexer.getSymbols(pingUri);
|
||||
assertSymbolCount(1, symbols);
|
||||
assertSymbol(pingUri, "@/pong -- GET", "@GetMapping(PongConstantRequestMapping.PONG)");
|
||||
}
|
||||
{
|
||||
List<? extends SymbolInformation> symbols = indexer.getSymbols(pongUri);
|
||||
List<? extends WorkspaceSymbol> symbols = indexer.getSymbols(pongUri);
|
||||
assertSymbolCount(1, symbols);
|
||||
assertSymbol(pongUri, "@/ping -- GET", "@GetMapping(PingConstantRequestMapping.PING)");
|
||||
}
|
||||
@@ -167,12 +167,12 @@ public class RequestMappingDependentConstantChangedTest {
|
||||
indexer.updateDocument(pingUri, null, "triggered by test code").get();
|
||||
|
||||
{
|
||||
List<? extends SymbolInformation> symbols = indexer.getSymbols(pingUri);
|
||||
List<? extends WorkspaceSymbol> symbols = indexer.getSymbols(pingUri);
|
||||
assertSymbolCount(1, symbols);
|
||||
assertSymbol(pingUri, "@/pong -- GET", "@GetMapping(PongConstantRequestMapping.PONG)");
|
||||
}
|
||||
{
|
||||
List<? extends SymbolInformation> symbols = indexer.getSymbols(pongUri);
|
||||
List<? extends WorkspaceSymbol> symbols = indexer.getSymbols(pongUri);
|
||||
assertSymbolCount(1, symbols);
|
||||
assertSymbol(pongUri, "@/changed -- GET", "@GetMapping(PingConstantRequestMapping.PING)");
|
||||
}
|
||||
@@ -186,12 +186,12 @@ public class RequestMappingDependentConstantChangedTest {
|
||||
String pongUri = directory.resolve("src/main/java/org/test/PongConstantRequestMapping.java").toUri().toString();
|
||||
|
||||
{
|
||||
List<? extends SymbolInformation> symbols = indexer.getSymbols(pingUri);
|
||||
List<? extends WorkspaceSymbol> symbols = indexer.getSymbols(pingUri);
|
||||
assertSymbolCount(1, symbols);
|
||||
assertSymbol(pingUri, "@/pong -- GET", "@GetMapping(PongConstantRequestMapping.PONG)");
|
||||
}
|
||||
{
|
||||
List<? extends SymbolInformation> symbols = indexer.getSymbols(pongUri);
|
||||
List<? extends WorkspaceSymbol> symbols = indexer.getSymbols(pongUri);
|
||||
assertSymbolCount(1, symbols);
|
||||
assertSymbol(pongUri, "@/ping -- GET", "@GetMapping(PingConstantRequestMapping.PING)");
|
||||
}
|
||||
@@ -200,12 +200,12 @@ public class RequestMappingDependentConstantChangedTest {
|
||||
indexer.updateDocuments(new String[] {pingUri}, "triggered by test code").get();
|
||||
|
||||
{
|
||||
List<? extends SymbolInformation> symbols = indexer.getSymbols(pingUri);
|
||||
List<? extends WorkspaceSymbol> symbols = indexer.getSymbols(pingUri);
|
||||
assertSymbolCount(1, symbols);
|
||||
assertSymbol(pingUri, "@/pong -- GET", "@GetMapping(PongConstantRequestMapping.PONG)");
|
||||
}
|
||||
{
|
||||
List<? extends SymbolInformation> symbols = indexer.getSymbols(pongUri);
|
||||
List<? extends WorkspaceSymbol> symbols = indexer.getSymbols(pongUri);
|
||||
assertSymbolCount(1, symbols);
|
||||
assertSymbol(pongUri, "@/changed -- GET", "@GetMapping(PingConstantRequestMapping.PING)");
|
||||
}
|
||||
@@ -213,10 +213,10 @@ public class RequestMappingDependentConstantChangedTest {
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
private void assertSymbolCount(int expectedCount, List<? extends SymbolInformation> symbols) {
|
||||
private void assertSymbolCount(int expectedCount, List<? extends WorkspaceSymbol> symbols) {
|
||||
if (symbols.size()!=expectedCount) {
|
||||
StringBuilder found = new StringBuilder();
|
||||
for (SymbolInformation s : symbols) {
|
||||
for (WorkspaceSymbol s : symbols) {
|
||||
found.append(s.getName());
|
||||
found.append("\n");
|
||||
}
|
||||
@@ -225,15 +225,15 @@ public class RequestMappingDependentConstantChangedTest {
|
||||
}
|
||||
|
||||
private void assertSymbol(String docUri, String name, String coveredText) throws Exception {
|
||||
List<? extends SymbolInformation> symbols = indexer.getSymbols(docUri);
|
||||
Optional<? extends SymbolInformation> maybeSymbol = symbols.stream().filter(s -> name.equals(s.getName())).findFirst();
|
||||
List<? extends WorkspaceSymbol> symbols = indexer.getSymbols(docUri);
|
||||
Optional<? extends WorkspaceSymbol> maybeSymbol = symbols.stream().filter(s -> name.equals(s.getName())).findFirst();
|
||||
assertTrue(maybeSymbol.isPresent());
|
||||
|
||||
TextDocument doc = new TextDocument(docUri, LanguageId.JAVA);
|
||||
doc.setText(FileUtils.readFileToString(UriUtil.toFile(docUri)));
|
||||
|
||||
SymbolInformation symbol = maybeSymbol.get();
|
||||
Location loc = symbol.getLocation();
|
||||
WorkspaceSymbol symbol = maybeSymbol.get();
|
||||
Location loc = symbol.getLocation().getLeft();
|
||||
assertEquals(docUri, loc.getUri());
|
||||
int start = doc.toOffset(loc.getRange().getStart());
|
||||
int end = doc.toOffset(loc.getRange().getEnd());
|
||||
|
||||
@@ -22,8 +22,8 @@ import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.eclipse.lsp4j.Location;
|
||||
import org.eclipse.lsp4j.SymbolInformation;
|
||||
import org.eclipse.lsp4j.TextDocumentIdentifier;
|
||||
import org.eclipse.lsp4j.WorkspaceSymbol;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -75,7 +75,7 @@ public class RequestMappingSymbolProviderTest {
|
||||
@Test
|
||||
public void testSimpleRequestMappingSymbol() throws Exception {
|
||||
String docUri = directory.toPath().resolve("src/main/java/org/test/SimpleMappingClass.java").toUri().toString();
|
||||
List<? extends SymbolInformation> symbols = indexer.getSymbols(docUri);
|
||||
List<? extends WorkspaceSymbol> symbols = indexer.getSymbols(docUri);
|
||||
assertEquals(1, symbols.size());
|
||||
assertTrue(containsSymbol(symbols, "@/greeting", docUri, 6, 1, 6, 29));
|
||||
}
|
||||
@@ -84,7 +84,7 @@ public class RequestMappingSymbolProviderTest {
|
||||
public void testSimpleRequestMappingSymbolFromConstantInDifferentClass() throws Exception {
|
||||
String docUri = directory.toPath().resolve("src/main/java/org/test/SimpleMappingClassWithConstantInDifferentClass.java").toUri().toString();
|
||||
String constantsUri = directory.toPath().resolve("src/main/java/org/test/Constants.java").toUri().toString();
|
||||
List<? extends SymbolInformation> symbols = indexer.getSymbols(docUri);
|
||||
List<? extends WorkspaceSymbol> symbols = indexer.getSymbols(docUri);
|
||||
assertEquals(1, symbols.size());
|
||||
assertTrue(containsSymbol(symbols, "@/path/from/constant", docUri, 6, 1, 6, 48));
|
||||
|
||||
@@ -107,7 +107,7 @@ public class RequestMappingSymbolProviderTest {
|
||||
public void testUpdateDocumentWithConstantFromDifferentClass() throws Exception {
|
||||
String docUri = directory.toPath().resolve("src/main/java/org/test/SimpleMappingClassWithConstantInDifferentClass.java").toUri().toString();
|
||||
String constantsUri = directory.toPath().resolve("src/main/java/org/test/Constants.java").toUri().toString();
|
||||
List<? extends SymbolInformation> symbols = indexer.getSymbols(docUri);
|
||||
List<? extends WorkspaceSymbol> symbols = indexer.getSymbols(docUri);
|
||||
assertEquals(1, symbols.size());
|
||||
assertTrue(containsSymbol(symbols, "@/path/from/constant", docUri, 6, 1, 6, 48));
|
||||
|
||||
@@ -160,7 +160,7 @@ public class RequestMappingSymbolProviderTest {
|
||||
@Test
|
||||
public void testSimpleRequestMappingSymbolFromConstantInSameClass() throws Exception {
|
||||
String docUri = directory.toPath().resolve("src/main/java/org/test/SimpleMappingClassWithConstantInSameClass.java").toUri().toString();
|
||||
List<? extends SymbolInformation> symbols = indexer.getSymbols(docUri);
|
||||
List<? extends WorkspaceSymbol> symbols = indexer.getSymbols(docUri);
|
||||
assertEquals(1, symbols.size());
|
||||
assertTrue(containsSymbol(symbols, "@/request/mapping/path/from/same/class/constant", docUri, 8, 1, 8, 52));
|
||||
|
||||
@@ -171,7 +171,7 @@ public class RequestMappingSymbolProviderTest {
|
||||
@Test
|
||||
public void testSimpleRequestMappingSymbolFromConstantInBinaryType() throws Exception {
|
||||
String docUri = directory.toPath().resolve("src/main/java/org/test/SimpleMappingClassWithConstantFromBinaryType.java").toUri().toString();
|
||||
List<? extends SymbolInformation> symbols = indexer.getSymbols(docUri);
|
||||
List<? extends WorkspaceSymbol> symbols = indexer.getSymbols(docUri);
|
||||
assertEquals(1, symbols.size());
|
||||
assertTrue(containsSymbol(symbols, "@/(inferred)", docUri, 7, 1, 7, 53));
|
||||
|
||||
@@ -182,7 +182,7 @@ public class RequestMappingSymbolProviderTest {
|
||||
@Test
|
||||
public void testParentRequestMappingSymbol() throws Exception {
|
||||
String docUri = directory.toPath().resolve("src/main/java/org/test/ParentMappingClass.java").toUri().toString();
|
||||
List<? extends SymbolInformation> symbols = indexer.getSymbols(docUri);
|
||||
List<? extends WorkspaceSymbol> symbols = indexer.getSymbols(docUri);
|
||||
assertEquals(1, symbols.size());
|
||||
assertTrue(containsSymbol(symbols, "@/parent/greeting -- GET", docUri, 8, 1, 8, 47));
|
||||
}
|
||||
@@ -190,7 +190,7 @@ public class RequestMappingSymbolProviderTest {
|
||||
@Test
|
||||
public void testEmptyPathWithParentRequestMappingSymbol() throws Exception {
|
||||
String docUri = directory.toPath().resolve("src/main/java/org/test/ParentMappingClass2.java").toUri().toString();
|
||||
List<? extends SymbolInformation> symbols = indexer.getSymbols(docUri);
|
||||
List<? extends WorkspaceSymbol> symbols = indexer.getSymbols(docUri);
|
||||
assertEquals(1, symbols.size());
|
||||
assertTrue(containsSymbol(symbols, "@/parent2 -- GET,POST,DELETE", docUri, 8, 1, 8, 16));
|
||||
}
|
||||
@@ -198,7 +198,7 @@ public class RequestMappingSymbolProviderTest {
|
||||
@Test
|
||||
public void testMultiRequestMappingSymbol() throws Exception {
|
||||
String docUri = directory.toPath().resolve("src/main/java/org/test/MultiRequestMappingClass.java").toUri().toString();
|
||||
List<? extends SymbolInformation> symbols = indexer.getSymbols(docUri);
|
||||
List<? extends WorkspaceSymbol> symbols = indexer.getSymbols(docUri);
|
||||
assertEquals(2, symbols.size());
|
||||
assertTrue(containsSymbol(symbols, "@/hello1", docUri, 6, 1, 6, 44));
|
||||
assertTrue(containsSymbol(symbols, "@/hello2", docUri, 6, 1, 6, 44));
|
||||
@@ -207,70 +207,70 @@ public class RequestMappingSymbolProviderTest {
|
||||
@Test
|
||||
public void testGetMappingSymbol() throws Exception {
|
||||
String docUri = directory.toPath().resolve("src/main/java/org/test/RequestMethodClass.java").toUri().toString();
|
||||
List<? extends SymbolInformation> symbols = indexer.getSymbols(docUri);
|
||||
List<? extends WorkspaceSymbol> symbols = indexer.getSymbols(docUri);
|
||||
assertTrue(containsSymbol(symbols, "@/getData -- GET", docUri, 12, 1, 12, 24));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetMappingSymbolWithoutPath() throws Exception {
|
||||
String docUri = directory.toPath().resolve("src/main/java/org/test/RequestMethodClass.java").toUri().toString();
|
||||
List<? extends SymbolInformation> symbols = indexer.getSymbols(docUri);
|
||||
List<? extends WorkspaceSymbol> symbols = indexer.getSymbols(docUri);
|
||||
assertTrue(containsSymbol(symbols, "@/ -- GET", docUri, 40, 1, 40, 16));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetMappingSymbolWithoutAnything() throws Exception {
|
||||
String docUri = directory.toPath().resolve("src/main/java/org/test/RequestMethodClass.java").toUri().toString();
|
||||
List<? extends SymbolInformation> symbols = indexer.getSymbols(docUri);
|
||||
List<? extends WorkspaceSymbol> symbols = indexer.getSymbols(docUri);
|
||||
assertTrue(containsSymbol(symbols, "@/ -- GET", docUri, 44, 1, 44, 14));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeleteMappingSymbol() throws Exception {
|
||||
String docUri = directory.toPath().resolve("src/main/java/org/test/RequestMethodClass.java").toUri().toString();
|
||||
List<? extends SymbolInformation> symbols = indexer.getSymbols(docUri);
|
||||
List<? extends WorkspaceSymbol> symbols = indexer.getSymbols(docUri);
|
||||
assertTrue(containsSymbol(symbols, "@/deleteData -- DELETE",docUri, 20, 1, 20, 30));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPostMappingSymbol() throws Exception {
|
||||
String docUri = directory.toPath().resolve("src/main/java/org/test/RequestMethodClass.java").toUri().toString();
|
||||
List<? extends SymbolInformation> symbols = indexer.getSymbols(docUri);
|
||||
List<? extends WorkspaceSymbol> symbols = indexer.getSymbols(docUri);
|
||||
assertTrue(containsSymbol(symbols, "@/postData -- POST", docUri, 24, 1, 24, 26));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPutMappingSymbol() throws Exception {
|
||||
String docUri = directory.toPath().resolve("src/main/java/org/test/RequestMethodClass.java").toUri().toString();
|
||||
List<? extends SymbolInformation> symbols = indexer.getSymbols(docUri);
|
||||
List<? extends WorkspaceSymbol> symbols = indexer.getSymbols(docUri);
|
||||
assertTrue(containsSymbol(symbols, "@/putData -- PUT", docUri, 16, 1, 16, 24));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPatchMappingSymbol() throws Exception {
|
||||
String docUri = directory.toPath().resolve("src/main/java/org/test/RequestMethodClass.java").toUri().toString();
|
||||
List<? extends SymbolInformation> symbols = indexer.getSymbols(docUri);
|
||||
List<? extends WorkspaceSymbol> symbols = indexer.getSymbols(docUri);
|
||||
assertTrue(containsSymbol(symbols, "@/patchData -- PATCH", docUri, 28, 1, 28, 28));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetRequestMappingSymbol() throws Exception {
|
||||
String docUri = directory.toPath().resolve("src/main/java/org/test/RequestMethodClass.java").toUri().toString();
|
||||
List<? extends SymbolInformation> symbols = indexer.getSymbols(docUri);
|
||||
List<? extends WorkspaceSymbol> symbols = indexer.getSymbols(docUri);
|
||||
assertTrue(containsSymbol(symbols, "@/getHello -- GET", docUri, 32, 1, 32, 61));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMultiRequestMethodMappingSymbol() throws Exception {
|
||||
String docUri = directory.toPath().resolve("src/main/java/org/test/RequestMethodClass.java").toUri().toString();
|
||||
List<? extends SymbolInformation> symbols = indexer.getSymbols(docUri);
|
||||
List<? extends WorkspaceSymbol> symbols = indexer.getSymbols(docUri);
|
||||
assertTrue(containsSymbol(symbols, "@/postAndPutHello -- POST,PUT", docUri, 36, 1, 36, 76));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMediaTypes() throws Exception {
|
||||
String docUri = directory.toPath().resolve("src/main/java/org/test/RequestMappingMediaTypes.java").toUri().toString();
|
||||
List<? extends SymbolInformation> symbols = indexer.getSymbols(docUri);
|
||||
List<? extends WorkspaceSymbol> symbols = indexer.getSymbols(docUri);
|
||||
assertEquals(7, symbols.size());
|
||||
assertTrue(containsSymbol(symbols, "@/consume1 -- HEAD - Accept: testconsume", docUri, 8, 1, 8, 90));
|
||||
assertTrue(containsSymbol(symbols, "@/consume2 - Accept: text/plain", docUri, 13, 1, 13, 73));
|
||||
@@ -281,16 +281,16 @@ public class RequestMappingSymbolProviderTest {
|
||||
assertTrue(containsSymbol(symbols, "@/everything - Accept: application/json,text/plain,testconsume - Content-Type: application/json", docUri, 38, 1, 38, 170));
|
||||
}
|
||||
|
||||
private boolean containsSymbol(List<? extends SymbolInformation> symbols, String name, String uri, int startLine, int startCHaracter, int endLine, int endCharacter) {
|
||||
for (Iterator<? extends SymbolInformation> iterator = symbols.iterator(); iterator.hasNext();) {
|
||||
SymbolInformation symbol = iterator.next();
|
||||
private boolean containsSymbol(List<? extends WorkspaceSymbol> symbols, String name, String uri, int startLine, int startCHaracter, int endLine, int endCharacter) {
|
||||
for (Iterator<? extends WorkspaceSymbol> iterator = symbols.iterator(); iterator.hasNext();) {
|
||||
WorkspaceSymbol symbol = iterator.next();
|
||||
|
||||
if (symbol.getName().equals(name)
|
||||
&& symbol.getLocation().getUri().equals(uri)
|
||||
&& symbol.getLocation().getRange().getStart().getLine() == startLine
|
||||
&& symbol.getLocation().getRange().getStart().getCharacter() == startCHaracter
|
||||
&& symbol.getLocation().getRange().getEnd().getLine() == endLine
|
||||
&& symbol.getLocation().getRange().getEnd().getCharacter() == endCharacter) {
|
||||
&& symbol.getLocation().getLeft().getUri().equals(uri)
|
||||
&& symbol.getLocation().getLeft().getRange().getStart().getLine() == startLine
|
||||
&& symbol.getLocation().getLeft().getRange().getStart().getCharacter() == startCHaracter
|
||||
&& symbol.getLocation().getLeft().getRange().getEnd().getLine() == endLine
|
||||
&& symbol.getLocation().getLeft().getRange().getEnd().getCharacter() == endCharacter) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -299,15 +299,15 @@ public class RequestMappingSymbolProviderTest {
|
||||
}
|
||||
|
||||
private void assertSymbol(String docUri, String name, String coveredText) throws Exception {
|
||||
List<? extends SymbolInformation> symbols = indexer.getSymbols(docUri);
|
||||
Optional<? extends SymbolInformation> maybeSymbol = symbols.stream().filter(s -> name.equals(s.getName())).findFirst();
|
||||
List<? extends WorkspaceSymbol> symbols = indexer.getSymbols(docUri);
|
||||
Optional<? extends WorkspaceSymbol> maybeSymbol = symbols.stream().filter(s -> name.equals(s.getName())).findFirst();
|
||||
assertTrue(maybeSymbol.isPresent());
|
||||
|
||||
TextDocument doc = new TextDocument(docUri, LanguageId.JAVA);
|
||||
doc.setText(FileUtils.readFileToString(UriUtil.toFile(docUri)));
|
||||
|
||||
SymbolInformation symbol = maybeSymbol.get();
|
||||
Location loc = symbol.getLocation();
|
||||
WorkspaceSymbol symbol = maybeSymbol.get();
|
||||
Location loc = symbol.getLocation().getLeft();
|
||||
assertEquals(docUri, loc.getUri());
|
||||
int start = doc.toOffset(loc.getRange().getStart());
|
||||
int end = doc.toOffset(loc.getRange().getEnd());
|
||||
|
||||
@@ -21,8 +21,8 @@ import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.eclipse.lsp4j.SymbolInformation;
|
||||
import org.eclipse.lsp4j.TextDocumentIdentifier;
|
||||
import org.eclipse.lsp4j.WorkspaceSymbol;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -35,7 +35,6 @@ import org.springframework.ide.vscode.boot.java.beans.BeansSymbolAddOnInformatio
|
||||
import org.springframework.ide.vscode.boot.java.handlers.SymbolAddOnInformation;
|
||||
import org.springframework.ide.vscode.boot.java.requestmapping.WebfluxHandlerInformation;
|
||||
import org.springframework.ide.vscode.commons.languageserver.java.JavaProjectFinder;
|
||||
import org.springframework.ide.vscode.commons.util.Assert;
|
||||
import org.springframework.ide.vscode.project.harness.BootLanguageServerHarness;
|
||||
import org.springframework.ide.vscode.project.harness.ProjectsHarness;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
@@ -75,7 +74,7 @@ public class WebFluxMappingSymbolProviderTest {
|
||||
@Test
|
||||
public void testSimpleRequestMappingSymbol() throws Exception {
|
||||
String docUri = directory.toPath().resolve("src/main/java/org/test/UserController.java").toUri().toString();
|
||||
List<? extends SymbolInformation> symbols = indexer.getSymbols(docUri);
|
||||
List<? extends WorkspaceSymbol> symbols = indexer.getSymbols(docUri);
|
||||
assertEquals(4, symbols.size());
|
||||
assertTrue(containsSymbol(symbols, "@/users -- GET - Content-Type: application/json", docUri, 13, 1, 13, 74));
|
||||
assertTrue(containsSymbol(symbols, "@/users/{username} -- GET - Content-Type: application/json", docUri, 18, 1, 18, 85));
|
||||
@@ -88,7 +87,7 @@ public class WebFluxMappingSymbolProviderTest {
|
||||
@Test
|
||||
public void testRoutesMappingSymbols() throws Exception {
|
||||
String docUri = directory.toPath().resolve("src/main/java/org/test/QuoteRouter.java").toUri().toString();
|
||||
List<? extends SymbolInformation> symbols = indexer.getSymbols(docUri);
|
||||
List<? extends WorkspaceSymbol> symbols = indexer.getSymbols(docUri);
|
||||
assertEquals(6, symbols.size());
|
||||
assertTrue(containsSymbol(symbols, "@/hello -- GET - Accept: text/plain", docUri, 22, 5, 22, 70));
|
||||
assertTrue(containsSymbol(symbols, "@/echo -- POST - Accept: text/plain - Content-Type: text/plain", docUri, 23, 5, 23, 101));
|
||||
@@ -134,7 +133,7 @@ public class WebFluxMappingSymbolProviderTest {
|
||||
@Test
|
||||
public void testNestedRoutesMappingSymbols1() throws Exception {
|
||||
String docUri = directory.toPath().resolve("src/main/java/org/test/NestedRouter1.java").toUri().toString();
|
||||
List<? extends SymbolInformation> symbols = indexer.getSymbols(docUri);
|
||||
List<? extends WorkspaceSymbol> symbols = indexer.getSymbols(docUri);
|
||||
assertEquals(5, symbols.size());
|
||||
assertTrue(containsSymbol(symbols, "@/person/{id} -- GET - Accept: application/json", docUri, 27, 6, 27, 45));
|
||||
assertTrue(containsSymbol(symbols, "@/person/ -- POST - Content-Type: application/json", docUri, 29, 6, 29, 83));
|
||||
@@ -171,7 +170,7 @@ public class WebFluxMappingSymbolProviderTest {
|
||||
@Test
|
||||
public void testNestedRoutesMappingSymbols2() throws Exception {
|
||||
String docUri = directory.toPath().resolve("src/main/java/org/test/NestedRouter2.java").toUri().toString();
|
||||
List<? extends SymbolInformation> symbols = indexer.getSymbols(docUri);
|
||||
List<? extends WorkspaceSymbol> symbols = indexer.getSymbols(docUri);
|
||||
assertEquals(5, symbols.size());
|
||||
assertTrue(containsSymbol(symbols, "@/person/{id} -- GET - Accept: application/json", docUri, 29, 6, 29, 45));
|
||||
assertTrue(containsSymbol(symbols, "@/ -- POST - Accept: application/json - Content-Type: application/json,application/pdf", docUri, 31, 6, 31, 117));
|
||||
@@ -208,7 +207,7 @@ public class WebFluxMappingSymbolProviderTest {
|
||||
@Test
|
||||
public void testNestedRoutesMappingSymbols3() throws Exception {
|
||||
String docUri = directory.toPath().resolve("src/main/java/org/test/NestedRouter3.java").toUri().toString();
|
||||
List<? extends SymbolInformation> symbols = indexer.getSymbols(docUri);
|
||||
List<? extends WorkspaceSymbol> symbols = indexer.getSymbols(docUri);
|
||||
assertEquals(8, symbols.size());
|
||||
|
||||
assertTrue(containsSymbol(symbols, "@/person/sub1/sub2/{id} -- GET - Accept: application/json", docUri, 29, 7, 29, 46));
|
||||
@@ -270,16 +269,16 @@ public class WebFluxMappingSymbolProviderTest {
|
||||
assertEquals("public Mono<org.springframework.web.reactive.function.server.ServerResponse> deletePerson(org.springframework.web.reactive.function.server.ServerRequest)", handlerInfo6.getHandlerMethod());
|
||||
}
|
||||
|
||||
private boolean containsSymbol(List<? extends SymbolInformation> symbols, String name, String uri, int startLine, int startCHaracter, int endLine, int endCharacter) {
|
||||
for (Iterator<? extends SymbolInformation> iterator = symbols.iterator(); iterator.hasNext();) {
|
||||
SymbolInformation symbol = iterator.next();
|
||||
private boolean containsSymbol(List<? extends WorkspaceSymbol> symbols, String name, String uri, int startLine, int startCHaracter, int endLine, int endCharacter) {
|
||||
for (Iterator<? extends WorkspaceSymbol> iterator = symbols.iterator(); iterator.hasNext();) {
|
||||
WorkspaceSymbol symbol = iterator.next();
|
||||
|
||||
if (symbol.getName().equals(name)
|
||||
&& symbol.getLocation().getUri().equals(uri)
|
||||
&& symbol.getLocation().getRange().getStart().getLine() == startLine
|
||||
&& symbol.getLocation().getRange().getStart().getCharacter() == startCHaracter
|
||||
&& symbol.getLocation().getRange().getEnd().getLine() == endLine
|
||||
&& symbol.getLocation().getRange().getEnd().getCharacter() == endCharacter) {
|
||||
&& symbol.getLocation().getLeft().getUri().equals(uri)
|
||||
&& symbol.getLocation().getLeft().getRange().getStart().getLine() == startLine
|
||||
&& symbol.getLocation().getLeft().getRange().getStart().getCharacter() == startCHaracter
|
||||
&& symbol.getLocation().getLeft().getRange().getEnd().getLine() == endLine
|
||||
&& symbol.getLocation().getLeft().getRange().getEnd().getCharacter() == endCharacter) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,8 +18,8 @@ import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.eclipse.lsp4j.SymbolInformation;
|
||||
import org.eclipse.lsp4j.TextDocumentIdentifier;
|
||||
import org.eclipse.lsp4j.WorkspaceSymbol;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -67,23 +67,23 @@ public class SpringIndexerMultiProjectTest {
|
||||
|
||||
@Test
|
||||
public void testQueryingAllSymbolsWithRegularLimit() throws Exception {
|
||||
List<? extends SymbolInformation> symbols = indexer.getAllSymbols("");
|
||||
List<? extends WorkspaceSymbol> symbols = indexer.getAllSymbols("");
|
||||
assertEquals(50, symbols.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testQueryingAllSymbolsWithNoLimit() throws Exception {
|
||||
List<? extends SymbolInformation> symbols = indexer.getAllSymbols("*");
|
||||
List<? extends WorkspaceSymbol> symbols = indexer.getAllSymbols("*");
|
||||
assertEquals(220, symbols.size());
|
||||
|
||||
int count1 = 0;
|
||||
int count2 = 0;
|
||||
|
||||
for (SymbolInformation symbol : symbols) {
|
||||
if (symbol.getLocation().getUri().startsWith(projectUri1)) {
|
||||
for (WorkspaceSymbol symbol : symbols) {
|
||||
if (symbol.getLocation().getLeft().getUri().startsWith(projectUri1)) {
|
||||
count1++;
|
||||
}
|
||||
else if (symbol.getLocation().getUri().startsWith(projectUri2)) {
|
||||
else if (symbol.getLocation().getLeft().getUri().startsWith(projectUri2)) {
|
||||
count2++;
|
||||
}
|
||||
}
|
||||
@@ -94,31 +94,31 @@ public class SpringIndexerMultiProjectTest {
|
||||
|
||||
@Test
|
||||
public void testQueryingSymbolsForSpecificProjectWithRegularLimit() throws Exception {
|
||||
List<? extends SymbolInformation> symbols = indexer.getAllSymbols("locationPrefix:" + projectUri2);
|
||||
List<? extends WorkspaceSymbol> symbols = indexer.getAllSymbols("locationPrefix:" + projectUri2);
|
||||
assertEquals(50, symbols.size());
|
||||
|
||||
for (SymbolInformation symbol : symbols) {
|
||||
assertTrue(symbol.getLocation().getUri().startsWith(projectUri2));
|
||||
for (WorkspaceSymbol symbol : symbols) {
|
||||
assertTrue(symbol.getLocation().getLeft().getUri().startsWith(projectUri2));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testQueryingSymbolsForSpecificProjectWithNoLimit() throws Exception {
|
||||
List<? extends SymbolInformation> symbols = indexer.getAllSymbols("locationPrefix:" + projectUri2 + "?*");
|
||||
List<? extends WorkspaceSymbol> symbols = indexer.getAllSymbols("locationPrefix:" + projectUri2 + "?*");
|
||||
assertEquals(110, symbols.size());
|
||||
|
||||
for (SymbolInformation symbol : symbols) {
|
||||
assertTrue(symbol.getLocation().getUri().startsWith(projectUri2));
|
||||
for (WorkspaceSymbol symbol : symbols) {
|
||||
assertTrue(symbol.getLocation().getLeft().getUri().startsWith(projectUri2));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testQueryingSymbolsForSpecificProjectWithQuery() throws Exception {
|
||||
List<? extends SymbolInformation> symbols = indexer.getAllSymbols("locationPrefix:" + projectUri2 + "?seventhWowSuperBean");
|
||||
List<? extends WorkspaceSymbol> symbols = indexer.getAllSymbols("locationPrefix:" + projectUri2 + "?seventhWowSuperBean");
|
||||
assertEquals(10, symbols.size());
|
||||
|
||||
for (SymbolInformation symbol : symbols) {
|
||||
assertTrue(symbol.getLocation().getUri().startsWith(projectUri2));
|
||||
for (WorkspaceSymbol symbol : symbols) {
|
||||
assertTrue(symbol.getLocation().getLeft().getUri().startsWith(projectUri2));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,14 +17,13 @@ import java.io.File;
|
||||
import java.net.URI;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.attribute.FileTime;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.eclipse.lsp4j.SymbolInformation;
|
||||
import org.eclipse.lsp4j.TextDocumentIdentifier;
|
||||
import org.eclipse.lsp4j.WorkspaceSymbol;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -90,8 +89,8 @@ public class SpringIndexerMultipleFilesTest {
|
||||
|
||||
try {
|
||||
// update document and update index
|
||||
List<? extends SymbolInformation> symbols = indexer.getSymbols(changedDocURI);
|
||||
assertTrue(containsSymbol(symbols, "@/mapping1", changedDocURI));
|
||||
List<? extends WorkspaceSymbol> symbols = indexer.getSymbols(changedDocURI);
|
||||
assertTrue(SpringIndexerTest.containsSymbol(symbols, "@/mapping1", changedDocURI));
|
||||
|
||||
String newContent = originalContent.replace("mapping1", "mapping1-CHANGED");
|
||||
FileUtils.writeStringToFile(new File(new URI(changedDocURI)), newContent);
|
||||
@@ -106,8 +105,8 @@ public class SpringIndexerMultipleFilesTest {
|
||||
// check for updated index per document
|
||||
symbols = indexer.getSymbols(changedDocURI);
|
||||
assertEquals(2, symbols.size());
|
||||
assertTrue(containsSymbol(symbols, "@/mapping1-CHANGED", changedDocURI, 6, 1, 6, 36));
|
||||
assertTrue(containsSymbol(symbols, "@/mapping2", changedDocURI, 11, 1, 11, 28));
|
||||
assertTrue(SpringIndexerTest.containsSymbol(symbols, "@/mapping1-CHANGED", changedDocURI, 6, 1, 6, 36));
|
||||
assertTrue(SpringIndexerTest.containsSymbol(symbols, "@/mapping2", changedDocURI, 11, 1, 11, 28));
|
||||
|
||||
fileScanListener.assertScannedUris(changedDocURI);
|
||||
fileScanListener.assertScannedUri(changedDocURI, 1);
|
||||
@@ -152,18 +151,18 @@ public class SpringIndexerMultipleFilesTest {
|
||||
updateFuture.get(5, TimeUnit.SECONDS);
|
||||
|
||||
// check for updated index per document
|
||||
List<? extends SymbolInformation> symbols1 = indexer.getSymbols(doc1URI);
|
||||
List<? extends WorkspaceSymbol> symbols1 = indexer.getSymbols(doc1URI);
|
||||
assertEquals(2, symbols1.size());
|
||||
assertTrue(containsSymbol(symbols1, "@/mapping1-CHANGED", doc1URI, 6, 1, 6, 36));
|
||||
assertTrue(containsSymbol(symbols1, "@/mapping2", doc1URI, 11, 1, 11, 28));
|
||||
assertTrue(SpringIndexerTest.containsSymbol(symbols1, "@/mapping1-CHANGED", doc1URI, 6, 1, 6, 36));
|
||||
assertTrue(SpringIndexerTest.containsSymbol(symbols1, "@/mapping2", doc1URI, 11, 1, 11, 28));
|
||||
|
||||
List<? extends SymbolInformation> symbols2 = indexer.getSymbols(doc2URI);
|
||||
assertTrue(containsSymbol(symbols2, "@+ 'mainClass' (@SpringBootApplication <: @SpringBootConfiguration, @Configuration, @Component) MainClass", doc2URI, 6, 0, 6, 22));
|
||||
assertTrue(containsSymbol(symbols2, "@/embedded-foo-mapping-CHANGED", doc2URI, 17, 1, 17, 49));
|
||||
assertTrue(containsSymbol(symbols2, "@/foo-root-mapping/embedded-foo-mapping-with-root", doc2URI, 27, 1, 27, 51));
|
||||
List<? extends WorkspaceSymbol> symbols2 = indexer.getSymbols(doc2URI);
|
||||
assertTrue(SpringIndexerTest.containsSymbol(symbols2, "@+ 'mainClass' (@SpringBootApplication <: @SpringBootConfiguration, @Configuration, @Component) MainClass", doc2URI, 6, 0, 6, 22));
|
||||
assertTrue(SpringIndexerTest.containsSymbol(symbols2, "@/embedded-foo-mapping-CHANGED", doc2URI, 17, 1, 17, 49));
|
||||
assertTrue(SpringIndexerTest.containsSymbol(symbols2, "@/foo-root-mapping/embedded-foo-mapping-with-root", doc2URI, 27, 1, 27, 51));
|
||||
|
||||
List<? extends SymbolInformation> symbols3 = indexer.getSymbols(doc3URI);
|
||||
assertTrue(containsSymbol(symbols3, "@/classlevel-CHANGED/mapping-subpackage", doc3URI, 7, 1, 7, 38));
|
||||
List<? extends WorkspaceSymbol> symbols3 = indexer.getSymbols(doc3URI);
|
||||
assertTrue(SpringIndexerTest.containsSymbol(symbols3, "@/classlevel-CHANGED/mapping-subpackage", doc3URI, 7, 1, 7, 38));
|
||||
}
|
||||
finally {
|
||||
FileUtils.writeStringToFile(new File(new URI(doc1URI)), original1Content);
|
||||
@@ -185,7 +184,7 @@ public class SpringIndexerMultipleFilesTest {
|
||||
fileScanListener.assertScannedUris();
|
||||
fileScanListener.assertScannedUri(unchangedDocURI, 0);
|
||||
|
||||
List<? extends SymbolInformation> symbols = indexer.getSymbols(unchangedDocURI);
|
||||
List<? extends WorkspaceSymbol> symbols = indexer.getSymbols(unchangedDocURI);
|
||||
assertEquals(2, symbols.size());
|
||||
}
|
||||
|
||||
@@ -220,16 +219,16 @@ public class SpringIndexerMultipleFilesTest {
|
||||
updateFuture.get(5, TimeUnit.SECONDS);
|
||||
|
||||
// check for updated index per document
|
||||
List<? extends SymbolInformation> symbols1 = indexer.getSymbols(doc1URI);
|
||||
List<? extends WorkspaceSymbol> symbols1 = indexer.getSymbols(doc1URI);
|
||||
assertEquals(2, symbols1.size());
|
||||
assertTrue(containsSymbol(symbols1, "@/mapping1-CHANGED", doc1URI, 6, 1, 6, 36));
|
||||
assertTrue(containsSymbol(symbols1, "@/mapping2", doc1URI, 11, 1, 11, 28));
|
||||
assertTrue(SpringIndexerTest.containsSymbol(symbols1, "@/mapping1-CHANGED", doc1URI, 6, 1, 6, 36));
|
||||
assertTrue(SpringIndexerTest.containsSymbol(symbols1, "@/mapping2", doc1URI, 11, 1, 11, 28));
|
||||
|
||||
List<? extends SymbolInformation> symbols2 = indexer.getSymbols(doc2URI);
|
||||
List<? extends WorkspaceSymbol> symbols2 = indexer.getSymbols(doc2URI);
|
||||
assertEquals(3, symbols2.size());
|
||||
|
||||
List<? extends SymbolInformation> symbols3 = indexer.getSymbols(doc3URI);
|
||||
assertTrue(containsSymbol(symbols3, "@/classlevel-CHANGED/mapping-subpackage", doc3URI, 7, 1, 7, 38));
|
||||
List<? extends WorkspaceSymbol> symbols3 = indexer.getSymbols(doc3URI);
|
||||
assertTrue(SpringIndexerTest.containsSymbol(symbols3, "@/classlevel-CHANGED/mapping-subpackage", doc3URI, 7, 1, 7, 38));
|
||||
|
||||
fileScanListener.assertScannedUris(doc1URI, doc3URI);
|
||||
fileScanListener.assertScannedUri(doc1URI, 1);
|
||||
@@ -242,36 +241,4 @@ public class SpringIndexerMultipleFilesTest {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean containsSymbol(List<? extends SymbolInformation> symbols, String name, String uri) {
|
||||
for (Iterator<? extends SymbolInformation> iterator = symbols.iterator(); iterator.hasNext();) {
|
||||
SymbolInformation symbol = iterator.next();
|
||||
|
||||
if (
|
||||
symbol.getName().equals(name) &&
|
||||
symbol.getLocation().getUri().equals(uri)
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean containsSymbol(List<? extends SymbolInformation> symbols, String name, String uri, int startLine, int startCHaracter, int endLine, int endCharacter) {
|
||||
for (Iterator<? extends SymbolInformation> iterator = symbols.iterator(); iterator.hasNext();) {
|
||||
SymbolInformation symbol = iterator.next();
|
||||
|
||||
if (symbol.getName().equals(name)
|
||||
&& symbol.getLocation().getUri().equals(uri)
|
||||
&& symbol.getLocation().getRange().getStart().getLine() == startLine
|
||||
&& symbol.getLocation().getRange().getStart().getCharacter() == startCHaracter
|
||||
&& symbol.getLocation().getRange().getEnd().getLine() == endLine
|
||||
&& symbol.getLocation().getRange().getEnd().getCharacter() == endCharacter) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -14,13 +14,12 @@ import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.eclipse.lsp4j.SymbolInformation;
|
||||
import org.eclipse.lsp4j.TextDocumentIdentifier;
|
||||
import org.eclipse.lsp4j.WorkspaceSymbol;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -65,33 +64,16 @@ public class SpringIndexerNonBootProjectTest {
|
||||
|
||||
@Test
|
||||
public void testScanningSimpleRegularSpringProject() throws Exception {
|
||||
List<? extends SymbolInformation> allSymbols = indexer.getAllSymbols("");
|
||||
List<? extends WorkspaceSymbol> allSymbols = indexer.getAllSymbols("");
|
||||
|
||||
assertEquals(3, allSymbols.size());
|
||||
|
||||
String docUri = directory.toPath().resolve("src/main/java/org/test/SimpleMappingClass.java").toUri().toString();
|
||||
assertTrue(containsSymbol(allSymbols, "@/mapping1", docUri, 6, 1, 6, 28));
|
||||
assertTrue(containsSymbol(allSymbols, "@/mapping2", docUri, 11, 1, 11, 28));
|
||||
assertTrue(SpringIndexerTest.containsSymbol(allSymbols, "@/mapping1", docUri, 6, 1, 6, 28));
|
||||
assertTrue(SpringIndexerTest.containsSymbol(allSymbols, "@/mapping2", docUri, 11, 1, 11, 28));
|
||||
|
||||
docUri = directory.toPath().resolve("src/main/java/org/test/ClassWithDefaultSymbol.java").toUri().toString();
|
||||
assertTrue(containsSymbol(allSymbols, "@Configurable", docUri, 4, 0, 4, 13));
|
||||
}
|
||||
|
||||
private boolean containsSymbol(List<? extends SymbolInformation> symbols, String name, String uri, int startLine, int startCHaracter, int endLine, int endCharacter) {
|
||||
for (Iterator<? extends SymbolInformation> iterator = symbols.iterator(); iterator.hasNext();) {
|
||||
SymbolInformation symbol = iterator.next();
|
||||
|
||||
if (symbol.getName().equals(name)
|
||||
&& symbol.getLocation().getUri().equals(uri)
|
||||
&& symbol.getLocation().getRange().getStart().getLine() == startLine
|
||||
&& symbol.getLocation().getRange().getStart().getCharacter() == startCHaracter
|
||||
&& symbol.getLocation().getRange().getEnd().getLine() == endLine
|
||||
&& symbol.getLocation().getRange().getEnd().getCharacter() == endCharacter) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
assertTrue(SpringIndexerTest.containsSymbol(allSymbols, "@Configurable", docUri, 4, 0, 4, 13));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -23,8 +23,8 @@ import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.eclipse.lsp4j.SymbolInformation;
|
||||
import org.eclipse.lsp4j.TextDocumentIdentifier;
|
||||
import org.eclipse.lsp4j.WorkspaceSymbol;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -74,7 +74,7 @@ public class SpringIndexerTest {
|
||||
|
||||
@Test
|
||||
public void testScanningAllAnnotationsSimpleProjectUpfront() throws Exception {
|
||||
List<? extends SymbolInformation> allSymbols = indexer.getAllSymbols("");
|
||||
List<? extends WorkspaceSymbol> allSymbols = indexer.getAllSymbols("");
|
||||
|
||||
assertEquals(7, allSymbols.size());
|
||||
|
||||
@@ -98,7 +98,7 @@ public class SpringIndexerTest {
|
||||
public void testScanTestJavaSources() throws Exception {
|
||||
indexer.configureIndexer(SymbolIndexConfig.builder().scanTestJavaSources(true).build());
|
||||
|
||||
List<? extends SymbolInformation> allSymbols = indexer.getAllSymbols("");
|
||||
List<? extends WorkspaceSymbol> allSymbols = indexer.getAllSymbols("");
|
||||
assertEquals(8, allSymbols.size());
|
||||
String docUri = directory.toPath().resolve("src/test/java/demo/ApplicationTests.java").toUri().toString();
|
||||
assertTrue(containsSymbol(allSymbols, "@SpringBootTest", docUri, 8, 0, 8, 15));
|
||||
@@ -112,7 +112,7 @@ public class SpringIndexerTest {
|
||||
@Test
|
||||
public void testRetrievingSymbolsPerDocument() throws Exception {
|
||||
String docUri = directory.toPath().resolve("src/main/java/org/test/MainClass.java").toUri().toString();
|
||||
List<? extends SymbolInformation> symbols = indexer.getSymbols(docUri);
|
||||
List<? extends WorkspaceSymbol> symbols = indexer.getSymbols(docUri);
|
||||
assertEquals(3, symbols.size());
|
||||
assertTrue(containsSymbol(symbols, "@+ 'mainClass' (@SpringBootApplication <: @SpringBootConfiguration, @Configuration, @Component) MainClass", docUri, 6, 0, 6, 22));
|
||||
assertTrue(containsSymbol(symbols, "@/embedded-foo-mapping", docUri, 17, 1, 17, 41));
|
||||
@@ -132,7 +132,7 @@ public class SpringIndexerTest {
|
||||
|
||||
@Test
|
||||
public void testScanningAllAnnotationsMultiModuleProjectUpfront() throws Exception {
|
||||
List<? extends SymbolInformation> allSymbols = indexer.getAllSymbols("");
|
||||
List<? extends WorkspaceSymbol> allSymbols = indexer.getAllSymbols("");
|
||||
|
||||
assertEquals(7, allSymbols.size());
|
||||
|
||||
@@ -165,13 +165,13 @@ public class SpringIndexerTest {
|
||||
updateFuture.get(5, TimeUnit.SECONDS);
|
||||
|
||||
// check for updated index per document
|
||||
List<? extends SymbolInformation> symbols = indexer.getSymbols(changedDocURI);
|
||||
List<? extends WorkspaceSymbol> symbols = indexer.getSymbols(changedDocURI);
|
||||
assertEquals(2, symbols.size());
|
||||
assertTrue(containsSymbol(symbols, "@/mapping1-CHANGED", changedDocURI, 6, 1, 6, 36));
|
||||
assertTrue(containsSymbol(symbols, "@/mapping2", changedDocURI, 11, 1, 11, 28));
|
||||
|
||||
// check for updated index in all symbols
|
||||
List<? extends SymbolInformation> allSymbols = indexer.getAllSymbols("");
|
||||
List<? extends WorkspaceSymbol> allSymbols = indexer.getAllSymbols("");
|
||||
assertEquals(7, allSymbols.size());
|
||||
|
||||
String docUri = directory.toPath().resolve("src/main/java/org/test/MainClass.java").toUri().toString();
|
||||
@@ -194,11 +194,11 @@ public class SpringIndexerTest {
|
||||
public void testNewDocumentCreated() throws Exception {
|
||||
String createdDocURI = directory.toPath().resolve("src/main/java/org/test/CreatedClass.java").toUri().toString();
|
||||
// check for document to not be created yet
|
||||
List<? extends SymbolInformation> symbols = indexer.getSymbols(createdDocURI);
|
||||
List<? extends WorkspaceSymbol> symbols = indexer.getSymbols(createdDocURI);
|
||||
assertNotNull(symbols);
|
||||
assertEquals(0, symbols.size());
|
||||
|
||||
List<? extends SymbolInformation> allSymbols = indexer.getAllSymbols("");
|
||||
List<? extends WorkspaceSymbol> allSymbols = indexer.getAllSymbols("");
|
||||
assertEquals(7, allSymbols.size());
|
||||
|
||||
try {
|
||||
@@ -271,7 +271,7 @@ public class SpringIndexerTest {
|
||||
Assert.noElements(indexer.getSymbols(deletedDocURI));
|
||||
|
||||
// check for updated index in all symbols
|
||||
List<? extends SymbolInformation> allSymbols = indexer.getAllSymbols("");
|
||||
List<? extends WorkspaceSymbol> allSymbols = indexer.getAllSymbols("");
|
||||
assertEquals(5, allSymbols.size());
|
||||
|
||||
String docUri = directory.toPath().resolve("src/main/java/org/test/MainClass.java").toUri().toString();
|
||||
@@ -288,7 +288,7 @@ public class SpringIndexerTest {
|
||||
|
||||
@Test
|
||||
public void testFilterSymbolsUsingQueryString() throws Exception {
|
||||
List<? extends SymbolInformation> allSymbols = indexer.getAllSymbols("mapp");
|
||||
List<? extends WorkspaceSymbol> allSymbols = indexer.getAllSymbols("mapp");
|
||||
|
||||
assertEquals(6, allSymbols.size());
|
||||
|
||||
@@ -306,7 +306,7 @@ public class SpringIndexerTest {
|
||||
|
||||
@Test
|
||||
public void testFilterSymbolsUsingQueryStringSplittedResult() throws Exception {
|
||||
List<? extends SymbolInformation> allSymbols = indexer.getAllSymbols("@/foo-root-mapping");
|
||||
List<? extends WorkspaceSymbol> allSymbols = indexer.getAllSymbols("@/foo-root-mapping");
|
||||
|
||||
assertEquals(1, allSymbols.size());
|
||||
|
||||
@@ -317,7 +317,7 @@ public class SpringIndexerTest {
|
||||
|
||||
@Test
|
||||
public void testFilterSymbolsUsingQueryStringFullSymbolString() throws Exception {
|
||||
List<? extends SymbolInformation> allSymbols = indexer.getAllSymbols("@/foo-root-mapping/embedded-foo-mapping-with-root");
|
||||
List<? extends WorkspaceSymbol> allSymbols = indexer.getAllSymbols("@/foo-root-mapping/embedded-foo-mapping-with-root");
|
||||
|
||||
assertEquals(1, allSymbols.size());
|
||||
|
||||
@@ -328,7 +328,7 @@ public class SpringIndexerTest {
|
||||
|
||||
@Test
|
||||
public void testDeleteProject() throws Exception {
|
||||
List<? extends SymbolInformation> allSymbols = indexer.getAllSymbols("");
|
||||
List<? extends WorkspaceSymbol> allSymbols = indexer.getAllSymbols("");
|
||||
assertEquals(7, allSymbols.size());
|
||||
|
||||
CompletableFuture<Void> deleteProject = indexer.deleteProject(project);
|
||||
@@ -338,13 +338,13 @@ public class SpringIndexerTest {
|
||||
assertEquals(0, allSymbols.size());
|
||||
}
|
||||
|
||||
private boolean containsSymbol(List<? extends SymbolInformation> symbols, String name, String uri) {
|
||||
for (Iterator<? extends SymbolInformation> iterator = symbols.iterator(); iterator.hasNext();) {
|
||||
SymbolInformation symbol = iterator.next();
|
||||
static boolean containsSymbol(List<? extends WorkspaceSymbol> symbols, String name, String uri) {
|
||||
for (Iterator<? extends WorkspaceSymbol> iterator = symbols.iterator(); iterator.hasNext();) {
|
||||
WorkspaceSymbol symbol = iterator.next();
|
||||
|
||||
if (
|
||||
symbol.getName().equals(name) &&
|
||||
symbol.getLocation().getUri().equals(uri)
|
||||
symbol.getLocation().getLeft().getUri().equals(uri)
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
@@ -353,16 +353,16 @@ public class SpringIndexerTest {
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean containsSymbol(List<? extends SymbolInformation> symbols, String name, String uri, int startLine, int startCHaracter, int endLine, int endCharacter) {
|
||||
for (Iterator<? extends SymbolInformation> iterator = symbols.iterator(); iterator.hasNext();) {
|
||||
SymbolInformation symbol = iterator.next();
|
||||
static boolean containsSymbol(List<? extends WorkspaceSymbol> symbols, String name, String uri, int startLine, int startCHaracter, int endLine, int endCharacter) {
|
||||
for (Iterator<? extends WorkspaceSymbol> iterator = symbols.iterator(); iterator.hasNext();) {
|
||||
WorkspaceSymbol symbol = iterator.next();
|
||||
|
||||
if (symbol.getName().equals(name)
|
||||
&& symbol.getLocation().getUri().equals(uri)
|
||||
&& symbol.getLocation().getRange().getStart().getLine() == startLine
|
||||
&& symbol.getLocation().getRange().getStart().getCharacter() == startCHaracter
|
||||
&& symbol.getLocation().getRange().getEnd().getLine() == endLine
|
||||
&& symbol.getLocation().getRange().getEnd().getCharacter() == endCharacter) {
|
||||
&& symbol.getLocation().getLeft().getUri().equals(uri)
|
||||
&& symbol.getLocation().getLeft().getRange().getStart().getLine() == startLine
|
||||
&& symbol.getLocation().getLeft().getRange().getStart().getCharacter() == startCHaracter
|
||||
&& symbol.getLocation().getLeft().getRange().getEnd().getLine() == endLine
|
||||
&& symbol.getLocation().getLeft().getRange().getEnd().getCharacter() == endCharacter) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,20 +11,15 @@
|
||||
package org.springframework.ide.vscode.boot.java.utils.test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.URI;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.eclipse.lsp4j.SymbolInformation;
|
||||
import org.eclipse.lsp4j.TextDocumentIdentifier;
|
||||
import org.eclipse.lsp4j.WorkspaceSymbol;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -36,7 +31,6 @@ import org.springframework.ide.vscode.boot.bootiful.SymbolProviderTestConf;
|
||||
import org.springframework.ide.vscode.boot.java.utils.SymbolIndexConfig;
|
||||
import org.springframework.ide.vscode.commons.java.IJavaProject;
|
||||
import org.springframework.ide.vscode.commons.languageserver.java.JavaProjectFinder;
|
||||
import org.springframework.ide.vscode.commons.util.Assert;
|
||||
import org.springframework.ide.vscode.commons.util.UriUtil;
|
||||
import org.springframework.ide.vscode.project.harness.BootLanguageServerHarness;
|
||||
import org.springframework.ide.vscode.project.harness.ProjectsHarness;
|
||||
@@ -75,7 +69,7 @@ public class SpringIndexerTestSpecialCharacters {
|
||||
|
||||
@Test
|
||||
public void testScanningAllAnnotationsSimpleProjectUpfront() throws Exception {
|
||||
List<? extends SymbolInformation> allSymbols = indexer.getAllSymbols("");
|
||||
List<? extends WorkspaceSymbol> allSymbols = indexer.getAllSymbols("");
|
||||
|
||||
assertEquals(8, allSymbols.size());
|
||||
|
||||
@@ -84,24 +78,7 @@ public class SpringIndexerTestSpecialCharacters {
|
||||
// String docUri = directory.toPath().resolve("src/main/java/org/test/ClassWithSpécialCharacter.java").toUri().toString();
|
||||
String docUri = UriUtil.toUri(directory.toPath().resolve("src/main/java/org/test/ClassWithSpécialCharacter.java").toFile()).toString();
|
||||
|
||||
assertTrue(containsSymbol(allSymbols, "@Configurable", docUri, 4, 0, 4, 13));
|
||||
assertTrue(SpringIndexerTest.containsSymbol(allSymbols, "@Configurable", docUri, 4, 0, 4, 13));
|
||||
}
|
||||
|
||||
private boolean containsSymbol(List<? extends SymbolInformation> symbols, String name, String uri, int startLine, int startCHaracter, int endLine, int endCharacter) {
|
||||
for (Iterator<? extends SymbolInformation> iterator = symbols.iterator(); iterator.hasNext();) {
|
||||
SymbolInformation symbol = iterator.next();
|
||||
|
||||
if (symbol.getName().equals(name)
|
||||
&& symbol.getLocation().getUri().equals(uri)
|
||||
&& symbol.getLocation().getRange().getStart().getLine() == startLine
|
||||
&& symbol.getLocation().getRange().getStart().getCharacter() == startCHaracter
|
||||
&& symbol.getLocation().getRange().getEnd().getLine() == endLine
|
||||
&& symbol.getLocation().getRange().getEnd().getCharacter() == endCharacter) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -15,12 +15,11 @@ import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.eclipse.lsp4j.SymbolInformation;
|
||||
import org.eclipse.lsp4j.WorkspaceSymbol;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -84,15 +83,15 @@ public class SpringIndexerXMLProjectTest {
|
||||
|
||||
@Test
|
||||
public void testScanningSimpleSpringXMLConfig() throws Exception {
|
||||
List<? extends SymbolInformation> allSymbols = indexer.getAllSymbols("");
|
||||
List<? extends WorkspaceSymbol> allSymbols = indexer.getAllSymbols("");
|
||||
|
||||
assertEquals(5, allSymbols.size());
|
||||
|
||||
String docUri = directory.toPath().resolve("config/simple-spring-config.xml").toUri().toString();
|
||||
assertTrue(containsSymbol(allSymbols, "@+ 'transactionManager' DataSourceTransactionManager", docUri, 6, 14, 6, 37));
|
||||
assertTrue(containsSymbol(allSymbols, "@+ 'jdbcTemplate' JdbcTemplate", docUri, 8, 14, 8, 31));
|
||||
assertTrue(containsSymbol(allSymbols, "@+ 'namedParameterJdbcTemplate' NamedParameterJdbcTemplate", docUri, 12, 14, 12, 45));
|
||||
assertTrue(containsSymbol(allSymbols, "@+ 'persistenceExceptionTranslationPostProcessor' PersistenceExceptionTranslationPostProcessor", docUri, 18, 10, 18, 97));
|
||||
assertTrue(SpringIndexerTest.containsSymbol(allSymbols, "@+ 'transactionManager' DataSourceTransactionManager", docUri, 6, 14, 6, 37));
|
||||
assertTrue(SpringIndexerTest.containsSymbol(allSymbols, "@+ 'jdbcTemplate' JdbcTemplate", docUri, 8, 14, 8, 31));
|
||||
assertTrue(SpringIndexerTest.containsSymbol(allSymbols, "@+ 'namedParameterJdbcTemplate' NamedParameterJdbcTemplate", docUri, 12, 14, 12, 45));
|
||||
assertTrue(SpringIndexerTest.containsSymbol(allSymbols, "@+ 'persistenceExceptionTranslationPostProcessor' PersistenceExceptionTranslationPostProcessor", docUri, 18, 10, 18, 97));
|
||||
|
||||
List<? extends SymbolAddOnInformation> addon = indexer.getAdditonalInformation(docUri);
|
||||
assertEquals(4, addon.size());
|
||||
@@ -119,7 +118,7 @@ public class SpringIndexerXMLProjectTest {
|
||||
|
||||
|
||||
String beansOnClasspathDocUri = directory.toPath().resolve("src/main/resources/beans.xml").toUri().toString();
|
||||
assertTrue(containsSymbol(allSymbols, "@+ 'sb' SimpleBean", beansOnClasspathDocUri, 6, 14, 6, 21));
|
||||
assertTrue(SpringIndexerTest.containsSymbol(allSymbols, "@+ 'sb' SimpleBean", beansOnClasspathDocUri, 6, 14, 6, 21));
|
||||
|
||||
addon = indexer.getAdditonalInformation(beansOnClasspathDocUri);
|
||||
assertEquals(1, addon.size());
|
||||
@@ -128,7 +127,7 @@ public class SpringIndexerXMLProjectTest {
|
||||
|
||||
@Test
|
||||
public void testReindexXMLConfig() throws Exception {
|
||||
List<? extends SymbolInformation> allSymbols = indexer.getAllSymbols("");
|
||||
List<? extends WorkspaceSymbol> allSymbols = indexer.getAllSymbols("");
|
||||
assertEquals(5, allSymbols.size());
|
||||
|
||||
indexer.configureIndexer(SymbolIndexConfig.builder()
|
||||
@@ -187,21 +186,4 @@ public class SpringIndexerXMLProjectTest {
|
||||
assertEquals(0, allSymbols.size());
|
||||
}
|
||||
|
||||
private boolean containsSymbol(List<? extends SymbolInformation> symbols, String name, String uri, int startLine, int startCHaracter, int endLine, int endCharacter) {
|
||||
for (Iterator<? extends SymbolInformation> iterator = symbols.iterator(); iterator.hasNext();) {
|
||||
SymbolInformation symbol = iterator.next();
|
||||
|
||||
if (symbol.getName().equals(name)
|
||||
&& symbol.getLocation().getUri().equals(uri)
|
||||
&& symbol.getLocation().getRange().getStart().getLine() == startLine
|
||||
&& symbol.getLocation().getRange().getStart().getCharacter() == startCHaracter
|
||||
&& symbol.getLocation().getRange().getEnd().getLine() == endLine
|
||||
&& symbol.getLocation().getRange().getEnd().getCharacter() == endCharacter) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -29,8 +29,9 @@ import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.eclipse.lsp4j.Location;
|
||||
import org.eclipse.lsp4j.Position;
|
||||
import org.eclipse.lsp4j.Range;
|
||||
import org.eclipse.lsp4j.SymbolInformation;
|
||||
import org.eclipse.lsp4j.SymbolKind;
|
||||
import org.eclipse.lsp4j.WorkspaceSymbol;
|
||||
import org.eclipse.lsp4j.jsonrpc.messages.Either;
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
@@ -84,7 +85,7 @@ public class SymbolCacheOnDiscTest {
|
||||
String[] files = {file1.toString(), file2.toString(), file3.toString()};
|
||||
|
||||
List<CachedSymbol> generatedSymbols = new ArrayList<>();
|
||||
SymbolInformation symbol = new SymbolInformation("symbol1", SymbolKind.Field, new Location("docURI", new Range(new Position(3, 10), new Position(3, 20))));
|
||||
WorkspaceSymbol symbol = new WorkspaceSymbol("symbol1", SymbolKind.Field, Either.forLeft(new Location("docURI", new Range(new Position(3, 10), new Position(3, 20)))));
|
||||
EnhancedSymbolInformation enhancedSymbol = new EnhancedSymbolInformation(symbol, null);
|
||||
generatedSymbols.add(new CachedSymbol("", timeFile1.toMillis(), enhancedSymbol));
|
||||
|
||||
@@ -102,7 +103,7 @@ public class SymbolCacheOnDiscTest {
|
||||
|
||||
assertEquals("symbol1", cachedSymbols[0].getEnhancedSymbol().getSymbol().getName());
|
||||
assertEquals(SymbolKind.Field, cachedSymbols[0].getEnhancedSymbol().getSymbol().getKind());
|
||||
assertEquals(new Location("docURI", new Range(new Position(3, 10), new Position(3, 20))), cachedSymbols[0].getEnhancedSymbol().getSymbol().getLocation());
|
||||
assertEquals(new Location("docURI", new Range(new Position(3, 10), new Position(3, 20))), cachedSymbols[0].getEnhancedSymbol().getSymbol().getLocation().getLeft());
|
||||
assertNull(cachedSymbols[0].getEnhancedSymbol().getAdditionalInformation());
|
||||
|
||||
Multimap<String, String> dependencies = result.getRight();
|
||||
@@ -128,7 +129,7 @@ public class SymbolCacheOnDiscTest {
|
||||
String[] files = {file1.toString(), file2.toString(), file3.toString()};
|
||||
|
||||
List<CachedSymbol> generatedSymbols = new ArrayList<>();
|
||||
SymbolInformation symbol = new SymbolInformation("symbol1", SymbolKind.Field, new Location("docURI", new Range(new Position(3, 10), new Position(3, 20))));
|
||||
WorkspaceSymbol symbol = new WorkspaceSymbol("symbol1", SymbolKind.Field, Either.forLeft(new Location("docURI", new Range(new Position(3, 10), new Position(3, 20)))));
|
||||
EnhancedSymbolInformation enhancedSymbol = new EnhancedSymbolInformation(symbol, null);
|
||||
generatedSymbols.add(new CachedSymbol("", timeFile1.toMillis(), enhancedSymbol));
|
||||
|
||||
@@ -152,7 +153,7 @@ public class SymbolCacheOnDiscTest {
|
||||
String[] files = {file1.toString(), file2.toString(), file3.toString()};
|
||||
|
||||
List<CachedSymbol> generatedSymbols = new ArrayList<>();
|
||||
SymbolInformation symbol = new SymbolInformation("symbol1", SymbolKind.Field, new Location("docURI", new Range(new Position(3, 10), new Position(3, 20))));
|
||||
WorkspaceSymbol symbol = new WorkspaceSymbol("symbol1", SymbolKind.Field, Either.forLeft(new Location("docURI", new Range(new Position(3, 10), new Position(3, 20)))));
|
||||
EnhancedSymbolInformation enhancedSymbol = new EnhancedSymbolInformation(symbol, null);
|
||||
generatedSymbols.add(new CachedSymbol("", timeFile1.toMillis(), enhancedSymbol));
|
||||
|
||||
@@ -224,7 +225,7 @@ public class SymbolCacheOnDiscTest {
|
||||
|
||||
List<CachedSymbol> generatedSymbols = new ArrayList<>();
|
||||
|
||||
SymbolInformation symbol = new SymbolInformation("symbol1", SymbolKind.Field, new Location(doc1URI, new Range(new Position(3, 10), new Position(3, 20))));
|
||||
WorkspaceSymbol symbol = new WorkspaceSymbol("symbol1", SymbolKind.Field, Either.forLeft(new Location(doc1URI, new Range(new Position(3, 10), new Position(3, 20)))));
|
||||
WebfluxElementsInformation addon = new WebfluxElementsInformation(new Range(new Position(4, 4), new Position(5, 5)), new Range(new Position(6, 6), new Position(7, 7)));
|
||||
EnhancedSymbolInformation enhancedSymbol = new EnhancedSymbolInformation(symbol, new SymbolAddOnInformation[] {addon});
|
||||
|
||||
@@ -238,7 +239,7 @@ public class SymbolCacheOnDiscTest {
|
||||
|
||||
assertEquals("symbol1", cachedSymbols[0].getEnhancedSymbol().getSymbol().getName());
|
||||
assertEquals(SymbolKind.Field, cachedSymbols[0].getEnhancedSymbol().getSymbol().getKind());
|
||||
assertEquals(new Location(doc1URI, new Range(new Position(3, 10), new Position(3, 20))), cachedSymbols[0].getEnhancedSymbol().getSymbol().getLocation());
|
||||
assertEquals(new Location(doc1URI, new Range(new Position(3, 10), new Position(3, 20))), cachedSymbols[0].getEnhancedSymbol().getSymbol().getLocation().getLeft());
|
||||
|
||||
SymbolAddOnInformation[] retrievedAddOns = cachedSymbols[0].getEnhancedSymbol().getAdditionalInformation();
|
||||
assertNotNull(retrievedAddOns);
|
||||
@@ -263,17 +264,17 @@ public class SymbolCacheOnDiscTest {
|
||||
String doc1URI = UriUtil.toUri(file1.toFile()).toString();
|
||||
|
||||
List<CachedSymbol> generatedSymbols1 = new ArrayList<>();
|
||||
SymbolInformation symbol1 = new SymbolInformation("symbol1", SymbolKind.Field, new Location("docURI", new Range(new Position(3, 10), new Position(3, 20))));
|
||||
WorkspaceSymbol symbol1 = new WorkspaceSymbol("symbol1", SymbolKind.Field, Either.forLeft(new Location("docURI", new Range(new Position(3, 10), new Position(3, 20)))));
|
||||
EnhancedSymbolInformation enhancedSymbol1 = new EnhancedSymbolInformation(symbol1, null);
|
||||
generatedSymbols1.add(new CachedSymbol(doc1URI, timeFile1.toMillis(), enhancedSymbol1));
|
||||
|
||||
cache.store(new SymbolCacheKey("somekey", "1"), files, generatedSymbols1, null);
|
||||
|
||||
List<CachedSymbol> generatedSymbols2 = new ArrayList<>();
|
||||
symbol1 = new SymbolInformation("symbol1", SymbolKind.Field, new Location(doc1URI, new Range(new Position(3, 10), new Position(3, 20))));
|
||||
symbol1 = new WorkspaceSymbol("symbol1", SymbolKind.Field, Either.forLeft(new Location(doc1URI, new Range(new Position(3, 10), new Position(3, 20)))));
|
||||
enhancedSymbol1 = new EnhancedSymbolInformation(symbol1, null);
|
||||
|
||||
SymbolInformation symbol2 = new SymbolInformation("symbol2", SymbolKind.Interface, new Location(doc1URI, new Range(new Position(5, 5), new Position(5, 10))));
|
||||
WorkspaceSymbol symbol2 = new WorkspaceSymbol("symbol2", SymbolKind.Interface, Either.forLeft(new Location(doc1URI, new Range(new Position(5, 5), new Position(5, 10)))));
|
||||
EnhancedSymbolInformation enhancedSymbol2 = new EnhancedSymbolInformation(symbol2, null);
|
||||
|
||||
generatedSymbols2.add(new CachedSymbol(doc1URI, timeFile1.toMillis() + 2000, enhancedSymbol1));
|
||||
@@ -312,15 +313,15 @@ public class SymbolCacheOnDiscTest {
|
||||
String doc3URI = UriUtil.toUri(file3.toFile()).toString();
|
||||
|
||||
List<CachedSymbol> generatedSymbols = new ArrayList<>();
|
||||
SymbolInformation symbol1 = new SymbolInformation("symbol1", SymbolKind.Field, new Location(doc1URI, new Range(new Position(3, 10), new Position(3, 20))));
|
||||
WorkspaceSymbol symbol1 = new WorkspaceSymbol("symbol1", SymbolKind.Field, Either.forLeft(new Location(doc1URI, new Range(new Position(3, 10), new Position(3, 20)))));
|
||||
EnhancedSymbolInformation enhancedSymbol1 = new EnhancedSymbolInformation(symbol1, null);
|
||||
generatedSymbols.add(new CachedSymbol(doc1URI, timeFile1.toMillis(), enhancedSymbol1));
|
||||
|
||||
SymbolInformation symbol2 = new SymbolInformation("symbol2", SymbolKind.Field, new Location(doc2URI, new Range(new Position(3, 10), new Position(3, 20))));
|
||||
WorkspaceSymbol symbol2 = new WorkspaceSymbol("symbol2", SymbolKind.Field, Either.forLeft(new Location(doc2URI, new Range(new Position(3, 10), new Position(3, 20)))));
|
||||
EnhancedSymbolInformation enhancedSymbol2 = new EnhancedSymbolInformation(symbol2, null);
|
||||
generatedSymbols.add(new CachedSymbol(doc2URI, timeFile2.toMillis(), enhancedSymbol2));
|
||||
|
||||
SymbolInformation symbol3 = new SymbolInformation("symbol3", SymbolKind.Field, new Location(doc3URI, new Range(new Position(3, 10), new Position(3, 20))));
|
||||
WorkspaceSymbol symbol3 = new WorkspaceSymbol("symbol3", SymbolKind.Field, Either.forLeft(new Location(doc3URI, new Range(new Position(3, 10), new Position(3, 20)))));
|
||||
EnhancedSymbolInformation enhancedSymbol3 = new EnhancedSymbolInformation(symbol3, null);
|
||||
generatedSymbols.add(new CachedSymbol(doc3URI, timeFile3.toMillis(), enhancedSymbol3));
|
||||
|
||||
@@ -331,17 +332,17 @@ public class SymbolCacheOnDiscTest {
|
||||
// create updated and new symbols
|
||||
List<CachedSymbol> updatedSymbols = new ArrayList<>();
|
||||
|
||||
SymbolInformation updatedSymbol1 = new SymbolInformation("symbol1", SymbolKind.Field, new Location(doc1URI, new Range(new Position(3, 10), new Position(3, 20))));
|
||||
WorkspaceSymbol updatedSymbol1 = new WorkspaceSymbol("symbol1", SymbolKind.Field, Either.forLeft(new Location(doc1URI, new Range(new Position(3, 10), new Position(3, 20)))));
|
||||
EnhancedSymbolInformation updatedEnhancedSymbol1 = new EnhancedSymbolInformation(updatedSymbol1, null);
|
||||
|
||||
SymbolInformation newSymbol1 = new SymbolInformation("symbol1-new", SymbolKind.Interface, new Location(doc1URI, new Range(new Position(5, 5), new Position(5, 10))));
|
||||
WorkspaceSymbol newSymbol1 = new WorkspaceSymbol("symbol1-new", SymbolKind.Interface, Either.forLeft(new Location(doc1URI, new Range(new Position(5, 5), new Position(5, 10)))));
|
||||
EnhancedSymbolInformation newEnhancedSymbol1 = new EnhancedSymbolInformation(newSymbol1, null);
|
||||
|
||||
updatedSymbols.add(new CachedSymbol(doc1URI, timeFile1.toMillis() + 2000, updatedEnhancedSymbol1));
|
||||
updatedSymbols.add(new CachedSymbol(doc1URI, timeFile1.toMillis() + 2000, newEnhancedSymbol1));
|
||||
assertTrue(file1.toFile().setLastModified(timeFile1.toMillis() + 2000));
|
||||
|
||||
SymbolInformation updatedSymbol2 = new SymbolInformation("symbol2-updated", SymbolKind.Field, new Location(doc2URI, new Range(new Position(3, 10), new Position(3, 20))));
|
||||
WorkspaceSymbol updatedSymbol2 = new WorkspaceSymbol("symbol2-updated", SymbolKind.Field, Either.forLeft(new Location(doc2URI, new Range(new Position(3, 10), new Position(3, 20)))));
|
||||
EnhancedSymbolInformation updatedEnhancedSymbol2 = new EnhancedSymbolInformation(updatedSymbol2, null);
|
||||
updatedSymbols.add(new CachedSymbol(doc2URI, timeFile2.toMillis() + 3000, updatedEnhancedSymbol2));
|
||||
assertTrue(file2.toFile().setLastModified(timeFile2.toMillis() + 3000));
|
||||
@@ -369,7 +370,7 @@ public class SymbolCacheOnDiscTest {
|
||||
|
||||
private void assertSymbol(EnhancedSymbolInformation enhancedSymbol, CachedSymbol[] cachedSymbols) {
|
||||
for (CachedSymbol cachedSymbol : cachedSymbols) {
|
||||
SymbolInformation symbol = cachedSymbol.getEnhancedSymbol().getSymbol();
|
||||
WorkspaceSymbol symbol = cachedSymbol.getEnhancedSymbol().getSymbol();
|
||||
|
||||
if (symbol.toString().equals(enhancedSymbol.getSymbol().toString())) {
|
||||
return;
|
||||
@@ -415,7 +416,7 @@ public class SymbolCacheOnDiscTest {
|
||||
String doc1URI = UriUtil.toUri(file1.toFile()).toString();
|
||||
|
||||
List<CachedSymbol> generatedSymbols1 = new ArrayList<>();
|
||||
SymbolInformation symbol1 = new SymbolInformation("symbol1", SymbolKind.Field, new Location("docURI", new Range(new Position(3, 10), new Position(3, 20))));
|
||||
WorkspaceSymbol symbol1 = new WorkspaceSymbol("symbol1", SymbolKind.Field, Either.forLeft(new Location("docURI", new Range(new Position(3, 10), new Position(3, 20)))));
|
||||
EnhancedSymbolInformation enhancedSymbol1 = new EnhancedSymbolInformation(symbol1, null);
|
||||
generatedSymbols1.add(new CachedSymbol(doc1URI, timeFile1.toMillis(), enhancedSymbol1));
|
||||
|
||||
@@ -476,14 +477,14 @@ public class SymbolCacheOnDiscTest {
|
||||
String doc2URI = UriUtil.toUri(file2.toFile()).toString();
|
||||
|
||||
List<CachedSymbol> generatedSymbols1 = new ArrayList<>();
|
||||
SymbolInformation symbol1 = new SymbolInformation("symbol1", SymbolKind.Field, new Location(doc1URI, new Range(new Position(3, 10), new Position(3, 20))));
|
||||
WorkspaceSymbol symbol1 = new WorkspaceSymbol("symbol1", SymbolKind.Field, Either.forLeft(new Location(doc1URI, new Range(new Position(3, 10), new Position(3, 20)))));
|
||||
EnhancedSymbolInformation enhancedSymbol1 = new EnhancedSymbolInformation(symbol1, null);
|
||||
generatedSymbols1.add(new CachedSymbol(doc1URI, timeFile1.toMillis(), enhancedSymbol1));
|
||||
|
||||
cache.store(new SymbolCacheKey("somekey", "1"), files, generatedSymbols1, null);
|
||||
|
||||
List<CachedSymbol> generatedSymbols2 = new ArrayList<>();
|
||||
SymbolInformation symbol2 = new SymbolInformation("symbol2", SymbolKind.Interface, new Location(doc2URI, new Range(new Position(5, 5), new Position(5, 10))));
|
||||
WorkspaceSymbol symbol2 = new WorkspaceSymbol("symbol2", SymbolKind.Interface, Either.forLeft(new Location(doc2URI, new Range(new Position(5, 5), new Position(5, 10)))));
|
||||
EnhancedSymbolInformation enhancedSymbol2 = new EnhancedSymbolInformation(symbol2, null);
|
||||
|
||||
generatedSymbols2.add(new CachedSymbol(doc2URI, timeFile2.toMillis(), enhancedSymbol2));
|
||||
@@ -548,10 +549,10 @@ public class SymbolCacheOnDiscTest {
|
||||
|
||||
List<CachedSymbol> generatedSymbols = new ArrayList<>();
|
||||
|
||||
SymbolInformation symbol1 = new SymbolInformation("symbol1", SymbolKind.Field, new Location(doc1URI, new Range(new Position(3, 10), new Position(3, 20))));
|
||||
WorkspaceSymbol symbol1 = new WorkspaceSymbol("symbol1", SymbolKind.Field, Either.forLeft(new Location(doc1URI, new Range(new Position(3, 10), new Position(3, 20)))));
|
||||
EnhancedSymbolInformation enhancedSymbol1 = new EnhancedSymbolInformation(symbol1, null);
|
||||
|
||||
SymbolInformation symbol2 = new SymbolInformation("symbol2", SymbolKind.Field, new Location(doc2URI, new Range(new Position(5, 10), new Position(5, 20))));
|
||||
WorkspaceSymbol symbol2 = new WorkspaceSymbol("symbol2", SymbolKind.Field, Either.forLeft(new Location(doc2URI, new Range(new Position(5, 10), new Position(5, 20)))));
|
||||
EnhancedSymbolInformation enhancedSymbol2 = new EnhancedSymbolInformation(symbol2, null);
|
||||
|
||||
generatedSymbols.add(new CachedSymbol(doc1URI, timeFile1.toMillis(), enhancedSymbol1));
|
||||
@@ -572,7 +573,7 @@ public class SymbolCacheOnDiscTest {
|
||||
|
||||
assertEquals("symbol2", cachedSymbols[0].getEnhancedSymbol().getSymbol().getName());
|
||||
assertEquals(SymbolKind.Field, cachedSymbols[0].getEnhancedSymbol().getSymbol().getKind());
|
||||
assertEquals(new Location(doc2URI, new Range(new Position(5, 10), new Position(5, 20))), cachedSymbols[0].getEnhancedSymbol().getSymbol().getLocation());
|
||||
assertEquals(new Location(doc2URI, new Range(new Position(5, 10), new Position(5, 20))), cachedSymbols[0].getEnhancedSymbol().getSymbol().getLocation().getLeft());
|
||||
assertNull(cachedSymbols[0].getEnhancedSymbol().getAdditionalInformation());
|
||||
|
||||
Multimap<String, String> cachedDependencies = result.getRight();
|
||||
|
||||
Reference in New Issue
Block a user