GH-1400: include more precise location information for annotations and annotation attribute values in spring index
This commit is contained in:
@@ -30,6 +30,7 @@ import org.eclipse.lsp4j.Range;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.ide.vscode.boot.index.SpringMetamodelIndex;
|
||||
import org.springframework.ide.vscode.boot.index.cache.IndexCacheOnDisc;
|
||||
import org.springframework.ide.vscode.commons.protocol.spring.AnnotationAttributeValue;
|
||||
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.DefaultValues;
|
||||
@@ -43,7 +44,7 @@ public class SpringMetamodelIndexTest {
|
||||
private Set<String> emptySupertypes = new HashSet<>();
|
||||
private AnnotationMetadata[] emptyAnnotations = new AnnotationMetadata[0];
|
||||
private AnnotationMetadata[] emptyInjectionAnnotations = new AnnotationMetadata[0];
|
||||
private Map<String, String[]> emptyAnnotationAttributes = new LinkedHashMap<>();
|
||||
private Map<String, AnnotationAttributeValue[]> emptyAnnotationAttributes = new LinkedHashMap<>();
|
||||
|
||||
private Location locationForDoc1 = new Location("docURI1", new Range(new Position(1, 1), new Position(1, 10)));
|
||||
private Location locationForDoc2 = new Location("docURI2", new Range(new Position(2, 1), new Position(2, 10)));
|
||||
@@ -225,8 +226,24 @@ public class SpringMetamodelIndexTest {
|
||||
|
||||
@Test
|
||||
void testOverallSerializeDeserializeBeans() {
|
||||
Location locationForAnnotation1 = new Location("docURI1", new Range(new Position(100, 5), new Position(100, 20)));
|
||||
Location locationForAnnotation2 = new Location("docURI1", new Range(new Position(200, 10), new Position(200, 40)));
|
||||
|
||||
Location locationForAttribute1 = new Location("docURI1", new Range(new Position(1000, 100), new Position(1000, 400)));
|
||||
Location locationForAttribute2 = new Location("docURI1", new Range(new Position(2000, 200), new Position(2000, 800)));
|
||||
Location locationForAttribute3 = new Location("docURI1", new Range(new Position(3000, 400), new Position(3000, 1600)));
|
||||
|
||||
AnnotationAttributeValue annotationAttributeValue1 = new AnnotationAttributeValue("attribute1", locationForAttribute1);
|
||||
AnnotationAttributeValue annotationAttributeValue2 = new AnnotationAttributeValue("attribute2", locationForAttribute2);
|
||||
AnnotationAttributeValue annotationAttributeValue3 = new AnnotationAttributeValue("attribute3", locationForAttribute3);
|
||||
|
||||
InjectionPoint point1 = new InjectionPoint("point1", "point1-type", locationForDoc2, new AnnotationMetadata[]
|
||||
{new AnnotationMetadata("anno1", false, emptyAnnotationAttributes),new AnnotationMetadata("anno2", false, emptyAnnotationAttributes)});
|
||||
{
|
||||
new AnnotationMetadata("anno1", false, locationForAnnotation1, Map.of(
|
||||
"attribute1", new AnnotationAttributeValue[] {annotationAttributeValue1, annotationAttributeValue2},
|
||||
"attribute2", new AnnotationAttributeValue[] {annotationAttributeValue3})),
|
||||
new AnnotationMetadata("anno2", false, locationForAnnotation2, emptyAnnotationAttributes)
|
||||
});
|
||||
|
||||
InjectionPoint point2 = new InjectionPoint("point2", "point2-type", locationForDoc1, null);
|
||||
|
||||
@@ -250,6 +267,7 @@ public class SpringMetamodelIndexTest {
|
||||
assertEquals("point2", points[1].getName());
|
||||
assertEquals("point2-type", points[1].getType());
|
||||
assertEquals(locationForDoc1, points[1].getLocation());
|
||||
assertSame(DefaultValues.EMPTY_ANNOTATIONS, points[1].getAnnotations());
|
||||
|
||||
assertTrue(deserializedBean.isTypeCompatibleWith("supertype1"));
|
||||
assertTrue(deserializedBean.isTypeCompatibleWith("supertype2"));
|
||||
@@ -259,6 +277,21 @@ public class SpringMetamodelIndexTest {
|
||||
assertEquals("anno1", points[0].getAnnotations()[0].getAnnotationType());
|
||||
assertEquals("anno2", points[0].getAnnotations()[1].getAnnotationType());
|
||||
|
||||
assertEquals(locationForAnnotation1, points[0].getAnnotations()[0].getLocation());
|
||||
assertEquals(locationForAnnotation2, points[0].getAnnotations()[1].getLocation());
|
||||
|
||||
Map<String, AnnotationAttributeValue[]> attributes = points[0].getAnnotations()[0].getAttributes();
|
||||
assertEquals(2, attributes.get("attribute1").length);
|
||||
assertEquals(1, attributes.get("attribute2").length);
|
||||
|
||||
assertEquals(annotationAttributeValue1, attributes.get("attribute1")[0]);
|
||||
assertEquals(annotationAttributeValue2, attributes.get("attribute1")[1]);
|
||||
assertEquals(annotationAttributeValue3, attributes.get("attribute2")[0]);
|
||||
|
||||
assertEquals(locationForAttribute1, attributes.get("attribute1")[0].getLocation());
|
||||
assertEquals(locationForAttribute2, attributes.get("attribute1")[1].getLocation());
|
||||
assertEquals(locationForAttribute3, attributes.get("attribute2")[0].getLocation());
|
||||
|
||||
assertEquals(0, points[1].getAnnotations().length);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2023 VMware, Inc.
|
||||
* Copyright (c) 2023, 2024 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
|
||||
@@ -36,6 +36,7 @@ import org.springframework.ide.vscode.boot.bootiful.BootLanguageServerTest;
|
||||
import org.springframework.ide.vscode.boot.bootiful.SymbolProviderTestConf;
|
||||
import org.springframework.ide.vscode.boot.index.SpringMetamodelIndex;
|
||||
import org.springframework.ide.vscode.commons.languageserver.java.JavaProjectFinder;
|
||||
import org.springframework.ide.vscode.commons.protocol.spring.AnnotationAttributeValue;
|
||||
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.DefaultValues;
|
||||
@@ -277,22 +278,41 @@ public class SpringMetamodelIndexerBeansTest {
|
||||
assertEquals("org.springframework.context.annotation.Bean", beanAnnotation.getAnnotationType());
|
||||
assertFalse(annotations[0].isMetaAnnotation());
|
||||
assertEquals(0, annotations[0].getAttributes().size());
|
||||
assertEquals(new Location(mainClassBean.getLocation().getUri(), new Range(new Position(25, 1), new Position(25, 6))), beanAnnotation.getLocation());
|
||||
|
||||
AnnotationMetadata qualifierAnnotation = annotations[1];
|
||||
assertEquals("org.springframework.beans.factory.annotation.Qualifier", qualifierAnnotation.getAnnotationType());
|
||||
Map<String, String[]> attributes = qualifierAnnotation.getAttributes();
|
||||
assertEquals(new Location(mainClassBean.getLocation().getUri(), new Range(new Position(26, 1), new Position(26, 25))), qualifierAnnotation.getLocation());
|
||||
|
||||
Map<String, AnnotationAttributeValue[]> attributes = qualifierAnnotation.getAttributes();
|
||||
assertEquals(1, attributes.size());
|
||||
assertTrue(attributes.containsKey("value"));
|
||||
assertArrayEquals(new String[] {"qualifier1"}, attributes.get("value"));
|
||||
|
||||
AnnotationAttributeValue[] valueAttributes = attributes.get("value");
|
||||
assertEquals(1, valueAttributes.length);
|
||||
assertEquals("qualifier1", valueAttributes[0].getName());
|
||||
Location expectedValueAttributeLocation = new Location(mainClassBean.getLocation().getUri(), new Range(new Position(26, 12), new Position(26, 24)));
|
||||
assertEquals(expectedValueAttributeLocation, valueAttributes[0].getLocation());
|
||||
|
||||
AnnotationMetadata profileAnnotation = annotations[2];
|
||||
assertEquals("org.springframework.context.annotation.Profile", profileAnnotation.getAnnotationType());
|
||||
assertFalse(profileAnnotation.isMetaAnnotation());
|
||||
assertEquals(new Location(mainClassBean.getLocation().getUri(), new Range(new Position(27, 1), new Position(27, 41))), profileAnnotation.getLocation());
|
||||
|
||||
attributes = profileAnnotation.getAttributes();
|
||||
assertEquals(1, attributes.size());
|
||||
assertTrue(attributes.containsKey("value"));
|
||||
assertArrayEquals(new String[] {"testprofile","testprofile2"}, attributes.get("value"));
|
||||
|
||||
AnnotationAttributeValue[] profileValueAttributes = attributes.get("value");
|
||||
assertEquals(2, profileValueAttributes.length);
|
||||
|
||||
assertEquals("testprofile", profileValueAttributes[0].getName());
|
||||
assertEquals("testprofile2", profileValueAttributes[1].getName());
|
||||
|
||||
Location profileValueLocation1 = new Location(mainClassBean.getLocation().getUri(), new Range(new Position(27, 11), new Position(27, 24)));
|
||||
Location profileValueLocation2 = new Location(mainClassBean.getLocation().getUri(), new Range(new Position(27, 25), new Position(27, 39)));
|
||||
|
||||
assertEquals(profileValueLocation1, profileValueAttributes[0].getLocation());
|
||||
assertEquals(profileValueLocation2, profileValueAttributes[1].getLocation());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -309,11 +329,18 @@ public class SpringMetamodelIndexerBeansTest {
|
||||
AnnotationMetadata dependsonAnnotation = annotations[1];
|
||||
|
||||
assertEquals("org.springframework.context.annotation.Bean", beanAnnotation.getAnnotationType());
|
||||
assertEquals(new Location(bean.getLocation().getUri(), new Range(new Position(16, 1), new Position(16, 6))), beanAnnotation.getLocation());
|
||||
|
||||
assertEquals("org.springframework.context.annotation.DependsOn", dependsonAnnotation.getAnnotationType());
|
||||
|
||||
Map<String, String[]> dependsOnAttributes = dependsonAnnotation.getAttributes();
|
||||
Map<String, AnnotationAttributeValue[]> dependsOnAttributes = dependsonAnnotation.getAttributes();
|
||||
assertEquals(1, dependsOnAttributes.size());
|
||||
assertArrayEquals(new String[] {"bean1", "bean2"}, dependsOnAttributes.get("value"));
|
||||
AnnotationAttributeValue[] dependsOnValueAttribute = dependsOnAttributes.get("value");
|
||||
assertEquals(2, dependsOnValueAttribute.length);
|
||||
assertEquals("bean1", dependsOnValueAttribute[0].getName());
|
||||
assertEquals("bean2", dependsOnValueAttribute[1].getName());
|
||||
assertEquals(new Location(bean.getLocation().getUri(), new Range(new Position(17, 13), new Position(17, 20))), dependsOnValueAttribute[0].getLocation());
|
||||
assertEquals(new Location(bean.getLocation().getUri(), new Range(new Position(17, 22), new Position(17, 29))), dependsOnValueAttribute[1].getLocation());
|
||||
|
||||
InjectionPoint[] injectionPoints = bean.getInjectionPoints();
|
||||
assertEquals(2, injectionPoints.length);
|
||||
@@ -325,14 +352,20 @@ public class SpringMetamodelIndexerBeansTest {
|
||||
assertEquals(1, annotationsFromPoint2.length);
|
||||
|
||||
assertEquals("org.springframework.beans.factory.annotation.Qualifier", annotationsFromPoint1[0].getAnnotationType());
|
||||
Map<String, String[]> attributesFromParam1 = annotationsFromPoint1[0].getAttributes();
|
||||
Map<String, AnnotationAttributeValue[]> attributesFromParam1 = annotationsFromPoint1[0].getAttributes();
|
||||
assertEquals(1, attributesFromParam1.size());
|
||||
assertArrayEquals(new String[] {"q1"}, attributesFromParam1.get("value"));
|
||||
AnnotationAttributeValue[] qualifier1ValueAttributes = attributesFromParam1.get("value");
|
||||
assertEquals(1, qualifier1ValueAttributes.length);
|
||||
assertEquals("q1", qualifier1ValueAttributes[0].getName());
|
||||
assertEquals(new Location(bean.getLocation().getUri(), new Range(new Position(18, 84), new Position(18, 88))), qualifier1ValueAttributes[0].getLocation());
|
||||
|
||||
assertEquals("org.springframework.beans.factory.annotation.Qualifier", annotationsFromPoint2[0].getAnnotationType());
|
||||
Map<String, String[]> attributesFromParam2 = annotationsFromPoint2[0].getAttributes();
|
||||
Map<String, AnnotationAttributeValue[]> attributesFromParam2 = annotationsFromPoint2[0].getAttributes();
|
||||
assertEquals(1, attributesFromParam2.size());
|
||||
assertArrayEquals(new String[] {"q2"}, attributesFromParam2.get("value"));
|
||||
AnnotationAttributeValue[] qualifier2ValueAttributes = attributesFromParam2.get("value");
|
||||
assertEquals(1, qualifier2ValueAttributes.length);
|
||||
assertEquals("q2", qualifier2ValueAttributes[0].getName());
|
||||
assertEquals(new Location(bean.getLocation().getUri(), new Range(new Position(18, 119), new Position(18, 123))), qualifier2ValueAttributes[0].getLocation());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -359,13 +392,26 @@ public class SpringMetamodelIndexerBeansTest {
|
||||
assertEquals("org.springframework.context.annotation.ImportRuntimeHints", runtimeHintsAnnotation.getAnnotationType());
|
||||
assertEquals("org.springframework.stereotype.Component", componentMetaAnnotation.getAnnotationType());
|
||||
|
||||
Map<String, String[]> qualifierAttributes = qualifierAnnotation.getAttributes();
|
||||
Map<String, AnnotationAttributeValue[]> qualifierAttributes = qualifierAnnotation.getAttributes();
|
||||
assertEquals(1, qualifierAttributes.size());
|
||||
assertArrayEquals(new String[] {"qualifier"}, qualifierAttributes.get("value"));
|
||||
|
||||
Map<String, String[]> runtimeHintsAttributes = runtimeHintsAnnotation.getAttributes();
|
||||
AnnotationAttributeValue[] valueAttributes = qualifierAttributes.get("value");
|
||||
assertNotNull(valueAttributes);
|
||||
assertEquals(1, valueAttributes.length);
|
||||
|
||||
Location qualifierValueLocation = new Location(bean.getLocation().getUri(), new Range(new Position(12, 11), new Position(12, 22)));
|
||||
assertEquals("qualifier", valueAttributes[0].getName());
|
||||
assertEquals(qualifierValueLocation, valueAttributes[0].getLocation());
|
||||
|
||||
Map<String, AnnotationAttributeValue[]> runtimeHintsAttributes = runtimeHintsAnnotation.getAttributes();
|
||||
assertEquals(1, runtimeHintsAttributes.size());
|
||||
assertArrayEquals(new String[] {"org.test.injections.DummyRuntimeHintsRegistrar"}, runtimeHintsAttributes.get("value"));
|
||||
AnnotationAttributeValue[] runtimeHintsValueAttribute = runtimeHintsAttributes.get("value");
|
||||
assertNotNull(runtimeHintsValueAttribute);
|
||||
assertEquals(1, runtimeHintsValueAttribute.length);
|
||||
|
||||
Location runtimeHintsValueLocation = new Location(bean.getLocation().getUri(), new Range(new Position(13, 20), new Position(13, 52)));
|
||||
assertEquals("org.test.injections.DummyRuntimeHintsRegistrar", runtimeHintsValueAttribute[0].getName());
|
||||
assertEquals(runtimeHintsValueLocation, runtimeHintsValueAttribute[0].getLocation());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -395,9 +441,11 @@ public class SpringMetamodelIndexerBeansTest {
|
||||
assertFalse(qualifierFromPoint2.isMetaAnnotation());
|
||||
assertEquals(1, qualifierFromPoint2.getAttributes().size());
|
||||
|
||||
Map<String, String[]> qualifierAttributes = qualifierFromPoint2.getAttributes();
|
||||
assertEquals(1, qualifierAttributes.size());
|
||||
assertArrayEquals(new String[] {"qual1"}, qualifierAttributes.get("value"));
|
||||
Map<String, AnnotationAttributeValue[]> qualifierAttributes = qualifierFromPoint2.getAttributes();
|
||||
AnnotationAttributeValue[] qualifierAttributeValues = qualifierAttributes.get("value");
|
||||
assertEquals(1, qualifierAttributeValues.length);
|
||||
assertEquals("qual1", qualifierAttributeValues[0].getName());
|
||||
assertEquals(new Location(beans[0].getLocation().getUri(), new Range(new Position(15, 12), new Position(15, 19))), qualifierAttributeValues[0].getLocation());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -415,16 +463,26 @@ public class SpringMetamodelIndexerBeansTest {
|
||||
assertEquals("org.springframework.beans.factory.annotation.Qualifier", qualifierAnnotation.getAnnotationType());
|
||||
assertFalse(qualifierAnnotation.isMetaAnnotation());
|
||||
|
||||
Map<String, String[]> qualifierAttributes = qualifierAnnotation.getAttributes();
|
||||
Map<String, AnnotationAttributeValue[]> qualifierAttributes = qualifierAnnotation.getAttributes();
|
||||
assertEquals(1, qualifierAttributes.size());
|
||||
assertArrayEquals(new String[] {"repoQualifier"}, qualifierAttributes.get("value"));
|
||||
AnnotationAttributeValue[] qualifierAttributeValues = qualifierAttributes.get("value");
|
||||
assertEquals(1, qualifierAttributeValues.length);
|
||||
assertEquals("repoQualifier", qualifierAttributeValues[0].getName());
|
||||
assertEquals(new Location(beans[0].getLocation().getUri(), new Range(new Position(8, 11), new Position(8, 26))), qualifierAttributeValues[0].getLocation());
|
||||
|
||||
assertEquals("org.springframework.context.annotation.Profile", profileAnnotation.getAnnotationType());
|
||||
assertFalse(profileAnnotation.isMetaAnnotation());
|
||||
|
||||
Map<String, String[]> profileAttributes = profileAnnotation.getAttributes();
|
||||
Map<String, AnnotationAttributeValue[]> profileAttributes = profileAnnotation.getAttributes();
|
||||
assertEquals(1, profileAttributes.size());
|
||||
assertArrayEquals(new String[] {"prof1", "prof2"}, profileAttributes.get("value"));
|
||||
AnnotationAttributeValue[] profileAttributeValues = profileAttributes.get("value");
|
||||
assertEquals(2, profileAttributeValues.length);
|
||||
|
||||
assertEquals("prof1", profileAttributeValues[0].getName());
|
||||
assertEquals(new Location(beans[0].getLocation().getUri(), new Range(new Position(9, 10), new Position(9, 17))), profileAttributeValues[0].getLocation());
|
||||
|
||||
assertEquals("prof2", profileAttributeValues[1].getName());
|
||||
assertEquals(new Location(beans[0].getLocation().getUri(), new Range(new Position(9, 19), new Position(9, 26))), profileAttributeValues[1].getLocation());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@ import org.springframework.ide.vscode.boot.bootiful.SymbolProviderTestConf;
|
||||
import org.springframework.ide.vscode.boot.index.SpringMetamodelIndex;
|
||||
import org.springframework.ide.vscode.commons.java.IJavaProject;
|
||||
import org.springframework.ide.vscode.commons.languageserver.java.JavaProjectFinder;
|
||||
import org.springframework.ide.vscode.commons.protocol.spring.AnnotationAttributeValue;
|
||||
import org.springframework.ide.vscode.commons.protocol.spring.AnnotationMetadata;
|
||||
import org.springframework.ide.vscode.commons.protocol.spring.Bean;
|
||||
import org.springframework.ide.vscode.commons.util.text.LanguageId;
|
||||
@@ -79,8 +80,8 @@ public class NamedCompletionProviderTest {
|
||||
indexedBeans = springIndex.getBeansOfProject(project.getElementName());
|
||||
|
||||
tempJavaDocUri = directory.toPath().resolve("src/main/java/org/test/TempClass.java").toUri().toString();
|
||||
AnnotationMetadata annotationBean1 = new AnnotationMetadata("jakarta.inject.Named", false, Map.of("value", new String[] {"named1"}));
|
||||
AnnotationMetadata annotationBean2 = new AnnotationMetadata("jakarta.inject.Named", false, Map.of("value", new String[] {"named2"}));
|
||||
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});
|
||||
bean2 = new Bean("bean2", "type2", new Location(tempJavaDocUri, new Range(new Position(1,1), new Position(1, 20))), null, null, new AnnotationMetadata[] {annotationBean2});
|
||||
|
||||
@@ -36,6 +36,7 @@ import org.springframework.ide.vscode.boot.bootiful.SymbolProviderTestConf;
|
||||
import org.springframework.ide.vscode.boot.index.SpringMetamodelIndex;
|
||||
import org.springframework.ide.vscode.commons.java.IJavaProject;
|
||||
import org.springframework.ide.vscode.commons.languageserver.java.JavaProjectFinder;
|
||||
import org.springframework.ide.vscode.commons.protocol.spring.AnnotationAttributeValue;
|
||||
import org.springframework.ide.vscode.commons.protocol.spring.AnnotationMetadata;
|
||||
import org.springframework.ide.vscode.commons.protocol.spring.Bean;
|
||||
import org.springframework.ide.vscode.commons.util.text.LanguageId;
|
||||
@@ -80,8 +81,8 @@ public class ProfileCompletionProviderTest {
|
||||
indexedBeans = springIndex.getBeansOfProject(project.getElementName());
|
||||
|
||||
tempJavaDocUri = directory.toPath().resolve("src/main/java/org/test/TempClass.java").toUri().toString();
|
||||
AnnotationMetadata annotationBean1 = new AnnotationMetadata("org.springframework.context.annotation.Profile", false, Map.of("value", new String[] {"prof1", "prof2"}));
|
||||
AnnotationMetadata annotationBean2 = new AnnotationMetadata("org.springframework.context.annotation.Profile", false, Map.of("value", new String[] {"prof3"}));
|
||||
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});
|
||||
bean2 = new Bean("bean2", "type2", new Location(tempJavaDocUri, new Range(new Position(1,1), new Position(1, 20))), null, null, new AnnotationMetadata[] {annotationBean2});
|
||||
|
||||
@@ -37,6 +37,7 @@ import org.springframework.ide.vscode.boot.bootiful.SymbolProviderTestConf;
|
||||
import org.springframework.ide.vscode.boot.index.SpringMetamodelIndex;
|
||||
import org.springframework.ide.vscode.commons.java.IJavaProject;
|
||||
import org.springframework.ide.vscode.commons.languageserver.java.JavaProjectFinder;
|
||||
import org.springframework.ide.vscode.commons.protocol.spring.AnnotationAttributeValue;
|
||||
import org.springframework.ide.vscode.commons.protocol.spring.AnnotationMetadata;
|
||||
import org.springframework.ide.vscode.commons.protocol.spring.Bean;
|
||||
import org.springframework.ide.vscode.commons.util.text.LanguageId;
|
||||
@@ -80,8 +81,8 @@ public class QualifierCompletionProviderTest {
|
||||
indexedBeans = springIndex.getBeansOfProject(project.getElementName());
|
||||
|
||||
tempJavaDocUri = directory.toPath().resolve("src/main/java/org/test/TempClass.java").toUri().toString();
|
||||
AnnotationMetadata annotationBean1 = new AnnotationMetadata("org.springframework.beans.factory.annotation.Qualifier", false, Map.of("value", new String[] {"quali1"}));
|
||||
AnnotationMetadata annotationBean2 = new AnnotationMetadata("org.springframework.beans.factory.annotation.Qualifier", false, Map.of("value", new String[] {"quali2"}));
|
||||
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});
|
||||
bean2 = new Bean("bean2", "type2", new Location(tempJavaDocUri, new Range(new Position(1,1), new Position(1, 20))), null, null, new AnnotationMetadata[] {annotationBean2});
|
||||
|
||||
@@ -36,6 +36,7 @@ import org.springframework.ide.vscode.boot.bootiful.SymbolProviderTestConf;
|
||||
import org.springframework.ide.vscode.boot.index.SpringMetamodelIndex;
|
||||
import org.springframework.ide.vscode.commons.java.IJavaProject;
|
||||
import org.springframework.ide.vscode.commons.languageserver.java.JavaProjectFinder;
|
||||
import org.springframework.ide.vscode.commons.protocol.spring.AnnotationAttributeValue;
|
||||
import org.springframework.ide.vscode.commons.protocol.spring.AnnotationMetadata;
|
||||
import org.springframework.ide.vscode.commons.protocol.spring.Bean;
|
||||
import org.springframework.ide.vscode.commons.util.text.LanguageId;
|
||||
@@ -79,8 +80,8 @@ public class ResourceCompletionProviderTest {
|
||||
indexedBeans = springIndex.getBeansOfProject(project.getElementName());
|
||||
|
||||
tempJavaDocUri = directory.toPath().resolve("src/main/java/org/test/TempClass.java").toUri().toString();
|
||||
AnnotationMetadata annotationBean1 = new AnnotationMetadata("org.springframework.beans.factory.annotation.Qualifier", false, Map.of("value", new String[] {"quali1"}));
|
||||
AnnotationMetadata annotationBean2 = new AnnotationMetadata("org.springframework.beans.factory.annotation.Qualifier", false, Map.of("value", new String[] {"quali2"}));
|
||||
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});
|
||||
bean2 = new Bean("bean2", "type2", new Location(tempJavaDocUri, new Range(new Position(1,1), new Position(1, 20))), null, null, new AnnotationMetadata[] {annotationBean2});
|
||||
|
||||
@@ -67,7 +67,8 @@ public class SpringIndexerJakartaJavaxAnnotationsTest {
|
||||
String docUri = directory.toPath().resolve("src/main/java/org/test/jakarta/SimpleMovieLister.java").toUri().toString();
|
||||
|
||||
SpringIndexerHarness.assertDocumentSymbols(indexer, docUri,
|
||||
SpringIndexerHarness.symbol("@Resource", "@Resource"),
|
||||
SpringIndexerHarness.symbol("@Component", "@+ 'simpleMovieLister' (@Component) SimpleMovieLister"),
|
||||
SpringIndexerHarness.symbol("@Resource", "@Resource"),
|
||||
SpringIndexerHarness.symbol("@Resource", "@Resource"),
|
||||
SpringIndexerHarness.symbol("@Resource(name=\"myMovieFinder\")", "@Resource(name=\"myMovieFinder\")"),
|
||||
SpringIndexerHarness.symbol("@Inject", "@Inject"),
|
||||
|
||||
@@ -6,6 +6,9 @@ import jakarta.annotation.Resource;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.inject.Named;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class SimpleMovieLister {
|
||||
|
||||
@Resource
|
||||
|
||||
@@ -4,8 +4,11 @@ import javax.annotation.Resource;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import org.test.MovieFinder;
|
||||
|
||||
@Component
|
||||
public class SimpleMovieLister {
|
||||
|
||||
@Resource
|
||||
|
||||
Reference in New Issue
Block a user