GH-1431: let bean index elements create document symbols on-demand
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2023, 2024 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
|
||||
@@ -12,11 +12,13 @@ package org.springframework.ide.vscode.commons.protocol.spring;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import org.eclipse.lsp4j.DocumentSymbol;
|
||||
import org.eclipse.lsp4j.Location;
|
||||
import org.eclipse.lsp4j.SymbolKind;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
|
||||
public class Bean extends AbstractSpringIndexElement {
|
||||
public class Bean extends AbstractSpringIndexElement implements SymbolElement {
|
||||
|
||||
private final String name;
|
||||
private final String type;
|
||||
@@ -25,6 +27,7 @@ public class Bean extends AbstractSpringIndexElement {
|
||||
private final Set<String> supertypes;
|
||||
private final AnnotationMetadata[] annotations;
|
||||
private final boolean isConfiguration;
|
||||
private final String symbolLabel;
|
||||
|
||||
public Bean(
|
||||
String name,
|
||||
@@ -33,12 +36,14 @@ public class Bean extends AbstractSpringIndexElement {
|
||||
InjectionPoint[] injectionPoints,
|
||||
Set<String> supertypes,
|
||||
AnnotationMetadata[] annotations,
|
||||
boolean isConfiguration) {
|
||||
boolean isConfiguration,
|
||||
String symbolLabel) {
|
||||
|
||||
this.name = name;
|
||||
this.type = type;
|
||||
this.location = location;
|
||||
this.isConfiguration = isConfiguration;
|
||||
this.symbolLabel = symbolLabel;
|
||||
|
||||
if (injectionPoints != null && injectionPoints.length == 0) {
|
||||
this.injectionPoints = DefaultValues.EMPTY_INJECTION_POINTS;
|
||||
@@ -93,14 +98,30 @@ public class Bean extends AbstractSpringIndexElement {
|
||||
return isConfiguration;
|
||||
}
|
||||
|
||||
public Set<String> getSupertypes() {
|
||||
return supertypes;
|
||||
}
|
||||
|
||||
public String getSymbolLabel() {
|
||||
return symbolLabel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DocumentSymbol getDocumentSymbol() {
|
||||
DocumentSymbol symbol = new DocumentSymbol();
|
||||
|
||||
symbol.setName(this.symbolLabel);
|
||||
symbol.setKind(SymbolKind.Interface);
|
||||
symbol.setRange(this.location.getRange());
|
||||
symbol.setSelectionRange(this.location.getRange());
|
||||
|
||||
return symbol;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
Gson gson = new Gson();
|
||||
return gson.toJson(this);
|
||||
}
|
||||
|
||||
public Set<String> getSupertypes() {
|
||||
return supertypes;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -449,8 +449,10 @@ public class IndexCacheOnDisc implements IndexCache {
|
||||
|
||||
JsonElement isConfigurationObject = parsedObject.get("isConfiguration");
|
||||
boolean isConfiguration = context.deserialize(isConfigurationObject, boolean.class);
|
||||
|
||||
String symbolLabel = parsedObject.get("symbolLabel").getAsString();
|
||||
|
||||
return new Bean(beanName, beanType, location, injectionPoints, supertypes, annotations, isConfiguration);
|
||||
return new Bean(beanName, beanType, location, injectionPoints, supertypes, annotations, isConfiguration, symbolLabel);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -659,11 +659,14 @@ public class IndexCacheOnDiscDeltaBased implements IndexCache {
|
||||
JsonElement isConfigurationObject = parsedObject.get("isConfiguration");
|
||||
boolean isConfiguration = context.deserialize(isConfigurationObject, boolean.class);
|
||||
|
||||
String symbolLabel = parsedObject.get("symbolLabel").getAsString();
|
||||
|
||||
JsonElement childrenObject = parsedObject.get("children");
|
||||
Type childrenListType = TypeToken.getParameterized(List.class, SpringIndexElement.class).getType();
|
||||
List<SpringIndexElement> children = context.deserialize(childrenObject, childrenListType);
|
||||
|
||||
Bean bean = new Bean(beanName, beanType, location, injectionPoints, supertypes, annotations, isConfiguration);
|
||||
Bean bean = new Bean(beanName, beanType, location, injectionPoints, supertypes, annotations, isConfiguration, symbolLabel);
|
||||
|
||||
for (SpringIndexElement springIndexElement : children) {
|
||||
bean.addChild(springIndexElement);
|
||||
}
|
||||
@@ -685,6 +688,7 @@ public class IndexCacheOnDiscDeltaBased implements IndexCache {
|
||||
bean.add("annotations", context.serialize(src.getAnnotations()));
|
||||
|
||||
bean.addProperty("isConfiguration", src.isConfiguration());
|
||||
bean.addProperty("symbolLabel", src.getSymbolLabel());
|
||||
|
||||
Type childrenListType = TypeToken.getParameterized(List.class, SpringIndexElement.class).getType();
|
||||
bean.add("children", context.serialize(src.getChildren(), childrenListType));
|
||||
|
||||
@@ -113,7 +113,7 @@ public class BeansSymbolProvider extends AbstractSymbolProvider {
|
||||
Collection<Annotation> annotationsOnMethod = ASTUtils.getAnnotations(method);
|
||||
AnnotationMetadata[] annotations = ASTUtils.getAnnotationsMetadata(annotationsOnMethod, doc);
|
||||
|
||||
Bean beanDefinition = new Bean(nameAndRegion.getT1(), beanType.getQualifiedName(), location, injectionPoints, supertypes, annotations, false);
|
||||
Bean beanDefinition = new Bean(nameAndRegion.getT1(), beanType.getQualifiedName(), location, injectionPoints, supertypes, annotations, false, symbol.getName());
|
||||
if (childElements.size() > 0) {
|
||||
for (SpringIndexElement springIndexElement : childElements) {
|
||||
beanDefinition.addChild(springIndexElement);
|
||||
@@ -174,7 +174,7 @@ public class BeansSymbolProvider extends AbstractSymbolProvider {
|
||||
|
||||
InjectionPoint[] injectionPoints = ASTUtils.findInjectionPoints(typeDeclaration, doc);
|
||||
|
||||
Bean beanDefinition = new Bean(beanName, concreteBeanType.getQualifiedName(), beanLocation, injectionPoints, supertypes, annotations, false);
|
||||
Bean beanDefinition = new Bean(beanName, concreteBeanType.getQualifiedName(), beanLocation, injectionPoints, supertypes, annotations, false, symbol.getName());
|
||||
context.getBeans().add(new CachedBean(context.getDocURI(), beanDefinition));
|
||||
|
||||
} catch (BadLocationException e) {
|
||||
|
||||
@@ -44,6 +44,7 @@ import org.springframework.ide.vscode.boot.java.utils.SpringIndexerJavaContext;
|
||||
import org.springframework.ide.vscode.commons.protocol.spring.AnnotationMetadata;
|
||||
import org.springframework.ide.vscode.commons.protocol.spring.Bean;
|
||||
import org.springframework.ide.vscode.commons.protocol.spring.InjectionPoint;
|
||||
import org.springframework.ide.vscode.commons.protocol.spring.SimpleSymbolElement;
|
||||
import org.springframework.ide.vscode.commons.util.BadLocationException;
|
||||
import org.springframework.ide.vscode.commons.util.text.DocumentRegion;
|
||||
import org.springframework.ide.vscode.commons.util.text.TextDocument;
|
||||
@@ -65,6 +66,7 @@ public class ComponentSymbolProvider extends AbstractSymbolProvider {
|
||||
else if (Annotations.NAMED_ANNOTATIONS.contains(annotationType.getQualifiedName())) {
|
||||
WorkspaceSymbol symbol = DefaultSymbolProvider.provideDefaultSymbol(node, doc);
|
||||
context.getGeneratedSymbols().add(new CachedSymbol(context.getDocURI(), context.getLastModified(), symbol));
|
||||
context.getBeans().add(new CachedBean(context.getDocURI(), new SimpleSymbolElement(symbol)));
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
@@ -107,7 +109,7 @@ public class ComponentSymbolProvider extends AbstractSymbolProvider {
|
||||
.map(an -> new AnnotationMetadata(an.getQualifiedName(), true, null, null)))
|
||||
.toArray(AnnotationMetadata[]::new);
|
||||
|
||||
Bean beanDefinition = new Bean(beanName, beanType.getQualifiedName(), location, injectionPoints, supertypes, annotations, isConfiguration);
|
||||
Bean beanDefinition = new Bean(beanName, beanType.getQualifiedName(), location, injectionPoints, supertypes, annotations, isConfiguration, symbol.getName());
|
||||
|
||||
// type implements event listener - move those already created event index elements under the bean node
|
||||
List<CachedBean> alreadyCreatedEventListenerChilds = context.getBeans().stream()
|
||||
|
||||
@@ -94,7 +94,7 @@ public class FeignClientSymbolProvider extends AbstractSymbolProvider {
|
||||
.map(an -> new AnnotationMetadata(an.getQualifiedName(), true, null, null)))
|
||||
.toArray(AnnotationMetadata[]::new);
|
||||
|
||||
Bean beanDefinition = new Bean(beanName, beanType == null ? "" : beanType.getQualifiedName(), location, injectionPoints, supertypes, annotations, false);
|
||||
Bean beanDefinition = new Bean(beanName, beanType == null ? "" : beanType.getQualifiedName(), location, injectionPoints, supertypes, annotations, false, symbol.getName());
|
||||
|
||||
return Tuple.two(symbol, beanDefinition);
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ public class DataRepositorySymbolProvider extends AbstractSymbolProvider {
|
||||
Collection<Annotation> annotationsOnMethod = ASTUtils.getAnnotations(typeDeclaration);
|
||||
AnnotationMetadata[] annotations = ASTUtils.getAnnotationsMetadata(annotationsOnMethod, doc);
|
||||
|
||||
Bean beanDefinition = new Bean(beanName, concreteRepoType, location, injectionPoints, supertypes, annotations, false);
|
||||
Bean beanDefinition = new Bean(beanName, concreteRepoType, location, injectionPoints, supertypes, annotations, false, symbol.getName());
|
||||
|
||||
context.getGeneratedSymbols().add(new CachedSymbol(context.getDocURI(), context.getLastModified(), symbol));
|
||||
context.getBeans().add(new CachedBean(context.getDocURI(), beanDefinition));
|
||||
|
||||
@@ -95,7 +95,7 @@ public class SpringIndexerXMLNamespaceHandlerBeans implements SpringIndexerXMLNa
|
||||
generatedSymbols.add(cachedSymbol);
|
||||
|
||||
// TODO: bean index
|
||||
generatedBeans.add(new CachedBean(docURI, new Bean(beanID, fqBeanClass, location, null, null, null, false)));
|
||||
generatedBeans.add(new CachedBean(docURI, new Bean(beanID, fqBeanClass, location, null, null, null, false, symbol.getName())));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -60,9 +60,9 @@ public class SpringMetamodelIndexTest {
|
||||
@Test
|
||||
void testSimpleProjectWithBeansPerProject() {
|
||||
SpringMetamodelIndex index = new SpringMetamodelIndex();
|
||||
Bean bean1 = new Bean("beanName1", "beanType", locationForDoc1, emptyInjectionPoints, emptySupertypes, emptyAnnotations, false);
|
||||
Bean bean2 = new Bean("beanName2", "beanType", locationForDoc1, emptyInjectionPoints, emptySupertypes, emptyAnnotations, false);
|
||||
Bean bean3 = new Bean("beanName3", "beanType", locationForDoc2, emptyInjectionPoints, emptySupertypes, emptyAnnotations, false);
|
||||
Bean bean1 = new Bean("beanName1", "beanType", locationForDoc1, emptyInjectionPoints, emptySupertypes, emptyAnnotations, false, "symbolLabel");
|
||||
Bean bean2 = new Bean("beanName2", "beanType", locationForDoc1, emptyInjectionPoints, emptySupertypes, emptyAnnotations, false, "symbolLabel");
|
||||
Bean bean3 = new Bean("beanName3", "beanType", locationForDoc2, emptyInjectionPoints, emptySupertypes, emptyAnnotations, false, "symbolLabel");
|
||||
|
||||
index.updateBeans("someProject", new Bean[] {bean1, bean2, bean3});
|
||||
|
||||
@@ -75,7 +75,7 @@ public class SpringMetamodelIndexTest {
|
||||
assertTrue(beansList.contains(bean2));
|
||||
assertTrue(beansList.contains(bean3));
|
||||
|
||||
Bean anotherBean = new Bean("anotherBean", "beanType", null, emptyInjectionPoints, emptySupertypes, emptyAnnotations, false);
|
||||
Bean anotherBean = new Bean("anotherBean", "beanType", null, emptyInjectionPoints, emptySupertypes, emptyAnnotations, false, "symbolLabel");
|
||||
|
||||
assertFalse(beansList.contains(anotherBean));
|
||||
}
|
||||
@@ -83,9 +83,9 @@ public class SpringMetamodelIndexTest {
|
||||
@Test
|
||||
void testSimpleProjectWithBeansPerDocument() {
|
||||
SpringMetamodelIndex index = new SpringMetamodelIndex();
|
||||
Bean bean1 = new Bean("beanName1", "beanType", locationForDoc1, emptyInjectionPoints, emptySupertypes, emptyAnnotations, false);
|
||||
Bean bean2 = new Bean("beanName1", "beanType", locationForDoc1, emptyInjectionPoints, emptySupertypes, emptyAnnotations, false);
|
||||
Bean bean3 = new Bean("beanWithDifferentName", "beanType", locationForDoc2, emptyInjectionPoints, emptySupertypes, emptyAnnotations, false);
|
||||
Bean bean1 = new Bean("beanName1", "beanType", locationForDoc1, emptyInjectionPoints, emptySupertypes, emptyAnnotations, false, "symbolLabel");
|
||||
Bean bean2 = new Bean("beanName1", "beanType", locationForDoc1, emptyInjectionPoints, emptySupertypes, emptyAnnotations, false, "symbolLabel");
|
||||
Bean bean3 = new Bean("beanWithDifferentName", "beanType", locationForDoc2, emptyInjectionPoints, emptySupertypes, emptyAnnotations, false, "symbolLabel");
|
||||
|
||||
index.updateBeans("someProject", new Bean[] {bean1, bean2, bean3});
|
||||
|
||||
@@ -110,9 +110,9 @@ public class SpringMetamodelIndexTest {
|
||||
@Test
|
||||
void testSimpleProjectWithBeansPerName() {
|
||||
SpringMetamodelIndex index = new SpringMetamodelIndex();
|
||||
Bean bean1 = new Bean("beanName1", "beanType", locationForDoc1, emptyInjectionPoints, emptySupertypes, emptyAnnotations, false);
|
||||
Bean bean2 = new Bean("beanName1", "beanType", locationForDoc1, emptyInjectionPoints, emptySupertypes, emptyAnnotations, false);
|
||||
Bean bean3 = new Bean("beanWithDifferentName", "beanType", locationForDoc2, emptyInjectionPoints, emptySupertypes, emptyAnnotations, false);
|
||||
Bean bean1 = new Bean("beanName1", "beanType", locationForDoc1, emptyInjectionPoints, emptySupertypes, emptyAnnotations, false, "symbolLabel");
|
||||
Bean bean2 = new Bean("beanName1", "beanType", locationForDoc1, emptyInjectionPoints, emptySupertypes, emptyAnnotations, false, "symbolLabel");
|
||||
Bean bean3 = new Bean("beanWithDifferentName", "beanType", locationForDoc2, emptyInjectionPoints, emptySupertypes, emptyAnnotations, false, "symbolLabel");
|
||||
|
||||
index.updateBeans("someProject", new Bean[] {bean1, bean2, bean3});
|
||||
|
||||
@@ -131,15 +131,15 @@ public class SpringMetamodelIndexTest {
|
||||
@Test
|
||||
void testUpdateBeansForSpecificDoc() {
|
||||
SpringMetamodelIndex index = new SpringMetamodelIndex();
|
||||
Bean bean1 = new Bean("beanName1", "beanType", locationForDoc1, emptyInjectionPoints, emptySupertypes, emptyAnnotations, false);
|
||||
Bean bean2 = new Bean("beanName2", "beanType", locationForDoc1, emptyInjectionPoints, emptySupertypes, emptyAnnotations, false);
|
||||
Bean bean3 = new Bean("beanName3", "beanType", locationForDoc2, emptyInjectionPoints, emptySupertypes, emptyAnnotations, false);
|
||||
Bean bean1 = new Bean("beanName1", "beanType", locationForDoc1, emptyInjectionPoints, emptySupertypes, emptyAnnotations, false, "symbolLabel");
|
||||
Bean bean2 = new Bean("beanName2", "beanType", locationForDoc1, emptyInjectionPoints, emptySupertypes, emptyAnnotations, false, "symbolLabel");
|
||||
Bean bean3 = new Bean("beanName3", "beanType", locationForDoc2, emptyInjectionPoints, emptySupertypes, emptyAnnotations, false, "symbolLabel");
|
||||
|
||||
index.updateElements("someProject", locationForDoc1.getUri(), new Bean[] {bean1, bean2});
|
||||
index.updateElements("someProject", locationForDoc2.getUri(), new Bean[] {bean3});
|
||||
|
||||
Bean updatedBean1 = new Bean("updated1", "beanType", locationForDoc1, emptyInjectionPoints, emptySupertypes, emptyAnnotations, false);
|
||||
Bean updatedBean2 = new Bean("updated2", "beanType", locationForDoc1, emptyInjectionPoints, emptySupertypes, emptyAnnotations, false);
|
||||
Bean updatedBean1 = new Bean("updated1", "beanType", locationForDoc1, emptyInjectionPoints, emptySupertypes, emptyAnnotations, false, "symbolLabel");
|
||||
Bean updatedBean2 = new Bean("updated2", "beanType", locationForDoc1, emptyInjectionPoints, emptySupertypes, emptyAnnotations, false, "symbolLabel");
|
||||
|
||||
index.updateElements("someProject", locationForDoc1.getUri(), new Bean[] {updatedBean1, updatedBean2});
|
||||
|
||||
@@ -155,19 +155,19 @@ public class SpringMetamodelIndexTest {
|
||||
assertFalse(beansList.contains(bean1));
|
||||
assertFalse(beansList.contains(bean2));
|
||||
|
||||
Bean anotherBean = new Bean("anotherBean", "beanType", null, emptyInjectionPoints, emptySupertypes, emptyAnnotations, false);
|
||||
Bean anotherBean = new Bean("anotherBean", "beanType", null, emptyInjectionPoints, emptySupertypes, emptyAnnotations, false, "symbolLabel");
|
||||
assertFalse(beansList.contains(anotherBean));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testUpdateAllBeansForSpecificProject() {
|
||||
SpringMetamodelIndex index = new SpringMetamodelIndex();
|
||||
Bean bean1 = new Bean("beanName1", "beanType", locationForDoc1, emptyInjectionPoints, emptySupertypes, emptyAnnotations, false);
|
||||
Bean bean2 = new Bean("beanName2", "beanType", locationForDoc1, emptyInjectionPoints, emptySupertypes, emptyAnnotations, false);
|
||||
Bean bean1 = new Bean("beanName1", "beanType", locationForDoc1, emptyInjectionPoints, emptySupertypes, emptyAnnotations, false, "symbolLabel");
|
||||
Bean bean2 = new Bean("beanName2", "beanType", locationForDoc1, emptyInjectionPoints, emptySupertypes, emptyAnnotations, false, "symbolLabel");
|
||||
|
||||
index.updateBeans("someProject", new Bean[] {bean1, bean2});
|
||||
|
||||
Bean bean3 = new Bean("beanName3", "beanType", locationForDoc2, emptyInjectionPoints, emptySupertypes, emptyAnnotations, false);
|
||||
Bean bean3 = new Bean("beanName3", "beanType", locationForDoc2, emptyInjectionPoints, emptySupertypes, emptyAnnotations, false, "symbolLabel");
|
||||
|
||||
index.updateBeans("someProject", new Bean[] {bean3});
|
||||
|
||||
@@ -184,9 +184,9 @@ public class SpringMetamodelIndexTest {
|
||||
@Test
|
||||
void testRemoveAllBeansForSpecificProject() {
|
||||
SpringMetamodelIndex index = new SpringMetamodelIndex();
|
||||
Bean bean1 = new Bean("beanName1", "beanType", locationForDoc1, emptyInjectionPoints, emptySupertypes, emptyAnnotations, false);
|
||||
Bean bean2 = new Bean("beanName2", "beanType", locationForDoc1, emptyInjectionPoints, emptySupertypes, emptyAnnotations, false);
|
||||
Bean bean3 = new Bean("beanName3", "beanType", locationForDoc2, emptyInjectionPoints, emptySupertypes, emptyAnnotations, false);
|
||||
Bean bean1 = new Bean("beanName1", "beanType", locationForDoc1, emptyInjectionPoints, emptySupertypes, emptyAnnotations, false, "symbolLabel");
|
||||
Bean bean2 = new Bean("beanName2", "beanType", locationForDoc1, emptyInjectionPoints, emptySupertypes, emptyAnnotations, false, "symbolLabel");
|
||||
Bean bean3 = new Bean("beanName3", "beanType", locationForDoc2, emptyInjectionPoints, emptySupertypes, emptyAnnotations, false, "symbolLabel");
|
||||
|
||||
index.updateBeans("someProject1", new Bean[] {bean1, bean2});
|
||||
index.updateBeans("someProject2", new Bean[] {bean3});
|
||||
@@ -208,9 +208,9 @@ public class SpringMetamodelIndexTest {
|
||||
@Test
|
||||
void testRemoveAllBeansForSpecificDocument() {
|
||||
SpringMetamodelIndex index = new SpringMetamodelIndex();
|
||||
Bean bean1 = new Bean("beanName1", "beanType", locationForDoc1, emptyInjectionPoints, emptySupertypes, emptyAnnotations, false);
|
||||
Bean bean2 = new Bean("beanName2", "beanType", locationForDoc1, emptyInjectionPoints, emptySupertypes, emptyAnnotations, false);
|
||||
Bean bean3 = new Bean("beanName3", "beanType", locationForDoc2, emptyInjectionPoints, emptySupertypes, emptyAnnotations, false);
|
||||
Bean bean1 = new Bean("beanName1", "beanType", locationForDoc1, emptyInjectionPoints, emptySupertypes, emptyAnnotations, false, "symbolLabel");
|
||||
Bean bean2 = new Bean("beanName2", "beanType", locationForDoc1, emptyInjectionPoints, emptySupertypes, emptyAnnotations, false, "symbolLabel");
|
||||
Bean bean3 = new Bean("beanName3", "beanType", locationForDoc2, emptyInjectionPoints, emptySupertypes, emptyAnnotations, false, "symbolLabel");
|
||||
|
||||
index.updateBeans("someProject", new Bean[] {bean1, bean2, bean3});
|
||||
index.removeElements("someProject", locationForDoc1.getUri());
|
||||
@@ -248,7 +248,7 @@ public class SpringMetamodelIndexTest {
|
||||
|
||||
InjectionPoint point2 = new InjectionPoint("point2", "point2-type", locationForDoc1, null);
|
||||
|
||||
Bean bean1 = new Bean("beanName1", "beanType", locationForDoc1, new InjectionPoint[] {point1, point2}, Set.of("supertype1", "supertype2"), emptyAnnotations, true);
|
||||
Bean bean1 = new Bean("beanName1", "beanType", locationForDoc1, new InjectionPoint[] {point1, point2}, Set.of("supertype1", "supertype2"), emptyAnnotations, true, "symbolLabel");
|
||||
|
||||
Gson gson = IndexCacheOnDiscDeltaBased.createGson();
|
||||
String serialized = gson.toJson(bean1);
|
||||
@@ -299,7 +299,7 @@ public class SpringMetamodelIndexTest {
|
||||
|
||||
@Test
|
||||
void testEmptyInjectionPointsOptimizationWithSerializeDeserializeBeans() {
|
||||
Bean bean1 = new Bean("beanName1", "beanType", locationForDoc1, emptyInjectionPoints, emptySupertypes, emptyAnnotations, false);
|
||||
Bean bean1 = new Bean("beanName1", "beanType", locationForDoc1, emptyInjectionPoints, emptySupertypes, emptyAnnotations, false, "symbolLabel");
|
||||
|
||||
Gson gson = IndexCacheOnDiscDeltaBased.createGson();
|
||||
String serialized = gson.toJson(bean1);
|
||||
@@ -314,7 +314,7 @@ public class SpringMetamodelIndexTest {
|
||||
|
||||
@Test
|
||||
void testEmptyInjectionPointsOptimization() {
|
||||
Bean bean1 = new Bean("beanName1", "beanType", locationForDoc1, emptyInjectionPoints, emptySupertypes, emptyAnnotations, false);
|
||||
Bean bean1 = new Bean("beanName1", "beanType", locationForDoc1, emptyInjectionPoints, emptySupertypes, emptyAnnotations, false, "symbolLabel");
|
||||
assertSame(DefaultValues.EMPTY_INJECTION_POINTS, bean1.getInjectionPoints());
|
||||
}
|
||||
|
||||
@@ -327,8 +327,8 @@ public class SpringMetamodelIndexTest {
|
||||
@Test
|
||||
void testFindNoMatchingBeansWithEmptySupertypes() {
|
||||
SpringMetamodelIndex index = new SpringMetamodelIndex();
|
||||
Bean bean1 = new Bean("beanName1", "beanType", locationForDoc1, emptyInjectionPoints, emptySupertypes, emptyAnnotations, false);
|
||||
Bean bean2 = new Bean("beanName2", "beanType", locationForDoc1, emptyInjectionPoints, emptySupertypes, emptyAnnotations, false);
|
||||
Bean bean1 = new Bean("beanName1", "beanType", locationForDoc1, emptyInjectionPoints, emptySupertypes, emptyAnnotations, false, "symbolLabel");
|
||||
Bean bean2 = new Bean("beanName2", "beanType", locationForDoc1, emptyInjectionPoints, emptySupertypes, emptyAnnotations, false, "symbolLabel");
|
||||
|
||||
index.updateBeans("someProject", new Bean[] {bean1, bean2});
|
||||
|
||||
@@ -342,8 +342,8 @@ public class SpringMetamodelIndexTest {
|
||||
@Test
|
||||
void testFindMatchingBeansWithOneProject() {
|
||||
SpringMetamodelIndex index = new SpringMetamodelIndex();
|
||||
Bean bean1 = new Bean("beanName1", "beanType1", locationForDoc1, emptyInjectionPoints, Set.of("supertype1", "supertype2"), emptyAnnotations, false);
|
||||
Bean bean2 = new Bean("beanName2", "beanType2", locationForDoc1, emptyInjectionPoints, Set.of("supertype3", "supertype4", "supertype5"), emptyAnnotations, false);
|
||||
Bean bean1 = new Bean("beanName1", "beanType1", locationForDoc1, emptyInjectionPoints, Set.of("supertype1", "supertype2"), emptyAnnotations, false, "symbolLabel");
|
||||
Bean bean2 = new Bean("beanName2", "beanType2", locationForDoc1, emptyInjectionPoints, Set.of("supertype3", "supertype4", "supertype5"), emptyAnnotations, false, "symbolLabel");
|
||||
|
||||
index.updateBeans("someProject", new Bean[] {bean1, bean2});
|
||||
|
||||
@@ -369,11 +369,11 @@ public class SpringMetamodelIndexTest {
|
||||
@Test
|
||||
void testFindMatchingBeansWithMultipleProjects() {
|
||||
SpringMetamodelIndex index = new SpringMetamodelIndex();
|
||||
Bean bean1 = new Bean("beanName1", "beanType1", locationForDoc1, emptyInjectionPoints, Set.of("supertype1", "supertype2"), emptyAnnotations, false);
|
||||
Bean bean2 = new Bean("beanName2", "beanType2", locationForDoc1, emptyInjectionPoints, Set.of("supertype3", "supertype4, supertype5"), emptyAnnotations, false);
|
||||
Bean bean1 = new Bean("beanName1", "beanType1", locationForDoc1, emptyInjectionPoints, Set.of("supertype1", "supertype2"), emptyAnnotations, false, "symbolLabel");
|
||||
Bean bean2 = new Bean("beanName2", "beanType2", locationForDoc1, emptyInjectionPoints, Set.of("supertype3", "supertype4, supertype5"), emptyAnnotations, false, "symbolLabel");
|
||||
|
||||
Bean bean3 = new Bean("beanName3", "beanType1", locationForDoc1, emptyInjectionPoints, Set.of("supertype1", "supertype2"), emptyAnnotations, false);
|
||||
Bean bean4 = new Bean("beanName4", "beanType2", locationForDoc1, emptyInjectionPoints, Set.of("supertype3", "supertype4, supertype5"), emptyAnnotations, false);
|
||||
Bean bean3 = new Bean("beanName3", "beanType1", locationForDoc1, emptyInjectionPoints, Set.of("supertype1", "supertype2"), emptyAnnotations, false, "symbolLabel");
|
||||
Bean bean4 = new Bean("beanName4", "beanType2", locationForDoc1, emptyInjectionPoints, Set.of("supertype3", "supertype4, supertype5"), emptyAnnotations, false, "symbolLabel");
|
||||
|
||||
index.updateBeans("projectA", new Bean[] {bean1, bean2});
|
||||
index.updateBeans("projectB", new Bean[] {bean3, bean4});
|
||||
@@ -399,7 +399,7 @@ public class SpringMetamodelIndexTest {
|
||||
|
||||
@Test
|
||||
void testBasicSpringIndexStructure() {
|
||||
Bean bean1 = new Bean("beanName1", "beanType1", locationForDoc1, emptyInjectionPoints, Set.of("supertype1", "supertype2"), emptyAnnotations, false);
|
||||
Bean bean1 = new Bean("beanName1", "beanType1", locationForDoc1, emptyInjectionPoints, Set.of("supertype1", "supertype2"), emptyAnnotations, false, "symbolLabel");
|
||||
|
||||
SubType1 child1 = new SubType1();
|
||||
bean1.addChild(child1);
|
||||
@@ -446,11 +446,11 @@ public class SpringMetamodelIndexTest {
|
||||
|
||||
Gson gson = IndexCacheOnDiscDeltaBased.createGson();
|
||||
|
||||
Bean bean1 = new Bean("beanName1", "beanType1", locationForDoc1, emptyInjectionPoints, Set.of("supertype1", "supertype2"), emptyAnnotations, false);
|
||||
Bean bean2 = new Bean("beanName2", "beanType2", locationForDoc1, emptyInjectionPoints, Set.of("supertype3", "supertype4, supertype5"), emptyAnnotations, false);
|
||||
Bean bean1 = new Bean("beanName1", "beanType1", locationForDoc1, emptyInjectionPoints, Set.of("supertype1", "supertype2"), emptyAnnotations, false, "symbolLabel");
|
||||
Bean bean2 = new Bean("beanName2", "beanType2", locationForDoc1, emptyInjectionPoints, Set.of("supertype3", "supertype4, supertype5"), emptyAnnotations, false, "symbolLabel");
|
||||
|
||||
Bean bean3 = new Bean("beanName3", "beanType1", locationForDoc1, emptyInjectionPoints, Set.of("supertype1", "supertype2"), emptyAnnotations, false);
|
||||
Bean bean4 = new Bean("beanName4", "beanType2", locationForDoc1, emptyInjectionPoints, Set.of("supertype3", "supertype4, supertype5"), emptyAnnotations, false);
|
||||
Bean bean3 = new Bean("beanName3", "beanType1", locationForDoc1, emptyInjectionPoints, Set.of("supertype1", "supertype2"), emptyAnnotations, false, "symbolLabel");
|
||||
Bean bean4 = new Bean("beanName4", "beanType2", locationForDoc1, emptyInjectionPoints, Set.of("supertype3", "supertype4, supertype5"), emptyAnnotations, false, "symbolLabel");
|
||||
|
||||
bean1.addChild(bean2);
|
||||
bean2.addChild(bean3);
|
||||
@@ -475,7 +475,7 @@ public class SpringMetamodelIndexTest {
|
||||
child1.addChild(childOfChild);
|
||||
|
||||
SubType2 child2 = new SubType2();
|
||||
Bean bean1 = new Bean("beanName1", "beanType", locationForDoc1, emptyInjectionPoints, emptySupertypes, emptyAnnotations, true);
|
||||
Bean bean1 = new Bean("beanName1", "beanType", locationForDoc1, emptyInjectionPoints, emptySupertypes, emptyAnnotations, true, "symbolLabel");
|
||||
bean1.addChild(child1);
|
||||
bean1.addChild(child2);
|
||||
|
||||
@@ -503,7 +503,7 @@ public class SpringMetamodelIndexTest {
|
||||
Gson gson = IndexCacheOnDiscDeltaBased.createGson();
|
||||
|
||||
SubType1 child1 = new SubType1();
|
||||
Bean bean1 = new Bean("beanName1", "beanType", locationForDoc1, emptyInjectionPoints, emptySupertypes, emptyAnnotations, true);
|
||||
Bean bean1 = new Bean("beanName1", "beanType", locationForDoc1, emptyInjectionPoints, emptySupertypes, emptyAnnotations, true, "symbolLabel");
|
||||
bean1.addChild(child1);
|
||||
|
||||
String serialized = gson.toJson(bean1);
|
||||
|
||||
@@ -81,11 +81,11 @@ public class BeanCompletionProviderTest {
|
||||
indexedBeans = springIndex.getBeansOfProject(project.getElementName());
|
||||
|
||||
tempJavaDocUri = directory.toPath().resolve("src/main/java/org/test/TempClass.java").toUri().toString();
|
||||
bean1 = new Bean("ownerRepository", "org.springframework.samples.petclinic.owner.OwnerRepository", new Location(tempJavaDocUri, new Range(new Position(1,1), new Position(1, 20))), null, null, null, false);
|
||||
bean2 = new Bean("ownerService", "org.springframework.samples.petclinic.owner.OwnerService", new Location(tempJavaDocUri, new Range(new Position(1,1), new Position(1, 20))), null, null, null, false);
|
||||
bean3 = new Bean("visitRepository", "org.springframework.samples.petclinic.owner.VisitRepository", new Location(tempJavaDocUri, new Range(new Position(1,1), new Position(1, 20))), null, null, null, false);
|
||||
bean4 = new Bean("visitService", "org.springframework.samples.petclinic.owner.VisitService", new Location(tempJavaDocUri, new Range(new Position(1,1), new Position(1, 20))), null, null, null, false);
|
||||
bean5 = new Bean("petService", "org.springframework.samples.petclinic.pet.Inner.PetService", new Location(tempJavaDocUri, new Range(new Position(1,1), new Position(1, 20))), null, null, null, false);
|
||||
bean1 = new Bean("ownerRepository", "org.springframework.samples.petclinic.owner.OwnerRepository", new Location(tempJavaDocUri, new Range(new Position(1,1), new Position(1, 20))), null, null, null, false, "symbolLabel");
|
||||
bean2 = new Bean("ownerService", "org.springframework.samples.petclinic.owner.OwnerService", new Location(tempJavaDocUri, new Range(new Position(1,1), new Position(1, 20))), null, null, null, false, "symbolLabel");
|
||||
bean3 = new Bean("visitRepository", "org.springframework.samples.petclinic.owner.VisitRepository", new Location(tempJavaDocUri, new Range(new Position(1,1), new Position(1, 20))), null, null, null, false, "symbolLabel");
|
||||
bean4 = new Bean("visitService", "org.springframework.samples.petclinic.owner.VisitService", new Location(tempJavaDocUri, new Range(new Position(1,1), new Position(1, 20))), null, null, null, false, "symbolLabel");
|
||||
bean5 = new Bean("petService", "org.springframework.samples.petclinic.pet.Inner.PetService", new Location(tempJavaDocUri, new Range(new Position(1,1), new Position(1, 20))), null, null, null, false, "symbolLabel");
|
||||
|
||||
springIndex.updateBeans(project.getElementName(), new Bean[] {bean1, bean2, bean3, bean4, bean5});
|
||||
}
|
||||
|
||||
@@ -76,8 +76,8 @@ public class DependsOnCompletionProviderTest {
|
||||
indexedBeans = springIndex.getBeansOfProject(project.getElementName());
|
||||
|
||||
tempJavaDocUri = directory.toPath().resolve("src/main/java/org/test/TempClass.java").toUri().toString();
|
||||
bean1 = new Bean("bean1", "type1", new Location(tempJavaDocUri, new Range(new Position(1,1), new Position(1, 20))), null, null, null, false);
|
||||
bean2 = new Bean("bean2", "type2", new Location(tempJavaDocUri, new Range(new Position(1,1), new Position(1, 20))), null, null, null, false);
|
||||
bean1 = new Bean("bean1", "type1", new Location(tempJavaDocUri, new Range(new Position(1,1), new Position(1, 20))), null, null, null, false, "symbolLabel");
|
||||
bean2 = new Bean("bean2", "type2", new Location(tempJavaDocUri, new Range(new Position(1,1), new Position(1, 20))), null, null, null, false, "symbolLabel");
|
||||
|
||||
springIndex.updateBeans(project.getElementName(), new Bean[] {bean1, bean2});
|
||||
}
|
||||
@@ -201,7 +201,7 @@ public class DependsOnCompletionProviderTest {
|
||||
|
||||
@Test
|
||||
public void testDependsOnCompletionInsideOfArrayBetweenExistingElements() throws Exception {
|
||||
Bean bean3 = new Bean("bean3", "type3", new Location(tempJavaDocUri, new Range(new Position(1,1), new Position(1, 20))), null, null, null, false);
|
||||
Bean bean3 = new Bean("bean3", "type3", new Location(tempJavaDocUri, new Range(new Position(1,1), new Position(1, 20))), null, null, null, false, "symbolLabel");
|
||||
springIndex.updateBeans(project.getElementName(), new Bean[] {bean1, bean2, bean3});
|
||||
|
||||
assertCompletions("@DependsOn({\"bean1\",<*>\"bean2\"})", 1, "@DependsOn({\"bean1\",\"bean3\",<*>\"bean2\"})");
|
||||
@@ -209,7 +209,7 @@ public class DependsOnCompletionProviderTest {
|
||||
|
||||
@Test
|
||||
public void testDependsOnCompletionWithinQuotesExcludeDefaultBeanNameFromComponent() throws Exception {
|
||||
Bean componentBean = new Bean("testDependsOnClass", "org.test.TestDependsOnClass", new Location(tempJavaDocUri, new Range(new Position(1,1), new Position(1, 20))), null, null, null, false);
|
||||
Bean componentBean = new Bean("testDependsOnClass", "org.test.TestDependsOnClass", new Location(tempJavaDocUri, new Range(new Position(1,1), new Position(1, 20))), null, null, null, false, "symbolLabel");
|
||||
springIndex.updateBeans(project.getElementName(), new Bean[] {bean1, bean2, componentBean});
|
||||
|
||||
assertCompletions("@DependsOn(\"<*>\")", 2, "@DependsOn(\"bean1<*>\")");
|
||||
@@ -217,7 +217,7 @@ public class DependsOnCompletionProviderTest {
|
||||
|
||||
@Test
|
||||
public void testDependsOnCompletionExcludeDefaultBeanNameFromComponent() throws Exception {
|
||||
Bean componentBean = new Bean("testDependsOnClass", "org.test.TestDependsOnClass", new Location(tempJavaDocUri, new Range(new Position(1,1), new Position(1, 20))), null, null, null, false);
|
||||
Bean componentBean = new Bean("testDependsOnClass", "org.test.TestDependsOnClass", new Location(tempJavaDocUri, new Range(new Position(1,1), new Position(1, 20))), null, null, null, false, "symbolLabel");
|
||||
springIndex.updateBeans(project.getElementName(), new Bean[] {bean1, bean2, componentBean});
|
||||
|
||||
assertCompletions("@DependsOn(<*>)", 2, "@DependsOn(\"bean1\"<*>)");
|
||||
@@ -225,7 +225,7 @@ public class DependsOnCompletionProviderTest {
|
||||
|
||||
@Test
|
||||
public void testDependsOnCompletionExcludeExplicitBeanNameFromComponent() throws Exception {
|
||||
Bean componentBeanWithName = new Bean("explicitBeanName", "org.test.TestDependsOnClass", new Location(tempJavaDocUri, new Range(new Position(1,1), new Position(1, 20))), null, null, null, false);
|
||||
Bean componentBeanWithName = new Bean("explicitBeanName", "org.test.TestDependsOnClass", new Location(tempJavaDocUri, new Range(new Position(1,1), new Position(1, 20))), null, null, null, false, "symbolLabel");
|
||||
springIndex.updateBeans(project.getElementName(), new Bean[] {bean1, bean2, componentBeanWithName});
|
||||
|
||||
assertCompletionsWithComponentBeanName("@DependsOn(<*>)", 2, "@DependsOn(\"bean1\"<*>)");
|
||||
@@ -233,7 +233,7 @@ public class DependsOnCompletionProviderTest {
|
||||
|
||||
@Test
|
||||
public void testDependsOnCompletionExcludeDefaultBeanNameFromBeanMethod() throws Exception {
|
||||
Bean beanFromMethod = new Bean("beanFromMethod", "org.test.TestDependsOnClass", new Location(tempJavaDocUri, new Range(new Position(1,1), new Position(1, 20))), null, null, null, false);
|
||||
Bean beanFromMethod = new Bean("beanFromMethod", "org.test.TestDependsOnClass", new Location(tempJavaDocUri, new Range(new Position(1,1), new Position(1, 20))), null, null, null, false, "symbolLabel");
|
||||
springIndex.updateBeans(project.getElementName(), new Bean[] {bean1, bean2, beanFromMethod});
|
||||
|
||||
assertCompletionsOnBeanMethod("@DependsOn(<*>)", 2, "@DependsOn(\"bean1\"<*>)");
|
||||
@@ -241,7 +241,7 @@ public class DependsOnCompletionProviderTest {
|
||||
|
||||
@Test
|
||||
public void testDependsOnCompletionExcludeExplicitBeanNameFromBeanMethod() throws Exception {
|
||||
Bean beanFromMethodWithName = new Bean("beanFromMethodWithName", "org.test.TestDependsOnClass", new Location(tempJavaDocUri, new Range(new Position(1,1), new Position(1, 20))), null, null, null, false);
|
||||
Bean beanFromMethodWithName = new Bean("beanFromMethodWithName", "org.test.TestDependsOnClass", new Location(tempJavaDocUri, new Range(new Position(1,1), new Position(1, 20))), null, null, null, false, "symbolLabel");
|
||||
springIndex.updateBeans(project.getElementName(), new Bean[] {bean1, bean2, beanFromMethodWithName});
|
||||
|
||||
assertCompletionsOnBeanMethodWithName("@DependsOn(<*>)", 2, "@DependsOn(\"bean1\"<*>)");
|
||||
|
||||
@@ -143,7 +143,7 @@ public class DependsOnDefinitionProviderTest {
|
||||
String expectedDefinitionUri = directory.toPath().resolve("src/main/java/org/test/MainClass.java").toUri().toString();
|
||||
|
||||
DocumentElement document = springIndex.getDocument(expectedDefinitionUri);
|
||||
document.addChild(new Bean("bean1", "type", new Location(expectedDefinitionUri, new Range(new Position(20, 1), new Position(20, 10))), null, null, null, false));
|
||||
document.addChild(new Bean("bean1", "type", new Location(expectedDefinitionUri, new Range(new Position(20, 1), new Position(20, 10))), null, null, null, false, "symbolLabel"));
|
||||
|
||||
Bean[] beans = springIndex.getBeansWithName(project.getElementName(), "bean1");
|
||||
assertEquals(2, beans.length);
|
||||
|
||||
@@ -83,8 +83,8 @@ public class NamedCompletionProviderTest {
|
||||
AnnotationMetadata annotationBean1 = new AnnotationMetadata("jakarta.inject.Named", false, null, Map.of("value", new AnnotationAttributeValue[] {new AnnotationAttributeValue("named1", null)}));
|
||||
AnnotationMetadata annotationBean2 = new AnnotationMetadata("jakarta.inject.Named", false, null, Map.of("value", new AnnotationAttributeValue[] {new AnnotationAttributeValue("named2", null)}));
|
||||
|
||||
bean1 = new Bean("bean1", "type1", new Location(tempJavaDocUri, new Range(new Position(1,1), new Position(1, 20))), null, null, new AnnotationMetadata[] {annotationBean1}, false);
|
||||
bean2 = new Bean("bean2", "type2", new Location(tempJavaDocUri, new Range(new Position(1,1), new Position(1, 20))), null, null, new AnnotationMetadata[] {annotationBean2}, false);
|
||||
bean1 = new Bean("bean1", "type1", new Location(tempJavaDocUri, new Range(new Position(1,1), new Position(1, 20))), null, null, new AnnotationMetadata[] {annotationBean1}, false, "symbolLabel");
|
||||
bean2 = new Bean("bean2", "type2", new Location(tempJavaDocUri, new Range(new Position(1,1), new Position(1, 20))), null, null, new AnnotationMetadata[] {annotationBean2}, false, "symbolLabel");
|
||||
|
||||
springIndex.updateBeans(project.getElementName(), new Bean[] {bean1, bean2});
|
||||
}
|
||||
|
||||
@@ -87,8 +87,8 @@ public class NamedDefinitionProviderTest {
|
||||
AnnotationMetadata annotationBean1 = new AnnotationMetadata("jakarta.inject.Named", false, null, Map.of("value", new AnnotationAttributeValue[] {new AnnotationAttributeValue("named1", locationNamedAnnotation1)}));
|
||||
AnnotationMetadata annotationBean2 = new AnnotationMetadata("jakarta.inject.Named", false, null, Map.of("value", new AnnotationAttributeValue[] {new AnnotationAttributeValue("named2", locationNamedAnnotation2)}));
|
||||
|
||||
bean1 = new Bean("bean1", "type1", new Location(tempJavaDocUri1, new Range(new Position(1,1), new Position(1, 20))), null, null, new AnnotationMetadata[] {annotationBean1}, false);
|
||||
bean2 = new Bean("bean2", "type2", new Location(tempJavaDocUri2, new Range(new Position(1,1), new Position(1, 20))), null, null, new AnnotationMetadata[] {annotationBean2}, false);
|
||||
bean1 = new Bean("bean1", "type1", new Location(tempJavaDocUri1, new Range(new Position(1,1), new Position(1, 20))), null, null, new AnnotationMetadata[] {annotationBean1}, false, "symbolLabel");
|
||||
bean2 = new Bean("bean2", "type2", new Location(tempJavaDocUri2, new Range(new Position(1,1), new Position(1, 20))), null, null, new AnnotationMetadata[] {annotationBean2}, false, "symbolLabel");
|
||||
|
||||
springIndex.updateBeans(project.getElementName(), new Bean[] {bean1, bean2});
|
||||
}
|
||||
|
||||
@@ -96,8 +96,8 @@ public class NamedReferencesProviderTest {
|
||||
|
||||
InjectionPoint point1 = new InjectionPoint("point1", "type1", null, new AnnotationMetadata[] {point1Metadata});
|
||||
|
||||
bean1 = new Bean("bean1", "type1", new Location(tempJavaDocUri1, new Range(new Position(1,1), new Position(1, 20))), new InjectionPoint[] {point1}, null, new AnnotationMetadata[] {annotationBean1}, false);
|
||||
bean2 = new Bean("bean2", "type2", new Location(tempJavaDocUri2, new Range(new Position(1,1), new Position(1, 20))), null, null, new AnnotationMetadata[] {annotationBean2}, false);
|
||||
bean1 = new Bean("bean1", "type1", new Location(tempJavaDocUri1, new Range(new Position(1,1), new Position(1, 20))), new InjectionPoint[] {point1}, null, new AnnotationMetadata[] {annotationBean1}, false, "symbolLabel");
|
||||
bean2 = new Bean("bean2", "type2", new Location(tempJavaDocUri2, new Range(new Position(1,1), new Position(1, 20))), null, null, new AnnotationMetadata[] {annotationBean2}, false, "symbolLabel");
|
||||
|
||||
springIndex.updateBeans(project.getElementName(), new Bean[] {bean1, bean2});
|
||||
}
|
||||
|
||||
@@ -84,8 +84,8 @@ public class ProfileCompletionProviderTest {
|
||||
AnnotationMetadata annotationBean1 = new AnnotationMetadata("org.springframework.context.annotation.Profile", false, null, Map.of("value", new AnnotationAttributeValue[] {new AnnotationAttributeValue("prof1", null), new AnnotationAttributeValue("prof2", null)}));
|
||||
AnnotationMetadata annotationBean2 = new AnnotationMetadata("org.springframework.context.annotation.Profile", false, null, Map.of("value", new AnnotationAttributeValue[] {new AnnotationAttributeValue("prof3", null)}));
|
||||
|
||||
bean1 = new Bean("bean1", "type1", new Location(tempJavaDocUri, new Range(new Position(1,1), new Position(1, 20))), null, null, new AnnotationMetadata[] {annotationBean1}, false);
|
||||
bean2 = new Bean("bean2", "type2", new Location(tempJavaDocUri, new Range(new Position(1,1), new Position(1, 20))), null, null, new AnnotationMetadata[] {annotationBean2}, false);
|
||||
bean1 = new Bean("bean1", "type1", new Location(tempJavaDocUri, new Range(new Position(1,1), new Position(1, 20))), null, null, new AnnotationMetadata[] {annotationBean1}, false, "symbolLabel");
|
||||
bean2 = new Bean("bean2", "type2", new Location(tempJavaDocUri, new Range(new Position(1,1), new Position(1, 20))), null, null, new AnnotationMetadata[] {annotationBean2}, false, "symbolLabel");
|
||||
|
||||
springIndex.updateBeans(project.getElementName(), new Bean[] {bean1, bean2});
|
||||
|
||||
|
||||
@@ -84,8 +84,8 @@ public class QualifierCompletionProviderTest {
|
||||
AnnotationMetadata annotationBean1 = new AnnotationMetadata("org.springframework.beans.factory.annotation.Qualifier", false, null, Map.of("value", new AnnotationAttributeValue[] {new AnnotationAttributeValue("quali1", null)}));
|
||||
AnnotationMetadata annotationBean2 = new AnnotationMetadata("org.springframework.beans.factory.annotation.Qualifier", false, null, Map.of("value", new AnnotationAttributeValue[] {new AnnotationAttributeValue("quali2", null)}));
|
||||
|
||||
bean1 = new Bean("bean1", "type1", new Location(tempJavaDocUri, new Range(new Position(1,1), new Position(1, 20))), null, null, new AnnotationMetadata[] {annotationBean1}, false);
|
||||
bean2 = new Bean("bean2", "type2", new Location(tempJavaDocUri, new Range(new Position(1,1), new Position(1, 20))), null, null, new AnnotationMetadata[] {annotationBean2}, false);
|
||||
bean1 = new Bean("bean1", "type1", new Location(tempJavaDocUri, new Range(new Position(1,1), new Position(1, 20))), null, null, new AnnotationMetadata[] {annotationBean1}, false, "symbolLabel");
|
||||
bean2 = new Bean("bean2", "type2", new Location(tempJavaDocUri, new Range(new Position(1,1), new Position(1, 20))), null, null, new AnnotationMetadata[] {annotationBean2}, false, "symbolLabel");
|
||||
|
||||
springIndex.updateBeans(project.getElementName(), new Bean[] {bean1, bean2});
|
||||
}
|
||||
|
||||
@@ -83,8 +83,8 @@ public class ResourceCompletionProviderTest {
|
||||
AnnotationMetadata annotationBean1 = new AnnotationMetadata("org.springframework.beans.factory.annotation.Qualifier", false, null, Map.of("value", new AnnotationAttributeValue[] {new AnnotationAttributeValue("quali1", null)}));
|
||||
AnnotationMetadata annotationBean2 = new AnnotationMetadata("org.springframework.beans.factory.annotation.Qualifier", false, null, Map.of("value", new AnnotationAttributeValue[] {new AnnotationAttributeValue("quali2", null)}));
|
||||
|
||||
bean1 = new Bean("bean1", "type1", new Location(tempJavaDocUri, new Range(new Position(1,1), new Position(1, 20))), null, null, new AnnotationMetadata[] {annotationBean1}, false);
|
||||
bean2 = new Bean("bean2", "type2", new Location(tempJavaDocUri, new Range(new Position(1,1), new Position(1, 20))), null, null, new AnnotationMetadata[] {annotationBean2}, false);
|
||||
bean1 = new Bean("bean1", "type1", new Location(tempJavaDocUri, new Range(new Position(1,1), new Position(1, 20))), null, null, new AnnotationMetadata[] {annotationBean1}, false, "symbolLabel");
|
||||
bean2 = new Bean("bean2", "type2", new Location(tempJavaDocUri, new Range(new Position(1,1), new Position(1, 20))), null, null, new AnnotationMetadata[] {annotationBean2}, false, "symbolLabel");
|
||||
|
||||
springIndex.updateBeans(project.getElementName(), new Bean[] {bean1, bean2});
|
||||
}
|
||||
|
||||
@@ -116,7 +116,7 @@ public class ResourceDefinitionProviderTest {
|
||||
String expectedDefinitionUri = directory.toPath().resolve("src/main/java/org/test/MainClass.java").toUri().toString();
|
||||
|
||||
DocumentElement document = springIndex.getDocument(expectedDefinitionUri);
|
||||
document.addChild(new Bean("bean1", "type", new Location(expectedDefinitionUri, new Range(new Position(20, 1), new Position(20, 10))), null, null, null, false));
|
||||
document.addChild(new Bean("bean1", "type", new Location(expectedDefinitionUri, new Range(new Position(20, 1), new Position(20, 10))), null, null, null, false, "symbolLabel"));
|
||||
|
||||
Bean[] beans = springIndex.getBeansWithName(project.getElementName(), "bean1");
|
||||
assertEquals(2, beans.length);
|
||||
|
||||
@@ -72,8 +72,8 @@ public class ConditionalOnBeanCompletionTest {
|
||||
initProject.get(5, TimeUnit.SECONDS);
|
||||
|
||||
tempJavaDocUri = directory.toPath().resolve("src/main/java/org/test/TempClass.java").toUri().toString();
|
||||
bean1 = new Bean("bean1", "org.example.type1", new Location(tempJavaDocUri, new Range(new Position(1,1), new Position(1, 20))), null, null, null, false);
|
||||
bean2 = new Bean("bean2", "org.example.type2", new Location(tempJavaDocUri, new Range(new Position(1,1), new Position(1, 20))), null, null, null, false);
|
||||
bean1 = new Bean("bean1", "org.example.type1", new Location(tempJavaDocUri, new Range(new Position(1,1), new Position(1, 20))), null, null, null, false, "symbolLabel");
|
||||
bean2 = new Bean("bean2", "org.example.type2", new Location(tempJavaDocUri, new Range(new Position(1,1), new Position(1, 20))), null, null, null, false, "symbolLabel");
|
||||
|
||||
springIndex.updateBeans(project.getElementName(), new Bean[] {bean1, bean2});
|
||||
}
|
||||
@@ -165,7 +165,7 @@ public class ConditionalOnBeanCompletionTest {
|
||||
|
||||
@Test
|
||||
public void testConditionalOnBeanCompletionInsideOfArrayBetweenExistingElements() throws Exception {
|
||||
Bean bean3 = new Bean("bean3", "org.example.type3", new Location(tempJavaDocUri, new Range(new Position(1,1), new Position(1, 20))), null, null, null, false);
|
||||
Bean bean3 = new Bean("bean3", "org.example.type3", new Location(tempJavaDocUri, new Range(new Position(1,1), new Position(1, 20))), null, null, null, false, "symbolLabel");
|
||||
springIndex.updateBeans(project.getElementName(), new Bean[] {bean1, bean2, bean3});
|
||||
|
||||
assertCompletions("@ConditionalOnBean(name={\"bean1\",<*>\"bean2\"})", 1, "@ConditionalOnBean(name={\"bean1\",\"bean3\",<*>\"bean2\"})");
|
||||
|
||||
@@ -111,7 +111,7 @@ public class AddConfigurationIfBeansPresentReconcilerTest extends BaseReconciler
|
||||
|
||||
AnnotationMetadata annotationMetadata = new AnnotationMetadata(Annotations.CONFIGURATION, false, null, Map.of());
|
||||
AnnotationMetadata[] annotations = new AnnotationMetadata[] {annotationMetadata};
|
||||
Bean configBean = new Bean("a", "example.demo.A", null, null, null, annotations, false);
|
||||
Bean configBean = new Bean("a", "example.demo.A", null, null, null, annotations, false, "symbolLabel");
|
||||
Bean[] beans = new Bean[] {configBean};
|
||||
springIndex.updateBeans(getProjectName(), beans);
|
||||
|
||||
@@ -144,7 +144,7 @@ public class AddConfigurationIfBeansPresentReconcilerTest extends BaseReconciler
|
||||
|
||||
AnnotationMetadata annotationMetadata = new AnnotationMetadata(Annotations.FEIGN_CLIENT, false, null, Map.of("configuration", new AnnotationAttributeValue[] {new AnnotationAttributeValue("example.demo.A", null)}));
|
||||
AnnotationMetadata[] annotations = new AnnotationMetadata[] {annotationMetadata};
|
||||
Bean configBean = new Bean("feignClient", "example.demo.FeignClientExample", null, null, null, annotations, false);
|
||||
Bean configBean = new Bean("feignClient", "example.demo.FeignClientExample", null, null, null, annotations, false, "symbolLabel");
|
||||
Bean[] beans = new Bean[] {configBean};
|
||||
springIndex.updateBeans(getProjectName(), beans);
|
||||
|
||||
|
||||
@@ -72,7 +72,7 @@ public class NotRegisteredBeansReconcilerTest extends BaseReconcilerTest {
|
||||
""";
|
||||
|
||||
SpringMetamodelIndex springIndex = new SpringMetamodelIndex();
|
||||
Bean aotBean = new Bean("a", "example.demo.A", new Location("docURI", new Range()), null, null, null, true);
|
||||
Bean aotBean = new Bean("a", "example.demo.A", new Location("docURI", new Range()), null, null, null, true, "symbolLabel");
|
||||
springIndex.updateBeans(getProjectName(), new Bean[] {aotBean});
|
||||
|
||||
List<ReconcileProblem> problems = reconcile(() -> createReconciler(springIndex), "A.java", source, true);
|
||||
@@ -122,7 +122,7 @@ public class NotRegisteredBeansReconcilerTest extends BaseReconcilerTest {
|
||||
""";
|
||||
|
||||
SpringMetamodelIndex springIndex = new SpringMetamodelIndex();
|
||||
Bean configBean = new Bean("testConfig", "example.demo.TestConfig", new Location("docURI", new Range()), null, null, null, true);
|
||||
Bean configBean = new Bean("testConfig", "example.demo.TestConfig", new Location("docURI", new Range()), null, null, null, true, "symbolLabel");
|
||||
springIndex.updateBeans(getProjectName(), new Bean[] {configBean});
|
||||
|
||||
List<ReconcileProblem> problems = reconcile(() -> createReconciler(springIndex), "A.java", source, true);
|
||||
|
||||
@@ -75,10 +75,10 @@ public class SpelDefinitionProviderTest {
|
||||
expectedDefinitionUriSpelClass = directory.toPath().resolve("src/main/java/org/test/SpelExpressionsClass.java").toUri().toString();
|
||||
visitService = new Bean("visitService", "org.test.VisitService",
|
||||
new Location(expectedDefinitionUriVisitService, new Range(new Position(4, 0), new Position(4, 8))),
|
||||
null, null, null, false);
|
||||
null, null, null, false, "symbolLabel");
|
||||
spelExpressionsClass = new Bean("spelExpressionsClass", "org.test.SpelExpressionsClass",
|
||||
new Location(expectedDefinitionUriSpelClass, new Range(new Position(7, 0), new Position(7, 11))), null,
|
||||
null, null, false);
|
||||
null, null, false, "symbolLabel");
|
||||
|
||||
springIndex.updateBeans(project.getElementName(), new Bean[] { visitService, spelExpressionsClass });
|
||||
|
||||
|
||||
Reference in New Issue
Block a user