Outline with JDT LS LightWeight mode
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2017, 2020 Pivotal, Inc.
|
||||
* Copyright (c) 2017, 2021 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
|
||||
@@ -546,7 +546,8 @@ public class SpringSymbolIndex implements InitializingBean {
|
||||
|
||||
public List<? extends SymbolInformation> getSymbols(String docURI) {
|
||||
try {
|
||||
CompletableFuture<Void> projectInitialized = futureProjectFinder.findFuture(URI.create(docURI)).thenCompose(project -> projectInitializedFuture(project));
|
||||
URI uri = URI.create(docURI);
|
||||
CompletableFuture<Void> projectInitialized = futureProjectFinder.findFuture(uri).thenCompose(project -> projectInitializedFuture(project));
|
||||
projectInitialized.get(60, TimeUnit.SECONDS);
|
||||
List<EnhancedSymbolInformation> docSymbols = this.symbolsByDoc.get(docURI);
|
||||
if (docSymbols != null) {
|
||||
|
||||
@@ -37,14 +37,11 @@ import org.springframework.ide.vscode.commons.javadoc.JdtLsJavadocProvider;
|
||||
import org.springframework.ide.vscode.commons.languageserver.java.ls.ClasspathListener;
|
||||
import org.springframework.ide.vscode.commons.languageserver.util.SimpleLanguageServer;
|
||||
import org.springframework.ide.vscode.commons.protocol.java.Classpath.CPE;
|
||||
import org.springframework.ide.vscode.commons.util.ExceptionUtil;
|
||||
import org.springframework.ide.vscode.commons.util.FileObserver;
|
||||
import org.springframework.ide.vscode.commons.util.UriUtil;
|
||||
|
||||
import reactor.core.Disposable;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
import reactor.util.context.Context;
|
||||
|
||||
public class JdtLsProjectCache implements InitializableJavaProjectsService {
|
||||
|
||||
@@ -57,6 +54,8 @@ public class JdtLsProjectCache implements InitializableJavaProjectsService {
|
||||
private Map<String, IJavaProject> table = new HashMap<String, IJavaProject>();
|
||||
private Logger log = LoggerFactory.getLogger(JdtLsProjectCache.class);
|
||||
private List<Listener> listeners = new ArrayList<>();
|
||||
|
||||
private boolean projectWatchingSupported = true;
|
||||
|
||||
public JdtLsProjectCache(SimpleLanguageServer server, boolean isJandexIndex) {
|
||||
this.server = server;
|
||||
@@ -70,6 +69,7 @@ public class JdtLsProjectCache implements InitializableJavaProjectsService {
|
||||
})
|
||||
.doOnError(error -> {
|
||||
log.error("JDT-based JavaProject service not available!", error);
|
||||
switchOffProjectObserver();
|
||||
})
|
||||
.toFuture();
|
||||
}
|
||||
@@ -78,14 +78,6 @@ public class JdtLsProjectCache implements InitializableJavaProjectsService {
|
||||
return server.getWorkspaceService().getFileObserver();
|
||||
}
|
||||
|
||||
private boolean isOldJdt(Throwable e) {
|
||||
return ExceptionUtil.getMessage(e).contains("'sts.java.addClasspathListener' not supported");
|
||||
}
|
||||
|
||||
private boolean isNoJdtError(Throwable e) {
|
||||
return ExceptionUtil.getMessage(e).contains("command 'java.execute.workspaceCommand' not found");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addListener(Listener listener) {
|
||||
synchronized (listeners) {
|
||||
@@ -139,6 +131,15 @@ public class JdtLsProjectCache implements InitializableJavaProjectsService {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void notifyProjectObserverSupported() {
|
||||
log.info("Project Observer is " + (projectWatchingSupported ? "" : "not ") + "supported");
|
||||
synchronized (listeners) {
|
||||
for (Listener listener : listeners) {
|
||||
listener.supported();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void logEvent(String type, IJavaProject project) {
|
||||
try {
|
||||
@@ -274,12 +275,24 @@ public class JdtLsProjectCache implements InitializableJavaProjectsService {
|
||||
.doOnSubscribe(x -> log.info("addClasspathListener ..."))
|
||||
.doOnSuccess(x -> log.info("addClasspathListener DONE"))
|
||||
.doOnError(t -> {
|
||||
log.error("Unexpected error registering classpath listener with JDT. Fallback classpath provider will be used instead.", t);
|
||||
log.error("Unexpected error registering classpath listener with JDT.", t);
|
||||
switchOffProjectObserver();
|
||||
}));
|
||||
}
|
||||
|
||||
private void switchOffProjectObserver() {
|
||||
projectWatchingSupported = false;
|
||||
notifyProjectObserverSupported();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<? extends IJavaProject> all() {
|
||||
return table.values();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSupported() {
|
||||
return projectWatchingSupported;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user