fix flacky webflux tests caused by two symbol indexers being created and used in different places
This commit is contained in:
@@ -20,6 +20,9 @@ import org.eclipse.lsp4j.TextDocumentIdentifier;
|
||||
import org.springframework.ide.vscode.boot.java.handlers.RunningAppProvider;
|
||||
import org.springframework.ide.vscode.boot.java.links.SourceLinks;
|
||||
import org.springframework.ide.vscode.boot.java.utils.SpringLiveHoverWatchdog;
|
||||
import org.springframework.ide.vscode.boot.java.utils.SymbolCache;
|
||||
import org.springframework.ide.vscode.boot.java.utils.SymbolCacheOnDisc;
|
||||
import org.springframework.ide.vscode.boot.java.utils.SymbolCacheVoid;
|
||||
import org.springframework.ide.vscode.boot.jdt.ls.JavaProjectsService;
|
||||
import org.springframework.ide.vscode.boot.jdt.ls.JavaProjectsServiceWithFallback;
|
||||
import org.springframework.ide.vscode.boot.jdt.ls.JdtLsProjectCache;
|
||||
@@ -68,6 +71,7 @@ public class BootLanguageServerParams {
|
||||
//Boot Java
|
||||
public final RunningAppProvider runningAppProvider;
|
||||
public final Duration watchDogInterval;
|
||||
public final SymbolCache symbolCache;
|
||||
|
||||
public BootLanguageServerParams(
|
||||
JavaProjectFinder projectFinder,
|
||||
@@ -75,8 +79,8 @@ public class BootLanguageServerParams {
|
||||
SpringPropertyIndexProvider indexProvider,
|
||||
TypeUtilProvider typeUtilProvider,
|
||||
RunningAppProvider runningAppProvider,
|
||||
Duration watchDogInterval
|
||||
) {
|
||||
Duration watchDogInterval,
|
||||
SymbolCache symbolCache) {
|
||||
super();
|
||||
Assert.isNotNull(projectObserver); // null is bad should be ProjectObserver.NULL
|
||||
this.projectFinder = projectFinder;
|
||||
@@ -85,6 +89,7 @@ public class BootLanguageServerParams {
|
||||
this.typeUtilProvider = typeUtilProvider;
|
||||
this.runningAppProvider = runningAppProvider;
|
||||
this.watchDogInterval = watchDogInterval;
|
||||
this.symbolCache = symbolCache;
|
||||
}
|
||||
|
||||
public static BootLanguageServerParams createDefault(SimpleLanguageServer server, ValueProviderRegistry valueProviders, boolean isJandexIndex) {
|
||||
@@ -99,13 +104,22 @@ public class BootLanguageServerParams {
|
||||
DefaultSpringPropertyIndexProvider indexProvider = new DefaultSpringPropertyIndexProvider(jdtProjectCache, jdtProjectCache, fileObserver, valueProviders);
|
||||
indexProvider.setProgressService(server.getProgressService());
|
||||
|
||||
SymbolCache symbolCache = null;
|
||||
if ("true".equals(System.getProperty("boot.ls.symbols.caching.enabled", "true"))) {
|
||||
symbolCache = new SymbolCacheOnDisc();
|
||||
}
|
||||
else {
|
||||
symbolCache = new SymbolCacheVoid();
|
||||
}
|
||||
|
||||
return new BootLanguageServerParams(
|
||||
jdtProjectCache.filter(project -> SpringProjectUtil.isBootProject(project) || SpringProjectUtil.isSpringProject(project)),
|
||||
jdtProjectCache,
|
||||
indexProvider,
|
||||
(SourceLinks sourceLinks, IDocument doc) -> new TypeUtil(sourceLinks, jdtProjectCache.find(new TextDocumentIdentifier(doc.getUri()))),
|
||||
RunningAppProvider.createDefault(server),
|
||||
SpringLiveHoverWatchdog.DEFAULT_INTERVAL
|
||||
SpringLiveHoverWatchdog.DEFAULT_INTERVAL,
|
||||
symbolCache
|
||||
);
|
||||
}
|
||||
|
||||
@@ -173,7 +187,8 @@ public class BootLanguageServerParams {
|
||||
indexProvider,
|
||||
(SourceLinks sourceLinks, IDocument doc) -> new TypeUtil(sourceLinks, javaProjectFinder.find(new TextDocumentIdentifier(doc.getUri()))),
|
||||
RunningAppProvider.NULL,
|
||||
SpringLiveHoverWatchdog.DEFAULT_INTERVAL
|
||||
SpringLiveHoverWatchdog.DEFAULT_INTERVAL,
|
||||
new SymbolCacheVoid()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -141,20 +141,9 @@ public class BootJavaLanguageServerComponents implements LanguageServerComponent
|
||||
ReferencesHandler referencesHandler = createReferenceHandler(server, projectFinder);
|
||||
documents.onReferences(referencesHandler);
|
||||
|
||||
if ("true".equals(System.getProperty("boot.ls.symbols.caching.enabled", "true"))) {
|
||||
try {
|
||||
this.symbolCache = new SymbolCacheOnDisc();
|
||||
}
|
||||
catch (Exception e) {
|
||||
log.warn("symbol cache directory could not be created, no cache enabled");
|
||||
this.symbolCache = new SymbolCacheVoid();
|
||||
}
|
||||
}
|
||||
else {
|
||||
this.symbolCache = new SymbolCacheVoid();
|
||||
}
|
||||
this.symbolCache = this.serverParams.symbolCache;
|
||||
this.indexer = createAnnotationIndexer(server, serverParams, symbolCache);
|
||||
|
||||
indexer = createAnnotationIndexer(server, serverParams, symbolCache);
|
||||
documents.onDidSave(params -> {
|
||||
TextDocument document = params.getDocument();
|
||||
// Spring Boot LS get events from boot properties files as well, so filter them out
|
||||
|
||||
@@ -49,11 +49,11 @@ public class SymbolCacheOnDisc implements SymbolCache {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(SymbolCacheOnDisc.class);
|
||||
|
||||
public SymbolCacheOnDisc() throws Exception {
|
||||
public SymbolCacheOnDisc() {
|
||||
this(new File(System.getProperty("user.home") + File.separatorChar + ".sts4" + File.separatorChar + ".symbolCache"));
|
||||
}
|
||||
|
||||
public SymbolCacheOnDisc(File cacheDirectory) throws Exception {
|
||||
public SymbolCacheOnDisc(File cacheDirectory) {
|
||||
this.cacheDirectory = cacheDirectory;
|
||||
this.stores = new ConcurrentHashMap<>();
|
||||
|
||||
@@ -62,7 +62,7 @@ public class SymbolCacheOnDisc implements SymbolCache {
|
||||
}
|
||||
|
||||
if (!this.cacheDirectory.exists()) {
|
||||
throw new Exception("symbol cache directory could not be created:");
|
||||
log.warn("symbol cache directory does not exist and cannot be created: " + this.cacheDirectory.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -254,5 +254,4 @@ public class SymbolCacheOnDisc implements SymbolCache {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2018 Pivotal, Inc.
|
||||
* Copyright (c) 2018, 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
|
||||
@@ -19,6 +19,7 @@ import org.springframework.ide.vscode.boot.app.BootLanguageServerParams;
|
||||
import org.springframework.ide.vscode.boot.editor.harness.PropertyIndexHarness;
|
||||
import org.springframework.ide.vscode.boot.java.links.SourceLinkFactory;
|
||||
import org.springframework.ide.vscode.boot.java.links.SourceLinks;
|
||||
import org.springframework.ide.vscode.boot.java.utils.SymbolCacheVoid;
|
||||
import org.springframework.ide.vscode.boot.metadata.ValueProviderRegistry;
|
||||
import org.springframework.ide.vscode.commons.languageserver.java.JavaProjectFinder;
|
||||
import org.springframework.ide.vscode.commons.languageserver.util.SimpleLanguageServer;
|
||||
@@ -54,7 +55,8 @@ public class HoverTestConf {
|
||||
indexHarness.getIndexProvider(),
|
||||
testDefaults.typeUtilProvider,
|
||||
mockAppsHarness().provider,
|
||||
watchDogInterval()
|
||||
watchDogInterval(),
|
||||
new SymbolCacheVoid()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ import org.springframework.ide.vscode.boot.java.links.SourceLinkFactory;
|
||||
import org.springframework.ide.vscode.boot.java.links.SourceLinks;
|
||||
import org.springframework.ide.vscode.boot.java.utils.CompilationUnitCache;
|
||||
import org.springframework.ide.vscode.boot.java.utils.SpringLiveHoverWatchdog;
|
||||
import org.springframework.ide.vscode.boot.java.utils.SymbolCacheVoid;
|
||||
import org.springframework.ide.vscode.boot.metadata.ValueProviderRegistry;
|
||||
import org.springframework.ide.vscode.boot.metadata.types.TypeUtil;
|
||||
import org.springframework.ide.vscode.boot.metadata.types.TypeUtilProvider;
|
||||
@@ -67,7 +68,8 @@ public class PropertyEditorTestConf {
|
||||
indexHarness.getIndexProvider(),
|
||||
typeUtilProvider,
|
||||
mockAppsHarness().provider,
|
||||
SpringLiveHoverWatchdog.DEFAULT_INTERVAL
|
||||
SpringLiveHoverWatchdog.DEFAULT_INTERVAL,
|
||||
new SymbolCacheVoid()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -48,8 +48,8 @@ public class SymbolProviderTestConf {
|
||||
return BootLanguageServerParams.createTestDefault(server, valueProviders);
|
||||
}
|
||||
|
||||
@Bean SpringSymbolIndex springSymbolIndex(BootLanguageServerInitializer serverInit, SimpleLanguageServer server, BootLanguageServerParams params) {
|
||||
return serverInit.getComponents().get(BootJavaLanguageServerComponents.class).createAnnotationIndexer(server, params, new SymbolCacheVoid());
|
||||
@Bean SpringSymbolIndex springSymbolIndex(BootLanguageServerInitializer serverInit) {
|
||||
return serverInit.getComponents().get(BootJavaLanguageServerComponents.class).getSpringSymbolIndex();
|
||||
}
|
||||
|
||||
@Bean DefaultSpringPropertyIndexProvider indexProvider(BootLanguageServerParams serverParams) {
|
||||
|
||||
@@ -46,7 +46,6 @@ import org.springframework.test.context.junit4.SpringRunner;
|
||||
@RunWith(SpringRunner.class)
|
||||
@BootLanguageServerTest
|
||||
@Import(SymbolProviderTestConf.class)
|
||||
@Ignore // temporarily ignore this test
|
||||
public class WebFluxCodeLensProviderTest {
|
||||
|
||||
@Autowired private BootLanguageServerHarness harness;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2017, 2018 Pivotal, Inc.
|
||||
* Copyright (c) 2017, 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
|
||||
@@ -38,6 +38,7 @@ import org.springframework.ide.vscode.boot.java.handlers.RunningAppProvider;
|
||||
import org.springframework.ide.vscode.boot.java.links.SourceLinkFactory;
|
||||
import org.springframework.ide.vscode.boot.java.links.SourceLinks;
|
||||
import org.springframework.ide.vscode.boot.java.utils.CompilationUnitCache;
|
||||
import org.springframework.ide.vscode.boot.java.utils.SymbolCacheVoid;
|
||||
import org.springframework.ide.vscode.boot.metadata.ValueProviderRegistry;
|
||||
import org.springframework.ide.vscode.commons.languageserver.java.JavaProjectFinder;
|
||||
import org.springframework.ide.vscode.commons.languageserver.util.SimpleLanguageServer;
|
||||
@@ -97,7 +98,8 @@ public class CompilationUnitCacheTest {
|
||||
indexHarness.getIndexProvider(),
|
||||
testDefaults.typeUtilProvider,
|
||||
RunningAppProvider.NULL,
|
||||
null
|
||||
null,
|
||||
new SymbolCacheVoid()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -40,6 +40,7 @@ import org.springframework.ide.vscode.boot.java.handlers.RunningAppProvider;
|
||||
import org.springframework.ide.vscode.boot.java.links.SourceLinkFactory;
|
||||
import org.springframework.ide.vscode.boot.java.links.SourceLinks;
|
||||
import org.springframework.ide.vscode.boot.java.utils.CompilationUnitCache;
|
||||
import org.springframework.ide.vscode.boot.java.utils.SymbolCacheVoid;
|
||||
import org.springframework.ide.vscode.boot.java.value.ValueCompletionProcessor;
|
||||
import org.springframework.ide.vscode.boot.metadata.AdHocSpringPropertyIndexProvider;
|
||||
import org.springframework.ide.vscode.boot.metadata.SpringPropertyIndexProvider;
|
||||
@@ -117,7 +118,8 @@ public class ValueCompletionTest {
|
||||
indexHarness.getIndexProvider(),
|
||||
testDefaults.typeUtilProvider,
|
||||
RunningAppProvider.NULL,
|
||||
null
|
||||
null,
|
||||
new SymbolCacheVoid()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user