Settings for bean injection completion and bean structure
This commit is contained in:
@@ -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
|
||||
@@ -52,4 +52,8 @@ public class Constants {
|
||||
|
||||
public static final String PREF_CRON_INLAY_HINTS = "boot-java.cron.inlay-hints";
|
||||
|
||||
public static final String PREF_COMPLETION_JAVA_INJECT_BEAN = "boot-java.java.completions.inject-bean";
|
||||
|
||||
public static final String PREF_BEANS_STRUCTURE_TREE = "boot-java.java.beans-structure-tree";
|
||||
|
||||
}
|
||||
|
||||
@@ -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
|
||||
@@ -182,8 +182,8 @@ public class DelegatingStreamConnectionProvider implements StreamConnectionProvi
|
||||
Map<String, Object> supportXML = new HashMap<>();
|
||||
Map<String, Object> bootChangeDetection = new HashMap<>();
|
||||
Map<String, Object> scanTestJavaSources = new HashMap<>();
|
||||
Map<String, Object> validation = new HashMap<>();
|
||||
Map<String, Object> javaValidation = new HashMap<>();
|
||||
Map<String, Object> javaSettings = new HashMap<>();
|
||||
Map<String, Object> javaCompletionSettings = new HashMap<>();
|
||||
|
||||
IPreferenceStore preferenceStore = BootLanguageServerPlugin.getDefault().getPreferenceStore();
|
||||
|
||||
@@ -200,8 +200,11 @@ public class DelegatingStreamConnectionProvider implements StreamConnectionProvi
|
||||
bootChangeDetection.put("on", preferenceStore.getBoolean(Constants.PREF_CHANGE_DETECTION));
|
||||
scanTestJavaSources.put("on", preferenceStore.getBoolean(Constants.PREF_SCAN_JAVA_TEST_SOURCES));
|
||||
|
||||
javaValidation.put("reconcilers", preferenceStore.getBoolean(Constants.PREF_JAVA_RECONCILE));
|
||||
validation.put("java", javaValidation);
|
||||
javaCompletionSettings.put("inject-bean", preferenceStore.getBoolean(Constants.PREF_COMPLETION_JAVA_INJECT_BEAN));
|
||||
|
||||
javaSettings.put("beans-structure-tree", preferenceStore.getBoolean(Constants.PREF_BEANS_STRUCTURE_TREE));
|
||||
javaSettings.put("completions", javaCompletionSettings);
|
||||
javaSettings.put("reconcilers", preferenceStore.getBoolean(Constants.PREF_JAVA_RECONCILE));
|
||||
|
||||
bootJavaObj.put("jpql", preferenceStore.getBoolean(Constants.PREF_JPQL));
|
||||
bootJavaObj.put("live-information", liveInformation);
|
||||
@@ -209,7 +212,7 @@ public class DelegatingStreamConnectionProvider implements StreamConnectionProvi
|
||||
bootJavaObj.put("change-detection", bootChangeDetection);
|
||||
bootJavaObj.put("scan-java-test-sources", scanTestJavaSources);
|
||||
bootJavaObj.put("change-detection", bootChangeDetection);
|
||||
bootJavaObj.put("validation", validation);
|
||||
bootJavaObj.put("java", javaSettings);
|
||||
bootJavaObj.put("remote-apps", getAllRemoteApps());
|
||||
bootJavaObj.put("modulith-project-tracking", preferenceStore.getBoolean(Constants.PREF_MODULITH));
|
||||
|
||||
|
||||
@@ -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
|
||||
@@ -54,6 +54,12 @@ public class BootJavaPreferencesPage extends FieldEditorPreferencePage implement
|
||||
|
||||
// Experimental Modulith support
|
||||
addField(new BooleanFieldEditor(Constants.PREF_MODULITH, "Spring Boot Modulith automatic project tracking and metadata update", fieldEditorParent));
|
||||
|
||||
// Experimental Bean Injections completion in Java editor
|
||||
addField(new BooleanFieldEditor(Constants.PREF_COMPLETION_JAVA_INJECT_BEAN, "Inject Bean completion proposals in Java editor", fieldEditorParent));
|
||||
|
||||
// Experimental Beans tree
|
||||
addField(new BooleanFieldEditor(Constants.PREF_BEANS_STRUCTURE_TREE, "Beans structure tree in the outline view", fieldEditorParent));
|
||||
|
||||
Composite c = new Composite(fieldEditorParent, SWT.NONE);
|
||||
GridDataFactory.fillDefaults().grab(true, false).applyTo(c);
|
||||
|
||||
@@ -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
|
||||
@@ -69,6 +69,10 @@ public class PrefsInitializer extends AbstractPreferenceInitializer {
|
||||
preferenceStore.setDefault(Constants.PREF_PROPS_COMPLETIONS_ELIDE_PREFIX, false);
|
||||
|
||||
preferenceStore.setDefault(Constants.PREF_CRON_INLAY_HINTS, true);
|
||||
|
||||
preferenceStore.setDefault(Constants.PREF_COMPLETION_JAVA_INJECT_BEAN, true);
|
||||
|
||||
preferenceStore.setDefault(Constants.PREF_BEANS_STRUCTURE_TREE, false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -281,7 +281,7 @@
|
||||
"default": true,
|
||||
"description": "Syntax Hyghlighting for Languages embedded into Java source code"
|
||||
},
|
||||
"boot-java.validation.java.reconcilers": {
|
||||
"boot-java.java.reconcilers": {
|
||||
"type": "boolean",
|
||||
"default": true,
|
||||
"description": "Reconciling Java Sources"
|
||||
@@ -363,6 +363,16 @@
|
||||
"default": false,
|
||||
"description": "Enable/Disable detecting changes of running Spring Boot applications"
|
||||
},
|
||||
"boot-java.java.completions.inject-bean": {
|
||||
"type": "boolean",
|
||||
"default": true,
|
||||
"description": "Inject Bean completion proposals in Java editor"
|
||||
},
|
||||
"boot-java.java.beans-structure-tree": {
|
||||
"type": "boolean",
|
||||
"default": false,
|
||||
"description": "Beans structure tree in the outline view"
|
||||
},
|
||||
"boot-java.remote-apps": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
|
||||
Reference in New Issue
Block a user