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 2021/05/13 15:23:49 UTC

[GitHub] [netbeans] dbalek opened a new pull request #2955: LSP: Provide hover information in Micronaut yaml files.

dbalek opened a new pull request #2955:
URL: https://github.com/apache/netbeans/pull/2955


   - `Hover` and `HoverProvider` introduced that allow to resolve a hover information at a given document offset and return its content vial LSP
   - Implementations for Java and Micronaut config Yaml files provided 


-- 
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] JaroslavTulach commented on a change in pull request #2955: LSP: Provide hover information in Micronaut yaml files.

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



##########
File path: ide/api.lsp/src/org/netbeans/spi/lsp/HoverProvider.java
##########
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.spi.lsp;
+
+import java.util.concurrent.CompletableFuture;
+import javax.swing.text.Document;
+import org.netbeans.api.annotations.common.NonNull;
+import org.netbeans.spi.editor.mimelookup.MimeLocation;
+
+/**
+ * Interface for resolving hover information at a given document position.
+ * Implementations of the interface should be registered in MimeLookup.
+ * <pre>
+ *
+ *  {@code @MimeRegistration(mimeType = "text/foo", service = HoverProvider.class)

Review comment:
       Why it is not used in `HoverProvider`?




-- 
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] JaroslavTulach commented on a change in pull request #2955: LSP: Provide hover information in Micronaut yaml files.

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



##########
File path: ide/api.lsp/src/org/netbeans/spi/lsp/HoverProvider.java
##########
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.spi.lsp;
+
+import java.util.concurrent.CompletableFuture;
+import javax.swing.text.Document;
+import org.netbeans.api.annotations.common.NonNull;
+import org.netbeans.spi.editor.mimelookup.MimeLocation;
+
+/**
+ * Interface for resolving hover information at a given document position.
+ * Implementations of the interface should be registered in MimeLookup.
+ * <pre>
+ *
+ *  {@code @MimeRegistration(mimeType = "text/foo", service = HoverProvider.class)

Review comment:
        Can you please use `{@codesnippet}`? Also update other examples to use the tag? See [codesnippet4javadoc](https://github.com/jtulach/codesnippet4javadoc).

##########
File path: ide/api.lsp/apichanges.xml
##########
@@ -47,6 +47,21 @@
 <!-- ACTUAL CHANGES BEGIN HERE: -->
 
 <changes>
+    <change id="HoverProvider">
+        <api name="LSP_API"/>
+        <summary>Adding Hover and HoverProvider</summary>
+        <version major="1" minor="2"/>
+        <date day="13" month="5" year="2021"/>
+        <author login="dbalek"/>
+        <compatibility binary="compatible" source="compatible" addition="yes" deletion="no"/>
+        <description>
+            A <code>Hover</code> class and <code>HoverProvider</code> interface introduced
+            that allows to resolve a hover information at a given document offset and
+            return its content.
+        </description>
+        <class package="org.netbeans.api.lsp" name="Hover"/>
+        <class package="org.netbeans.spi.lsp" name="HoverProvider"/>
+    </change>
     <change id="HyperlinkTypeDefLocationProvider">

Review comment:
       Is there an `arch.xml` document? It has to be and it should define one `<api type="export" group="stable"/>` to make the Javadoc mention proper stability on its background.

##########
File path: ide/api.lsp/apichanges.xml
##########
@@ -47,6 +47,21 @@
 <!-- ACTUAL CHANGES BEGIN HERE: -->
 
 <changes>
+    <change id="HoverProvider">

Review comment:
       I don't see any `api.lsp` Javadoc at https://bits.netbeans.org/dev/javadoc/




-- 
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] dbalek commented on a change in pull request #2955: LSP: Provide hover information in Micronaut yaml files.

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



##########
File path: java/java.sourceui/src/org/netbeans/api/java/source/ui/ElementJavadoc.java
##########
@@ -371,26 +371,29 @@ private ElementJavadoc(CompilationInfo compilationInfo, Element element, final U
                 computeDocURL(Collections.emptyList(), true, cancel);
                 doc = header.append(noJavadocFound());
             }
-            this.content = new Now(doc.toString());
+            this.content = CompletableFuture.completedFuture(doc.toString());
         } catch (JavadocHelper.RemoteJavadocException re) {
             if (fileObject == null || JavaSource.forFileObject(fileObject) == null) {
                 header.append(noJavadocFound());
-                this.content = new Now(header.toString());
+                this.content = CompletableFuture.completedFuture(header.toString());
                 return;
             }
-            this.content = new FutureTask<>(() -> {
-                final JavaSourceUtil.Handle ch = JavaSourceUtil.createControllerHandle(fileObject, null);
-                final CompilationController c = (CompilationController) ch.getCompilationController();
-                c.toPhase(Phase.RESOLVED);
-                final Element el = handle.resolve(c);
-                CharSequence doc = getElementDoc(el, c, header, url, false);
-                if (doc == null) {
-                    computeDocURL(Collections.emptyList(), false, cancel);
-                    doc = header.append(noJavadocFound());
+            this.content = CompletableFuture.supplyAsync(() -> {
+                try {
+                    final JavaSourceUtil.Handle ch = JavaSourceUtil.createControllerHandle(fileObject, null);
+                    final CompilationController c = (CompilationController) ch.getCompilationController();
+                    c.toPhase(Phase.RESOLVED);
+                    final Element el = handle.resolve(c);
+                    CharSequence doc = getElementDoc(el, c, header, url, false);
+                    if (doc == null) {
+                        computeDocURL(Collections.emptyList(), false, cancel);
+                        doc = header.append(noJavadocFound());
+                    }
+                    return doc.toString();
+                } catch (Exception ex) {
+                    return null;

Review comment:
       Fixed.




-- 
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] dbalek commented on a change in pull request #2955: LSP: Provide hover information in Micronaut yaml files.

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



##########
File path: ide/api.lsp/apichanges.xml
##########
@@ -47,6 +47,21 @@
 <!-- ACTUAL CHANGES BEGIN HERE: -->
 
 <changes>
+    <change id="HoverProvider">
+        <api name="LSP_API"/>
+        <summary>Adding Hover and HoverProvider</summary>
+        <version major="1" minor="2"/>
+        <date day="13" month="5" year="2021"/>
+        <author login="dbalek"/>
+        <compatibility binary="compatible" source="compatible" addition="yes" deletion="no"/>
+        <description>
+            A <code>Hover</code> class and <code>HoverProvider</code> interface introduced
+            that allows to resolve a hover information at a given document offset and
+            return its content.
+        </description>
+        <class package="org.netbeans.api.lsp" name="Hover"/>
+        <class package="org.netbeans.spi.lsp" name="HoverProvider"/>
+    </change>
     <change id="HyperlinkTypeDefLocationProvider">

Review comment:
       `arch.xml` document added.




-- 
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] dbalek merged pull request #2955: LSP: Provide hover information in Micronaut yaml files.

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


   


-- 
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] dbalek commented on a change in pull request #2955: LSP: Provide hover information in Micronaut yaml files.

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



##########
File path: ide/api.lsp/src/org/netbeans/spi/lsp/HoverProvider.java
##########
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.spi.lsp;
+
+import java.util.concurrent.CompletableFuture;
+import javax.swing.text.Document;
+import org.netbeans.api.annotations.common.NonNull;
+import org.netbeans.spi.editor.mimelookup.MimeLocation;
+
+/**
+ * Interface for resolving hover information at a given document position.
+ * Implementations of the interface should be registered in MimeLookup.
+ * <pre>
+ *
+ *  {@code @MimeRegistration(mimeType = "text/foo", service = HoverProvider.class)

Review comment:
       `{@codesnippet}` used in `Hover.getContent`,  `HyperlinkLocation.resolve`, and `HyperlinkLocation.resolveTypeDefinition` documentation.




-- 
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 #2955: LSP: Provide hover information in Micronaut yaml files.

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



##########
File path: java/java.sourceui/src/org/netbeans/api/java/source/ui/ElementJavadoc.java
##########
@@ -371,26 +371,29 @@ private ElementJavadoc(CompilationInfo compilationInfo, Element element, final U
                 computeDocURL(Collections.emptyList(), true, cancel);
                 doc = header.append(noJavadocFound());
             }
-            this.content = new Now(doc.toString());
+            this.content = CompletableFuture.completedFuture(doc.toString());
         } catch (JavadocHelper.RemoteJavadocException re) {
             if (fileObject == null || JavaSource.forFileObject(fileObject) == null) {
                 header.append(noJavadocFound());
-                this.content = new Now(header.toString());
+                this.content = CompletableFuture.completedFuture(header.toString());
                 return;
             }
-            this.content = new FutureTask<>(() -> {
-                final JavaSourceUtil.Handle ch = JavaSourceUtil.createControllerHandle(fileObject, null);
-                final CompilationController c = (CompilationController) ch.getCompilationController();
-                c.toPhase(Phase.RESOLVED);
-                final Element el = handle.resolve(c);
-                CharSequence doc = getElementDoc(el, c, header, url, false);
-                if (doc == null) {
-                    computeDocURL(Collections.emptyList(), false, cancel);
-                    doc = header.append(noJavadocFound());
+            this.content = CompletableFuture.supplyAsync(() -> {
+                try {
+                    final JavaSourceUtil.Handle ch = JavaSourceUtil.createControllerHandle(fileObject, null);
+                    final CompilationController c = (CompilationController) ch.getCompilationController();
+                    c.toPhase(Phase.RESOLVED);
+                    final Element el = handle.resolve(c);
+                    CharSequence doc = getElementDoc(el, c, header, url, false);
+                    if (doc == null) {
+                        computeDocURL(Collections.emptyList(), false, cancel);
+                        doc = header.append(noJavadocFound());
+                    }
+                    return doc.toString();
+                } catch (Exception ex) {
+                    return null;

Review comment:
       Maybe log the exception ?




-- 
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] dbalek commented on a change in pull request #2955: LSP: Provide hover information in Micronaut yaml files.

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



##########
File path: ide/api.lsp/apichanges.xml
##########
@@ -47,6 +47,21 @@
 <!-- ACTUAL CHANGES BEGIN HERE: -->
 
 <changes>
+    <change id="HoverProvider">

Review comment:
       Javadoc added.




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