Skip to content

Commit f44c773

Browse files
committed
Add some beans to index from spring factories
1 parent 3cd3148 commit f44c773

File tree

9 files changed

+331
-16
lines changed

9 files changed

+331
-16
lines changed

eclipse-language-servers/org.springframework.tooling.boot.ls/src/org/springframework/tooling/boot/ls/DelegatingStreamConnectionProvider.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,8 @@ public void handleMessage(Message message, LanguageServer languageServer, URI ro
142142
FileSystems.getDefault().getPathMatcher("glob:**/*.java"),
143143
FileSystems.getDefault().getPathMatcher("glob:**/*.json"),
144144
FileSystems.getDefault().getPathMatcher("glob:**/*.yml"),
145-
FileSystems.getDefault().getPathMatcher("glob:**/*.properties")
145+
FileSystems.getDefault().getPathMatcher("glob:**/*.properties"),
146+
FileSystems.getDefault().getPathMatcher("glob:**/META-INF/spring/*.factories")
146147
)));
147148

148149
//Add remote boot apps listener

headless-services/commons/commons-util/src/main/java/org/springframework/ide/vscode/commons/util/text/LanguageId.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2017, 2019 Pivotal, Inc.
2+
* Copyright (c) 2017, 2022 Pivotal, Inc.
33
* All rights reserved. This program and the accompanying materials
44
* are made available under the terms of the Eclipse Public License v1.0
55
* which accompanies this distribution, and is available at
@@ -31,6 +31,7 @@ public class LanguageId {
3131
public static final LanguageId BOSH_CLOUD_CONFIG = of("bosh-cloud-config");
3232
public static final LanguageId BOOT_PROPERTIES = of("spring-boot-properties");
3333
public static final LanguageId BOOT_PROPERTIES_YAML = of("spring-boot-properties-yaml");
34+
public static final LanguageId SPRING_FACTORIES = of("spring-factories");
3435

3536
private final String id;
3637

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,10 +264,10 @@ private void validateProject(IJavaProject project, IReconcileEngine reconcileEng
264264
projectReconcileRequests.put(uri, Mono.delay(Duration.ofMillis(100))
265265
.publishOn(projectReconcileScheduler)
266266
.doOnSuccess(l -> {
267+
projectReconcileRequests.remove(uri);
267268
projectFinder.find(new TextDocumentIdentifier(uri.toString())).ifPresent(p -> {
268269
projectReconciler.reconcile(p, doc -> server.createProblemCollector(doc));
269270
});
270-
projectReconcileRequests.remove(uri);
271271
})
272272
.subscribe());
273273
}

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
import org.springframework.ide.vscode.boot.java.handlers.SymbolAddOnInformation;
5050
import org.springframework.ide.vscode.boot.java.handlers.SymbolProvider;
5151
import org.springframework.ide.vscode.boot.java.utils.DocumentDescriptor;
52+
import org.springframework.ide.vscode.boot.java.utils.SpringFactoriesIndexer;
5253
import org.springframework.ide.vscode.boot.java.utils.SpringIndexer;
5354
import org.springframework.ide.vscode.boot.java.utils.SpringIndexerJava;
5455
import org.springframework.ide.vscode.boot.java.utils.SpringIndexerXML;
@@ -125,6 +126,7 @@ public void deleted(IJavaProject project) {
125126

126127
private SpringIndexerXML springIndexerXML;
127128
private SpringIndexerJava springIndexerJava;
129+
private SpringFactoriesIndexer factoriesIndexer;
128130

129131
private String watchXMLDeleteRegistration;
130132
private String watchXMLCreatedRegistration;
@@ -163,8 +165,9 @@ public void removeSymbols(IJavaProject project, String docURI) {
163165
namespaceHandler.put("http://www.springframework.org/schema/beans", new SpringIndexerXMLNamespaceHandlerBeans());
164166
springIndexerXML = new SpringIndexerXML(handler, namespaceHandler, this.cache, projectFinder());
165167
springIndexerJava = new SpringIndexerJava(handler, specificProviders, this.cache, projectFinder());
168+
factoriesIndexer = new SpringFactoriesIndexer(handler, cache);
166169

167-
this.indexers = new SpringIndexer[] {springIndexerJava};
170+
this.indexers = new SpringIndexer[] {springIndexerJava, factoriesIndexer};
168171

169172

170173
getWorkspaceService().onDidChangeWorkspaceFolders(evt -> {
@@ -206,7 +209,8 @@ public void removeSymbols(IJavaProject project, String docURI) {
206209
}
207210

208211
public void serverInitialized() {
209-
List<String> globPattern = Arrays.asList(springIndexerJava.getFileWatchPatterns());
212+
List<String> globPattern = Stream.concat(Arrays.stream(springIndexerJava.getFileWatchPatterns()), Arrays.stream(factoriesIndexer.getFileWatchPatterns()))
213+
.collect(Collectors.toList());
210214

211215
getWorkspaceService().getFileObserver().onFilesDeleted(globPattern, (files) -> {
212216
deleteDocuments(files);
@@ -222,11 +226,11 @@ public void serverInitialized() {
222226
public void configureIndexer(SymbolIndexConfig config) {
223227
synchronized (this) {
224228
if (config.isScanXml() && !(Arrays.asList(this.indexers).contains(springIndexerXML))) {
225-
this.indexers = new SpringIndexer[] { springIndexerJava, springIndexerXML };
229+
this.indexers = new SpringIndexer[] { springIndexerJava, factoriesIndexer, springIndexerXML };
226230
springIndexerXML.updateScanFolders(config.getXmlScanFolders());
227231
addXmlFileListeners(Arrays.asList(springIndexerXML.getFileWatchPatterns()));
228232
} else if (!config.isScanXml() && Arrays.asList(this.indexers).contains(springIndexerXML)) {
229-
this.indexers = new SpringIndexer[] { springIndexerJava };
233+
this.indexers = new SpringIndexer[] { springIndexerJava, factoriesIndexer };
230234
springIndexerXML.updateScanFolders(new String[0]);
231235
removeXmlFileListeners();
232236
} else if (config.isScanXml()) {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2017, 2019 Pivotal, Inc.
2+
* Copyright (c) 2017, 2022 Pivotal, Inc.
33
* All rights reserved. This program and the accompanying materials
44
* are made available under the terms of the Eclipse Public License v1.0
55
* which accompanies this distribution, and is available at
@@ -127,7 +127,7 @@ protected Collection<Tuple2<String, DocumentRegion>> getBeanNames(Annotation nod
127127
}
128128
}
129129

130-
protected String beanLabel(boolean isFunctionBean, String beanName, String beanType, String markerString) {
130+
public static String beanLabel(boolean isFunctionBean, String beanName, String beanType, String markerString) {
131131
StringBuilder symbolLabel = new StringBuilder();
132132
symbolLabel.append('@');
133133
symbolLabel.append(isFunctionBean ? '>' : '+');
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2022 VMware, Inc.
3+
* All rights reserved. This program and the accompanying materials
4+
* are made available under the terms of the Eclipse Public License v1.0
5+
* which accompanies this distribution, and is available at
6+
* https://www.eclipse.org/legal/epl-v10.html
7+
*
8+
* Contributors:
9+
* VMware, Inc. - initial API and implementation
10+
*******************************************************************************/
11+
package org.springframework.ide.vscode.boot.java.beans;
12+
13+
import org.springframework.ide.vscode.boot.java.handlers.SymbolAddOnInformation;
14+
15+
public class SpringFactoryInformation implements SymbolAddOnInformation {
16+
17+
private String key;
18+
19+
public SpringFactoryInformation(String key) {
20+
this.key = key;
21+
}
22+
23+
public String getKey() {
24+
return key;
25+
}
26+
27+
}

headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/java/rewrite/reconcile/BeanPostProcessingIgnoreInAotProblem.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,7 @@ public ClassDeclaration visitClassDeclaration(ClassDeclaration classDecl, Execut
5656
.withFixes(
5757
new FixDescriptor(RECIPE_ID, List.of(uri), RecipeCodeActionDescriptor.buildLabel(LABEL, RecipeScope.NODE))
5858
.withRangeScope(classDecl.getMarkers().findFirst(Range.class).orElse(null))
59-
.withRecipeScope(RecipeScope.NODE),
60-
new FixDescriptor(RECIPE_ID, List.of(uri), RecipeCodeActionDescriptor.buildLabel(LABEL, RecipeScope.FILE))
61-
.withRecipeScope(RecipeScope.FILE),
62-
new FixDescriptor(RECIPE_ID, List.of(uri), RecipeCodeActionDescriptor.buildLabel(LABEL, RecipeScope.PROJECT))
63-
.withRecipeScope(RecipeScope.PROJECT)
59+
.withRecipeScope(RecipeScope.NODE)
6460
);
6561
if (methods.isEmpty()) {
6662
// Didn't find a method. Default implementation return true therefore mark it.

headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/java/rewrite/reconcile/NotRegisteredBeansProblem.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,7 @@ public class NotRegisteredBeansProblem implements RecipeSpringJavaProblemDescrip
5555

5656
private static final List<String> AOT_BEANS = List.of(
5757
"org.springframework.beans.factory.aot.BeanFactoryInitializationAotProcessor",
58-
"org.springframework.beans.factory.aot.BeanRegistrationAotProcessor",
59-
"org.springframework.beans.factory.aot.RuntimeHintsRegistrar"
58+
"org.springframework.beans.factory.aot.BeanRegistrationAotProcessor"
6059
);
6160

6261
@Override

0 commit comments

Comments
 (0)