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/03/01 20:24:38 UTC

[GitHub] [netbeans] matthiasblaesing opened a new pull request #1996: Only register LSP based formatting if MimePath has language server

matthiasblaesing opened a new pull request #1996: Only register LSP based formatting if MimePath has language server
URL: https://github.com/apache/netbeans/pull/1996
 
 
   It was observed that XML formatting did not work after enabling LSP
   formatting. The problem was caused by the MimeLookup for application/xml
   that returned two ReformatTask.Factory implementations. One was the
   right factory, the other the Formatter provided by the LSP Client
   module.
   
   Instead of registering the ReformatTask.Factory of the LSP client module
   on the empty mime path, it is now dynamically registered by a
   MimeDataProvider (LspMimeDataProvider). That MimeDataProvider ensures
   that the lsp based formatter is only registered if a
   LanguageServerProvider is present on the targetted mime path.
   
   As an implementation note the LspMimeDataProvider is registered with a
   position, which ensures, that it is registered with higher priority than
   LegacyFormattersProvider which unconditionally registers a formatter.
   Having a higher priority (any position has higher priority than no
   position) ensures LspMimeDataProvider is queried first.

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


With regards,
Apache Git Services

---------------------------------------------------------------------
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 #1996: Only register LSP based formatting if MimePath has language server

Posted by GitBox <gi...@apache.org>.
matthiasblaesing commented on issue #1996: Only register LSP based formatting if MimePath has language server
URL: https://github.com/apache/netbeans/pull/1996#issuecomment-593141139
 
 
   @jlahoda could you please have a look at this? I noticed that after merging the lsp formatting patch my nightly build no longer supports formatting XML files. I suspect that other file types are affected too. The approach I chose might also be interesting for other cases where services should not be registered on the empty mime path.

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


With regards,
Apache Git Services

---------------------------------------------------------------------
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 merged pull request #1996: Only register LSP based formatting if MimePath has language server

Posted by GitBox <gi...@apache.org>.
matthiasblaesing merged pull request #1996: Only register LSP based formatting if MimePath has language server
URL: https://github.com/apache/netbeans/pull/1996
 
 
   

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


With regards,
Apache Git Services

---------------------------------------------------------------------
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 #1996: Only register LSP based formatting if MimePath has language server

Posted by GitBox <gi...@apache.org>.
matthiasblaesing commented on issue #1996: Only register LSP based formatting if MimePath has language server
URL: https://github.com/apache/netbeans/pull/1996#issuecomment-595429051
 
 
   Thank you both for checking - merged with updated format.

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


With regards,
Apache Git Services

---------------------------------------------------------------------
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 change in pull request #1996: Only register LSP based formatting if MimePath has language server

Posted by GitBox <gi...@apache.org>.
junichi11 commented on a change in pull request #1996: Only register LSP based formatting if MimePath has language server
URL: https://github.com/apache/netbeans/pull/1996#discussion_r387991446
 
 

 ##########
 File path: ide/lsp.client/src/org/netbeans/modules/lsp/client/bindings/Formatter.java
 ##########
 @@ -47,12 +45,18 @@
 
     private static final Logger LOG = Logger.getLogger(Formatter.class.getName());
 
-    @MimeRegistration(mimeType = "", service = ReformatTask.Factory.class)
     public static class Factory implements ReformatTask.Factory {
 
         @Override
         public ReformatTask createTask(Context context) {
-            return new Formatter(context);
+            FileObject file = NbEditorUtilities.getFileObject(context.document());
+            if (file != null) {
+                LSPBindings bindings = LSPBindings.getBindings(file);
+                if(bindings != null) {
 
 Review comment:
   Nitpick: missing whitespace after `if`

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


With regards,
Apache Git Services

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