sdedic commented on code in PR #6370:
URL: https://github.com/apache/netbeans/pull/6370#discussion_r1303966984
##########
java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/protocol/Server.java:
##########
@@ -869,11 +871,42 @@ public CompletableFuture<InitializeResult>
initialize(InitializeParams init) {
}
}
CompletableFuture<Project[]> prjs = workspaceProjects;
- SERVER_INIT_RP.post(() -> asyncOpenSelectedProjects0(prjs,
projectCandidates, true, true));
+ SERVER_INIT_RP.post(() -> {
+ List<FileObject> additionalCandidates = new ArrayList<>();
+ AtomicBoolean cancel = new AtomicBoolean();
+ ProgressHandle h = ProgressHandle.createHandle("Collecting
workspace projects...", () -> {
+ cancel.set(true);
+ return true;
+ });
+ h.start();
+ try {
+ for (FileObject candidate : projectCandidates) {
Review Comment:
I think this body loop is much the same as `collectProjectCandidates` body
loop; maybe worth joining ?
##########
java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/protocol/Server.java:
##########
@@ -885,6 +918,28 @@ public CompletableFuture<InitializeResult>
initialize(InitializeParams init) {
);
}
+ private void collectProjectCandidates(FileObject fo, List<FileObject>
candidates, AtomicBoolean cancel) {
+ for (FileObject chld : fo.getChildren()) {
+ if (cancel.get()) {
+ return;
+ }
+ if (chld.isFolder()) {
+ Project prj = FileOwnerQuery.getOwner(chld);
+ if (prj != null) {
+ candidates.add(chld);
+ Set<Project> containedProjects =
ProjectUtils.getContainedProjects(prj, true);
Review Comment:
:warning: This call is not safe for Gradle projects prior to their priming
build; it may return just empty - I think the subproject structure is not read
in the fallback mode. Some basic support could be perhaps added to read plain
`include` directives in well known places.
I suggest to query subprojects only after their parents prime.
##########
java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/protocol/Server.java:
##########
@@ -885,6 +918,28 @@ public CompletableFuture<InitializeResult>
initialize(InitializeParams init) {
);
}
+ private void collectProjectCandidates(FileObject fo, List<FileObject>
candidates, AtomicBoolean cancel) {
+ for (FileObject chld : fo.getChildren()) {
+ if (cancel.get()) {
Review Comment:
A weird idea -- consider a symlink in the directory tree; it can loop up the
hiererarchy, causing an infinite loop. I'd check somehow absolute paths of the
referenced file. Do we want to support symlinks outside of the directory
structure ?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists