Add LSP Implementation infra. AOT query method impl nav.
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2025 Broadcom, Inc.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* https://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Broadcom, Inc. - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.springframework.ide.vscode.commons.languageserver.util;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.lsp4j.ImplementationParams;
|
||||
import org.eclipse.lsp4j.LocationLink;
|
||||
import org.eclipse.lsp4j.jsonrpc.CancelChecker;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface ImplementationHandler {
|
||||
List<LocationLink> handle(CancelChecker cancelToken, ImplementationParams implParams);
|
||||
}
|
||||
@@ -513,6 +513,9 @@ public final class SimpleLanguageServer implements Sts4LanguageServer, SpringInd
|
||||
if (hasDefinitionHandler()) {
|
||||
c.setDefinitionProvider(true);
|
||||
}
|
||||
if (hasImplementationHandler()) {
|
||||
c.setImplementationProvider(true);
|
||||
}
|
||||
if (hasReferencesHandler()) {
|
||||
c.setReferencesProvider(true);
|
||||
}
|
||||
@@ -598,6 +601,10 @@ public final class SimpleLanguageServer implements Sts4LanguageServer, SpringInd
|
||||
private boolean hasDefinitionHandler() {
|
||||
return getTextDocumentService().hasDefinitionHandler();
|
||||
}
|
||||
|
||||
private boolean hasImplementationHandler() {
|
||||
return getTextDocumentService().hasImplementationHandler();
|
||||
}
|
||||
|
||||
private boolean hasQuickFixes() {
|
||||
return quickfixRegistry!=null && quickfixRegistry.hasFixes();
|
||||
|
||||
@@ -52,6 +52,7 @@ import org.eclipse.lsp4j.DocumentSymbol;
|
||||
import org.eclipse.lsp4j.DocumentSymbolParams;
|
||||
import org.eclipse.lsp4j.Hover;
|
||||
import org.eclipse.lsp4j.HoverParams;
|
||||
import org.eclipse.lsp4j.ImplementationParams;
|
||||
import org.eclipse.lsp4j.InlayHint;
|
||||
import org.eclipse.lsp4j.InlayHintParams;
|
||||
import org.eclipse.lsp4j.Location;
|
||||
@@ -120,6 +121,7 @@ public class SimpleTextDocumentService implements TextDocumentService, DocumentE
|
||||
private CompletionResolveHandler completionResolveHandler;
|
||||
private HoverHandler hoverHandler;
|
||||
private DefinitionHandler definitionHandler;
|
||||
private ImplementationHandler implementationHandler;
|
||||
private ReferencesHandler referencesHandler;
|
||||
private DocumentSymbolHandler documentSymbolHandler;
|
||||
private DocumentHighlightHandler documentHighlightHandler;
|
||||
@@ -401,6 +403,38 @@ public class SimpleTextDocumentService implements TextDocumentService, DocumentE
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Either<List<? extends Location>, List<? extends LocationLink>>> implementation(
|
||||
ImplementationParams implemetationParams) {
|
||||
ImplementationHandler h = this.implementationHandler;
|
||||
if (h != null) {
|
||||
return CompletableFutures.computeAsync(messageWorkerThreadPool, cancelToken -> {
|
||||
|
||||
cancelToken.checkCanceled();
|
||||
|
||||
List<LocationLink> locations = h.handle(cancelToken, implemetationParams);
|
||||
if (locations == null) {
|
||||
// vscode client does not like to receive null result. See: https://github.com/spring-projects/sts4/issues/309
|
||||
locations = ImmutableList.of();
|
||||
}
|
||||
// Workaround for https://github.com/eclipse-theia/theia/issues/6414
|
||||
// Theia does not support LocationLink yet
|
||||
switch (LspClient.currentClient()) {
|
||||
case THEIA:
|
||||
case ATOM:
|
||||
case INTELLIJ:
|
||||
return Either.forLeft(locations.stream().map(link -> new Location(link.getTargetUri(), link.getTargetRange())).collect(Collectors.toList()));
|
||||
default:
|
||||
return Either.forRight(locations);
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
return CompletableFuture.completedFuture(Either.forLeft(ImmutableList.of()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<List<? extends Location>> references(ReferenceParams params) {
|
||||
ReferencesHandler h = this.referencesHandler;
|
||||
@@ -783,10 +817,19 @@ public class SimpleTextDocumentService implements TextDocumentService, DocumentE
|
||||
Assert.isNull("A defintion handler is already set, multiple handlers not supported yet", definitionHandler);
|
||||
this.definitionHandler = h;
|
||||
}
|
||||
|
||||
public synchronized void onImplementation(ImplementationHandler h) {
|
||||
Assert.isNull("An implementation handler is already set, multiple handlers not supported yet", implementationHandler);
|
||||
this.implementationHandler = h;
|
||||
}
|
||||
|
||||
public boolean hasDefinitionHandler() {
|
||||
return definitionHandler != null;
|
||||
}
|
||||
|
||||
public boolean hasImplementationHandler() {
|
||||
return implementationHandler != null;
|
||||
}
|
||||
|
||||
public synchronized void onReferences(ReferencesHandler h) {
|
||||
Assert.isNull("A references handler is already set, multiple handlers not supported yet", referencesHandler);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2018, 2021 Pivotal, Inc.
|
||||
* Copyright (c) 2018, 2025 Pivotal, Inc.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
@@ -28,6 +28,7 @@ import org.springframework.ide.vscode.commons.languageserver.reconcile.Diagnosti
|
||||
import org.springframework.ide.vscode.commons.languageserver.util.CompletionServerCapabilityRegistration;
|
||||
import org.springframework.ide.vscode.commons.languageserver.util.DefinitionHandler;
|
||||
import org.springframework.ide.vscode.commons.languageserver.util.DocumentSymbolHandler;
|
||||
import org.springframework.ide.vscode.commons.languageserver.util.ImplementationHandler;
|
||||
import org.springframework.ide.vscode.commons.languageserver.util.LanguageSpecific;
|
||||
import org.springframework.ide.vscode.commons.languageserver.util.SimpleLanguageServer;
|
||||
import org.springframework.ide.vscode.commons.languageserver.util.SimpleTextDocumentService;
|
||||
@@ -93,6 +94,38 @@ public class LanguageServerAutoConf {
|
||||
}
|
||||
}
|
||||
|
||||
@ConditionalOnBean(ImplementationHandler.class)
|
||||
@Bean
|
||||
InitializingBean registerImplementationHandler(SimpleTextDocumentService documents,
|
||||
List<ImplementationHandler> implHandlers) {
|
||||
if (implHandlers.size() == 1) {
|
||||
return () -> documents.onImplementation(implHandlers.get(0));
|
||||
} else {
|
||||
Map<LanguageId, ImplementationHandler> handlers = new HashMap<>(implHandlers.size());
|
||||
for (ImplementationHandler h : implHandlers) {
|
||||
Assert.isInstanceOf(LanguageSpecific.class, h, "Only language specific defintion handlers supported!");
|
||||
for (LanguageId l : ((LanguageSpecific)h).supportedLanguages()) {
|
||||
Assert.isTrue(!handlers.containsKey(l), "Multiple definition handlers for the same language not supported!");
|
||||
handlers.put(l, h);
|
||||
}
|
||||
}
|
||||
|
||||
ImmutableMap<LanguageId, ImplementationHandler> immutableMap = ImmutableMap.copyOf(handlers);
|
||||
return () -> documents.onImplementation((cancelToken, position) -> {
|
||||
TextDocument doc = documents.getLatestSnapshot(position);
|
||||
|
||||
if (doc != null) {
|
||||
LanguageId language = doc.getLanguageId();
|
||||
ImplementationHandler handler = immutableMap.get(language);
|
||||
if (handler != null) {
|
||||
return handler.handle(cancelToken, position);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ConditionalOnBean(DocumentSymbolHandler.class)
|
||||
@Bean
|
||||
InitializingBean registerDocumentSymbolHandler(SimpleTextDocumentService documents, DocumentSymbolHandler handler) {
|
||||
|
||||
@@ -44,6 +44,7 @@ import org.eclipse.lsp4j.Diagnostic;
|
||||
import org.eclipse.lsp4j.DocumentHighlight;
|
||||
import org.eclipse.lsp4j.DocumentSymbol;
|
||||
import org.eclipse.lsp4j.Hover;
|
||||
import org.eclipse.lsp4j.ImplementationParams;
|
||||
import org.eclipse.lsp4j.InsertReplaceEdit;
|
||||
import org.eclipse.lsp4j.Location;
|
||||
import org.eclipse.lsp4j.LocationLink;
|
||||
@@ -864,24 +865,39 @@ public class Editor {
|
||||
return "Editor(\n" + getText() + "\n)";
|
||||
}
|
||||
|
||||
public void assertLinkTargets(String hoverOver, Collection<LocationLink> expectedLocations) throws Exception {
|
||||
public void assertDefinitionLinkTargets(String hoverOver, Collection<LocationLink> expectedLocations) throws Exception {
|
||||
int pos = getRawText().indexOf(hoverOver);
|
||||
if (pos >= 0) {
|
||||
pos += hoverOver.length() / 2;
|
||||
}
|
||||
assertTrue(pos>=0, "Not found in editor: '"+hoverOver+"'");
|
||||
|
||||
assertLinkTargets(doc.toPosition(pos), expectedLocations);
|
||||
assertDefinitionLinkTargets(doc.toPosition(pos), expectedLocations);
|
||||
}
|
||||
|
||||
public void assertLinkTargets(Position pos, Collection<LocationLink> expectedLocations) throws Exception {
|
||||
public void assertDefinitionLinkTargets(Position pos, Collection<LocationLink> expectedLocations) throws Exception {
|
||||
DefinitionParams params = new DefinitionParams(new TextDocumentIdentifier(getUri()), pos);
|
||||
List<? extends LocationLink> definitions = harness.getDefinitions(params);
|
||||
assertEquals(ImmutableSet.copyOf(expectedLocations), ImmutableSet.copyOf(definitions));
|
||||
}
|
||||
|
||||
|
||||
public void assertNoLinkTargets(String hoverOver) throws Exception {
|
||||
public void assertImplementationLinkTargets(String hoverOver, Collection<LocationLink> expectedLocations) throws Exception {
|
||||
int pos = getRawText().indexOf(hoverOver);
|
||||
if (pos >= 0) {
|
||||
pos += hoverOver.length() / 2;
|
||||
}
|
||||
assertTrue(pos>=0, "Not found in editor: '"+hoverOver+"'");
|
||||
|
||||
assertImplementationLinkTargets(doc.toPosition(pos), expectedLocations);
|
||||
}
|
||||
|
||||
public void assertImplementationLinkTargets(Position pos, Collection<LocationLink> expectedLocations) throws Exception {
|
||||
ImplementationParams params = new ImplementationParams(new TextDocumentIdentifier(getUri()), pos);
|
||||
List<? extends LocationLink> definitions = harness.getImplemetations(params);
|
||||
assertEquals(ImmutableSet.copyOf(expectedLocations), ImmutableSet.copyOf(definitions));
|
||||
}
|
||||
|
||||
public void assertNoDefinitionLinkTargets(String hoverOver) throws Exception {
|
||||
int pos = getRawText().indexOf(hoverOver);
|
||||
if (pos >= 0) {
|
||||
pos += hoverOver.length() / 2;
|
||||
|
||||
@@ -77,6 +77,7 @@ import org.eclipse.lsp4j.FileChangeType;
|
||||
import org.eclipse.lsp4j.FileEvent;
|
||||
import org.eclipse.lsp4j.Hover;
|
||||
import org.eclipse.lsp4j.HoverParams;
|
||||
import org.eclipse.lsp4j.ImplementationParams;
|
||||
import org.eclipse.lsp4j.InitializeParams;
|
||||
import org.eclipse.lsp4j.InitializeResult;
|
||||
import org.eclipse.lsp4j.InlayHint;
|
||||
@@ -825,6 +826,11 @@ public class LanguageServerHarness {
|
||||
return getServer().getTextDocumentService().definition(params).get().getRight();
|
||||
}
|
||||
|
||||
public List<? extends LocationLink> getImplemetations(ImplementationParams params) throws Exception {
|
||||
waitForReconcile(); //goto definitions relies on reconciler infos! Must wait or race condition breaking tests occasionally.
|
||||
return getServer().getTextDocumentService().implementation(params).get().getRight();
|
||||
}
|
||||
|
||||
public static void assertDocumentation(String expected, CompletionItem completion) {
|
||||
assertEquals(expected, getDocString(completion));
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ import org.springframework.ide.vscode.boot.java.conditionals.ConditionalOnBeanDe
|
||||
import org.springframework.ide.vscode.boot.java.conditionals.ConditionalOnResourceDefinitionProvider;
|
||||
import org.springframework.ide.vscode.boot.java.copilot.util.ResponseModifier;
|
||||
import org.springframework.ide.vscode.boot.java.data.DataRepositoryAotMetadataService;
|
||||
import org.springframework.ide.vscode.boot.java.data.GenAotQueryMethodDefinitionProvider;
|
||||
import org.springframework.ide.vscode.boot.java.data.GenAotQueryMethodImplProvider;
|
||||
import org.springframework.ide.vscode.boot.java.data.jpa.queries.DataQueryParameterDefinitionProvider;
|
||||
import org.springframework.ide.vscode.boot.java.data.jpa.queries.JdtDataQuerySemanticTokensProvider;
|
||||
import org.springframework.ide.vscode.boot.java.handlers.BootJavaCodeActionProvider;
|
||||
@@ -419,8 +419,11 @@ public class BootLanguageServerBootApp {
|
||||
new QualifierDefinitionProvider(springIndex),
|
||||
new NamedDefinitionProvider(springIndex),
|
||||
new DataQueryParameterDefinitionProvider(server.getTextDocumentService(), qurySemanticTokens),
|
||||
new SpelDefinitionProvider(springIndex, cuCache),
|
||||
new GenAotQueryMethodDefinitionProvider(server, cuCache, projectFinder)));
|
||||
new SpelDefinitionProvider(springIndex, cuCache)
|
||||
),
|
||||
List.of(
|
||||
new GenAotQueryMethodImplProvider(server, cuCache, projectFinder)
|
||||
));
|
||||
}
|
||||
|
||||
@Bean
|
||||
|
||||
@@ -19,8 +19,8 @@ import org.eclipse.lsp4j.TextDocumentIdentifier;
|
||||
import org.eclipse.lsp4j.jsonrpc.CancelChecker;
|
||||
import org.springframework.ide.vscode.commons.java.IJavaProject;
|
||||
|
||||
public interface IJavaDefinitionProvider {
|
||||
public interface IJavaLocationLinksProvider {
|
||||
|
||||
List<LocationLink> getDefinitions(CancelChecker cancelToken, IJavaProject project, TextDocumentIdentifier docId, CompilationUnit cu, ASTNode n, int offset);
|
||||
List<LocationLink> getLocationLinks(CancelChecker cancelToken, IJavaProject project, TextDocumentIdentifier docId, CompilationUnit cu, ASTNode n, int offset);
|
||||
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2023 VMware, Inc.
|
||||
* Copyright (c) 2023, 2025 VMware, Inc.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
@@ -18,8 +18,10 @@ import java.util.List;
|
||||
import org.eclipse.jdt.core.dom.ASTNode;
|
||||
import org.eclipse.jdt.core.dom.NodeFinder;
|
||||
import org.eclipse.lsp4j.DefinitionParams;
|
||||
import org.eclipse.lsp4j.ImplementationParams;
|
||||
import org.eclipse.lsp4j.LocationLink;
|
||||
import org.eclipse.lsp4j.TextDocumentIdentifier;
|
||||
import org.eclipse.lsp4j.TextDocumentPositionAndWorkDoneProgressAndPartialResultParams;
|
||||
import org.eclipse.lsp4j.jsonrpc.CancelChecker;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -27,25 +29,29 @@ import org.springframework.ide.vscode.boot.java.utils.CompilationUnitCache;
|
||||
import org.springframework.ide.vscode.commons.java.IJavaProject;
|
||||
import org.springframework.ide.vscode.commons.languageserver.java.JavaProjectFinder;
|
||||
import org.springframework.ide.vscode.commons.languageserver.util.DefinitionHandler;
|
||||
import org.springframework.ide.vscode.commons.languageserver.util.ImplementationHandler;
|
||||
import org.springframework.ide.vscode.commons.languageserver.util.LanguageSpecific;
|
||||
import org.springframework.ide.vscode.commons.util.text.LanguageId;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableList.Builder;
|
||||
|
||||
public class JavaDefinitionHandler implements DefinitionHandler, LanguageSpecific {
|
||||
public class JavaDefinitionHandler implements DefinitionHandler, ImplementationHandler, LanguageSpecific {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(JavaDefinitionHandler.class);
|
||||
|
||||
private CompilationUnitCache cuCache;
|
||||
private JavaProjectFinder projectFinder;
|
||||
private Collection<IJavaDefinitionProvider> providers;
|
||||
private final CompilationUnitCache cuCache;
|
||||
private final JavaProjectFinder projectFinder;
|
||||
private final Collection<IJavaLocationLinksProvider> defProviders;
|
||||
private final Collection<IJavaLocationLinksProvider> implProviders;
|
||||
|
||||
public JavaDefinitionHandler(CompilationUnitCache cuCache, JavaProjectFinder projectFinder,
|
||||
Collection<IJavaDefinitionProvider> providers) {
|
||||
Collection<IJavaLocationLinksProvider> defProviders,
|
||||
Collection<IJavaLocationLinksProvider> implProviders) {
|
||||
this.cuCache = cuCache;
|
||||
this.projectFinder = projectFinder;
|
||||
this.providers = providers;
|
||||
this.defProviders = defProviders;
|
||||
this.implProviders = implProviders;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -55,21 +61,30 @@ public class JavaDefinitionHandler implements DefinitionHandler, LanguageSpecifi
|
||||
|
||||
@Override
|
||||
public List<LocationLink> handle(CancelChecker cancelToken, DefinitionParams definitionParams) {
|
||||
TextDocumentIdentifier doc = definitionParams.getTextDocument();
|
||||
return findLinks(cancelToken, defProviders, definitionParams);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<LocationLink> handle(CancelChecker cancelToken, ImplementationParams implParams) {
|
||||
return findLinks(cancelToken, implProviders, implParams);
|
||||
}
|
||||
|
||||
private List<LocationLink> findLinks(CancelChecker cancelToken, Collection<IJavaLocationLinksProvider> providers, TextDocumentPositionAndWorkDoneProgressAndPartialResultParams params) {
|
||||
TextDocumentIdentifier doc = params.getTextDocument();
|
||||
IJavaProject project = projectFinder.find(doc).orElse(null);
|
||||
if (project != null) {
|
||||
URI docUri = URI.create(doc.getUri());
|
||||
return cuCache.withCompilationUnit(project, docUri, cu -> {
|
||||
Builder<LocationLink> builder = ImmutableList.builder();
|
||||
if (cu != null) {
|
||||
int start = cu.getPosition(definitionParams.getPosition().getLine() + 1, definitionParams.getPosition().getCharacter());
|
||||
int start = cu.getPosition(params.getPosition().getLine() + 1, params.getPosition().getCharacter());
|
||||
ASTNode node = NodeFinder.perform(cu, start, 0);
|
||||
for (IJavaDefinitionProvider provider : providers) {
|
||||
for (IJavaLocationLinksProvider provider : providers) {
|
||||
if (cancelToken.isCanceled()) {
|
||||
break;
|
||||
}
|
||||
try {
|
||||
builder.addAll(provider.getDefinitions(cancelToken, project, doc, cu, node, start));
|
||||
builder.addAll(provider.getLocationLinks(cancelToken, project, doc, cu, node, start));
|
||||
} catch (Exception e) {
|
||||
log.error("", e);
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ import org.eclipse.lsp4j.TextDocumentIdentifier;
|
||||
import org.eclipse.lsp4j.jsonrpc.CancelChecker;
|
||||
import org.springframework.ide.vscode.boot.index.SpringMetamodelIndex;
|
||||
import org.springframework.ide.vscode.boot.java.Annotations;
|
||||
import org.springframework.ide.vscode.boot.java.IJavaDefinitionProvider;
|
||||
import org.springframework.ide.vscode.boot.java.IJavaLocationLinksProvider;
|
||||
import org.springframework.ide.vscode.boot.java.utils.ASTUtils;
|
||||
import org.springframework.ide.vscode.commons.java.IJavaProject;
|
||||
import org.springframework.ide.vscode.commons.protocol.spring.Bean;
|
||||
@@ -33,7 +33,7 @@ import org.springframework.ide.vscode.commons.protocol.spring.Bean;
|
||||
/**
|
||||
* @author Martin Lippert
|
||||
*/
|
||||
public class DependsOnDefinitionProvider implements IJavaDefinitionProvider {
|
||||
public class DependsOnDefinitionProvider implements IJavaLocationLinksProvider {
|
||||
|
||||
private final SpringMetamodelIndex springIndex;
|
||||
|
||||
@@ -42,7 +42,7 @@ public class DependsOnDefinitionProvider implements IJavaDefinitionProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<LocationLink> getDefinitions(CancelChecker cancelToken, IJavaProject project, TextDocumentIdentifier docId, CompilationUnit cu, ASTNode n, int offset) {
|
||||
public List<LocationLink> getLocationLinks(CancelChecker cancelToken, IJavaProject project, TextDocumentIdentifier docId, CompilationUnit cu, ASTNode n, int offset) {
|
||||
if (n instanceof StringLiteral) {
|
||||
StringLiteral valueNode = (StringLiteral) n;
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ import org.eclipse.lsp4j.TextDocumentIdentifier;
|
||||
import org.eclipse.lsp4j.jsonrpc.CancelChecker;
|
||||
import org.springframework.ide.vscode.boot.index.SpringMetamodelIndex;
|
||||
import org.springframework.ide.vscode.boot.java.Annotations;
|
||||
import org.springframework.ide.vscode.boot.java.IJavaDefinitionProvider;
|
||||
import org.springframework.ide.vscode.boot.java.IJavaLocationLinksProvider;
|
||||
import org.springframework.ide.vscode.boot.java.utils.ASTUtils;
|
||||
import org.springframework.ide.vscode.commons.java.IJavaProject;
|
||||
import org.springframework.ide.vscode.commons.protocol.spring.Bean;
|
||||
@@ -35,7 +35,7 @@ import org.springframework.ide.vscode.commons.protocol.spring.Bean;
|
||||
/**
|
||||
* @author Martin Lippert
|
||||
*/
|
||||
public class NamedDefinitionProvider implements IJavaDefinitionProvider {
|
||||
public class NamedDefinitionProvider implements IJavaLocationLinksProvider {
|
||||
|
||||
private final SpringMetamodelIndex springIndex;
|
||||
|
||||
@@ -44,7 +44,7 @@ public class NamedDefinitionProvider implements IJavaDefinitionProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<LocationLink> getDefinitions(CancelChecker cancelToken, IJavaProject project, TextDocumentIdentifier docId, CompilationUnit cu, ASTNode n, int offset) {
|
||||
public List<LocationLink> getLocationLinks(CancelChecker cancelToken, IJavaProject project, TextDocumentIdentifier docId, CompilationUnit cu, ASTNode n, int offset) {
|
||||
if (n instanceof StringLiteral) {
|
||||
StringLiteral valueNode = (StringLiteral) n;
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ import org.eclipse.lsp4j.TextDocumentIdentifier;
|
||||
import org.eclipse.lsp4j.jsonrpc.CancelChecker;
|
||||
import org.springframework.ide.vscode.boot.index.SpringMetamodelIndex;
|
||||
import org.springframework.ide.vscode.boot.java.Annotations;
|
||||
import org.springframework.ide.vscode.boot.java.IJavaDefinitionProvider;
|
||||
import org.springframework.ide.vscode.boot.java.IJavaLocationLinksProvider;
|
||||
import org.springframework.ide.vscode.boot.java.utils.ASTUtils;
|
||||
import org.springframework.ide.vscode.commons.java.IJavaProject;
|
||||
import org.springframework.ide.vscode.commons.protocol.spring.Bean;
|
||||
@@ -33,7 +33,7 @@ import org.springframework.ide.vscode.commons.protocol.spring.Bean;
|
||||
/**
|
||||
* @author Martin Lippert
|
||||
*/
|
||||
public class QualifierDefinitionProvider implements IJavaDefinitionProvider {
|
||||
public class QualifierDefinitionProvider implements IJavaLocationLinksProvider {
|
||||
|
||||
private final SpringMetamodelIndex springIndex;
|
||||
|
||||
@@ -42,7 +42,7 @@ public class QualifierDefinitionProvider implements IJavaDefinitionProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<LocationLink> getDefinitions(CancelChecker cancelToken, IJavaProject project, TextDocumentIdentifier docId, CompilationUnit cu, ASTNode n, int offset) {
|
||||
public List<LocationLink> getLocationLinks(CancelChecker cancelToken, IJavaProject project, TextDocumentIdentifier docId, CompilationUnit cu, ASTNode n, int offset) {
|
||||
if (n instanceof StringLiteral) {
|
||||
StringLiteral valueNode = (StringLiteral) n;
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ import org.eclipse.lsp4j.TextDocumentIdentifier;
|
||||
import org.eclipse.lsp4j.jsonrpc.CancelChecker;
|
||||
import org.springframework.ide.vscode.boot.index.SpringMetamodelIndex;
|
||||
import org.springframework.ide.vscode.boot.java.Annotations;
|
||||
import org.springframework.ide.vscode.boot.java.IJavaDefinitionProvider;
|
||||
import org.springframework.ide.vscode.boot.java.IJavaLocationLinksProvider;
|
||||
import org.springframework.ide.vscode.boot.java.utils.ASTUtils;
|
||||
import org.springframework.ide.vscode.commons.java.IJavaProject;
|
||||
import org.springframework.ide.vscode.commons.protocol.spring.Bean;
|
||||
@@ -33,7 +33,7 @@ import org.springframework.ide.vscode.commons.protocol.spring.Bean;
|
||||
/**
|
||||
* @author Martin Lippert
|
||||
*/
|
||||
public class ResourceDefinitionProvider implements IJavaDefinitionProvider {
|
||||
public class ResourceDefinitionProvider implements IJavaLocationLinksProvider {
|
||||
|
||||
private final SpringMetamodelIndex springIndex;
|
||||
|
||||
@@ -42,7 +42,7 @@ public class ResourceDefinitionProvider implements IJavaDefinitionProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<LocationLink> getDefinitions(CancelChecker cancelToken, IJavaProject project, TextDocumentIdentifier docId, CompilationUnit cu, ASTNode n, int offset) {
|
||||
public List<LocationLink> getLocationLinks(CancelChecker cancelToken, IJavaProject project, TextDocumentIdentifier docId, CompilationUnit cu, ASTNode n, int offset) {
|
||||
if (n instanceof StringLiteral) {
|
||||
StringLiteral valueNode = (StringLiteral) n;
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ import org.eclipse.lsp4j.TextDocumentIdentifier;
|
||||
import org.eclipse.lsp4j.jsonrpc.CancelChecker;
|
||||
import org.springframework.ide.vscode.boot.index.SpringMetamodelIndex;
|
||||
import org.springframework.ide.vscode.boot.java.Annotations;
|
||||
import org.springframework.ide.vscode.boot.java.IJavaDefinitionProvider;
|
||||
import org.springframework.ide.vscode.boot.java.IJavaLocationLinksProvider;
|
||||
import org.springframework.ide.vscode.boot.java.utils.ASTUtils;
|
||||
import org.springframework.ide.vscode.commons.java.IJavaProject;
|
||||
import org.springframework.ide.vscode.commons.protocol.spring.Bean;
|
||||
@@ -35,7 +35,7 @@ import org.springframework.ide.vscode.commons.protocol.spring.Bean;
|
||||
/**
|
||||
* @author Karthik Sankaranarayanan
|
||||
*/
|
||||
public class ConditionalOnBeanDefinitionProvider implements IJavaDefinitionProvider {
|
||||
public class ConditionalOnBeanDefinitionProvider implements IJavaLocationLinksProvider {
|
||||
|
||||
private final SpringMetamodelIndex springIndex;
|
||||
|
||||
@@ -44,7 +44,7 @@ public class ConditionalOnBeanDefinitionProvider implements IJavaDefinitionProvi
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<LocationLink> getDefinitions(CancelChecker cancelToken, IJavaProject project, TextDocumentIdentifier docId, CompilationUnit cu, ASTNode n, int offset) {
|
||||
public List<LocationLink> getLocationLinks(CancelChecker cancelToken, IJavaProject project, TextDocumentIdentifier docId, CompilationUnit cu, ASTNode n, int offset) {
|
||||
if (n instanceof StringLiteral) {
|
||||
StringLiteral valueNode = (StringLiteral) n;
|
||||
|
||||
|
||||
@@ -23,15 +23,15 @@ import org.eclipse.lsp4j.Position;
|
||||
import org.eclipse.lsp4j.Range;
|
||||
import org.eclipse.lsp4j.TextDocumentIdentifier;
|
||||
import org.eclipse.lsp4j.jsonrpc.CancelChecker;
|
||||
import org.springframework.ide.vscode.boot.java.IJavaDefinitionProvider;
|
||||
import org.springframework.ide.vscode.boot.java.IJavaLocationLinksProvider;
|
||||
import org.springframework.ide.vscode.boot.java.utils.ASTUtils;
|
||||
import org.springframework.ide.vscode.commons.java.IClasspathUtil;
|
||||
import org.springframework.ide.vscode.commons.java.IJavaProject;
|
||||
|
||||
public class ConditionalOnResourceDefinitionProvider implements IJavaDefinitionProvider {
|
||||
public class ConditionalOnResourceDefinitionProvider implements IJavaLocationLinksProvider {
|
||||
|
||||
@Override
|
||||
public List<LocationLink> getDefinitions(CancelChecker cancelToken, IJavaProject project,
|
||||
public List<LocationLink> getLocationLinks(CancelChecker cancelToken, IJavaProject project,
|
||||
TextDocumentIdentifier docId, CompilationUnit cu, ASTNode n, int offset) {
|
||||
|
||||
if (n instanceof StringLiteral) {
|
||||
|
||||
@@ -126,7 +126,7 @@ public class DataRepositoryAotMetadataCodeLensProvider implements CodeLensProvid
|
||||
codeLenses.add(new CodeLens(range, refactorings.createFixCommand(COVERT_TO_QUERY_LABEL, createFixDescriptor(mb, document.getUri(), queryStatement)), null));
|
||||
}
|
||||
|
||||
Command impl = new Command("Implementation", GenAotQueryMethodDefinitionProvider.CMD_NAVIGATE_TO_IMPL, List.of(new GenAotQueryMethodDefinitionProvider.GoToImplParams(
|
||||
Command impl = new Command("Implementation", GenAotQueryMethodImplProvider.CMD_NAVIGATE_TO_IMPL, List.of(new GenAotQueryMethodImplProvider.GoToImplParams(
|
||||
document.getId(),
|
||||
mb.getDeclaringClass().getQualifiedName(),
|
||||
mb.getName(),
|
||||
|
||||
@@ -42,7 +42,7 @@ import org.eclipse.lsp4j.TextDocumentIdentifier;
|
||||
import org.eclipse.lsp4j.jsonrpc.CancelChecker;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.ide.vscode.boot.java.IJavaDefinitionProvider;
|
||||
import org.springframework.ide.vscode.boot.java.IJavaLocationLinksProvider;
|
||||
import org.springframework.ide.vscode.boot.java.utils.ASTUtils;
|
||||
import org.springframework.ide.vscode.boot.java.utils.CompilationUnitCache;
|
||||
import org.springframework.ide.vscode.commons.Version;
|
||||
@@ -57,9 +57,9 @@ import org.springframework.ide.vscode.commons.util.BadLocationException;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonElement;
|
||||
|
||||
public class GenAotQueryMethodDefinitionProvider implements IJavaDefinitionProvider {
|
||||
public class GenAotQueryMethodImplProvider implements IJavaLocationLinksProvider {
|
||||
|
||||
private static Logger log = LoggerFactory.getLogger(GenAotQueryMethodDefinitionProvider.class);
|
||||
private static Logger log = LoggerFactory.getLogger(GenAotQueryMethodImplProvider.class);
|
||||
|
||||
public static final String CMD_NAVIGATE_TO_IMPL = "sts/boot/open-data-query-method-aot-definition";
|
||||
|
||||
@@ -67,7 +67,7 @@ public class GenAotQueryMethodDefinitionProvider implements IJavaDefinitionProvi
|
||||
private final SimpleTextDocumentService docService;
|
||||
private final JavaProjectFinder projectFinder;
|
||||
|
||||
public GenAotQueryMethodDefinitionProvider(SimpleLanguageServer server, CompilationUnitCache cuCache, JavaProjectFinder projectFinder) {
|
||||
public GenAotQueryMethodImplProvider(SimpleLanguageServer server, CompilationUnitCache cuCache, JavaProjectFinder projectFinder) {
|
||||
this.cuCache = cuCache;
|
||||
this.docService = server.getTextDocumentService();
|
||||
this.projectFinder = projectFinder;
|
||||
@@ -75,7 +75,7 @@ public class GenAotQueryMethodDefinitionProvider implements IJavaDefinitionProvi
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<LocationLink> getDefinitions(CancelChecker cancelToken, IJavaProject project,
|
||||
public List<LocationLink> getLocationLinks(CancelChecker cancelToken, IJavaProject project,
|
||||
TextDocumentIdentifier docId, CompilationUnit cu, ASTNode n, int offset) {
|
||||
if (n instanceof SimpleName && n.getParent() instanceof MethodDeclaration md) {
|
||||
Version version = SpringProjectUtil.getDependencyVersion(project, "spring-data-jpa");
|
||||
@@ -90,7 +90,7 @@ public class GenAotQueryMethodDefinitionProvider implements IJavaDefinitionProvi
|
||||
try {
|
||||
Range originRange = docService.getLatestSnapshot(docId.getUri()).toRange(md.getName().getStartPosition(), md.getName().getLength());
|
||||
GoToImplParams params = new GoToImplParams(docId, methodBinding.getDeclaringClass().getQualifiedName(), methodBinding.getName(), Arrays.stream(methodBinding.getParameterTypes()).map(b -> b.getQualifiedName()).toArray(String[]::new), originRange);
|
||||
return findDefinitions(project, params);
|
||||
return findImplLocations(project, params);
|
||||
} catch (BadLocationException e) {
|
||||
log.error("", e);
|
||||
}
|
||||
@@ -101,7 +101,7 @@ public class GenAotQueryMethodDefinitionProvider implements IJavaDefinitionProvi
|
||||
return List.of();
|
||||
}
|
||||
|
||||
private List<LocationLink> findDefinitions(IJavaProject project, GoToImplParams implParams) {
|
||||
private List<LocationLink> findImplLocations(IJavaProject project, GoToImplParams implParams) {
|
||||
String genRepoFqn = implParams.repoFqName() + "Impl__Aot";
|
||||
Path relativeGenSourcePath = Paths.get("%s.java".formatted(genRepoFqn.replace('.', '/')));
|
||||
List<LocationLink> defs = findInSourceFolder(project, relativeGenSourcePath, genRepoFqn, implParams);
|
||||
@@ -215,7 +215,7 @@ public class GenAotQueryMethodDefinitionProvider implements IJavaDefinitionProvi
|
||||
if (project.isEmpty()) {
|
||||
return List.<LocationLink>of();
|
||||
}
|
||||
return findDefinitions(project.get(), implParams);
|
||||
return findImplLocations(project.get(), implParams);
|
||||
}).thenCompose(links -> {
|
||||
if (links.isEmpty()) {
|
||||
return CompletableFuture.completedFuture(null);
|
||||
@@ -24,7 +24,7 @@ import org.eclipse.lsp4j.TextDocumentIdentifier;
|
||||
import org.eclipse.lsp4j.jsonrpc.CancelChecker;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.ide.vscode.boot.java.IJavaDefinitionProvider;
|
||||
import org.springframework.ide.vscode.boot.java.IJavaLocationLinksProvider;
|
||||
import org.springframework.ide.vscode.boot.java.annotations.AnnotationHierarchies;
|
||||
import org.springframework.ide.vscode.commons.java.IJavaProject;
|
||||
import org.springframework.ide.vscode.commons.languageserver.semantic.tokens.SemanticTokenData;
|
||||
@@ -33,7 +33,7 @@ import org.springframework.ide.vscode.commons.util.BadLocationException;
|
||||
import org.springframework.ide.vscode.commons.util.Collector;
|
||||
import org.springframework.ide.vscode.commons.util.text.TextDocument;
|
||||
|
||||
public class DataQueryParameterDefinitionProvider implements IJavaDefinitionProvider {
|
||||
public class DataQueryParameterDefinitionProvider implements IJavaLocationLinksProvider {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(DataQueryParameterDefinitionProvider.class);
|
||||
|
||||
@@ -46,7 +46,7 @@ public class DataQueryParameterDefinitionProvider implements IJavaDefinitionProv
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<LocationLink> getDefinitions(CancelChecker cancelToken, IJavaProject project,
|
||||
public List<LocationLink> getLocationLinks(CancelChecker cancelToken, IJavaProject project,
|
||||
TextDocumentIdentifier docId, CompilationUnit cu, ASTNode n, int offset) {
|
||||
if (n instanceof StringLiteral || n instanceof TextBlock) {
|
||||
AnnotationHierarchies annotationHierarchies = AnnotationHierarchies.get(cu);
|
||||
|
||||
@@ -50,7 +50,7 @@ import org.springframework.expression.spel.standard.SpelExpression;
|
||||
import org.springframework.expression.spel.standard.SpelExpressionParser;
|
||||
import org.springframework.ide.vscode.boot.index.SpringMetamodelIndex;
|
||||
import org.springframework.ide.vscode.boot.java.Annotations;
|
||||
import org.springframework.ide.vscode.boot.java.IJavaDefinitionProvider;
|
||||
import org.springframework.ide.vscode.boot.java.IJavaLocationLinksProvider;
|
||||
import org.springframework.ide.vscode.boot.java.embedded.lang.EmbeddedLanguageSnippet;
|
||||
import org.springframework.ide.vscode.boot.java.links.SourceLinks;
|
||||
import org.springframework.ide.vscode.boot.java.utils.ASTUtils;
|
||||
@@ -74,7 +74,7 @@ import reactor.util.function.Tuples;
|
||||
/**
|
||||
* @author Udayani V
|
||||
*/
|
||||
public class SpelDefinitionProvider implements IJavaDefinitionProvider {
|
||||
public class SpelDefinitionProvider implements IJavaLocationLinksProvider {
|
||||
|
||||
protected static Logger logger = LoggerFactory.getLogger(SpelDefinitionProvider.class);
|
||||
|
||||
@@ -92,7 +92,7 @@ public class SpelDefinitionProvider implements IJavaDefinitionProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<LocationLink> getDefinitions(CancelChecker cancelToken, IJavaProject project,
|
||||
public List<LocationLink> getLocationLinks(CancelChecker cancelToken, IJavaProject project,
|
||||
TextDocumentIdentifier docId, CompilationUnit cu, ASTNode n, int offset) {
|
||||
if (n instanceof StringLiteral) {
|
||||
StringLiteral valueNode = (StringLiteral) n;
|
||||
|
||||
@@ -29,7 +29,7 @@ import org.eclipse.lsp4j.TextDocumentIdentifier;
|
||||
import org.eclipse.lsp4j.jsonrpc.CancelChecker;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.ide.vscode.boot.java.IJavaDefinitionProvider;
|
||||
import org.springframework.ide.vscode.boot.java.IJavaLocationLinksProvider;
|
||||
import org.springframework.ide.vscode.boot.java.utils.ASTUtils;
|
||||
import org.springframework.ide.vscode.boot.properties.BootPropertiesLanguageServerComponents;
|
||||
import org.springframework.ide.vscode.commons.java.IClasspathUtil;
|
||||
@@ -39,7 +39,7 @@ import org.yaml.snakeyaml.nodes.Node;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableList.Builder;
|
||||
|
||||
public class ValueDefinitionProvider implements IJavaDefinitionProvider {
|
||||
public class ValueDefinitionProvider implements IJavaLocationLinksProvider {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(ValueDefinitionProvider.class);
|
||||
private final PropertyExtractor propertyExtractor;
|
||||
@@ -49,7 +49,7 @@ public class ValueDefinitionProvider implements IJavaDefinitionProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<LocationLink> getDefinitions(CancelChecker cancelToken, IJavaProject project,
|
||||
public List<LocationLink> getLocationLinks(CancelChecker cancelToken, IJavaProject project,
|
||||
TextDocumentIdentifier docId, CompilationUnit cu, ASTNode n, int offset) {
|
||||
|
||||
if (n instanceof StringLiteral) {
|
||||
|
||||
@@ -95,7 +95,7 @@ public class DependsOnDefinitionProviderTest {
|
||||
beans[0].getLocation().getRange(), beans[0].getLocation().getRange(),
|
||||
null);
|
||||
|
||||
editor.assertLinkTargets("bean1", List.of(expectedLocation));
|
||||
editor.assertDefinitionLinkTargets("bean1", List.of(expectedLocation));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -122,7 +122,7 @@ public class DependsOnDefinitionProviderTest {
|
||||
beans[0].getLocation().getRange(), beans[0].getLocation().getRange(),
|
||||
null);
|
||||
|
||||
editor.assertLinkTargets("bean1", List.of(expectedLocation));
|
||||
editor.assertDefinitionLinkTargets("bean1", List.of(expectedLocation));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -156,7 +156,7 @@ public class DependsOnDefinitionProviderTest {
|
||||
beans[1].getLocation().getRange(), beans[1].getLocation().getRange(),
|
||||
null);
|
||||
|
||||
editor.assertLinkTargets("bean1", List.of(expectedLocation1, expectedLocation2));
|
||||
editor.assertDefinitionLinkTargets("bean1", List.of(expectedLocation1, expectedLocation2));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -108,7 +108,7 @@ public class NamedDefinitionProviderTest {
|
||||
locationNamedAnnotation1.getRange(), locationNamedAnnotation1.getRange(),
|
||||
null);
|
||||
|
||||
editor.assertLinkTargets("named1", List.of(expectedLocation));
|
||||
editor.assertDefinitionLinkTargets("named1", List.of(expectedLocation));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -131,7 +131,7 @@ public class NamedDefinitionProviderTest {
|
||||
locationNamedAnnotation1.getRange(), locationNamedAnnotation1.getRange(),
|
||||
null);
|
||||
|
||||
editor.assertLinkTargets("named1", List.of(expectedLocation));
|
||||
editor.assertDefinitionLinkTargets("named1", List.of(expectedLocation));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -150,7 +150,7 @@ public class NamedDefinitionProviderTest {
|
||||
|
||||
}""", tempJavaDocUri1);
|
||||
|
||||
editor.assertNoLinkTargets("bean1");
|
||||
editor.assertNoDefinitionLinkTargets("bean1");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ public class QualifierDefinitionProviderTest {
|
||||
beans[0].getLocation().getRange(), beans[0].getLocation().getRange(),
|
||||
null);
|
||||
|
||||
editor.assertLinkTargets("bean1", List.of(expectedLocation));
|
||||
editor.assertDefinitionLinkTargets("bean1", List.of(expectedLocation));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -108,7 +108,7 @@ public class QualifierDefinitionProviderTest {
|
||||
public class TestDependsOnClass {
|
||||
}""", tempJavaDocUri);
|
||||
|
||||
editor.assertNoLinkTargets("qualifier");
|
||||
editor.assertNoDefinitionLinkTargets("qualifier");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -13,7 +13,6 @@ package org.springframework.ide.vscode.boot.java.beans.test;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@@ -95,7 +94,7 @@ public class ResourceDefinitionProviderTest {
|
||||
beans[0].getLocation().getRange(), beans[0].getLocation().getRange(),
|
||||
null);
|
||||
|
||||
editor.assertLinkTargets("bean1", List.of(expectedLocation));
|
||||
editor.assertDefinitionLinkTargets("bean1", List.of(expectedLocation));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -129,7 +128,7 @@ public class ResourceDefinitionProviderTest {
|
||||
beans[1].getLocation().getRange(), beans[1].getLocation().getRange(),
|
||||
null);
|
||||
|
||||
editor.assertLinkTargets("bean1", List.of(expectedLocation1, expectedLocation2));
|
||||
editor.assertDefinitionLinkTargets("bean1", List.of(expectedLocation1, expectedLocation2));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ public class ConditionalOnBeanDefinitionProviderTest {
|
||||
beans[0].getLocation().getRange(), beans[0].getLocation().getRange(),
|
||||
null);
|
||||
|
||||
editor.assertLinkTargets("bean1", List.of(expectedLocation));
|
||||
editor.assertDefinitionLinkTargets("bean1", List.of(expectedLocation));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -121,7 +121,7 @@ public class ConditionalOnBeanDefinitionProviderTest {
|
||||
beans[0].getLocation().getRange(), beans[0].getLocation().getRange(),
|
||||
null);
|
||||
|
||||
editor.assertLinkTargets("bean1", List.of(expectedLocation));
|
||||
editor.assertDefinitionLinkTargets("bean1", List.of(expectedLocation));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -150,7 +150,7 @@ public class ConditionalOnBeanDefinitionProviderTest {
|
||||
beans[0].getLocation().getRange(), beans[0].getLocation().getRange(),
|
||||
null);
|
||||
|
||||
editor.assertLinkTargets("bean2", List.of(expectedLocation));
|
||||
editor.assertDefinitionLinkTargets("bean2", List.of(expectedLocation));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -179,7 +179,7 @@ public class ConditionalOnBeanDefinitionProviderTest {
|
||||
beans[0].getLocation().getRange(), beans[0].getLocation().getRange(),
|
||||
null);
|
||||
|
||||
editor.assertLinkTargets("bean2", List.of(expectedLocation));
|
||||
editor.assertDefinitionLinkTargets("bean2", List.of(expectedLocation));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -201,7 +201,7 @@ public class ConditionalOnBeanDefinitionProviderTest {
|
||||
}
|
||||
}""", tempJavaDocUri);
|
||||
|
||||
editor.assertNoLinkTargets("bean5");
|
||||
editor.assertNoDefinitionLinkTargets("bean5");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -223,7 +223,7 @@ public class ConditionalOnBeanDefinitionProviderTest {
|
||||
}
|
||||
}""", tempJavaDocUri);
|
||||
|
||||
editor.assertNoLinkTargets("bean5");
|
||||
editor.assertNoDefinitionLinkTargets("bean5");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -245,7 +245,7 @@ public class ConditionalOnBeanDefinitionProviderTest {
|
||||
}
|
||||
}""", tempJavaDocUri);
|
||||
|
||||
editor.assertNoLinkTargets("bean1");
|
||||
editor.assertNoDefinitionLinkTargets("bean1");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -267,7 +267,7 @@ public class ConditionalOnBeanDefinitionProviderTest {
|
||||
}
|
||||
}""", tempJavaDocUri);
|
||||
|
||||
editor.assertNoLinkTargets("bean1");
|
||||
editor.assertNoDefinitionLinkTargets("bean1");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ public class ConditionalOnResourceDefinitionProviderTest {
|
||||
new Range(new Position(0, 0), new Position(0, 0)),
|
||||
new Range(new Position(5, 23), new Position(5, 60)));
|
||||
|
||||
editor.assertLinkTargets("classpath:a-random-resource-root.md", List.of(expectedLocation));
|
||||
editor.assertDefinitionLinkTargets("classpath:a-random-resource-root.md", List.of(expectedLocation));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -41,7 +41,7 @@ import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@BootLanguageServerTest
|
||||
@Import(SymbolProviderTestConf.class)
|
||||
public class GenAotQueryMethodDefinitionProviderTest {
|
||||
public class GenAotQueryMethodImplProviderTest {
|
||||
|
||||
@Autowired private BootLanguageServerHarness harness;
|
||||
@Autowired private JavaProjectFinder projectFinder;
|
||||
@@ -73,9 +73,9 @@ public class GenAotQueryMethodDefinitionProviderTest {
|
||||
.resolve("target/spring-aot/main/sources/example/springdata/aot/UserRepositoryImpl__Aot.java").toUri()
|
||||
.toASCIIString());
|
||||
ll.setOriginSelectionRange(new Range(new Position(43, 15), new Position(43, 61)));
|
||||
ll.setTargetRange(new Range(new Position(144, 20), new Position(144, 66)));
|
||||
ll.setTargetSelectionRange(new Range(new Position(144, 20), new Position(144, 66)));
|
||||
editor.assertLinkTargets("findUserByLastnameStartingWith", List.of(ll));
|
||||
ll.setTargetRange(new Range(new Position(137, 20), new Position(137, 66)));
|
||||
ll.setTargetSelectionRange(new Range(new Position(137, 20), new Position(137, 66)));
|
||||
editor.assertImplementationLinkTargets("findUserByLastnameStartingWith", List.of(ll));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -89,9 +89,9 @@ public class GenAotQueryMethodDefinitionProviderTest {
|
||||
.resolve("target/spring-aot/main/sources/example/springdata/aot/UserRepositoryImpl__Aot.java").toUri()
|
||||
.toASCIIString());
|
||||
ll.setOriginSelectionRange(new Range(new Position(54, 15), new Position(54, 45)));
|
||||
ll.setTargetRange(new Range(new Position(190, 20), new Position(190, 50)));
|
||||
ll.setTargetSelectionRange(new Range(new Position(190, 20), new Position(190, 50)));
|
||||
editor.assertLinkTargets("usersWithUsernamesStartingWith", List.of(ll));
|
||||
ll.setTargetRange(new Range(new Position(180, 20), new Position(180, 50)));
|
||||
ll.setTargetSelectionRange(new Range(new Position(180, 20), new Position(180, 50)));
|
||||
editor.assertImplementationLinkTargets("usersWithUsernamesStartingWith", List.of(ll));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -99,7 +99,7 @@ public class GenAotQueryMethodDefinitionProviderTest {
|
||||
Path filePath = Paths.get(testProject.getLocationUri())
|
||||
.resolve("src/main/java/example/springdata/aot/UserRepository.java");
|
||||
Editor editor = harness.newEditor(LanguageId.JAVA, new String(Files.readAllBytes(filePath), StandardCharsets.UTF_8), filePath.toUri().toASCIIString());
|
||||
editor.assertLinkTargets("user", List.of());
|
||||
editor.assertImplementationLinkTargets("user", List.of());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -107,6 +107,6 @@ public class GenAotQueryMethodDefinitionProviderTest {
|
||||
Path filePath = Paths.get(testProject.getLocationUri())
|
||||
.resolve("src/main/java/example/springdata/aot/User.java");
|
||||
Editor editor = harness.newEditor(LanguageId.JAVA, new String(Files.readAllBytes(filePath), StandardCharsets.UTF_8), filePath.toUri().toASCIIString());
|
||||
editor.assertLinkTargets("getRegistrationDate", List.of());
|
||||
editor.assertImplementationLinkTargets("getRegistrationDate", List.of());
|
||||
}
|
||||
}
|
||||
@@ -115,7 +115,7 @@ public class SpelDefinitionProviderTest {
|
||||
LocationLink expectedLocation = new LocationLink(expectedDefinitionUriVisitService,
|
||||
beans[0].getLocation().getRange(), beans[0].getLocation().getRange(), null);
|
||||
|
||||
editor.assertLinkTargets("visitService", List.of(expectedLocation));
|
||||
editor.assertDefinitionLinkTargets("visitService", List.of(expectedLocation));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -155,8 +155,8 @@ public class SpelDefinitionProviderTest {
|
||||
LocationLink expectedLocation2 = new LocationLink(expectedDefinitionUriSpelClass,
|
||||
spelExpBean[0].getLocation().getRange(), spelExpBean[0].getLocation().getRange(), null);
|
||||
|
||||
editor.assertLinkTargets("visitService", List.of(expectedLocation1));
|
||||
editor.assertLinkTargets("spelExpressionsClass", List.of(expectedLocation2));
|
||||
editor.assertDefinitionLinkTargets("visitService", List.of(expectedLocation1));
|
||||
editor.assertDefinitionLinkTargets("spelExpressionsClass", List.of(expectedLocation2));
|
||||
|
||||
}
|
||||
|
||||
@@ -188,7 +188,7 @@ public class SpelDefinitionProviderTest {
|
||||
LocationLink expectedLocation2 = new LocationLink(expectedDefinitionUriSpelClass,
|
||||
spelExpBean[0].getLocation().getRange(), spelExpBean[0].getLocation().getRange(), null);
|
||||
|
||||
editor.assertLinkTargets("spelExpressionsClass", List.of(expectedLocation2));
|
||||
editor.assertDefinitionLinkTargets("spelExpressionsClass", List.of(expectedLocation2));
|
||||
|
||||
}
|
||||
|
||||
@@ -241,8 +241,8 @@ public class SpelDefinitionProviderTest {
|
||||
LocationLink expectedLocation2 = new LocationLink(expectedDefinitionUriSpelClass,
|
||||
new Range(new Position(37, 22), new Position(37, 28)), new Range(new Position(37, 22), new Position(37, 28)), null);
|
||||
|
||||
editor.assertLinkTargets("isValidVersion", List.of(expectedLocation1));
|
||||
editor.assertLinkTargets("concat", List.of(expectedLocation2));
|
||||
editor.assertDefinitionLinkTargets("isValidVersion", List.of(expectedLocation1));
|
||||
editor.assertDefinitionLinkTargets("concat", List.of(expectedLocation2));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ public class ValueDefinitionProviderTest {
|
||||
new Range(new Position(0, 0), new Position(0, 11)), new Range(new Position(0, 10), new Position(0, 11)),
|
||||
new Range(new Position(6, 8), new Position(6, 22)));
|
||||
|
||||
editor.assertLinkTargets("some.prop", List.of(expectedLocation));
|
||||
editor.assertDefinitionLinkTargets("some.prop", List.of(expectedLocation));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -113,7 +113,7 @@ public class ValueDefinitionProviderTest {
|
||||
new Range(new Position(1, 2), new Position(1, 9)), new Range(new Position(1, 8), new Position(1, 9)),
|
||||
new Range(new Position(6, 8), new Position(6, 22)));
|
||||
|
||||
editor.assertLinkTargets("some.prop", List.of(expectedLocation));
|
||||
editor.assertDefinitionLinkTargets("some.prop", List.of(expectedLocation));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -141,7 +141,7 @@ public class ValueDefinitionProviderTest {
|
||||
new Range(new Position(1, 2), new Position(1, 9)), new Range(new Position(1, 8), new Position(1, 9)),
|
||||
new Range(new Position(6, 8), new Position(6, 22)));
|
||||
|
||||
editor.assertLinkTargets("some.prop", List.of(expectedYamlLocation, expectedPropsLocation));
|
||||
editor.assertDefinitionLinkTargets("some.prop", List.of(expectedYamlLocation, expectedPropsLocation));
|
||||
|
||||
}
|
||||
|
||||
@@ -163,7 +163,7 @@ public class ValueDefinitionProviderTest {
|
||||
new Range(new Position(0, 0), new Position(0, 11)), new Range(new Position(0, 10), new Position(0, 11)),
|
||||
new Range(new Position(4, 23), new Position(4, 34)));
|
||||
|
||||
editor.assertLinkTargets("some.prop", List.of(expectedLocation));
|
||||
editor.assertDefinitionLinkTargets("some.prop", List.of(expectedLocation));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -184,7 +184,7 @@ public class ValueDefinitionProviderTest {
|
||||
new Range(new Position(0, 0), new Position(0, 11)), new Range(new Position(0, 10), new Position(0, 11)),
|
||||
new Range(new Position(4, 31), new Position(4, 42)));
|
||||
|
||||
editor.assertLinkTargets("some.prop", List.of(expectedLocation));
|
||||
editor.assertDefinitionLinkTargets("some.prop", List.of(expectedLocation));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -205,7 +205,7 @@ public class ValueDefinitionProviderTest {
|
||||
new Range(new Position(0, 0), new Position(0, 11)), new Range(new Position(0, 10), new Position(0, 11)),
|
||||
new Range(new Position(4, 47), new Position(4, 53)));
|
||||
|
||||
editor.assertLinkTargets("prop", List.of(expectedLocation));
|
||||
editor.assertDefinitionLinkTargets("prop", List.of(expectedLocation));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -227,7 +227,7 @@ public class ValueDefinitionProviderTest {
|
||||
new Range(new Position(0, 0), new Position(0, 0)),
|
||||
new Range(new Position(6, 8), new Position(6, 38)));
|
||||
|
||||
editor.assertLinkTargets("classpath:random-resource.md", List.of(expectedLocation));
|
||||
editor.assertDefinitionLinkTargets("classpath:random-resource.md", List.of(expectedLocation));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -337,7 +337,7 @@ public class DefinitionLinkAsserts {
|
||||
expectedLocations.add(new LocationLink(l.getUri(), l.getRange(), l.getRange(), highlightRange));
|
||||
}
|
||||
|
||||
editor.assertLinkTargets(hoverOver, expectedLocations);
|
||||
editor.assertDefinitionLinkTargets(hoverOver, expectedLocations);
|
||||
}
|
||||
|
||||
public void assertLinkTargets(Editor editor, Position pos, IJavaProject project, Range highlightRange, JavaLocationProvider... javaElements) throws Exception {
|
||||
@@ -347,7 +347,7 @@ public class DefinitionLinkAsserts {
|
||||
expectedLocations.add(new LocationLink(l.getUri(), l.getRange(), l.getRange(), highlightRange));
|
||||
}
|
||||
|
||||
editor.assertLinkTargets(pos, expectedLocations);
|
||||
editor.assertDefinitionLinkTargets(pos, expectedLocations);
|
||||
}
|
||||
|
||||
|
||||
@@ -357,7 +357,7 @@ public class DefinitionLinkAsserts {
|
||||
|
||||
LocationLink link = new LocationLink(l.getUri(), l.getRange(), l.getRange(), highlightRange);
|
||||
|
||||
editor.assertLinkTargets(hoverOver, ImmutableList.of(link));
|
||||
editor.assertDefinitionLinkTargets(hoverOver, ImmutableList.of(link));
|
||||
}
|
||||
|
||||
private static boolean isType(ASTNode node, String[] typeTokens, int length) {
|
||||
|
||||
@@ -194,7 +194,7 @@ public class XMLBeansHyperlinkTest {
|
||||
targetRange,
|
||||
editor.rangeOf("name=\"simple\" ref=\"simpleObj\"", "simpleObj")
|
||||
);
|
||||
editor.assertLinkTargets("simpleObj", Collections.singletonList(expectedLocation));
|
||||
editor.assertDefinitionLinkTargets("simpleObj", Collections.singletonList(expectedLocation));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -229,7 +229,7 @@ public class XMLBeansHyperlinkTest {
|
||||
Location expectedLocation = new Location();
|
||||
expectedLocation.setUri(UriUtil.toUri(rootContextFilePath.toFile()).toString());
|
||||
expectedLocation.setRange(new Range(new Position(6, 7), new Position(6, 21)));
|
||||
editor.assertNoLinkTargets("simpleObj");
|
||||
editor.assertNoDefinitionLinkTargets("simpleObj");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -269,7 +269,7 @@ public class XMLBeansHyperlinkTest {
|
||||
targetRange,
|
||||
editor.rangeOf("name=\"simple\" ref=\"simpleObj\"", "simpleObj")
|
||||
);
|
||||
editor.assertLinkTargets("simpleObj", Collections.singletonList(expectedLocation));
|
||||
editor.assertDefinitionLinkTargets("simpleObj", Collections.singletonList(expectedLocation));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -298,7 +298,7 @@ public class XMLBeansHyperlinkTest {
|
||||
"</beans>\n",
|
||||
UriUtil.toUri(xmlFilePath.toFile()).toString()
|
||||
);
|
||||
editor.assertNoLinkTargets("u.t.r.SimpleObj");
|
||||
editor.assertNoDefinitionLinkTargets("u.t.r.SimpleObj");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -327,6 +327,6 @@ public class XMLBeansHyperlinkTest {
|
||||
"</beans>\n",
|
||||
UriUtil.toUri(xmlFilePath.toFile()).toString()
|
||||
);
|
||||
editor.assertNoLinkTargets("u.t.r.SimpleObj");
|
||||
editor.assertNoDefinitionLinkTargets("u.t.r.SimpleObj");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user