sdedic commented on code in PR #4525:
URL: https://github.com/apache/netbeans/pull/4525#discussion_r956582278


##########
java/gradle.java/src/org/netbeans/modules/gradle/java/classpath/GradleSourcesImpl.java:
##########
@@ -159,7 +160,7 @@ public synchronized SourceGroup[] getSourceGroups(String 
type) {
         for (SourceType st : stype) {
             Set<File> processed = new HashSet<>();
             for (String group : gradleSources.keySet()) {
-                Set<File> dirs = gradleSources.get(group).getSourceDirs(st);
+                Set<File> dirs = 
filterEmptyGeneratedDirs(gradleSources.get(group).getSourceDirs(st));

Review Comment:
   Is it OK to filter the empty dirs from the data layer ? I'd rather leave 
them discoverable (as they are valid source roots), but filter them from the UI 
only.



##########
extide/gradle/src/org/netbeans/modules/gradle/api/NbGradleProject.java:
##########
@@ -255,34 +255,37 @@ private void fireProjectReload() {
     private void doFireReload() {
         detachResourceWatchers();
         support.firePropertyChange(PROP_PROJECT_INFO, null, null);
-        attachResourceWatchers();
+        attachResourceWatchers(false);
     }
 
     private void detachResourceWatchers() {
-        for (File resource : resources) {
-            try {
-                FileUtil.removeFileChangeListener(FCHSL, resource);
-            } catch (IllegalArgumentException ex) {
-                assert false : "Something is wrong with the resource handling";
+        synchronized (resources) {
+            for (File resource : resources) {
+                try {
+                    FileUtil.removeFileChangeListener(FCHSL, resource);
+                } catch (IllegalArgumentException ex) {
+                    assert false : "Something is wrong with the resource 
handling";
+                }
             }
+            resources.clear();
         }
-        resources.clear();
     }
 
-    private void attachResourceWatchers() {
+    private void attachResourceWatchers(boolean elevateQuality) {
         //Never listen on resource changes when only FALLBACK quality is needed
-        if (project.getAimedQuality() == Quality.FALLBACK) return;
-
-        Collection<? extends WatchedResourceProvider> all
-                = project.getLookup().lookupAll(WatchedResourceProvider.class);
-        for (WatchedResourceProvider pvd : all) {
-            resources.addAll(pvd.getWatchedResources());
-        }
-        for (File resource : resources) {
-            try {
-                FileUtil.addFileChangeListener(FCHSL, resource);
-            } catch (IllegalArgumentException ex) {
-                assert false : "Something is wrong with the resource handling";
+        if ((project.getAimedQuality() == Quality.FALLBACK) && 
!elevateQuality) return;
+        synchronized (resources) {
+            Collection<? extends WatchedResourceProvider> all

Review Comment:
   I'd clear `resources` at the start.



-- 
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: notifications-unsubscr...@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@netbeans.apache.org
For additional commands, e-mail: notifications-h...@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to