You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@netbeans.apache.org by "junichi11 (via GitHub)" <gi...@apache.org> on 2023/03/17 03:00:08 UTC

[GitHub] [netbeans] junichi11 opened a new pull request, #5670: Fix incorrect unused coloring #5551

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

   When there is an anonymous class in a method body, the anonymous class also removes method blocks of the enclosing class that need to be scanned. So, to prevent that, use `Map<TypeInfo, List<Block>>` instead of `List<Block>`
   
   #### Before:
   ![nb-php-gh-5551-before](https://user-images.githubusercontent.com/738383/225801144-77ae5fb9-f5dc-4f4a-ad51-30da96b8f392.png)
   
   #### After:
   ![nb-php-gh-5551-after](https://user-images.githubusercontent.com/738383/225801160-5c8693cf-abce-4d76-b6c7-dfe2cf463db8.png)
   


-- 
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] junichi11 commented on pull request #5670: Fix incorrect unused coloring #5551

Posted by "junichi11 (via GitHub)" <gi...@apache.org>.
junichi11 commented on PR #5670:
URL: https://github.com/apache/netbeans/pull/5670#issuecomment-1474731423

   @mbien Thank you!


-- 
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] junichi11 commented on pull request #5670: Fix incorrect unused coloring #5551

Posted by "junichi11 (via GitHub)" <gi...@apache.org>.
junichi11 commented on PR #5670:
URL: https://github.com/apache/netbeans/pull/5670#issuecomment-1474730216

   CI: Some checks were not successful
   
   I canceled jobs once because the CI status was not shown. I re-ran all jobs again.
   "NetBeans / Build cancelled (pull_request) — Run manually canceled" : maybe, no problem? (@mbien)


-- 
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] tmysik commented on a diff in pull request #5670: Fix incorrect unused coloring #5551

Posted by "tmysik (via GitHub)" <gi...@apache.org>.
tmysik commented on code in PR #5670:
URL: https://github.com/apache/netbeans/pull/5670#discussion_r1140378932


##########
php/php.editor/src/org/netbeans/modules/php/editor/csl/SemanticAnalysis.java:
##########
@@ -595,23 +596,27 @@ public void visit(ClassInstanceCreation node) {
                 // to avoid recognizing $this as an instance of an anonymous class
                 scan(node.ctorParams());
                 addToPath(node);
+                // GH-5551 keep original type info to scnan parent blocks
+                TypeInfo originalTypeInfo = typeInfo;
                 typeInfo = new ClassInstanceCreationTypeInfo(node);
                 scan(node.getAttributes());
                 scan(node.getSuperClass());
                 scan(node.getInterfaces());
-                needToScan = new ArrayList<>();
+                needToScan.put(typeInfo, new ArrayList<>());
                 Block body = node.getBody();
                 if (body != null) {
                     body.accept(this);
 
                     // find all usages in the method bodies
-                    while (!needToScan.isEmpty()) {
-                        Block block = needToScan.remove(0);
+                    while (!needToScan.get(typeInfo).isEmpty()) {
+                        Block block = needToScan.get(typeInfo).remove(0);

Review Comment:
   Yes, that should be "much" better, I think. Anyway, that was just a nitpick, nothing important, I would say.
   



-- 
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] tmysik commented on a diff in pull request #5670: Fix incorrect unused coloring #5551

Posted by "tmysik (via GitHub)" <gi...@apache.org>.
tmysik commented on code in PR #5670:
URL: https://github.com/apache/netbeans/pull/5670#discussion_r1140014200


##########
php/php.editor/src/org/netbeans/modules/php/editor/csl/SemanticAnalysis.java:
##########
@@ -595,23 +596,27 @@ public void visit(ClassInstanceCreation node) {
                 // to avoid recognizing $this as an instance of an anonymous class
                 scan(node.ctorParams());
                 addToPath(node);
+                // GH-5551 keep original type info to scnan parent blocks

Review Comment:
   ```suggestion
                   // GH-5551 keep original type info to scan parent blocks
   ```



-- 
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] tmysik commented on pull request #5670: Fix incorrect unused coloring #5551

Posted by "tmysik (via GitHub)" <gi...@apache.org>.
tmysik commented on PR #5670:
URL: https://github.com/apache/netbeans/pull/5670#issuecomment-1474822559

   @junichi11 You are welcome, of course!
   


-- 
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] tmysik commented on pull request #5670: Fix incorrect unused coloring #5551

Posted by "tmysik (via GitHub)" <gi...@apache.org>.
tmysik commented on PR #5670:
URL: https://github.com/apache/netbeans/pull/5670#issuecomment-1473560998

   @junichi11 Please, see my comment about the list implementation (I am OK with the current one), let me know. Then, I will merge it. Thanks!
   


-- 
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] junichi11 commented on a diff in pull request #5670: Fix incorrect unused coloring #5551

Posted by "junichi11 (via GitHub)" <gi...@apache.org>.
junichi11 commented on code in PR #5670:
URL: https://github.com/apache/netbeans/pull/5670#discussion_r1140740311


##########
php/php.editor/src/org/netbeans/modules/php/editor/csl/SemanticAnalysis.java:
##########
@@ -595,23 +596,27 @@ public void visit(ClassInstanceCreation node) {
                 // to avoid recognizing $this as an instance of an anonymous class
                 scan(node.ctorParams());
                 addToPath(node);
+                // GH-5551 keep original type info to scnan parent blocks

Review Comment:
   Fixed. Thank you!



-- 
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] junichi11 commented on pull request #5670: Fix incorrect unused coloring #5551

Posted by "junichi11 (via GitHub)" <gi...@apache.org>.
junichi11 commented on PR #5670:
URL: https://github.com/apache/netbeans/pull/5670#issuecomment-1474806218

   @tmysik Thank you, Tomas!!


-- 
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] junichi11 commented on a diff in pull request #5670: Fix incorrect unused coloring #5551

Posted by "junichi11 (via GitHub)" <gi...@apache.org>.
junichi11 commented on code in PR #5670:
URL: https://github.com/apache/netbeans/pull/5670#discussion_r1140033311


##########
php/php.editor/src/org/netbeans/modules/php/editor/csl/SemanticAnalysis.java:
##########
@@ -595,23 +596,27 @@ public void visit(ClassInstanceCreation node) {
                 // to avoid recognizing $this as an instance of an anonymous class
                 scan(node.ctorParams());
                 addToPath(node);
+                // GH-5551 keep original type info to scnan parent blocks
+                TypeInfo originalTypeInfo = typeInfo;
                 typeInfo = new ClassInstanceCreationTypeInfo(node);
                 scan(node.getAttributes());
                 scan(node.getSuperClass());
                 scan(node.getInterfaces());
-                needToScan = new ArrayList<>();
+                needToScan.put(typeInfo, new ArrayList<>());
                 Block body = node.getBody();
                 if (body != null) {
                     body.accept(this);
 
                     // find all usages in the method bodies
-                    while (!needToScan.isEmpty()) {
-                        Block block = needToScan.remove(0);
+                    while (!needToScan.get(typeInfo).isEmpty()) {
+                        Block block = needToScan.get(typeInfo).remove(0);

Review Comment:
   Use for loop?
   ```java
                   for (Block block : needToScan.get(typeInfo)) {
                       block.accept(this);
                   }
                   needToScan.get(typeInfo).clear();
   
   ```



-- 
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] mbien commented on pull request #5670: Fix incorrect unused coloring #5551

Posted by "mbien (via GitHub)" <gi...@apache.org>.
mbien commented on PR #5670:
URL: https://github.com/apache/netbeans/pull/5670#issuecomment-1474730855

   @junichi11 looks good to me, PHP is green, everything else too. Only the cleanup job doesn't want to cleanup - all good.


-- 
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] junichi11 commented on pull request #5670: Fix incorrect unused coloring #5551

Posted by "junichi11 (via GitHub)" <gi...@apache.org>.
junichi11 commented on PR #5670:
URL: https://github.com/apache/netbeans/pull/5670#issuecomment-1473145596

   @tmysik Could you please have a look at this? If there is no problem, let's merge it. Thanks!


-- 
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] tmysik commented on a diff in pull request #5670: Fix incorrect unused coloring #5551

Posted by "tmysik (via GitHub)" <gi...@apache.org>.
tmysik commented on code in PR #5670:
URL: https://github.com/apache/netbeans/pull/5670#discussion_r1140017075


##########
php/php.editor/src/org/netbeans/modules/php/editor/csl/SemanticAnalysis.java:
##########
@@ -595,23 +596,27 @@ public void visit(ClassInstanceCreation node) {
                 // to avoid recognizing $this as an instance of an anonymous class
                 scan(node.ctorParams());
                 addToPath(node);
+                // GH-5551 keep original type info to scnan parent blocks
+                TypeInfo originalTypeInfo = typeInfo;
                 typeInfo = new ClassInstanceCreationTypeInfo(node);
                 scan(node.getAttributes());
                 scan(node.getSuperClass());
                 scan(node.getInterfaces());
-                needToScan = new ArrayList<>();
+                needToScan.put(typeInfo, new ArrayList<>());
                 Block body = node.getBody();
                 if (body != null) {
                     body.accept(this);
 
                     // find all usages in the method bodies
-                    while (!needToScan.isEmpty()) {
-                        Block block = needToScan.remove(0);
+                    while (!needToScan.get(typeInfo).isEmpty()) {
+                        Block block = needToScan.get(typeInfo).remove(0);

Review Comment:
   _Note:_ Since you are removing from the first index, perhaps `ArtrayList` is not the best list implementation for it. So, perhaps `LinkedList` would be better here (although, personally, I don't like it :).
   



##########
php/php.editor/src/org/netbeans/modules/php/editor/csl/SemanticAnalysis.java:
##########
@@ -595,23 +596,27 @@ public void visit(ClassInstanceCreation node) {
                 // to avoid recognizing $this as an instance of an anonymous class
                 scan(node.ctorParams());
                 addToPath(node);
+                // GH-5551 keep original type info to scnan parent blocks
+                TypeInfo originalTypeInfo = typeInfo;
                 typeInfo = new ClassInstanceCreationTypeInfo(node);
                 scan(node.getAttributes());
                 scan(node.getSuperClass());
                 scan(node.getInterfaces());
-                needToScan = new ArrayList<>();
+                needToScan.put(typeInfo, new ArrayList<>());
                 Block body = node.getBody();
                 if (body != null) {
                     body.accept(this);
 
                     // find all usages in the method bodies
-                    while (!needToScan.isEmpty()) {
-                        Block block = needToScan.remove(0);
+                    while (!needToScan.get(typeInfo).isEmpty()) {
+                        Block block = needToScan.get(typeInfo).remove(0);

Review Comment:
   _Note:_ Since you are removing from the first index, perhaps `ArrayList` is not the best list implementation for it. So, perhaps `LinkedList` would be better here (although, personally, I don't like it :).
   



-- 
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] junichi11 commented on a diff in pull request #5670: Fix incorrect unused coloring #5551

Posted by "junichi11 (via GitHub)" <gi...@apache.org>.
junichi11 commented on code in PR #5670:
URL: https://github.com/apache/netbeans/pull/5670#discussion_r1140740127


##########
php/php.editor/src/org/netbeans/modules/php/editor/csl/SemanticAnalysis.java:
##########
@@ -595,23 +596,27 @@ public void visit(ClassInstanceCreation node) {
                 // to avoid recognizing $this as an instance of an anonymous class
                 scan(node.ctorParams());
                 addToPath(node);
+                // GH-5551 keep original type info to scnan parent blocks
+                TypeInfo originalTypeInfo = typeInfo;
                 typeInfo = new ClassInstanceCreationTypeInfo(node);
                 scan(node.getAttributes());
                 scan(node.getSuperClass());
                 scan(node.getInterfaces());
-                needToScan = new ArrayList<>();
+                needToScan.put(typeInfo, new ArrayList<>());
                 Block body = node.getBody();
                 if (body != null) {
                     body.accept(this);
 
                     // find all usages in the method bodies
-                    while (!needToScan.isEmpty()) {
-                        Block block = needToScan.remove(0);
+                    while (!needToScan.get(typeInfo).isEmpty()) {
+                        Block block = needToScan.get(typeInfo).remove(0);

Review Comment:
   Fixed. Thank you!



-- 
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] tmysik merged pull request #5670: Fix incorrect unused coloring #5551

Posted by "tmysik (via GitHub)" <gi...@apache.org>.
tmysik merged PR #5670:
URL: https://github.com/apache/netbeans/pull/5670


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