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 2019/09/27 06:09:39 UTC

[GitHub] [netbeans] jlahoda commented on a change in pull request #1508: Improving code completion appearance for both LSP client and Java LSP…

jlahoda commented on a change in pull request #1508: Improving code completion appearance for both LSP client and Java LSP…
URL: https://github.com/apache/netbeans/pull/1508#discussion_r328924761
 
 

 ##########
 File path: ide/lsp.client/src/org/netbeans/modules/lsp/client/bindings/CompletionProviderImpl.java
 ##########
 @@ -226,36 +223,66 @@ public void render(Graphics grphcs, Font font, Color color, Color color1, int i,
 
                             @Override
                             public CompletionTask createDocumentationTask() {
-                                return new CompletionTask() {
+                                return new AsyncCompletionTask(new AsyncCompletionQuery() {
                                     @Override
-                                    public void query(CompletionResultSet resultSet) {
-                                        resultSet.setDocumentation(new CompletionDocumentation() {
-                                            @Override
-                                            public String getText() {
-                                                return documentation;
-                                            }
-                                            @Override
-                                            public URL getURL() {
-                                                return null;
-                                            }
-                                            @Override
-                                            public CompletionDocumentation resolveLink(String link) {
-                                                return null;
+                                    protected void query(CompletionResultSet resultSet, Document doc, int caretOffset) {
+                                        CompletionItem resolved;
+                                        if ((i.getDetail() == null || i.getDocumentation() == null) && hasCompletionResolve(server)) {
+                                            CompletionItem temp;
+                                            try {
+                                                temp = server.getTextDocumentService().resolveCompletionItem(i).get();
+                                            } catch (InterruptedException | ExecutionException ex) {
+                                                Exceptions.printStackTrace(ex);
+                                                temp = i;
                                             }
-                                            @Override
-                                            public Action getGotoSourceAction() {
-                                                return null;
-                                            }
-                                        });
+                                            resolved = temp;
+                                        } else {
+                                            resolved = i;
+                                        }
+                                        if (resolved.getDocumentation() != null || resolved.getDetail() != null) {
+                                            resultSet.setDocumentation(new CompletionDocumentation() {
+                                                @Override
+                                                public String getText() {
+                                                    StringBuilder documentation = new StringBuilder();
+                                                    documentation.append("<html>\n");
+                                                    if (resolved.getDetail() != null) {
+                                                        documentation.append("<b>").append(escape(resolved.getDetail())).append("</b>");
+                                                        documentation.append("\n<p>");
+                                                    }
+                                                    if (resolved.getDocumentation() != null) {
+                                                        MarkupContent content;
+                                                        if (resolved.getDocumentation().isLeft()) {
+                                                            content = new MarkupContent();
+                                                            content.setKind("plaintext");
+                                                            content.setValue(resolved.getDocumentation().getLeft());
+                                                        } else {
+                                                            content = resolved.getDocumentation().getRight();
+                                                        }
+                                                        switch (content.getKind()) {
+                                                            case "markdown":
+                                                            default:
+                                                            case "plaintext": documentation.append("<pre>\n").append(content.getValue()).append("\n</pre>"); break;
 
 Review comment:
   (I apologize for a late reply.) Yes, intentional for now. I have a an update for this, which actually converts the markdown to HTML (so that it can be shown nicely in the HTML pane), and also that converts the HTML to markdown for the server, but this involves a new external library, and it felt a little late in the release cycle to do that, so I opted for this simpler thing. The markdown should be still readable, and for the next release, it is really a few lines of changes here to do the conversion.

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