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 2020/09/25 01:48:23 UTC

[GitHub] [netbeans] errael opened a new pull request #2399: [NETBEANS-4832] Avoid assertion & NPE in fxml code completion

errael opened a new pull request #2399:
URL: https://github.com/apache/netbeans/pull/2399


   @sdedic could you take a look at this fix.
   
   The assertion was due to CompilerInfo not having a list of modules. Fixed in `FXMLCompletion2.Q.Taks.run` with the getPackageElement:
   ```
       ci = CompilationInfo.get(result);
       // following populates module info, partial fix for [NETBEANS-4832]
       ci.getElements().getPackageElement("java.lang");
   ```
   
   This fixed code completion inside an UI element, for example<Label.../>"
   
   However there was an NPE inside a list, for example in`<children>...</children>`. This was fixed by what looks like a bug/oversight in `ElementUtils.getTypeElementByBinaryName`.
   
   In FxIncludeCompleter.createCompleter
   ```
       TypeMirror tm = prop.getType().resolve(ctx.getCompilationInfo());
   ```
   returned null which causes NPE in jdk.  fixed by the identity check in
   ```
       ElementUtils.getTypeElementByBinaryName
   ```
   


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

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 #2399: [NETBEANS-4832] Avoid assertion & NPE in fxml code completion

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


   


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

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] errael commented on a change in pull request #2399: [NETBEANS-4832] Avoid assertion & NPE in fxml code completion

Posted by GitBox <gi...@apache.org>.
errael commented on a change in pull request #2399:
URL: https://github.com/apache/netbeans/pull/2399#discussion_r496343193



##########
File path: java/java.source.base/src/org/netbeans/modules/java/source/ElementUtils.java
##########
@@ -60,6 +60,11 @@ public static TypeElement getTypeElementByBinaryName(JavacTask task, String name
         for (ModuleElement me : allModules) {
             TypeElement found = getTypeElementByBinaryName(task, me, name);
 
+            if (result == found) {
+                // avoid returning null, partial fix for [NETBEANS-4832]
+                continue;
+            }
+

Review comment:
       So you're saying that the `if(result==found)continue` seems OK.
   
   And that there's an additional issue that could arise in some cases; and you've proposed a fix which can be incorporated with this change.




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

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] errael commented on pull request #2399: [NETBEANS-4832] Avoid assertion & NPE in fxml code completion

Posted by GitBox <gi...@apache.org>.
errael commented on pull request #2399:
URL: https://github.com/apache/netbeans/pull/2399#issuecomment-699248205


   Just added stacktrace for the NPE to issue https://issues.apache.org/jira/browse/NETBEANS-4832


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

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 #2399: [NETBEANS-4832] Avoid assertion & NPE in fxml code completion

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


   


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

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] errael commented on a change in pull request #2399: [NETBEANS-4832] Avoid assertion & NPE in fxml code completion

Posted by GitBox <gi...@apache.org>.
errael commented on a change in pull request #2399:
URL: https://github.com/apache/netbeans/pull/2399#discussion_r497558706



##########
File path: java/java.source.base/src/org/netbeans/modules/java/source/ElementUtils.java
##########
@@ -60,6 +60,11 @@ public static TypeElement getTypeElementByBinaryName(JavacTask task, String name
         for (ModuleElement me : allModules) {
             TypeElement found = getTypeElementByBinaryName(task, me, name);
 
+            if (result == found) {
+                // avoid returning null, partial fix for [NETBEANS-4832]
+                continue;
+            }
+

Review comment:
       Added separate commit for ANNOTATION_TYPE, ENUM, still in 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.

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] jlahoda commented on a change in pull request #2399: [NETBEANS-4832] Avoid assertion & NPE in fxml code completion

Posted by GitBox <gi...@apache.org>.
jlahoda commented on a change in pull request #2399:
URL: https://github.com/apache/netbeans/pull/2399#discussion_r496389412



##########
File path: javafx/javafx2.editor/src/org/netbeans/modules/javafx2/editor/FXMLCompletion2.java
##########
@@ -161,6 +161,8 @@ public void run(ResultIterator resultIterator) throws Exception {
                 }
                 Parser.Result result = resultIterator.getParserResult();
                 ci = CompilationInfo.get(result);
+                // following populates module info, partial fix for [NETBEANS-4832]
+                ci.getElements().getPackageElement("java.lang");

Review comment:
       I think the expected way would be to get a CompilationController (instead of just CompilationInfo) and call toPhase(ELEMENTS_RESOLVED), or alike, on 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.

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] errael commented on pull request #2399: [NETBEANS-4832] Avoid assertion & NPE in fxml code completion

Posted by GitBox <gi...@apache.org>.
errael commented on pull request #2399:
URL: https://github.com/apache/netbeans/pull/2399#issuecomment-703682748


   ping @sdedic @jlahoda Your comment have been incorporated. Can we finish this?
   CC: @lkishalmi 


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

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] errael commented on a change in pull request #2399: [NETBEANS-4832] Avoid assertion & NPE in fxml code completion

Posted by GitBox <gi...@apache.org>.
errael commented on a change in pull request #2399:
URL: https://github.com/apache/netbeans/pull/2399#discussion_r497559728



##########
File path: javafx/javafx2.editor/src/org/netbeans/modules/javafx2/editor/FXMLCompletion2.java
##########
@@ -161,6 +161,8 @@ public void run(ResultIterator resultIterator) throws Exception {
                 }
                 Parser.Result result = resultIterator.getParserResult();
                 ci = CompilationInfo.get(result);
+                // following populates module info, partial fix for [NETBEANS-4832]
+                ci.getElements().getPackageElement("java.lang");

Review comment:
       @jlahoda Use CompilationController as suggested. Works, thanks. Please review.




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

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] errael commented on a change in pull request #2399: [NETBEANS-4832] Avoid assertion & NPE in fxml code completion

Posted by GitBox <gi...@apache.org>.
errael commented on a change in pull request #2399:
URL: https://github.com/apache/netbeans/pull/2399#discussion_r497560351



##########
File path: java/java.source.base/src/org/netbeans/modules/java/source/ElementUtils.java
##########
@@ -60,6 +60,11 @@ public static TypeElement getTypeElementByBinaryName(JavacTask task, String name
         for (ModuleElement me : allModules) {
             TypeElement found = getTypeElementByBinaryName(task, me, name);
 
+            if (result == found) {
+                // avoid returning null, partial fix for [NETBEANS-4832]
+                continue;
+            }
+

Review comment:
       @sdedic Known issues handled, please review.




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

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 change in pull request #2399: [NETBEANS-4832] Avoid assertion & NPE in fxml code completion

Posted by GitBox <gi...@apache.org>.
sdedic commented on a change in pull request #2399:
URL: https://github.com/apache/netbeans/pull/2399#discussion_r495565459



##########
File path: javafx/javafx2.editor/src/org/netbeans/modules/javafx2/editor/FXMLCompletion2.java
##########
@@ -161,6 +161,8 @@ public void run(ResultIterator resultIterator) throws Exception {
                 }
                 Parser.Result result = resultIterator.getParserResult();
                 ci = CompilationInfo.get(result);
+                // following populates module info, partial fix for [NETBEANS-4832]
+                ci.getElements().getPackageElement("java.lang");

Review comment:
       I understand the trigger, but couldn't it be fixed right in the getPackagElement(), @jlahoda ?




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

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] errael commented on a change in pull request #2399: [NETBEANS-4832] Avoid assertion & NPE in fxml code completion

Posted by GitBox <gi...@apache.org>.
errael commented on a change in pull request #2399:
URL: https://github.com/apache/netbeans/pull/2399#discussion_r496343360



##########
File path: javafx/javafx2.editor/src/org/netbeans/modules/javafx2/editor/FXMLCompletion2.java
##########
@@ -161,6 +161,8 @@ public void run(ResultIterator resultIterator) throws Exception {
                 }
                 Parser.Result result = resultIterator.getParserResult();
                 ci = CompilationInfo.get(result);
+                // following populates module info, partial fix for [NETBEANS-4832]
+                ci.getElements().getPackageElement("java.lang");

Review comment:
       Did you mean `getElements()` rather than `getPackageElement()`?




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

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 change in pull request #2399: [NETBEANS-4832] Avoid assertion & NPE in fxml code completion

Posted by GitBox <gi...@apache.org>.
sdedic commented on a change in pull request #2399:
URL: https://github.com/apache/netbeans/pull/2399#discussion_r495565280



##########
File path: java/java.source.base/src/org/netbeans/modules/java/source/ElementUtils.java
##########
@@ -60,6 +60,11 @@ public static TypeElement getTypeElementByBinaryName(JavacTask task, String name
         for (ModuleElement me : allModules) {
             TypeElement found = getTypeElementByBinaryName(task, me, name);
 
+            if (result == found) {
+                // avoid returning null, partial fix for [NETBEANS-4832]
+                continue;
+            }
+

Review comment:
       Not related to this bug, but a few lines below: `(elem.getKind() == ElementKind.CLASS || elem.getKind() == ElementKind.INTERFACE)` IMHO does not work for `ANNOTATION_TYPE` and `ENUM`. Could be worth to fix as
   `elem.getKind().isClass() || elem.getKind().isInterface` ?




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

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