Skip to content

Commit 02e3ede

Browse files
committed
GH-1041: bean now knows whether it is a configuration bean or not
1 parent 8491efa commit 02e3ede

23 files changed

+94
-69
lines changed

headless-services/commons/commons-lsp-extensions/src/main/java/org/springframework/ide/vscode/commons/protocol/spring/Bean.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,20 @@ public class Bean {
2424
private final InjectionPoint[] injectionPoints;
2525
private final Set<String> supertypes;
2626
private final AnnotationMetadata[] annotations;
27+
private final boolean isConfiguration;
28+
29+
public Bean(
30+
String name,
31+
String type,
32+
Location location,
33+
InjectionPoint[] injectionPoints,
34+
Set<String> supertypes,
35+
AnnotationMetadata[] annotations, boolean isConfiguration) {
2736

28-
public Bean(String name, String type, Location location, InjectionPoint[] injectionPoints, Set<String> supertypes, AnnotationMetadata[] annotations) {
2937
this.name = name;
3038
this.type = type;
3139
this.location = location;
40+
this.isConfiguration = isConfiguration;
3241

3342
if (injectionPoints != null && injectionPoints.length == 0) {
3443
this.injectionPoints = DefaultValues.EMPTY_INJECTION_POINTS;
@@ -79,6 +88,10 @@ public AnnotationMetadata[] getAnnotations() {
7988
return annotations;
8089
}
8190

91+
public boolean isConfiguration() {
92+
return isConfiguration;
93+
}
94+
8295
@Override
8396
public String toString() {
8497
Gson gson = new Gson();

headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/index/cache/IndexCacheOnDisc.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -476,8 +476,11 @@ public Bean deserialize(JsonElement json, Type type, JsonDeserializationContext
476476

477477
JsonElement annotationsObject = parsedObject.get("annotations");
478478
AnnotationMetadata[] annotations = annotationsObject == null ? DefaultValues.EMPTY_ANNOTATIONS : context.deserialize(annotationsObject, AnnotationMetadata[].class);
479+
480+
JsonElement isConfigurationObject = parsedObject.get("isConfiguration");
481+
boolean isConfiguration = context.deserialize(isConfigurationObject, boolean.class);
479482

480-
return new Bean(beanName, beanType, location, injectionPoints, supertypes, annotations);
483+
return new Bean(beanName, beanType, location, injectionPoints, supertypes, annotations, isConfiguration);
481484
}
482485
}
483486

headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/index/cache/IndexCacheOnDiscDeltaBased.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,10 @@ public Bean deserialize(JsonElement json, Type type, JsonDeserializationContext
688688
JsonElement annotationsObject = parsedObject.get("annotations");
689689
AnnotationMetadata[] annotations = annotationsObject == null ? DefaultValues.EMPTY_ANNOTATIONS : context.deserialize(annotationsObject, AnnotationMetadata[].class);
690690

691-
return new Bean(beanName, beanType, location, injectionPoints, supertypes, annotations);
691+
JsonElement isConfigurationObject = parsedObject.get("isConfiguration");
692+
boolean isConfiguration = context.deserialize(isConfigurationObject, boolean.class);
693+
694+
return new Bean(beanName, beanType, location, injectionPoints, supertypes, annotations, isConfiguration);
692695
}
693696
}
694697

headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/java/beans/BeansSymbolProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ protected void addSymbolsPass1(Annotation node, ITypeBinding annotationType, Col
9898
Collection<Annotation> annotationsOnMethod = ASTUtils.getAnnotations(method);
9999
AnnotationMetadata[] annotations = ASTUtils.getAnnotationsMetadata(annotationsOnMethod, doc);
100100

101-
Bean beanDefinition = new Bean(nameAndRegion.getT1(), beanType.getQualifiedName(), location, injectionPoints, supertypes, annotations);
101+
Bean beanDefinition = new Bean(nameAndRegion.getT1(), beanType.getQualifiedName(), location, injectionPoints, supertypes, annotations, false);
102102

103103
context.getGeneratedSymbols().add(new CachedSymbol(context.getDocURI(), context.getLastModified(), enhancedSymbol));
104104
context.getBeans().add(new CachedBean(context.getDocURI(), beanDefinition));

headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/java/beans/ComponentSymbolProvider.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,12 @@ protected Tuple.Two<EnhancedSymbolInformation, Bean> createSymbol(Annotation nod
9090
beanLabel("+", annotationTypeName, metaAnnotationNames, beanName, beanType.getName()), SymbolKind.Interface,
9191
Either.forLeft(location));
9292

93+
boolean isConfiguration = false;
9394
SymbolAddOnInformation[] addon = new SymbolAddOnInformation[0];
9495
if (Annotations.CONFIGURATION.equals(annotationType.getQualifiedName())
9596
|| metaAnnotations.stream().anyMatch(t -> Annotations.CONFIGURATION.equals(t.getQualifiedName()))) {
9697
addon = new SymbolAddOnInformation[] {new ConfigBeanSymbolAddOnInformation(beanName, beanType.getQualifiedName())};
98+
isConfiguration = true;
9799
} else {
98100
addon = new SymbolAddOnInformation[] {new BeansSymbolAddOnInformation(beanName, beanType.getQualifiedName())};
99101
}
@@ -112,7 +114,7 @@ protected Tuple.Two<EnhancedSymbolInformation, Bean> createSymbol(Annotation nod
112114
.map(an -> new AnnotationMetadata(an.getQualifiedName(), true, null, null)))
113115
.toArray(AnnotationMetadata[]::new);
114116

115-
Bean beanDefinition = new Bean(beanName, beanType.getQualifiedName(), location, injectionPoints, supertypes, annotations);
117+
Bean beanDefinition = new Bean(beanName, beanType.getQualifiedName(), location, injectionPoints, supertypes, annotations, isConfiguration);
116118

117119
return Tuple.two(new EnhancedSymbolInformation(symbol, addon), beanDefinition);
118120
}

headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/java/beans/FeignClientSymbolProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ private Two<EnhancedSymbolInformation, Bean> createSymbol(Annotation node, IType
9898
.map(an -> new AnnotationMetadata(an.getQualifiedName(), true, null, null)))
9999
.toArray(AnnotationMetadata[]::new);
100100

101-
Bean beanDefinition = new Bean(beanName, beanType == null ? "" : beanType.getQualifiedName(), location, injectionPoints, supertypes, annotations);
101+
Bean beanDefinition = new Bean(beanName, beanType == null ? "" : beanType.getQualifiedName(), location, injectionPoints, supertypes, annotations, false);
102102

103103
return Tuple.two(new EnhancedSymbolInformation(symbol, addon), beanDefinition);
104104
}

headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/java/data/DataRepositorySymbolProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ protected void addSymbolsPass1(TypeDeclaration typeDeclaration, SpringIndexerJav
8080
Collection<Annotation> annotationsOnMethod = ASTUtils.getAnnotations(typeDeclaration);
8181
AnnotationMetadata[] annotations = ASTUtils.getAnnotationsMetadata(annotationsOnMethod, doc);
8282

83-
Bean beanDefinition = new Bean(beanName, concreteRepoType, location, injectionPoints, supertypes, annotations);
83+
Bean beanDefinition = new Bean(beanName, concreteRepoType, location, injectionPoints, supertypes, annotations, false);
8484

8585
context.getGeneratedSymbols().add(new CachedSymbol(context.getDocURI(), context.getLastModified(), enhancedSymbol));
8686
context.getBeans().add(new CachedBean(context.getDocURI(), beanDefinition));

headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/java/utils/SpringIndexerJava.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public static enum SCAN_PASS {
9393

9494
// whenever the implementation of the indexer changes in a way that the stored data in the cache is no longer valid,
9595
// we need to change the generation - this will result in a re-indexing due to no up-to-date cache data being found
96-
private static final String GENERATION = "GEN-9";
96+
private static final String GENERATION = "GEN-10";
9797
private static final String INDEX_FILES_TASK_ID = "index-java-source-files-task-";
9898

9999
private static final String SYMBOL_KEY = "symbols";

headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/java/utils/SpringIndexerXMLNamespaceHandlerBeans.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ else if (name != null && name.equals("class")) {
102102
generatedSymbols.add(cachedSymbol);
103103

104104
// TODO: bean index
105-
generatedBeans.add(new CachedBean(docURI, new Bean(beanID, fqBeanClass, location, null, null, null)));
105+
generatedBeans.add(new CachedBean(docURI, new Bean(beanID, fqBeanClass, location, null, null, null, false)));
106106
}
107107
}
108108

0 commit comments

Comments
 (0)