Boot property for Jandex Index switch. Basic caching for JDTLS index

This commit is contained in:
BoykoAlex
2019-02-22 19:27:44 -05:00
parent 2b2413ee60
commit a3aabe534a
6 changed files with 67 additions and 14 deletions

View File

@@ -88,8 +88,8 @@ public class BootLanguagServerBootApp {
}
@ConditionalOnMissingClass("org.springframework.ide.vscode.languageserver.testharness.LanguageServerHarness")
@Bean BootLanguageServerParams serverParams(SimpleLanguageServer server, ValueProviderRegistry valueProviders) {
return BootLanguageServerParams.createDefault(server, valueProviders);
@Bean BootLanguageServerParams serverParams(SimpleLanguageServer server, ValueProviderRegistry valueProviders, BootLsConfigProperties configProperties) {
return BootLanguageServerParams.createDefault(server, valueProviders, configProperties.isEnableJandexIndex());
}
@ConditionalOnMissingClass("org.springframework.ide.vscode.languageserver.testharness.LanguageServerHarness")

View File

@@ -87,11 +87,11 @@ public class BootLanguageServerParams {
this.watchDogInterval = watchDogInterval;
}
public static BootLanguageServerParams createDefault(SimpleLanguageServer server, ValueProviderRegistry valueProviders) {
public static BootLanguageServerParams createDefault(SimpleLanguageServer server, ValueProviderRegistry valueProviders, boolean isJandexIndex) {
// Initialize project finders, project caches and project observers
JavaProjectsService jdtProjectCache = new JavaProjectsServiceWithFallback(
server,
new JdtLsProjectCache(server),
new JdtLsProjectCache(server, isJandexIndex),
() -> createFallbackProjectCache(server)
);

View File

@@ -0,0 +1,35 @@
/*******************************************************************************
* Copyright (c) 2019 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
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Pivotal, Inc. - initial API and implementation
*******************************************************************************/
package org.springframework.ide.vscode.boot.app;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
@Component
@ConfigurationProperties("languageserver.boot")
public class BootLsConfigProperties {
/**
* Enables/disables Jandex indexing of Java types. When disabled JDT LS will be
* used for type and package searches, type finding for FQ name etc.
*/
private boolean enableJandexIndex = false;
public boolean isEnableJandexIndex() {
return enableJandexIndex;
}
public void setEnableJandexIndex(boolean enableJandexIndex) {
this.enableJandexIndex = enableJandexIndex;
}
}

View File

@@ -43,15 +43,16 @@ import reactor.core.publisher.Mono;
public class JdtLsProjectCache implements InitializableJavaProjectsService {
private static final boolean IS_JANDEX_INDEX = Boolean.getBoolean("sts.lsp.jandex.index");
private final boolean IS_JANDEX_INDEX;
private SimpleLanguageServer server;
private Map<String, IJavaProject> table = new HashMap<String, IJavaProject>();
private Logger log = LoggerFactory.getLogger(JdtLsProjectCache.class);
private List<Listener> listeners = new ArrayList<>();
public JdtLsProjectCache(SimpleLanguageServer server) {
public JdtLsProjectCache(SimpleLanguageServer server, boolean isJandexIndex) {
this.server = server;
this.IS_JANDEX_INDEX = isJandexIndex;
}
private FileObserver getFileObserver() {