GH-1431: let bean index elements create document symbols on-demand

This commit is contained in:
Martin Lippert
2025-02-20 14:45:32 +01:00
parent 888669ae92
commit bb51280782
23 changed files with 123 additions and 94 deletions

View File

@@ -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);

View File

@@ -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});
}

View File

@@ -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\"<*>)");

View File

@@ -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);

View File

@@ -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});
}

View File

@@ -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});
}

View File

@@ -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});
}

View File

@@ -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});

View File

@@ -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});
}

View File

@@ -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});
}

View File

@@ -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);

View File

@@ -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\"})");

View File

@@ -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);

View File

@@ -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);

View File

@@ -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 });