sdedic commented on a change in pull request #3349: URL: https://github.com/apache/netbeans/pull/3349#discussion_r764646612
########## File path: java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/ui/AbstractLspHtmlViewer.java ########## @@ -0,0 +1,150 @@ +/* + * 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.modules.java.lsp.server.ui; + +import java.net.URL; +import java.util.concurrent.Callable; +import java.util.function.Consumer; +import net.java.html.js.JavaScriptBody; +import org.netbeans.modules.java.lsp.server.htmlui.Browser; +import org.netbeans.modules.java.lsp.server.protocol.HtmlPageParams; +import org.netbeans.spi.htmlui.HtmlViewer; +import org.openide.util.Exceptions; + +public class AbstractLspHtmlViewer implements HtmlViewer<AbstractLspHtmlViewer.View> { + protected AbstractLspHtmlViewer() { + } + + @Override + public View newView(Consumer<String> lifeCycleCallback) { + UIContext ui = UIContext.find(); + return new View(ui, lifeCycleCallback); + } + + @Override + public void makeVisible(View view, Runnable whenReady) { + whenReady.run(); + } + + @Override + public void load(View view, ClassLoader loader, URL pageUrl, Callable<Object> initialize, String[] techIds) { + view.load(pageUrl, initialize); + } + + @JavaScriptBody(args = {}, body = "\n" + + "const vscode = acquireVsCodeApi();\n" // this method can be called only once per WebView existance Review comment: @JaroslavTulach I am not sure that I understand the question: The LSP client declares its capabilities - see https://github.com/apache/netbeans/blob/master/java/java.lsp.server/vscode/src/extension.ts#L628 ; in this case, the client should probably sent something like `"org.netbeans.html.HtmlViewerCapable" : true` which could be checked by the LSP server. The NB LSP server already checks for stuff like `statusBarMessageSupport` and degrades the implementation if the capability is not present. -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected] For further information about the NetBeans mailing lists, visit: https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
