Skip to content

Commit 67eacae

Browse files
committed
CRON inlay-hints on/off setting
1 parent c3a45e7 commit 67eacae

File tree

9 files changed

+36
-6
lines changed

9 files changed

+36
-6
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,7 @@ public class Constants {
4949
public static final String PREF_JPQL = "boot-java.jpql";
5050

5151
public static final String PREF_PROPS_COMPLETIONS_ELIDE_PREFIX = "boot-java.properties.completions.elide-prefix";
52+
53+
public static final String PREF_CRON_INLAY_HINTS = "boot-java.cron.inlay-hints";
5254

5355
}

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,11 @@ private void sendConfiguration() {
229229
)
230230
));
231231

232+
bootJavaObj.put("cron", Map.of(
233+
"inlay-hints", preferenceStore.getBoolean(Constants.PREF_CRON_INLAY_HINTS)
234+
)
235+
);
236+
232237
settings.put("boot-java", bootJavaObj);
233238

234239
settings.put("http", createHttpProxySettings());

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ protected void createFieldEditors() {
4646
// JPQL Support switch
4747
addField(new BooleanFieldEditor(Constants.PREF_JPQL, "JPA Query language support", fieldEditorParent));
4848

49+
// CRON expressions inlay-hints on/off
50+
addField(new BooleanFieldEditor(Constants.PREF_CRON_INLAY_HINTS, "Show CRON expressions inlay-hints", fieldEditorParent));
51+
4952
// Properties Completions - Elide common prefix
5053
addField(new BooleanFieldEditor(Constants.PREF_PROPS_COMPLETIONS_ELIDE_PREFIX, "Elide common prefix in property key auto completions", fieldEditorParent));
5154

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ public void initializeDefaultPreferences() {
6868

6969
preferenceStore.setDefault(Constants.PREF_PROPS_COMPLETIONS_ELIDE_PREFIX, false);
7070

71+
preferenceStore.setDefault(Constants.PREF_CRON_INLAY_HINTS, true);
7172
}
7273

7374
}

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,10 @@ public boolean isModulithAutoProjectTrackingEnabled() {
8484
return enabled != null && enabled.booleanValue();
8585
}
8686

87+
public boolean isCronInlayHintsEnabled() {
88+
return Boolean.TRUE.equals(settings.getBoolean("boot-java", "cron", "inlay-hints"));
89+
}
90+
8791
public boolean isShowingAllJvmProcesses() {
8892
Boolean isAll = settings.getBoolean("boot-java", "live-information", "all-local-java-processes");
8993
return isAll != null && isAll.booleanValue();

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ public void afterPropertiesSet() throws Exception {
163163

164164
components.getSemanticTokensHandler().ifPresent(documents::onSemanticTokens);
165165

166-
startListeningToPerformReconcile();
166+
startListening();
167167

168168
server.onCommand("sts/show/document", p -> {
169169
ShowDocumentParams showDocParams = new Gson().fromJson((JsonElement)p.getArguments().get(0), ShowDocumentParams.class);
@@ -184,7 +184,7 @@ public void afterPropertiesSet() throws Exception {
184184

185185
}
186186

187-
private void startListeningToPerformReconcile() {
187+
private void startListening() {
188188
components.getReconcileEngine().ifPresent(reconcileEngine -> {
189189
server.getTextDocumentService().onDidChangeContent(params -> {
190190
TextDocument doc = params.getDocument();
@@ -193,7 +193,10 @@ private void startListeningToPerformReconcile() {
193193

194194
// ServerUtils.listenToClassFileChanges(server.getWorkspaceService().getFileObserver(), projectFinder, project -> validateAll(components, server, project));
195195
});
196-
config.addListener(evt -> reconcile());
196+
config.addListener(evt -> {
197+
server.getClient().refreshInlayHints();
198+
reconcile();
199+
});
197200
params.projectObserver.addListener(reconcileDocumentsForProjectChange(server, components, params.projectFinder));
198201

199202
// // TODO: index update even happens on every file save. Very expensive to blindly reconcile all projects.

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,8 @@ public class JdtConfig {
140140
return new JdtDataQueriesInlayHintsProvider(semanticTokensProvider);
141141
}
142142

143-
@Bean CronExpressionsInlayHintsProvider cronExpressionsInlayHintsProvider() {
144-
return new CronExpressionsInlayHintsProvider();
143+
@Bean CronExpressionsInlayHintsProvider cronExpressionsInlayHintsProvider(BootJavaConfig config) {
144+
return new CronExpressionsInlayHintsProvider(config);
145145
}
146146

147147
@Bean JdtQueryDocHighlightsProvider jdtDocHighlightsProvider(JdtDataQuerySemanticTokensProvider semanticTokensProvider) {

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import org.eclipse.lsp4j.jsonrpc.messages.Either;
2727
import org.slf4j.Logger;
2828
import org.slf4j.LoggerFactory;
29+
import org.springframework.ide.vscode.boot.app.BootJavaConfig;
2930
import org.springframework.ide.vscode.boot.java.Annotations;
3031
import org.springframework.ide.vscode.boot.java.JdtInlayHintsProvider;
3132
import org.springframework.ide.vscode.commons.java.IJavaProject;
@@ -46,12 +47,18 @@ public class CronExpressionsInlayHintsProvider implements JdtInlayHintsProvider
4647

4748
private static final String SCHEDULED = "Scheduled";
4849

50+
private final BootJavaConfig config;
51+
4952
public record EmbeddedCronExpression(Expression expression, String text, int offset) {
5053
};
5154

55+
public CronExpressionsInlayHintsProvider(BootJavaConfig config) {
56+
this.config = config;
57+
}
58+
5259
@Override
5360
public boolean isApplicable(IJavaProject project) {
54-
return true;
61+
return config.isCronInlayHintsEnabled();
5562
}
5663

5764
@Override

vscode-extensions/vscode-spring-boot/package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,11 @@
353353
"default": true,
354354
"description": "JPA Query language support"
355355
},
356+
"boot-java.cron.inlay-hints": {
357+
"type": "boolean",
358+
"default": true,
359+
"description": "Show CRON expressions inlay-hints"
360+
},
356361
"boot-java.change-detection.on": {
357362
"type": "boolean",
358363
"default": false,

0 commit comments

Comments
 (0)