Make ProjectReconcileScheduler beans conditional on property
This commit is contained in:
@@ -220,12 +220,14 @@ public class SimpleTextDocumentService implements TextDocumentService, DocumentE
|
||||
TextDocument lastSnapshot = documentSnapshots.remove(url);
|
||||
|
||||
log.info("Closed: "+url);
|
||||
if (props.isReconcileOnlyOpenedDocs()) {
|
||||
//Clear diagnostics when a file is closed. This makes the errors disapear when the language is changed for
|
||||
// a document (this resulst in a dicClose even as being sent to the language server if that changes make the
|
||||
// document go 'out of scope'.
|
||||
publishDiagnostics(params.getTextDocument(), ImmutableList.of());
|
||||
}
|
||||
//Clear diagnostics when a file is closed. This makes the errors disapear when the language is changed for
|
||||
// a document (this resulst in a dicClose even as being sent to the language server if that changes make the
|
||||
// document go 'out of scope'.
|
||||
|
||||
// TODO: Unclear what to do. If file is closed then problem markers should stay
|
||||
// around. However, exceptional case is if the file is opened in a different
|
||||
// editor (Eclipse) or with different grammar (vscode)
|
||||
// publishDiagnostics(params.getTextDocument(), ImmutableList.of());
|
||||
|
||||
documentCloseListeners.fire(lastSnapshot);
|
||||
} else {
|
||||
|
||||
@@ -32,6 +32,7 @@ import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.SpringBootConfiguration;
|
||||
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingClass;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.boot.autoconfigure.context.ConfigurationPropertiesAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
@@ -100,6 +101,7 @@ import org.springframework.ide.vscode.commons.yaml.structure.YamlDocument;
|
||||
import org.springframework.ide.vscode.commons.yaml.structure.YamlStructureProvider;
|
||||
import org.springframework.ide.vscode.languageserver.starter.LanguageServerAutoConf;
|
||||
import org.springframework.ide.vscode.languageserver.starter.LanguageServerRunnerAutoConf;
|
||||
import org.yaml.snakeyaml.LoaderOptions;
|
||||
import org.yaml.snakeyaml.Yaml;
|
||||
import org.yaml.snakeyaml.constructor.SafeConstructor;
|
||||
|
||||
@@ -279,7 +281,7 @@ public class BootLanguageServerBootApp {
|
||||
|
||||
@Bean Yaml yaml() {
|
||||
//TODO: Yaml is not re-entrant. So its a bit fishy to create a 're-usable' bean for this!
|
||||
return new Yaml(new SafeConstructor());
|
||||
return new Yaml(new SafeConstructor(new LoaderOptions()));
|
||||
}
|
||||
|
||||
@Bean YamlASTProvider yamlAstProvider() {
|
||||
@@ -353,6 +355,7 @@ public class BootLanguageServerBootApp {
|
||||
}
|
||||
|
||||
@ConditionalOnMissingClass("org.springframework.ide.vscode.languageserver.testharness.LanguageServerHarness")
|
||||
@ConditionalOnProperty(prefix = "languageserver", name = "reconcile-only-opened-docs", havingValue = "false", matchIfMissing = true)
|
||||
@Bean
|
||||
BootJavaProjectReconcilerScheduler bootJavaProjectReconcilerScheduler(SimpleLanguageServer server,
|
||||
BootJavaReconcileEngine bootJavaReconciler, ProjectObserver projectObserver, BootJavaConfig config,
|
||||
@@ -363,6 +366,7 @@ public class BootLanguageServerBootApp {
|
||||
}
|
||||
|
||||
@ConditionalOnMissingClass("org.springframework.ide.vscode.languageserver.testharness.LanguageServerHarness")
|
||||
@ConditionalOnProperty(prefix = "languageserver", name = "reconcile-only-opened-docs", havingValue = "false", matchIfMissing = true)
|
||||
@Bean
|
||||
ProjectReconcileScheduler bootVersionValidationScheduler(SimpleLanguageServer server, JavaProjectFinder projectFinder, BootJavaConfig config, ProjectObserver projectObserver) {
|
||||
return new ProjectReconcileScheduler(new BootVersionValidationEngine(server, config, projectObserver, projectFinder), projectFinder) {
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
*******************************************************************************/
|
||||
package org.springframework.ide.vscode.boot.app;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
@@ -36,7 +37,6 @@ import org.springframework.ide.vscode.commons.languageserver.completion.IComplet
|
||||
import org.springframework.ide.vscode.commons.languageserver.completion.VscodeCompletionEngineAdapter;
|
||||
import org.springframework.ide.vscode.commons.languageserver.composable.CompositeLanguageServerComponents;
|
||||
import org.springframework.ide.vscode.commons.languageserver.composable.LanguageServerComponents;
|
||||
import org.springframework.ide.vscode.commons.languageserver.config.LanguageServerProperties;
|
||||
import org.springframework.ide.vscode.commons.languageserver.java.JavaProjectFinder;
|
||||
import org.springframework.ide.vscode.commons.languageserver.java.ProjectObserver;
|
||||
import org.springframework.ide.vscode.commons.languageserver.util.HoverHandler;
|
||||
@@ -67,7 +67,6 @@ public class BootLanguageServerInitializer implements InitializingBean {
|
||||
@Autowired SpringSymbolIndex springIndexer;
|
||||
@Autowired(required = false) List<ICompletionEngine> completionEngines;
|
||||
@Autowired private JavaProjectFinder projectFinder;
|
||||
@Autowired private LanguageServerProperties configProps;
|
||||
@Autowired(required = false) private RewriteRecipeRepository recipesRepo;
|
||||
@Autowired(required = false) private ProjectReconcileScheduler[] reconcileSchedulers;
|
||||
|
||||
@@ -125,7 +124,7 @@ public class BootLanguageServerInitializer implements InitializingBean {
|
||||
builder.add(c);
|
||||
}
|
||||
|
||||
if (reconcileSchedulers != null && !configProps.isReconcileOnlyOpenedDocs()) {
|
||||
if (reconcileSchedulers != null) {
|
||||
// Kick off project reconcile schedulers
|
||||
for (ProjectReconcileScheduler scheduler : reconcileSchedulers) {
|
||||
scheduler.start();
|
||||
@@ -135,7 +134,7 @@ public class BootLanguageServerInitializer implements InitializingBean {
|
||||
|
||||
components = builder.build(server);
|
||||
|
||||
SimpleTextDocumentService documents = server.getTextDocumentService();
|
||||
final SimpleTextDocumentService documents = server.getTextDocumentService();
|
||||
|
||||
if (!completionEngines.isEmpty()) {
|
||||
CompositeCompletionEngine compositeCompletionEngine = new CompositeCompletionEngine();
|
||||
@@ -165,6 +164,12 @@ public class BootLanguageServerInitializer implements InitializingBean {
|
||||
// Reconcile would occur as listeners will be receiving events
|
||||
startListeningToPerformReconcile();
|
||||
}
|
||||
|
||||
server.onShutdown(() -> {
|
||||
for (TextDocument d : documents.getAll()) {
|
||||
documents.publishDiagnostics(d.getId(), Collections.emptyList());
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user