Settings for bean injection completion and bean structure
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2020, 2024 Pivotal, Inc.
|
||||
* Copyright (c) 2020, 2025 Pivotal, 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
|
||||
@@ -116,7 +116,8 @@ public class BootJavaCompletionEngineConfigurer {
|
||||
JavaSnippetManager snippetManager,
|
||||
CompilationUnitCache cuCache,
|
||||
SpringMetamodelIndex springIndex,
|
||||
RewriteRefactorings rewriteRefactorings ) {
|
||||
RewriteRefactorings rewriteRefactorings,
|
||||
BootJavaConfig config) {
|
||||
|
||||
SpringPropertyIndexProvider indexProvider = params.indexProvider;
|
||||
JavaProjectFinder javaProjectFinder = params.projectFinder;
|
||||
@@ -171,7 +172,7 @@ public class BootJavaCompletionEngineConfigurer {
|
||||
providers.put(Annotations.SCHEDULED, new AnnotationAttributeCompletionProcessor(javaProjectFinder, Map.of(
|
||||
"cron", new CronExpressionCompletionProvider())));
|
||||
|
||||
providers.put(Annotations.BEAN, new BeanCompletionProvider(javaProjectFinder, springIndex, rewriteRefactorings));
|
||||
providers.put(Annotations.BEAN, new BeanCompletionProvider(javaProjectFinder, springIndex, rewriteRefactorings, config));
|
||||
|
||||
return new BootJavaCompletionEngine(cuCache, providers, snippetManager);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2017, 2024 Pivotal, Inc.
|
||||
* Copyright (c) 2017, 2025 Pivotal, 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
|
||||
@@ -168,7 +168,7 @@ public class BootJavaConfig implements InitializingBean {
|
||||
}
|
||||
|
||||
public boolean isJavaSourceReconcileEnabled() {
|
||||
Boolean enabled = getRawSettings().getBoolean("boot-java", "validation", "java", "reconcilers");
|
||||
Boolean enabled = getRawSettings().getBoolean("boot-java", "java", "reconcilers");
|
||||
return enabled == null ? true : enabled.booleanValue();
|
||||
}
|
||||
|
||||
@@ -214,6 +214,16 @@ public class BootJavaConfig implements InitializingBean {
|
||||
return str == null || str.isBlank() ? null : Paths.get(str);
|
||||
}
|
||||
|
||||
public boolean isBeanInjectionCompletionEnabled() {
|
||||
Boolean b = settings.getBoolean("boot-java", "java", "completions", "inject-bean");
|
||||
return Boolean.TRUE.equals(b);
|
||||
}
|
||||
|
||||
public boolean isBeanStructureTreeEnabled() {
|
||||
Boolean b = settings.getBoolean("boot-java", "java", "beans-structure-tree");
|
||||
return Boolean.TRUE.equals(b);
|
||||
}
|
||||
|
||||
public Settings getRawSettings() {
|
||||
return settings;
|
||||
}
|
||||
|
||||
@@ -708,7 +708,8 @@ public class SpringSymbolIndex implements InitializingBean, SpringIndex {
|
||||
}
|
||||
|
||||
public List<? extends DocumentSymbol> getDocumentSymbols(String docURI) {
|
||||
if (System.getProperty(OUTLINE_SYMBOLS_FROM_INDEX_PROPERTY) != null) {
|
||||
if (System.getProperty(OUTLINE_SYMBOLS_FROM_INDEX_PROPERTY) != null
|
||||
|| config.isBeanStructureTreeEnabled()) {
|
||||
return getDocumentSymbolsFromMetamodelIndex(docURI);
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -29,6 +29,7 @@ import org.eclipse.jdt.core.dom.TypeDeclaration;
|
||||
import org.eclipse.jdt.core.dom.VariableDeclaration;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.ide.vscode.boot.app.BootJavaConfig;
|
||||
import org.springframework.ide.vscode.boot.index.SpringMetamodelIndex;
|
||||
import org.springframework.ide.vscode.boot.java.Annotations;
|
||||
import org.springframework.ide.vscode.boot.java.annotations.AnnotationHierarchies;
|
||||
@@ -51,17 +52,21 @@ public class BeanCompletionProvider implements CompletionProvider {
|
||||
private final SpringMetamodelIndex springIndex;
|
||||
private final RewriteRefactorings rewriteRefactorings;
|
||||
|
||||
private final BootJavaConfig config;
|
||||
|
||||
public BeanCompletionProvider(JavaProjectFinder javaProjectFinder, SpringMetamodelIndex springIndex,
|
||||
RewriteRefactorings rewriteRefactorings) {
|
||||
RewriteRefactorings rewriteRefactorings, BootJavaConfig config) {
|
||||
this.javaProjectFinder = javaProjectFinder;
|
||||
this.springIndex = springIndex;
|
||||
this.rewriteRefactorings = rewriteRefactorings;
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void provideCompletions(ASTNode node, int offset, TextDocument doc,
|
||||
Collection<ICompletionProposal> completions) {
|
||||
if (node instanceof SimpleName || node instanceof Block || node instanceof FieldAccess) {
|
||||
if (config.isBeanInjectionCompletionEnabled()
|
||||
&& (node instanceof SimpleName || node instanceof Block || node instanceof FieldAccess)) {
|
||||
try {
|
||||
|
||||
if (node instanceof SimpleName) {
|
||||
|
||||
Reference in New Issue
Block a user