Outline with JDT LS LightWeight mode
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2017 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
|
||||
@@ -36,4 +36,9 @@ public class CompositeProjectOvserver implements ProjectObserver {
|
||||
observers.forEach(o -> o.removeListener(listener));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSupported() {
|
||||
return observers.stream().map(o -> o.isSupported()).reduce(false, (a, b) -> a || b);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -42,6 +42,14 @@ public class FutureProjectFinder implements DisposableBean {
|
||||
@Override
|
||||
public void changed(IJavaProject project) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void supported() {
|
||||
if (!projectObserver.isSupported()) {
|
||||
resolveAllPendingRquests();
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -52,6 +60,14 @@ public class FutureProjectFinder implements DisposableBean {
|
||||
this.projectObserver.addListener(LISTENER);
|
||||
}
|
||||
}
|
||||
|
||||
synchronized private void resolveAllPendingRquests() {
|
||||
for (Map.Entry<URI, CompletableFuture<IJavaProject>> e : pendingFindProjectRequests.entrySet()) {
|
||||
Optional<IJavaProject> jp = projectFinder.find(new TextDocumentIdentifier(e.getKey().toString()));
|
||||
e.getValue().complete(jp.orElse(null));
|
||||
pendingFindProjectRequests.remove(e.getKey());
|
||||
}
|
||||
}
|
||||
|
||||
synchronized private void resolvePendingRequests(IJavaProject project) {
|
||||
for (Map.Entry<URI, CompletableFuture<IJavaProject>> e : pendingFindProjectRequests.entrySet()) {
|
||||
@@ -79,12 +95,16 @@ public class FutureProjectFinder implements DisposableBean {
|
||||
if (projectObserver == null) {
|
||||
throw new IllegalStateException("Future project lookup not supported without ProjectObserver bean present");
|
||||
}
|
||||
CompletableFuture<IJavaProject> cf = pendingFindProjectRequests.get(uri);
|
||||
if (cf == null) {
|
||||
cf = new CompletableFuture<IJavaProject>();
|
||||
pendingFindProjectRequests.put(uri, cf);
|
||||
if (projectObserver.isSupported()) {
|
||||
CompletableFuture<IJavaProject> cf = pendingFindProjectRequests.get(uri);
|
||||
if (cf == null) {
|
||||
cf = new CompletableFuture<IJavaProject>();
|
||||
pendingFindProjectRequests.put(uri, cf);
|
||||
}
|
||||
return cf;
|
||||
} else {
|
||||
return CompletableFuture.completedFuture(null);
|
||||
}
|
||||
return cf;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2017 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
|
||||
@@ -26,7 +26,9 @@ public interface ProjectObserver {
|
||||
void created(IJavaProject project);
|
||||
void changed(IJavaProject project);
|
||||
void deleted(IJavaProject project);
|
||||
default void supported() { }
|
||||
}
|
||||
default boolean isSupported() { return true; };
|
||||
void addListener(Listener listener);
|
||||
void removeListener(Listener listener);
|
||||
|
||||
@@ -38,6 +40,11 @@ public interface ProjectObserver {
|
||||
@Override
|
||||
public void removeListener(Listener listener) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSupported() {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user