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/04/25 14:14:32 UTC

[GitHub] [netbeans] negora opened a new issue, #4034: LSP/TypeScript: "Fix code" causes "NullPointerException"

negora opened a new issue, #4034:
URL: https://github.com/apache/netbeans/issues/4034

   ### Apache NetBeans version
   
   Apache NetBeans 13
   
   ### What happened
   
   When I try to generate a getter for a class field (and, optionally, also a setter), NetBeans shows the following error in the *Notifications* window:
   
   ```
   Cannot invoke "org.eclipse.lsp4j.WorkspaceEdit.getDocumentChanges()" because "edit" is null
   ```
   
   This is the stack trace:
   
   ```
   java.lang.NullPointerException: Cannot invoke "org.eclipse.lsp4j.WorkspaceEdit.getDocumentChanges()" because "edit" is null
   	at org.netbeans.modules.lsp.client.Utils.applyWorkspaceEdit(Utils.java:94)
   	at org.netbeans.modules.lsp.client.Utils.applyCodeAction(Utils.java:198)
   	at org.netbeans.modules.lsp.client.bindings.LanguageClientImpl$DiagnosticFixList$CommandBasedFix.implement(LanguageClientImpl.java:299)
   [catch] at org.netbeans.modules.editor.hints.HintsUI$1.run(HintsUI.java:810)
   	at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1418)
   	at org.netbeans.modules.openide.util.GlobalLookup.execute(GlobalLookup.java:45)
   	at org.openide.util.lookup.Lookups.executeWith(Lookups.java:278)
   	at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:2033)
   ```
   
   
   ### How to reproduce
   
   Suppose that I've the following TypeScript source file:
   
   ```ts
   export class Student {
   	private age: number;
   }
   ```
   
   When I open it in NetBeans, the editor shows an error saying this: *'age' is declared but its value is never read.* Then, if I do one of these things:
   
   * Option A
   1. Main menu
   2. Source
   3. Fix code...
   4. Generate 'get' and 'set' accessors
   
   * Bulb in editor's gutter
   1. Click
   2. Generate 'get' and 'set' accessors
   
   The error mentioned in the previous section is thrown.
   
   
   ### Did this work correctly in an earlier version?
   
   No
   
   ### Operating System
   
   Debian GNU/Linux 11.3 (Bullseye)
   
   ### JDK
   
   OpenJDK Runtime Environment (build 17.0.2+8-Debian-1deb11u1)
   
   ### Apache NetBeans packaging
   
   Apache NetBeans binary zip
   
   ### Anything else
   
   In NetBeans IDE 13, the same error was thrown when adding an `import` automatically, by choosing *Add import from <package>* in the bulb's menu. However, in version 14 RC 1 this seems to be fixed.
   
   In NetBeans IDE 14 RC1, this error also occurs when you select a piece of code and try to extract it into a method (or other kind of refactoring). In this case, we need to choose *Insert code...* instead of *Fix code...*, but the result is the same.
   
   
   ### Are you willing to submit a pull request?
   
   No
   
   ### Code of Conduct
   
   Yes


-- 
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.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] ebarboni closed issue #4034: LSP/TypeScript: NPE when trying to generate getter

Posted by GitBox <gi...@apache.org>.
ebarboni closed issue #4034: LSP/TypeScript: NPE when trying to generate getter
URL: https://github.com/apache/netbeans/issues/4034


-- 
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] matthiasblaesing commented on issue #4034: LSP/TypeScript: NPE when trying to generate getter

Posted by GitBox <gi...@apache.org>.
matthiasblaesing commented on issue #4034:
URL: https://github.com/apache/netbeans/issues/4034#issuecomment-1112492285

   Thank you - the fix for the exception is trivial - but the it becomes more interesting:
   
   ```diff
   # This patch file was generated by NetBeans IDE
   # It uses platform neutral UTF-8 encoding and \n newlines.
   --- a/ide/lsp.client/src/org/netbeans/modules/lsp/client/Utils.java
   +++ b/ide/lsp.client/src/org/netbeans/modules/lsp/client/Utils.java
   @@ -195,7 +195,9 @@
                if (cmd.isLeft()) {
                    command = cmd.getLeft();
                } else {
   -                Utils.applyWorkspaceEdit(cmd.getRight().getEdit());
   +                if(cmd.getRight().getEdit() != null) {
   +                    Utils.applyWorkspaceEdit(cmd.getRight().getEdit());
   +                }
                    command = cmd.getRight().getCommand();
                }
                if (command != null) {
   ```
   
   But then it becomes more interesting: the typescript server sends a request to the IDE `_typescript.rename`. The IDE logs that as unsupported and the typescript server then sends an error notification, that the IDE does not support the request. This needs more work and maybe tie in from the typescript plugin in NetBeans itself.


-- 
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] matthiasblaesing commented on issue #4034: LSP/TypeScript: NPE when trying to generate getter

Posted by GitBox <gi...@apache.org>.
matthiasblaesing commented on issue #4034:
URL: https://github.com/apache/netbeans/issues/4034#issuecomment-1112569711

   Ok - I pushed a PR, that holds a partial fix:  https://github.com/apache/netbeans/pull/4049
   
   Here is a development build from that branch:
   
   https://doppel-helix.eu/NetBeans-dev-dev-de5beb43947a575c5c77eafca7945dda59dff8d0-release.zip
   
   It does not handle the "_typescript.rename" request, but it turns the exception into a log entry with payload, which makes this a usable case in my eyes. In the long run we most probably need to enable language specific plugins to handle these cases, but that is a problem not to be fixed directly before a release.


-- 
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] matthiasblaesing commented on issue #4034: LSP/TypeScript: NPE when trying to generate getter

Posted by GitBox <gi...@apache.org>.
matthiasblaesing commented on issue #4034:
URL: https://github.com/apache/netbeans/issues/4034#issuecomment-1113479086

   > Exactly, that is also what I got from someone. The LSP is in general, as generic as possible but everyone makes their own soup. 
   
   In this case the problem is totally unnecessary. The request is obviously not core LSP, so the LSP server should make sure, that the client can understand the request, which it does not and errors. Contrary to the following error, the full rename works correctly and all is good (apart from the exception being raised).
   


-- 
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] matthiasblaesing commented on issue #4034: LSP/TypeScript: NPE when trying to generate getter

Posted by GitBox <gi...@apache.org>.
matthiasblaesing commented on issue #4034:
URL: https://github.com/apache/netbeans/issues/4034#issuecomment-1111381799

   Please provide detailed steps to reproduce. If necessary provide a sample project. I can explain the problem, but I can not reproduce.


-- 
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] negora commented on issue #4034: LSP/TypeScript: NPE when trying to generate getter

Posted by GitBox <gi...@apache.org>.
negora commented on issue #4034:
URL: https://github.com/apache/netbeans/issues/4034#issuecomment-1112505894

   @matthiasblaesing
   
   > But then it becomes more interesting: the typescript server sends a request to the IDE _typescript.rename.
   
   I guess that's because the server wants the `age` field to be renamed, so that the field and the getter names don't clash. At least that's what happens in other editors such as VS Code and Eclipse. In them, `age` would be renamed to `_age` automatically.


-- 
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] Chris2011 commented on issue #4034: LSP/TypeScript: NPE when trying to generate getter

Posted by GitBox <gi...@apache.org>.
Chris2011 commented on issue #4034:
URL: https://github.com/apache/netbeans/issues/4034#issuecomment-1112950975

   Exactly, that is also what I got from someone. The LSP is in general, as generic as possible but everyone makes their own soup. So maybe the base is there but the rest is made customized. That's what I think. But maybe we should switch this to an discussion topic :)


-- 
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] negora commented on issue #4034: LSP/TypeScript: NPE when trying to generate getter

Posted by GitBox <gi...@apache.org>.
negora commented on issue #4034:
URL: https://github.com/apache/netbeans/issues/4034#issuecomment-1112299413

   @matthiasblaesing Here is a very simple HTML5/JavaScript project reflecting the example of my first message: [HTML5Application.zip](https://github.com/apache/netbeans/files/8583731/HTML5Application.zip)
   
   Here the bulb's menu that I click on:
   
   ![image](https://user-images.githubusercontent.com/2098654/165779298-dababefb-1253-4680-bec3-d1c49e168519.png)
   
   And here is the exception in the *Notifications* panel:
   
   ![image](https://user-images.githubusercontent.com/2098654/165779054-86535774-53e2-4c0f-bd99-54a8e152580c.png)
   
   All my tests have been made with a clean user profile, by deleting the `$HOME/.netbeans/14-rc1` directory (or whichever the version I use in that moment).
   
   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] Chris2011 commented on issue #4034: LSP/TypeScript: NPE when trying to generate getter

Posted by GitBox <gi...@apache.org>.
Chris2011 commented on issue #4034:
URL: https://github.com/apache/netbeans/issues/4034#issuecomment-1111472995

   When my cursor is right after the "g" in "age" and I hit Alt + Enter, I also got a NPE but w/o the message that you have:
   
   ```
   java.lang.NullPointerException
   	at org.netbeans.modules.lsp.client.Utils.applyWorkspaceEdit(Utils.java:94)
   	at org.netbeans.modules.lsp.client.Utils.applyCodeAction(Utils.java:198)
   	at org.netbeans.modules.lsp.client.bindings.LanguageClientImpl$DiagnosticFixList$CommandBasedFix.implement(LanguageClientImpl.java:299)
   [catch] at org.netbeans.modules.editor.hints.HintsUI$1.run(HintsUI.java:810)
   	at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1418)
   	at org.netbeans.modules.openide.util.GlobalLookup.execute(GlobalLookup.java:45)
   	at org.openide.util.lookup.Lookups.executeWith(Lookups.java:278)
   	at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:2033)
   
   ```
   
   but it seems the same.


-- 
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] negora commented on issue #4034: LSP/TypeScript: NPE when trying to generate getter

Posted by GitBox <gi...@apache.org>.
negora commented on issue #4034:
URL: https://github.com/apache/netbeans/issues/4034#issuecomment-1112670029

   >Here is a development build from that branch:
   
   I'll test that build as soon as possible. Thank you!
   
   > In the long run we most probably need to enable language specific plugins to handle these cases, but that is a problem not to be fixed directly before a release.
   
   For some time I've been wondering if it would be possible to create an universal LSP client (I've read little about this protocol). But this issue has clarified my doubt: I guess that some languages have certain constructions that need a special treatment.
   


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