jtulach commented on code in PR #9821:
URL: https://github.com/apache/netbeans/pull/9821#discussion_r4656902998


##########
ide/projectui/src/org/netbeans/modules/project/ui/groups/DirectoryGroup.java:
##########
@@ -112,34 +114,44 @@ public GroupEditPanel createPropertiesPanel() {
     }
 
     private void processFolderChildren(FileObject fo, Set<Project> projects, 
ProgressHandle h, Counter counter, boolean checkShare) throws 
IllegalArgumentException {
-        Enumeration<? extends FileObject> e = fo.getFolders(false);
-        while (e.hasMoreElements()) {
-            try {
-                FileObject em = e.nextElement();
-                SharabilityQuery.Sharability share = 
SharabilityQuery.Sharability.UNKNOWN;
-                if (checkShare) {
-                    share = SharabilityQuery.getSharability(fo);
+        Enumeration<? extends Project> rootProjects = 
Enumerations.queue(Enumerations.array(fo.getChildren()), (dir, toAdd) -> {
+            if (!dir.isFolder()) {
+                return null;
+            }
+            if (checkShare) {
+                try {
+                    SharabilityQuery.Sharability share = 
SharabilityQuery.getSharability(dir);
                     if (share == SharabilityQuery.Sharability.NOT_SHARABLE) {
-                        continue;
+                        return null;
                     }
-                }
-                Project p = ProjectManager.getDefault().findProject(em);
-                if (p != null && !ProjectConvertors.isConvertorProject(p)) {
-                    projects.add(p);
-                    if (h != null) {
-                        h.progress(progressMessage(p), 
Math.min(++counter.start, counter.end));
+                    Project p = ProjectManager.getDefault().findProject(dir);
+                    if (p != null && !ProjectConvertors.isConvertorProject(p)) 
{
+                        return p;
                     }
+                } catch (IOException ex) {
+                    Exceptions.printStackTrace(ex);
+                    return null;
+                }
+            }
+            toAdd.addAll(List.of(dir.getChildren()));
+            return null;
+        });
+        while (rootProjects.hasMoreElements()) {
+            Project p = rootProjects.nextElement();
+            if (p != null) {
+                projects.add(p);
+                if (h != null) {
+                    h.progress(progressMessage(p), Math.min(++counter.start, 
counter.end));
                 }
-                checkShare = share != SharabilityQuery.Sharability.SHARABLE;
-                // don't need to check the sharability if the current folder 
is marked as recursively sharable
-                
-                processFolderChildren(em, projects, h, counter, checkShare);

Review Comment:
   - this PR changes the behavior when a valid "root" `Project` is found
     - previously the scan continued inside of project structure
     - now it stops and relies on _open subprojects_ behavior of 
`OpenProjects.open`
   - such a **behavior is way faster**
     - scanning NetBeans repository now takes just **4s**
     - while previously it took **16s**
   -  the new **behavior is more predictable**
     - some Git repositories (like NetBeans or Maven) contain a lot of "testing 
projects" hidden in test data
       - the previous behavior found those projects ...
       - ... which was greatly unexpected ...
       - ... and also dangerous as those projects are often (intentionally) 
corrupted, misconfigured or otherwise broken
     - in case of NetBeans there was _more than three hundred_ of such modules
     - lowering the number might even improve the [Matthias 
warning](https://github.com/apache/netbeans/pull/9592#issuecomment-5536301353)  
a bit
        - although tons of time is then going to be spend while parsing the 
projects anyway ...
        - ... to be addressed in some future PR
   - the speed gain and the _matched expectations_ are the major UX 
improvements of this PR



-- 
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

Reply via email to