CRON inlay-hints on/off setting
This commit is contained in:
@@ -49,5 +49,7 @@ public class Constants {
|
||||
public static final String PREF_JPQL = "boot-java.jpql";
|
||||
|
||||
public static final String PREF_PROPS_COMPLETIONS_ELIDE_PREFIX = "boot-java.properties.completions.elide-prefix";
|
||||
|
||||
public static final String PREF_CRON_INLAY_HINTS = "boot-java.cron.inlay-hints";
|
||||
|
||||
}
|
||||
|
||||
@@ -229,6 +229,11 @@ public class DelegatingStreamConnectionProvider implements StreamConnectionProvi
|
||||
)
|
||||
));
|
||||
|
||||
bootJavaObj.put("cron", Map.of(
|
||||
"inlay-hints", preferenceStore.getBoolean(Constants.PREF_CRON_INLAY_HINTS)
|
||||
)
|
||||
);
|
||||
|
||||
settings.put("boot-java", bootJavaObj);
|
||||
|
||||
settings.put("http", createHttpProxySettings());
|
||||
|
||||
@@ -46,6 +46,9 @@ public class BootJavaPreferencesPage extends FieldEditorPreferencePage implement
|
||||
// JPQL Support switch
|
||||
addField(new BooleanFieldEditor(Constants.PREF_JPQL, "JPA Query language support", fieldEditorParent));
|
||||
|
||||
// CRON expressions inlay-hints on/off
|
||||
addField(new BooleanFieldEditor(Constants.PREF_CRON_INLAY_HINTS, "Show CRON expressions inlay-hints", fieldEditorParent));
|
||||
|
||||
// Properties Completions - Elide common prefix
|
||||
addField(new BooleanFieldEditor(Constants.PREF_PROPS_COMPLETIONS_ELIDE_PREFIX, "Elide common prefix in property key auto completions", fieldEditorParent));
|
||||
|
||||
|
||||
@@ -68,6 +68,7 @@ public class PrefsInitializer extends AbstractPreferenceInitializer {
|
||||
|
||||
preferenceStore.setDefault(Constants.PREF_PROPS_COMPLETIONS_ELIDE_PREFIX, false);
|
||||
|
||||
preferenceStore.setDefault(Constants.PREF_CRON_INLAY_HINTS, true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -84,6 +84,10 @@ public class BootJavaConfig implements InitializingBean {
|
||||
return enabled != null && enabled.booleanValue();
|
||||
}
|
||||
|
||||
public boolean isCronInlayHintsEnabled() {
|
||||
return Boolean.TRUE.equals(settings.getBoolean("boot-java", "cron", "inlay-hints"));
|
||||
}
|
||||
|
||||
public boolean isShowingAllJvmProcesses() {
|
||||
Boolean isAll = settings.getBoolean("boot-java", "live-information", "all-local-java-processes");
|
||||
return isAll != null && isAll.booleanValue();
|
||||
|
||||
@@ -163,7 +163,7 @@ public class BootLanguageServerInitializer implements InitializingBean {
|
||||
|
||||
components.getSemanticTokensHandler().ifPresent(documents::onSemanticTokens);
|
||||
|
||||
startListeningToPerformReconcile();
|
||||
startListening();
|
||||
|
||||
server.onCommand("sts/show/document", p -> {
|
||||
ShowDocumentParams showDocParams = new Gson().fromJson((JsonElement)p.getArguments().get(0), ShowDocumentParams.class);
|
||||
@@ -184,7 +184,7 @@ public class BootLanguageServerInitializer implements InitializingBean {
|
||||
|
||||
}
|
||||
|
||||
private void startListeningToPerformReconcile() {
|
||||
private void startListening() {
|
||||
components.getReconcileEngine().ifPresent(reconcileEngine -> {
|
||||
server.getTextDocumentService().onDidChangeContent(params -> {
|
||||
TextDocument doc = params.getDocument();
|
||||
@@ -193,7 +193,10 @@ public class BootLanguageServerInitializer implements InitializingBean {
|
||||
|
||||
// ServerUtils.listenToClassFileChanges(server.getWorkspaceService().getFileObserver(), projectFinder, project -> validateAll(components, server, project));
|
||||
});
|
||||
config.addListener(evt -> reconcile());
|
||||
config.addListener(evt -> {
|
||||
server.getClient().refreshInlayHints();
|
||||
reconcile();
|
||||
});
|
||||
params.projectObserver.addListener(reconcileDocumentsForProjectChange(server, components, params.projectFinder));
|
||||
|
||||
// // TODO: index update even happens on every file save. Very expensive to blindly reconcile all projects.
|
||||
|
||||
@@ -140,8 +140,8 @@ public class JdtConfig {
|
||||
return new JdtDataQueriesInlayHintsProvider(semanticTokensProvider);
|
||||
}
|
||||
|
||||
@Bean CronExpressionsInlayHintsProvider cronExpressionsInlayHintsProvider() {
|
||||
return new CronExpressionsInlayHintsProvider();
|
||||
@Bean CronExpressionsInlayHintsProvider cronExpressionsInlayHintsProvider(BootJavaConfig config) {
|
||||
return new CronExpressionsInlayHintsProvider(config);
|
||||
}
|
||||
|
||||
@Bean JdtQueryDocHighlightsProvider jdtDocHighlightsProvider(JdtDataQuerySemanticTokensProvider semanticTokensProvider) {
|
||||
|
||||
@@ -26,6 +26,7 @@ import org.eclipse.lsp4j.InlayHintKind;
|
||||
import org.eclipse.lsp4j.jsonrpc.messages.Either;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.ide.vscode.boot.app.BootJavaConfig;
|
||||
import org.springframework.ide.vscode.boot.java.Annotations;
|
||||
import org.springframework.ide.vscode.boot.java.JdtInlayHintsProvider;
|
||||
import org.springframework.ide.vscode.commons.java.IJavaProject;
|
||||
@@ -46,12 +47,18 @@ public class CronExpressionsInlayHintsProvider implements JdtInlayHintsProvider
|
||||
|
||||
private static final String SCHEDULED = "Scheduled";
|
||||
|
||||
private final BootJavaConfig config;
|
||||
|
||||
public record EmbeddedCronExpression(Expression expression, String text, int offset) {
|
||||
};
|
||||
|
||||
public CronExpressionsInlayHintsProvider(BootJavaConfig config) {
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isApplicable(IJavaProject project) {
|
||||
return true;
|
||||
return config.isCronInlayHintsEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -353,6 +353,11 @@
|
||||
"default": true,
|
||||
"description": "JPA Query language support"
|
||||
},
|
||||
"boot-java.cron.inlay-hints": {
|
||||
"type": "boolean",
|
||||
"default": true,
|
||||
"description": "Show CRON expressions inlay-hints"
|
||||
},
|
||||
"boot-java.change-detection.on": {
|
||||
"type": "boolean",
|
||||
"default": false,
|
||||
|
||||
Reference in New Issue
Block a user