PT #160596363: Fixes for live hints and navigation for multi-projects
Initial work: highlights fixed, source links bean SourceLinks bean uses project finder Project finder all projects. Source entries for dependency projects. Properly support peer projects for fall back Gradle projects Update code minings for e4.9
This commit is contained in:
@@ -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
|
||||
@@ -61,7 +61,7 @@ public class JdtLsJavadocProvider implements IJavadocProvider {
|
||||
long start = System.currentTimeMillis();
|
||||
try {
|
||||
log.info("Fetching javadoc {}", element.getBindingKey());
|
||||
JavadocResponse response = client.javadoc(new JavaDataParams(projectUri, element.getBindingKey())).get(10, TimeUnit.SECONDS);
|
||||
JavadocResponse response = client.javadoc(new JavaDataParams(projectUri, element.getBindingKey(), false)).get(10, TimeUnit.SECONDS);
|
||||
log.info("Fetching javadoc {} took {} ms", element.getBindingKey(), System.currentTimeMillis()-start);
|
||||
return produceJavadocFromMd(response);
|
||||
} catch (InterruptedException | ExecutionException | TimeoutException e) {
|
||||
|
||||
@@ -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
|
||||
@@ -10,6 +10,7 @@
|
||||
*******************************************************************************/
|
||||
package org.springframework.ide.vscode.commons.languageserver.java;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
@@ -21,29 +22,28 @@ import org.springframework.ide.vscode.commons.java.IJavaProject;
|
||||
import org.springframework.ide.vscode.commons.languageserver.Sts4LanguageServer;
|
||||
import org.springframework.ide.vscode.commons.util.FileObserver;
|
||||
import org.springframework.ide.vscode.commons.util.ListenerList;
|
||||
import org.springframework.ide.vscode.commons.util.Log;
|
||||
|
||||
import com.google.common.cache.Cache;
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
|
||||
/**
|
||||
* Abstract implementation of java project cache indexed by keys
|
||||
*
|
||||
*
|
||||
* @author Alex Boyko
|
||||
*
|
||||
* @param <K> key class
|
||||
* @param <P> project class
|
||||
*/
|
||||
public abstract class AbstractJavaProjectCache<K, P extends IJavaProject> implements JavaProjectCache<K, P> {
|
||||
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(AbstractJavaProjectCache.class);
|
||||
|
||||
|
||||
protected Sts4LanguageServer server;
|
||||
|
||||
private ListenerList<Listener> listeners = new ListenerList<>();
|
||||
|
||||
protected Cache<K, P> cache = CacheBuilder.newBuilder().build();
|
||||
|
||||
|
||||
public AbstractJavaProjectCache(Sts4LanguageServer server) {
|
||||
this.server = server;
|
||||
}
|
||||
@@ -70,16 +70,16 @@ public abstract class AbstractJavaProjectCache<K, P extends IJavaProject> implem
|
||||
}
|
||||
}
|
||||
} catch (ExecutionException e) {
|
||||
Log.log(e);
|
||||
log.error("", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public Optional<IJavaProject> projectByName(String name) {
|
||||
ConcurrentMap<K, P> map = cache.asMap();
|
||||
|
||||
|
||||
for (P project : map.values()) {
|
||||
if (project != null && project.getElementName().equals(name)) {
|
||||
return Optional.of(project);
|
||||
@@ -88,11 +88,11 @@ public abstract class AbstractJavaProjectCache<K, P extends IJavaProject> implem
|
||||
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
|
||||
abstract protected P createProject(K key) throws Exception;
|
||||
|
||||
|
||||
protected void attachListeners(K key, P project) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -105,17 +105,17 @@ public abstract class AbstractJavaProjectCache<K, P extends IJavaProject> implem
|
||||
public void removeListener(Listener listener) {
|
||||
listeners.remove(listener);
|
||||
}
|
||||
|
||||
|
||||
final protected void notifyProjectCreated(P project) {
|
||||
log.debug("project created {}", project);
|
||||
listeners.forEach(l -> l.created(project));
|
||||
}
|
||||
|
||||
|
||||
final protected void notifyProjectChanged(P project) {
|
||||
log.debug("project changed {}", project);
|
||||
listeners.forEach(l -> l.changed(project));
|
||||
}
|
||||
|
||||
|
||||
final protected void notifyProjectDeleted(P project) {
|
||||
log.debug("project deleted {}", project);
|
||||
listeners.forEach(l -> l.deleted(project));
|
||||
@@ -124,4 +124,8 @@ public abstract class AbstractJavaProjectCache<K, P extends IJavaProject> implem
|
||||
final protected FileObserver getFileObserver() {
|
||||
return server.getWorkspaceService().getFileObserver();
|
||||
}
|
||||
|
||||
final public Collection<? extends IJavaProject> all() {
|
||||
return cache.asMap().values();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2017 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
|
||||
@@ -19,32 +19,34 @@ import java.util.Optional;
|
||||
import org.eclipse.lsp4j.TextDocumentIdentifier;
|
||||
import org.springframework.ide.vscode.commons.java.IJavaProject;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
/**
|
||||
* Composite project manager that acts a single project manager but consists of many project managers
|
||||
*
|
||||
*
|
||||
* @author Alex Boyko
|
||||
*
|
||||
*/
|
||||
public class CompositeJavaProjectFinder implements JavaProjectFinder {
|
||||
|
||||
|
||||
private final List<JavaProjectFinder> projectFinders;
|
||||
|
||||
|
||||
public CompositeJavaProjectFinder(Collection<JavaProjectFinder> projectFinders) {
|
||||
this.projectFinders = new ArrayList<>(projectFinders);
|
||||
}
|
||||
|
||||
|
||||
public CompositeJavaProjectFinder() {
|
||||
this(Collections.emptyList());
|
||||
}
|
||||
|
||||
|
||||
public boolean addJavaProjectFinder(JavaProjectFinder javaProjectFinder) {
|
||||
return projectFinders.add(javaProjectFinder);
|
||||
}
|
||||
|
||||
|
||||
public boolean removeJavaProjectFinder(JavaProjectFinder javaProjectFinder) {
|
||||
return projectFinders.remove(javaProjectFinder);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Optional<IJavaProject> find(TextDocumentIdentifier doc) {
|
||||
for (JavaProjectFinder finder : projectFinders) {
|
||||
@@ -56,4 +58,13 @@ public class CompositeJavaProjectFinder implements JavaProjectFinder {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<? extends IJavaProject> all() {
|
||||
ImmutableList.Builder<IJavaProject> builder = ImmutableList.builder();
|
||||
for (JavaProjectFinder projectFinder : projectFinders) {
|
||||
builder.addAll(projectFinder.all());
|
||||
}
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2016, 2017 Pivotal, Inc.
|
||||
* Copyright (c) 2016, 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
|
||||
@@ -10,9 +10,10 @@
|
||||
*******************************************************************************/
|
||||
package org.springframework.ide.vscode.commons.languageserver.java;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.eclipse.lsp4j.TextDocumentIdentifier;
|
||||
import org.springframework.ide.vscode.commons.java.IJavaProject;
|
||||
@@ -28,13 +29,31 @@ public interface JavaProjectFinder {
|
||||
|
||||
Optional<IJavaProject> find(TextDocumentIdentifier doc);
|
||||
|
||||
Collection<? extends IJavaProject> all();
|
||||
|
||||
default JavaProjectFinder filter(Predicate<IJavaProject> acceptWhen) {
|
||||
return doc -> this.find(doc).flatMap(jp -> {
|
||||
if (acceptWhen.test(jp)) {
|
||||
return Optional.of(jp);
|
||||
|
||||
final JavaProjectFinder delegate = this;
|
||||
|
||||
return new JavaProjectFinder() {
|
||||
|
||||
@Override
|
||||
public Optional<IJavaProject> find(TextDocumentIdentifier doc) {
|
||||
return delegate.find(doc).flatMap(jp -> {
|
||||
if (acceptWhen.test(jp)) {
|
||||
return Optional.of(jp);
|
||||
}
|
||||
return Optional.empty();
|
||||
});
|
||||
}
|
||||
return Optional.empty();
|
||||
});
|
||||
|
||||
@Override
|
||||
public Collection<? extends IJavaProject> all() {
|
||||
return delegate.all().stream().filter(acceptWhen).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user