You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@netbeans.apache.org by GitBox <gi...@apache.org> on 2022/08/22 01:42:07 UTC

[GitHub] [netbeans] lkishalmi opened a new pull request, #4525: Gradle hide empty generated folders

lkishalmi opened a new pull request, #4525:
URL: https://github.com/apache/netbeans/pull/4525

   
   When added the support of Generated source directories in Gradle project, the project view become a bit crowded, as the generated folders are always generated by Gradle.
   
   Here there are two empty folder one for java and one for groovy.
   ![image](https://user-images.githubusercontent.com/1381701/185822259-9f91aaac-c525-4b9b-8c75-69a641f6e50a.png)
   
   Same project with the new code.
   ![image](https://user-images.githubusercontent.com/1381701/185822341-8a9192d5-af88-45b4-ab1f-11cfdd83d325.png)
   
   While implementing the change, I discovered a bug which prevented the freshly opened project to listen on resource changes. That one is the fist commit.


-- 
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-unsubscribe@netbeans.apache.org

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


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

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


[GitHub] [netbeans] lkishalmi commented on a diff in pull request #4525: Gradle hide empty generated folders

Posted by GitBox <gi...@apache.org>.
lkishalmi commented on code in PR #4525:
URL: https://github.com/apache/netbeans/pull/4525#discussion_r956614396


##########
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:
   Good insight! Thanks! Moving it to the UI!



-- 
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-unsubscribe@netbeans.apache.org

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


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

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


[GitHub] [netbeans] sdedic commented on a diff in pull request #4525: Gradle hide empty generated folders

Posted by GitBox <gi...@apache.org>.
sdedic commented on code in PR #4525:
URL: https://github.com/apache/netbeans/pull/4525#discussion_r960634890


##########
java/gradle.java/src/org/netbeans/modules/gradle/java/nodes/SourcesNodeFactory.java:
##########
@@ -79,7 +97,8 @@ public List<SourceGroup> keys() {
             ret.addAll(Arrays.asList(srcs.getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA)));
             ret.addAll(Arrays.asList(srcs.getSourceGroups(GradleSourcesImpl.SOURCE_TYPE_KOTLIN)));
             ret.addAll(Arrays.asList(srcs.getSourceGroups(JavaProjectConstants.SOURCES_TYPE_RESOURCES)));
-            ret.addAll(Arrays.asList(srcs.getSourceGroups(GradleSourcesImpl.SOURCE_TYPE_GENERATED)));
+            generatedGroups = Arrays.asList(srcs.getSourceGroups(GradleSourcesImpl.SOURCE_TYPE_GENERATED));

Review Comment:
   nitpick: `generatedGroups` access is unsynchronized; here, the value should be assigned first to local, then to generatedGroups + added to ret, to be consistent (within this thread). `generatedGroups` could be possibly `volatile`



-- 
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-unsubscribe@netbeans.apache.org

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


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

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


[GitHub] [netbeans] sdedic commented on a diff in pull request #4525: Gradle hide empty generated folders

Posted by GitBox <gi...@apache.org>.
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-unsubscribe@netbeans.apache.org

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


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

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


[GitHub] [netbeans] lkishalmi merged pull request #4525: Gradle hide empty generated folders

Posted by GitBox <gi...@apache.org>.
lkishalmi merged PR #4525:
URL: https://github.com/apache/netbeans/pull/4525


-- 
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-unsubscribe@netbeans.apache.org

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


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

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