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/12/01 17:00:51 UTC
[GitHub] [netbeans] JaroslavTulach opened a new pull request #3349: Rich HTML UI for (now only for) VSCode Refactorings
JaroslavTulach opened a new pull request #3349:
URL: https://github.com/apache/netbeans/pull/3349
This PR contains all the prototyping work we (Jirka Sedláček, Dušan Bálek and me) have done to make sure Rich UI for _Change Parameters Refactoring_ can be demonstrated. By default VSCode UI follows principles of asceticism and is very simplistic and straightforward. It is possible to use `WebView` for more complex UIs, but:
- it's always preferable to not do that
- coding HTML in Java might not seem easy
Anyway we really need it for the refactoring and we made it. Here is the result:

My goal is to get this into January version of NetBeans (its VSCode extension). That requires fixes in HTML/Java API, some API fixes in NetBeans itself and then implementation of the refactoring. Those are likely going to be done in a separate PRs and possibly this one will remain unmerged - however I wanted to demonstrate the whole picture here. Comments, questions, discussion is welcomed.
--
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] JaroslavTulach commented on a change in pull request #3349: Rich HTML UI for (now only for) VSCode Refactorings
Posted by GitBox <gi...@apache.org>.
JaroslavTulach commented on a change in pull request #3349:
URL: https://github.com/apache/netbeans/pull/3349#discussion_r765437662
##########
File path: java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/htmlui/Browser.java
##########
@@ -0,0 +1,741 @@
+/**
+ * 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.htmlui;
+
+import java.io.Closeable;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.Flushable;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.io.Reader;
+import java.io.Writer;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.net.URLConnection;
+import java.net.URLDecoder;
+import java.nio.file.Files;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Queue;
+import java.util.Random;
+import java.util.UUID;
+import java.util.concurrent.Executor;
+import java.util.function.Consumer;
+import java.util.function.Supplier;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import org.netbeans.html.boot.spi.Fn;
+import org.netbeans.html.boot.spi.Fn.Presenter;
+import org.netbeans.html.presenters.spi.ProtoPresenter;
+import org.netbeans.html.presenters.spi.ProtoPresenterBuilder;
+
+/** Browser based {@link Presenter}. It starts local server and
+ * launches browser that connects to it. Use {@link Browser.Config} to
+ * configure the actual browser to be started.
+ * <p>
+ * To use this presenter specify following dependency:
+ * <pre>
+ * <dependency>
+ * <groupId>org.netbeans.html.browser</groupId>
+ * <artifactId>browser</artifactId>
+ * <version><a target="blank" href="http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22com.dukescript.presenters%22%20AND%20a%3A%22browser%22">1.x</a></version>
+ * </dependency>
+ * </pre>
+ */
+public final class Browser implements Fn.Presenter, Fn.KeepAlive, Flushable,
+Executor, Closeable {
+ static final Logger LOG = Logger.getLogger(Browser.class.getName());
+ private final Map<String,Command> SESSIONS = new HashMap<>();
+ private final String app;
+ private HttpServer server;
+ private Runnable onPageLoad;
+ private Command current;
+ private final Config config;
+ private final Supplier<HttpServer<?, ?, ?, ?>> serverProvider;
+
+ /** Default constructor. Reads configuration from properties. The actual browser to
+ * be launched can be influenced by value of
+ * <code>com.dukescript.presenters.browser</code> property.
+ * It can have following values:
+ * <ul>
+ * <li><b>GTK</b> - use Gtk WebKit implementation. Requires presence of
+ * appropriate native libraries</li>
+ * <li><b>AWT</b> - use {@link java.awt.Desktop#browse(java.net.URI)} to
+ * launch a browser</li>
+ * <li><b>NONE</b> - just launches the server, useful together with
+ * <code>com.dukescript.presenters.browserPort</code> property that
+ * can specify a fixed port to open the server at
+ * </li>
+ * <li>any other value is interpreted as a command which is then
+ * launched on a command line with one parameter - the URL to connect to</li>
+ * </ul>
+ * If the property is not specified the system tries <b>GTK</b> mode first,
+ * followed by <b>AWT</b> and then tries to execute <code>xdg-open</code>
+ * (default LINUX command to launch a browser from a shell script).
+ * <p>
+ * In addition to the above properties, it is possible to also enable
+ * debugging by setting <code>com.dukescript.presenters.browserDebug=true</code>.
+ *
+ * @throws Exception
+ */
+ public Browser() {
+ this(new Config());
+ }
+
+ /**
+ * Browser configured by provided config.
+ *
+ * @param config the configuration
+ */
+ public Browser(Config config) {
+ this(findCalleeClassName(), config, null);
+ }
+
+ Browser(String app, Config config, Supplier<HttpServer<?,?,?, ?>> serverProvider) {
+ this.serverProvider = serverProvider != null ? serverProvider : () -> {
+ return new SimpleServer(config.random);
+ };
+ this.app = app;
+ this.config = new Config(config);
+ }
+
+ @Override
+ public final void execute(final Runnable r) {
+ current.execute(r);
+ }
+
+ @Override
+ public void close() throws IOException {
+ if (server != null) {
+ server.shutdownNow();
+ }
+ }
+
+ HttpServer server() {
+ return server;
+ }
+
+ static HttpServer findServer(Object obj) {
+ Command c;
+ if (obj instanceof Command) {
+ c = (Command) obj;
+ } else if (obj instanceof ProtoPresenter) {
+ c = ((ProtoPresenter) obj).lookup(Command.class);
+ } else {
+ throw new IllegalArgumentException("Cannot find server for " + obj);
+ }
+ return c.browser.server();
+ }
+
+ /** Shows URL in a browser.
+ * @param page the page to display in the browser
+ * @throws IOException if something goes wrong
+ */
+ void show(URI page) throws IOException {
+ config.getBrowser().accept(page);
+ }
+ @Override
+ public Fn defineFn(String string, String... strings) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void loadScript(Reader reader) throws Exception {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public Fn defineFn(String string, String[] strings, boolean[] blns) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void flush() throws IOException {
+ throw new UnsupportedOperationException();
+ }
+
+ private static URI pageURL(String protocol, HttpServer server, final String page) {
+ int port = server.getPort();
+ try {
+ return new URI(protocol + "://localhost:" + port + page);
+ } catch (URISyntaxException ex) {
+ throw new IllegalStateException(ex);
+ }
+ }
+
+ @Override
+ public final void displayPage(URL page, Runnable onPageLoad) {
+ try {
+ this.onPageLoad = onPageLoad;
+ this.server = serverProvider.get();
+ int from = 8080;
+ int to = 65535;
+ int port = config.getPort();
+ if (port != -1) {
+ from = to = port;
+ }
+ server.init(from, to);
+
+ String prefix = "/" + new UUID(config.random.nextLong(), config.random.nextLong()).toString();
+
Review comment:
a65a7de synchronizes the `SimpleServer` class with https://github.com/apache/netbeans-html4j/pull/26/commits/9bc1429686ea37037bba33d9d3a8123ae9ff1148
--
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] JaroslavTulach commented on a change in pull request #3349: Rich HTML UI for (now only for) VSCode Refactorings
Posted by GitBox <gi...@apache.org>.
JaroslavTulach commented on a change in pull request #3349:
URL: https://github.com/apache/netbeans/pull/3349#discussion_r760398629
##########
File path: java/java.lsp.server/vscode/src/extension.ts
##########
@@ -675,6 +676,53 @@ function doActivateWithJDK(specifiedJDK: string | null, context: ExtensionContex
window.showErrorMessage('Error initializing ' + reason);
});
+ async function showHtmlPage(params : HtmlPageParams): Promise<string> {
Review comment:
When there is a need to show the UI, the JVM opens a port (unsecured right now) with a simplistic HTTP server ands sends a LSP request to show a page where it passes the URL to show. The request is handled in this VSCode extension and opens a `WebView` that connects to the HTTP port and makes the page "live" and controllable from a Java code.
--
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 a change in pull request #3349: Rich HTML UI for (now only for) VSCode Refactorings
Posted by GitBox <gi...@apache.org>.
matthiasblaesing commented on a change in pull request #3349:
URL: https://github.com/apache/netbeans/pull/3349#discussion_r762586023
##########
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:
What I see is, that refactoring is in no way specific to a Java LSP and looking at:
https://microsoft.github.io/language-server-protocol/specification#textDocument_codeAction
https://microsoft.github.io/language-server-protocol/specifications/specification-3-17/#codeActionKind
I think this is a known problem and the protocol is beginning to build up support for it. I'm in no way an export on LSP, but I doubt, that it is sensisble, if such a generic functionality (refactorings) is reimplemented by each provider and even worse by each client.
--
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] JaroslavTulach commented on a change in pull request #3349: Rich HTML UI for (now only for) VSCode Refactorings
Posted by GitBox <gi...@apache.org>.
JaroslavTulach commented on a change in pull request #3349:
URL: https://github.com/apache/netbeans/pull/3349#discussion_r765412770
##########
File path: platform/api.htmlui/src/org/netbeans/modules/htmlui/HTMLDialogBase.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.modules.htmlui;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+public abstract class HTMLDialogBase {
Review comment:
No longer true. The most recent changes in #3357 use just a single implementation for all `HTMLViewerSpi`s.
--
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] JaroslavTulach commented on a change in pull request #3349: Rich HTML UI for (now only for) VSCode Refactorings
Posted by GitBox <gi...@apache.org>.
JaroslavTulach commented on a change in pull request #3349:
URL: https://github.com/apache/netbeans/pull/3349#discussion_r765412564
##########
File path: platform/api.htmlui/src/org/netbeans/spi/htmlui/HtmlViewer.java
##########
@@ -0,0 +1,35 @@
+/*
+ * 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.htmlui;
+
+import java.net.URL;
+import java.util.concurrent.Callable;
+import java.util.function.Consumer;
+
+/**
+ *
+ * @param <HtmlView>
+ * @since 1.21
+ */
+public interface HtmlViewer<HtmlView> {
Review comment:
Integrated by #3357
--
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] JaroslavTulach commented on a change in pull request #3349: Rich HTML UI for (now only for) VSCode Refactorings
Posted by GitBox <gi...@apache.org>.
JaroslavTulach commented on a change in pull request #3349:
URL: https://github.com/apache/netbeans/pull/3349#discussion_r760394214
##########
File path: java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/refactoring/ui/ChangeMethodParameters.html
##########
@@ -0,0 +1,59 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="Content-Security-Policy" content="default-src http: 'unsafe-inline' 'unsafe-eval'">
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
+ <link rel="stylesheet" href="refactoring.css">
+ <link rel="stylesheet" href="codicon.css">
Review comment:
These CSS shall ideally be provided dynamically by the "chrome".
--
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] JaroslavTulach commented on a change in pull request #3349: Rich HTML UI for (now only for) VSCode Refactorings
Posted by GitBox <gi...@apache.org>.
JaroslavTulach commented on a change in pull request #3349:
URL: https://github.com/apache/netbeans/pull/3349#discussion_r760403164
##########
File path: platform/api.htmlui/src/org/netbeans/modules/htmlui/HTMLDialogBase.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.modules.htmlui;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+public abstract class HTMLDialogBase {
Review comment:
The HTMLUI API module no longer requires JavaFX - it can work with different displayers - like the one provided by VSCode. To do that I had to abstract the `HTMLDialogBase` common functionality and provide two implementations - one for Swing (and JavaFX) and one for VSCode.
--
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] JaroslavTulach commented on a change in pull request #3349: Rich HTML UI for (now only for) VSCode Refactorings
Posted by GitBox <gi...@apache.org>.
JaroslavTulach commented on a change in pull request #3349:
URL: https://github.com/apache/netbeans/pull/3349#discussion_r765412224
##########
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:
Done in 7875578. Introducing `showHtmlPageSupport` capability. If it is missing, no dialog is shown and only a warning message is shown to the user.
--
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] JaroslavTulach commented on pull request #3349: Rich HTML UI for (now only for) VSCode Refactorings
Posted by GitBox <gi...@apache.org>.
JaroslavTulach commented on pull request #3349:
URL: https://github.com/apache/netbeans/pull/3349#issuecomment-989636780
Opps, I wanted to create a new PR, but instead I integrated 9e27e191c829978a9dbdcdaeee774d4208412348 into `master`. I made a mistake and forget to create new branch before push. I am sorry.
We don't have a way to remove commit from `master` (as far as I know). Rather than rolling back, I suggest to keep it and possibly polish it in the final PR I am about to create now. Sorry for the mess.
--
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] JaroslavTulach commented on a change in pull request #3349: Rich HTML UI for (now only for) VSCode Refactorings
Posted by GitBox <gi...@apache.org>.
JaroslavTulach commented on a change in pull request #3349:
URL: https://github.com/apache/netbeans/pull/3349#discussion_r762580276
##########
File path: java/libs.javacapi/external/binaries-list
##########
@@ -15,3 +15,4 @@
# specific language governing permissions and limitations
# under the License.
B195FD4F74CA4BA8BF5985E9103B96C6F0D9079D com.dukescript.nbjavac:nb-javac:jdk-17+35:api
+E748E597EACD349D65869A26FCB99A8B4DF887C2 com.dukescript.nbjavac:nb-javac:jdk-17+35
Review comment:
No, this PR has been worked on for a long time. However Dušan merged latest master in and now this diff is outdated.
--
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] JaroslavTulach commented on a change in pull request #3349: Rich HTML UI for (now only for) VSCode Refactorings
Posted by GitBox <gi...@apache.org>.
JaroslavTulach commented on a change in pull request #3349:
URL: https://github.com/apache/netbeans/pull/3349#discussion_r762580365
##########
File path: nb/updatecenters/extras/nbjavac.impl/build/no-license.txt
##########
@@ -0,0 +1 @@
+[NO LICENSE SPECIFIED]
Review comment:
Done by 276330e
--
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] JaroslavTulach commented on a change in pull request #3349: Rich HTML UI for (now only for) VSCode Refactorings
Posted by GitBox <gi...@apache.org>.
JaroslavTulach commented on a change in pull request #3349:
URL: https://github.com/apache/netbeans/pull/3349#discussion_r760852436
##########
File path: java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/htmlui/HttpServer.java
##########
@@ -0,0 +1,62 @@
+/**
+ * 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.htmlui;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.Writer;
+import org.netbeans.html.boot.spi.Fn;
+
+abstract class HttpServer<Request, Response, WebSocket, Runner> {
Review comment:
This package is a 1:1 copy of code from HTML/Java APIs. It'd be better to use the API than copy, however, until https://github.com/apache/netbeans-html4j/pull/26 gets integrated, we don't have much other options than to copy.
--
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 a change in pull request #3349: Rich HTML UI for (now only for) VSCode Refactorings
Posted by GitBox <gi...@apache.org>.
matthiasblaesing commented on a change in pull request #3349:
URL: https://github.com/apache/netbeans/pull/3349#discussion_r761391317
##########
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:
Is this really LSP or is this an API hardcoded against VSCode?
##########
File path: java/libs.javacapi/external/binaries-list
##########
@@ -15,3 +15,4 @@
# specific language governing permissions and limitations
# under the License.
B195FD4F74CA4BA8BF5985E9103B96C6F0D9079D com.dukescript.nbjavac:nb-javac:jdk-17+35:api
+E748E597EACD349D65869A26FCB99A8B4DF887C2 com.dukescript.nbjavac:nb-javac:jdk-17+35
Review comment:
Was this PR not done on a recent master checkout? This change is already in master?!
##########
File path: java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/refactoring/ui/codicon.css
##########
@@ -0,0 +1,485 @@
+/*---------------------------------------------------------------------------------------------
+ * Copyright (c) Microsoft Corporation. All rights reserved.
+ * Licensed under the MIT License. See License.txt in the project root for license information.
+ *--------------------------------------------------------------------------------------------*/
Review comment:
I assume, that the ttf file is under the same license?! Please add an entry for the `codicon.ttf` to `license-info.xml`. The same is true for other font and graphics files (I see `newHTML.png`).
##########
File path: platform/generic/manifest.mf
##########
@@ -0,0 +1 @@
+OpenIDE-Module: generic
Review comment:
The name is not good.
##########
File path: nb/updatecenters/extras/nbjavac.impl/build/no-license.txt
##########
@@ -0,0 +1 @@
+[NO LICENSE SPECIFIED]
Review comment:
This confirms, that this reintroduces changes, that were already reviewed and in this case is broken. Please drop all changes relating to the nbjavac changes from this and rebase the remaining parts onto master. That should ensure, that no regressions are pulled in.
--
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] JaroslavTulach commented on a change in pull request #3349: Rich HTML UI for (now only for) VSCode Refactorings
Posted by GitBox <gi...@apache.org>.
JaroslavTulach commented on a change in pull request #3349:
URL: https://github.com/apache/netbeans/pull/3349#discussion_r760404773
##########
File path: platform/api.htmlui/src/org/netbeans/spi/htmlui/HtmlViewer.java
##########
@@ -0,0 +1,35 @@
+/*
+ * 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.htmlui;
+
+import java.net.URL;
+import java.util.concurrent.Callable;
+import java.util.function.Consumer;
+
+/**
+ *
+ * @param <HtmlView>
+ * @since 1.21
+ */
+public interface HtmlViewer<HtmlView> {
Review comment:
The new SPI between HTML UI API and the VSCode module to do the "viewing" differently.
--
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] JaroslavTulach commented on a change in pull request #3349: Rich HTML UI for (now only for) VSCode Refactorings
Posted by GitBox <gi...@apache.org>.
JaroslavTulach commented on a change in pull request #3349:
URL: https://github.com/apache/netbeans/pull/3349#discussion_r762580779
##########
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:
The `java.lsp.server` is using some extensions to the standard LSP protocol. The _rich HTML UI_ is one such extension. There is a hand-shake negotiation to find out whether the client supports these extensions. @sdedic is an expert in this area. Sváťo, please guide me to use these _capabilities_ concept properly.
--
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] JaroslavTulach commented on a change in pull request #3349: Rich HTML UI for (now only for) VSCode Refactorings
Posted by GitBox <gi...@apache.org>.
JaroslavTulach commented on a change in pull request #3349:
URL: https://github.com/apache/netbeans/pull/3349#discussion_r762816805
##########
File path: java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/refactoring/ChangeMethodParametersRefactoring.java
##########
@@ -0,0 +1,363 @@
+/*
+ * 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.refactoring;
+
+import com.google.gson.Gson;
+import com.sun.source.tree.Tree;
+import com.sun.source.util.TreePath;
+import com.sun.source.util.Trees;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Set;
+import java.util.concurrent.CompletableFuture;
+import java.util.function.BiConsumer;
+import java.util.logging.Level;
+import javax.lang.model.element.Element;
+import javax.lang.model.element.ExecutableElement;
+import javax.lang.model.element.VariableElement;
+import javax.lang.model.type.TypeKind;
+import net.java.html.json.ComputedProperty;
+import net.java.html.json.Function;
+import net.java.html.json.Model;
+import net.java.html.json.ModelOperation;
+import net.java.html.json.Property;
+import org.eclipse.lsp4j.ApplyWorkspaceEditParams;
+import org.eclipse.lsp4j.CodeAction;
+import org.eclipse.lsp4j.CodeActionKind;
+import org.eclipse.lsp4j.CodeActionParams;
+import org.eclipse.lsp4j.MessageParams;
+import org.eclipse.lsp4j.MessageType;
+import org.netbeans.api.htmlui.HTMLDialog;
+import org.netbeans.api.java.source.ClasspathInfo;
+import org.netbeans.api.java.source.CompilationController;
+import org.netbeans.api.java.source.ElementHandle;
+import org.netbeans.api.java.source.JavaSource;
+import org.netbeans.api.java.source.SourceUtils;
+import org.netbeans.api.java.source.TreePathHandle;
+import org.netbeans.modules.editor.java.Utilities;
+import org.netbeans.modules.java.lsp.server.Utils;
+import org.netbeans.modules.java.lsp.server.protocol.CodeActionsProvider;
+import org.netbeans.modules.java.lsp.server.protocol.NbCodeLanguageClient;
+import org.netbeans.modules.java.lsp.server.protocol.QuickPickItem;
+import org.netbeans.modules.parsing.api.ResultIterator;
+import org.netbeans.modules.refactoring.java.api.ChangeParametersRefactoring;
+import org.netbeans.modules.refactoring.java.api.JavaRefactoringUtils;
+import org.openide.filesystems.FileObject;
+import org.openide.util.Exceptions;
+import org.openide.util.NbBundle;
+import org.openide.util.RequestProcessor;
+import org.openide.util.lookup.ServiceProvider;
+
+/**
+ *
+ * @author Dusan Balek
+ */
+@ServiceProvider(service = CodeActionsProvider.class, position = 200)
+public final class ChangeMethodParametersRefactoring extends CodeRefactoring {
+
+ private static final String CHANGE_METHOD_PARAMS_REFACTORING_KIND = "refactor.change.method.params";
+ private static final String CHANGE_METHOD_PARAMS_REFACTORING_COMMAND = "java.refactor.change.method.params";
+
+ private final Set<String> commands = Collections.singleton(CHANGE_METHOD_PARAMS_REFACTORING_COMMAND);
+ private final Gson gson = new Gson();
+
+ @Override
+ @NbBundle.Messages({
+ "DN_ChangeMethodParams=Change Method Parameters...",
+ })
+ public List<CodeAction> getCodeActions(ResultIterator resultIterator, CodeActionParams params) throws Exception {
+ List<String> only = params.getContext().getOnly();
+ if (only == null || !only.contains(CodeActionKind.Refactor)) {
+ return Collections.emptyList();
+ }
+ CompilationController info = CompilationController.get(resultIterator.getParserResult());
+ if (info == null || !JavaRefactoringUtils.isRefactorable(info.getFileObject())) {
+ return Collections.emptyList();
+ }
+ info.toPhase(JavaSource.Phase.ELEMENTS_RESOLVED);
+ int offset = getOffset(info, params.getRange().getStart());
+ Trees trees = info.getTrees();
+ TreePath path = info.getTreeUtilities().pathFor(offset);
+ Tree.Kind kind = null;
+ while (path != null && (kind = path.getLeaf().getKind()) != Tree.Kind.METHOD && kind != Tree.Kind.METHOD_INVOCATION && kind != Tree.Kind.NEW_CLASS && kind != Tree.Kind.MEMBER_REFERENCE) {
+ path = path.getParentPath();
+ }
+ Element element = null;
+ FileObject elementSource = null;
+ if (kind == Tree.Kind.METHOD || kind == Tree.Kind.METHOD_INVOCATION || kind == Tree.Kind.NEW_CLASS || kind == Tree.Kind.MEMBER_REFERENCE) {
+ element = trees.getElement(path);
+ if (element == null || element.asType().getKind() == TypeKind.ERROR) {
+ return Collections.emptyList();
+ }
+ elementSource = SourceUtils.getFile(ElementHandle.create(element), info.getClasspathInfo());
+ }
+ if (elementSource == null) {
+ return Collections.emptyList();
+ }
+ QuickPickItem elementItem = new QuickPickItem(createLabel(info, element, true));
+ elementItem.setUserData(new ElementData(element));
+ return Collections.singletonList(createCodeAction(Bundle.DN_ChangeMethodParams(), CHANGE_METHOD_PARAMS_REFACTORING_KIND, null, CHANGE_METHOD_PARAMS_REFACTORING_COMMAND, Utils.toUri(elementSource), elementItem));
+ }
+
+ @Override
+ public Set<String> getCommands() {
+ return commands;
+ }
+
+ @Override
+ @NbBundle.Messages({
+ "DN_ChangeMethodSignature=Change method signature",
+ })
+ public CompletableFuture<Object> processCommand(NbCodeLanguageClient client, String command, List<Object> arguments) {
+ try {
+ if (arguments.size() > 1) {
+ String uri = gson.fromJson(gson.toJson(arguments.get(0)), String.class);
+ QuickPickItem sourceItem = gson.fromJson(gson.toJson(arguments.get(1)), QuickPickItem.class);
+ ElementHandle handle = gson.fromJson(gson.toJson(sourceItem.getUserData()), ElementData.class).toHandle();
+ FileObject file = Utils.fromUri(uri);
+ JavaSource js = JavaSource.forFileObject(file);
+ if (js != null) {
+ return CompletableFuture.supplyAsync(() -> {
+ try {
+ js.runUserActionTask(ci -> {
+ ci.toPhase(JavaSource.Phase.ELEMENTS_RESOLVED);
+ ExecutableElement method = (ExecutableElement) handle.resolve(ci);
+ if (method != null) {
+ Pages.showChangeMethodParametersUI(ci, client, file, handle, method);
+ }
+ }, true);
+ return null;
+ } catch (IOException ex) {
+ throw new IllegalStateException(ex);
+ }
+ }, RequestProcessor.getDefault());
+ }
+ } else {
+ throw new IllegalArgumentException(String.format("Illegal number of arguments received for command: %s", command));
+ }
+ } catch (Exception ex) {
+ client.showMessage(new MessageParams(MessageType.Error, ex.getLocalizedMessage()));
+ }
+ return CompletableFuture.completedFuture(true);
+ }
+
+ private static String defaultValue(String type) {
+ switch(type) {
+ case "boolean":
+ return "false";
+ case "byte":
+ case "char":
+ case "double":
+ case "float":
+ case "int":
+ case "long":
+ case "short":
+ return "0";
+ }
+ return "null";
+ }
+
+ @HTMLDialog(url = "ui/ChangeMethodParameters.html")
+ static HTMLDialog.OnSubmit showChangeMethodParametersUI(
+ CompilationController ci,
+ NbCodeLanguageClient client,
+ FileObject file,
+ ElementHandle handle,
+ ExecutableElement method
+ ) {
+ ParameterUI[] params = new ParameterUI[method.getParameters().size()];
+ for (int i = 0; i < method.getParameters().size(); i++) {
+ VariableElement param = method.getParameters().get(i);
+ ChangeParametersRefactoring.ParameterInfo info = new ChangeParametersRefactoring.ParameterInfo(i, param.getSimpleName().toString(), Utilities.getTypeName(ci, param.asType(), true).toString(), null);
+ params[i] = new ParameterUI(info.getType(), info.getName());
+ params[i].assignInfo(info);
+ }
+ Modifier mod;
+ if (method.getModifiers().contains(javax.lang.model.element.Modifier.PUBLIC)) {
+ mod = Modifier.PUBLIC;
+ } else if (method.getModifiers().contains(javax.lang.model.element.Modifier.PROTECTED)) {
+ mod = Modifier.PROTECTED;
+ } else if (method.getModifiers().contains(javax.lang.model.element.Modifier.PRIVATE)) {
+ mod = Modifier.PRIVATE;
+ } else {
+ mod = Modifier.PACKAGE_PRIVATE;
+ }
+ ChangeMethodParameterUI model = new ChangeMethodParameterUI();
+ model.withName(method.getSimpleName().toString())
+ .withReturnType(Utilities.getTypeName(ci, method.getReturnType(), true).toString())
+ .withSelectedModifier(mod)
+ .withParameters(params)
+ .assignData(client, file, TreePathHandle.from(handle, ClasspathInfo.create(file)));
+ model.applyBindings();
+ return (id) -> {
+ if ("accept".equals(id)) {
Review comment:
Here you can validate the content of the dialog, @dbalek.
--
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] sdedic commented on a change in pull request #3349: Rich HTML UI for (now only for) VSCode Refactorings
Posted by GitBox <gi...@apache.org>.
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.
--
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] neilcsmith-net commented on pull request #3349: Rich HTML UI for (now only for) VSCode Refactorings
Posted by GitBox <gi...@apache.org>.
neilcsmith-net commented on pull request #3349:
URL: https://github.com/apache/netbeans/pull/3349#issuecomment-989907550
> Opps, I wanted to create a new PR, but instead I integrated [9e27e19](https://github.com/apache/netbeans/commit/9e27e191c829978a9dbdcdaeee774d4208412348) into `master`. I made a mistake and forget to create new branch before push. I am sorry.
Aside - it happens! :smile: I've long been in the habit of using `git remote set-url --push upstream DISABLED`.
--
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] neilcsmith-net commented on a change in pull request #3349: Rich HTML UI for (now only for) VSCode Refactorings
Posted by GitBox <gi...@apache.org>.
neilcsmith-net commented on a change in pull request #3349:
URL: https://github.com/apache/netbeans/pull/3349#discussion_r765854604
##########
File path: java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/refactoring/ChangeMethodParametersRefactoringAction.java
##########
@@ -0,0 +1,84 @@
+/*
+ * 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.refactoring;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.io.IOException;
+import javax.lang.model.element.Element;
+import javax.lang.model.element.ElementKind;
+import javax.lang.model.element.ExecutableElement;
+import javax.lang.model.element.TypeElement;
+import org.netbeans.api.java.source.ElementHandle;
+import org.netbeans.api.java.source.JavaSource;
+import org.openide.awt.ActionID;
+import org.openide.awt.ActionReference;
+import org.openide.awt.ActionRegistration;
+import org.openide.filesystems.FileObject;
+import org.openide.util.NbBundle.Messages;
+
+@ActionID(
+ category = "Refactoring",
+ id = "org.netbeans.modules.java.lsp.server.refactoring.ChangeMethodParametersRefactoringAction"
+)
+@ActionRegistration(
+ iconBase = "org/netbeans/modules/java/lsp/server/refactoring/newHTML.png",
+ displayName = "#CTL_ChangeMethodParametersRefactoringAction"
+)
+@ActionReference(path = "Menu/Refactoring", position = 1120)
+@Messages("CTL_ChangeMethodParametersRefactoringAction=Change Method Parameters Refactoring")
+public final class ChangeMethodParametersRefactoringAction implements ActionListener {
+ private final FileObject file;
+
+ public ChangeMethodParametersRefactoringAction(FileObject file) {
+ this.file = file;
+ }
+
+ @Override
+ public void actionPerformed(ActionEvent evt) {
+ JavaSource js = JavaSource.forFileObject(file);
+ if (js != null) {
+ try {
+ js.runUserActionTask(ci -> {
+ ci.toPhase(JavaSource.Phase.ELEMENTS_RESOLVED);
+ ExecutableElement method = null;
+ METHOD: for (Element type : ci.getTopLevelElements()) {
+ for (Element e : type.getEnclosedElements()) {
+ System.err.println("e: " + e);
+ if (e.getKind() == ElementKind.METHOD) {
+ method = (ExecutableElement) e;
+ break METHOD;
+ }
+ }
+ }
+ if (method != null) {
+ ElementHandle<ExecutableElement> handle = ElementHandle.create(method);
+ ChangeMethodParameterUI[] model = {null};
Review comment:
+1 to using for VSCode. -1 to using in NetBeans IDE. Not unless we get at least a presenter we can ship with, is more stable, and integrates properly with the L&F.
--
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] JaroslavTulach commented on a change in pull request #3349: Rich HTML UI for (now only for) VSCode Refactorings
Posted by GitBox <gi...@apache.org>.
JaroslavTulach commented on a change in pull request #3349:
URL: https://github.com/apache/netbeans/pull/3349#discussion_r762580397
##########
File path: platform/generic/manifest.mf
##########
@@ -0,0 +1 @@
+OpenIDE-Module: generic
Review comment:
Renamed to `org.netbeans.html.presenters.spi`.
--
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] JaroslavTulach commented on a change in pull request #3349: Rich HTML UI for (now only for) VSCode Refactorings
Posted by GitBox <gi...@apache.org>.
JaroslavTulach commented on a change in pull request #3349:
URL: https://github.com/apache/netbeans/pull/3349#discussion_r760393404
##########
File path: java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/refactoring/ChangeMethodParametersRefactoringAction.java
##########
@@ -0,0 +1,84 @@
+/*
+ * 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.refactoring;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.io.IOException;
+import javax.lang.model.element.Element;
+import javax.lang.model.element.ElementKind;
+import javax.lang.model.element.ExecutableElement;
+import javax.lang.model.element.TypeElement;
+import org.netbeans.api.java.source.ElementHandle;
+import org.netbeans.api.java.source.JavaSource;
+import org.openide.awt.ActionID;
+import org.openide.awt.ActionReference;
+import org.openide.awt.ActionRegistration;
+import org.openide.filesystems.FileObject;
+import org.openide.util.NbBundle.Messages;
+
+@ActionID(
+ category = "Refactoring",
+ id = "org.netbeans.modules.java.lsp.server.refactoring.ChangeMethodParametersRefactoringAction"
+)
+@ActionRegistration(
+ iconBase = "org/netbeans/modules/java/lsp/server/refactoring/newHTML.png",
+ displayName = "#CTL_ChangeMethodParametersRefactoringAction"
+)
+@ActionReference(path = "Menu/Refactoring", position = 1120)
+@Messages("CTL_ChangeMethodParametersRefactoringAction=Change Method Parameters Refactoring")
+public final class ChangeMethodParametersRefactoringAction implements ActionListener {
+ private final FileObject file;
+
+ public ChangeMethodParametersRefactoringAction(FileObject file) {
+ this.file = file;
+ }
+
+ @Override
+ public void actionPerformed(ActionEvent evt) {
+ JavaSource js = JavaSource.forFileObject(file);
+ if (js != null) {
+ try {
+ js.runUserActionTask(ci -> {
+ ci.toPhase(JavaSource.Phase.ELEMENTS_RESOLVED);
+ ExecutableElement method = null;
+ METHOD: for (Element type : ci.getTopLevelElements()) {
+ for (Element e : type.getEnclosedElements()) {
+ System.err.println("e: " + e);
+ if (e.getKind() == ElementKind.METHOD) {
+ method = (ExecutableElement) e;
+ break METHOD;
+ }
+ }
+ }
+ if (method != null) {
+ ElementHandle<ExecutableElement> handle = ElementHandle.create(method);
+ ChangeMethodParameterUI[] model = {null};
Review comment:
This action displays the same VSCode UI in NetBeans IDE! The CSS isn't optimized (e.g. no screenshot to share), but it does work (if the JDK has JavaFX libraries available).
While the current effort is only targeted towards VSCode, ideally we can reuse the UIs on both sides in a future - in NetBeans IDE as well as VSCode. To do so following has to happen:
- the HTML has to be (almost) without CSS
- CSS is applied by the "chrome" and needs to be compatible with current L&F
- modules using the UI in NetBeans IDE need a "presenter"
- currently we use JavaFX web view as a presenter - e.g. it is necessary to install JavaFX libraries
- we could show the UI in an external browser - so called "browser" presenter.
--
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] JaroslavTulach commented on a change in pull request #3349: Rich HTML UI for (now only for) VSCode Refactorings
Posted by GitBox <gi...@apache.org>.
JaroslavTulach commented on a change in pull request #3349:
URL: https://github.com/apache/netbeans/pull/3349#discussion_r765397801
##########
File path: java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/htmlui/Browser.java
##########
@@ -0,0 +1,741 @@
+/**
+ * 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.htmlui;
+
+import java.io.Closeable;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.Flushable;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.io.Reader;
+import java.io.Writer;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.net.URLConnection;
+import java.net.URLDecoder;
+import java.nio.file.Files;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Queue;
+import java.util.Random;
+import java.util.UUID;
+import java.util.concurrent.Executor;
+import java.util.function.Consumer;
+import java.util.function.Supplier;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import org.netbeans.html.boot.spi.Fn;
+import org.netbeans.html.boot.spi.Fn.Presenter;
+import org.netbeans.html.presenters.spi.ProtoPresenter;
+import org.netbeans.html.presenters.spi.ProtoPresenterBuilder;
+
+/** Browser based {@link Presenter}. It starts local server and
+ * launches browser that connects to it. Use {@link Browser.Config} to
+ * configure the actual browser to be started.
+ * <p>
+ * To use this presenter specify following dependency:
+ * <pre>
+ * <dependency>
+ * <groupId>org.netbeans.html.browser</groupId>
+ * <artifactId>browser</artifactId>
+ * <version><a target="blank" href="http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22com.dukescript.presenters%22%20AND%20a%3A%22browser%22">1.x</a></version>
+ * </dependency>
+ * </pre>
+ */
+public final class Browser implements Fn.Presenter, Fn.KeepAlive, Flushable,
+Executor, Closeable {
+ static final Logger LOG = Logger.getLogger(Browser.class.getName());
+ private final Map<String,Command> SESSIONS = new HashMap<>();
+ private final String app;
+ private HttpServer server;
+ private Runnable onPageLoad;
+ private Command current;
+ private final Config config;
+ private final Supplier<HttpServer<?, ?, ?, ?>> serverProvider;
+
+ /** Default constructor. Reads configuration from properties. The actual browser to
+ * be launched can be influenced by value of
+ * <code>com.dukescript.presenters.browser</code> property.
+ * It can have following values:
+ * <ul>
+ * <li><b>GTK</b> - use Gtk WebKit implementation. Requires presence of
+ * appropriate native libraries</li>
+ * <li><b>AWT</b> - use {@link java.awt.Desktop#browse(java.net.URI)} to
+ * launch a browser</li>
+ * <li><b>NONE</b> - just launches the server, useful together with
+ * <code>com.dukescript.presenters.browserPort</code> property that
+ * can specify a fixed port to open the server at
+ * </li>
+ * <li>any other value is interpreted as a command which is then
+ * launched on a command line with one parameter - the URL to connect to</li>
+ * </ul>
+ * If the property is not specified the system tries <b>GTK</b> mode first,
+ * followed by <b>AWT</b> and then tries to execute <code>xdg-open</code>
+ * (default LINUX command to launch a browser from a shell script).
+ * <p>
+ * In addition to the above properties, it is possible to also enable
+ * debugging by setting <code>com.dukescript.presenters.browserDebug=true</code>.
+ *
+ * @throws Exception
+ */
+ public Browser() {
+ this(new Config());
+ }
+
+ /**
+ * Browser configured by provided config.
+ *
+ * @param config the configuration
+ */
+ public Browser(Config config) {
+ this(findCalleeClassName(), config, null);
+ }
+
+ Browser(String app, Config config, Supplier<HttpServer<?,?,?, ?>> serverProvider) {
+ this.serverProvider = serverProvider != null ? serverProvider : () -> {
+ return new SimpleServer(config.random);
+ };
+ this.app = app;
+ this.config = new Config(config);
+ }
+
+ @Override
+ public final void execute(final Runnable r) {
+ current.execute(r);
+ }
+
+ @Override
+ public void close() throws IOException {
+ if (server != null) {
+ server.shutdownNow();
+ }
+ }
+
+ HttpServer server() {
+ return server;
+ }
+
+ static HttpServer findServer(Object obj) {
+ Command c;
+ if (obj instanceof Command) {
+ c = (Command) obj;
+ } else if (obj instanceof ProtoPresenter) {
+ c = ((ProtoPresenter) obj).lookup(Command.class);
+ } else {
+ throw new IllegalArgumentException("Cannot find server for " + obj);
+ }
+ return c.browser.server();
+ }
+
+ /** Shows URL in a browser.
+ * @param page the page to display in the browser
+ * @throws IOException if something goes wrong
+ */
+ void show(URI page) throws IOException {
+ config.getBrowser().accept(page);
+ }
+ @Override
+ public Fn defineFn(String string, String... strings) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void loadScript(Reader reader) throws Exception {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public Fn defineFn(String string, String[] strings, boolean[] blns) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void flush() throws IOException {
+ throw new UnsupportedOperationException();
+ }
+
+ private static URI pageURL(String protocol, HttpServer server, final String page) {
+ int port = server.getPort();
+ try {
+ return new URI(protocol + "://localhost:" + port + page);
+ } catch (URISyntaxException ex) {
+ throw new IllegalStateException(ex);
+ }
+ }
+
+ @Override
+ public final void displayPage(URL page, Runnable onPageLoad) {
+ try {
+ this.onPageLoad = onPageLoad;
+ this.server = serverProvider.get();
+ int from = 8080;
+ int to = 65535;
+ int port = config.getPort();
+ if (port != -1) {
+ from = to = port;
+ }
+ server.init(from, to);
+
+ String prefix = "/" + new UUID(config.random.nextLong(), config.random.nextLong()).toString();
+
Review comment:
https://github.com/apache/netbeans-html4j/pull/26#issuecomment-981762288 questions the security when opening a port. The 24cb4da fix is supposed to make sure the port is only available locally. Moreover e91bdcb uses random UUID to prefix the server pages and in case of misconnect, it closes the server.
That shall mitigate the basic problem. We can treat the rest as a bug.
--
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] sdedic commented on a change in pull request #3349: Rich HTML UI for (now only for) VSCode Refactorings
Posted by GitBox <gi...@apache.org>.
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: 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] JaroslavTulach edited a comment on pull request #3349: Rich HTML UI for (now only for) VSCode Refactorings
Posted by GitBox <gi...@apache.org>.
JaroslavTulach edited a comment on pull request #3349:
URL: https://github.com/apache/netbeans/pull/3349#issuecomment-989636780
Opps, I wanted to create a new PR, but instead I integrated 9e27e191c829978a9dbdcdaeee774d4208412348 into `master`. I made a mistake and forget to create new branch before push. I am sorry.
We don't have a way to remove commit from `master` (as far as I know). Rather than rolling back, I suggest to keep it and possibly polish it in the final PR I am about to create now: #3361. Sorry for the mess.
--
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