Skip to content

Commit

Permalink
Moving UIContext out of public package. (apache#4258)
Browse files Browse the repository at this point in the history
  • Loading branch information
dbalek authored Jun 22, 2022
1 parent a5c8929 commit 4a5fcd7
Show file tree
Hide file tree
Showing 13 changed files with 43 additions and 58 deletions.
2 changes: 1 addition & 1 deletion java/java.lsp.server/manifest.mf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Manifest-Version: 1.0
AutoUpdate-Show-In-Client: true
OpenIDE-Module: org.netbeans.modules.java.lsp.server
OpenIDE-Module: org.netbeans.modules.java.lsp.server/2
OpenIDE-Module-Implementation-Version: 1
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/java/lsp/server/Bundle.properties
OpenIDE-Module-Layer: org/netbeans/modules/java/lsp/server/layer.xml
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@
<build-prerequisite/>
<compile-dependency/>
<run-dependency>
<specification-version>1.19</specification-version>
<release-version>2</release-version>
<specification-version>2.0</specification-version>
</run-dependency>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,24 +123,6 @@ supr java.lang.Object
hfds lastCtx
hcls StdErrContext

CLSS public abstract org.netbeans.modules.java.lsp.server.ui.UIContext
cons public init()
meth protected abstract boolean isValid()
meth protected abstract java.util.concurrent.CompletableFuture<org.eclipse.lsp4j.MessageActionItem> showMessageRequest(org.eclipse.lsp4j.ShowMessageRequestParams)
meth protected abstract org.openide.awt.StatusDisplayer$Message showStatusMessage(org.netbeans.modules.java.lsp.server.protocol.ShowStatusMessageParams)
meth protected abstract void logMessage(org.eclipse.lsp4j.MessageParams)
meth protected abstract void showMessage(org.eclipse.lsp4j.MessageParams)
meth protected java.util.concurrent.CompletableFuture<java.lang.String> showHtmlPage(org.netbeans.modules.java.lsp.server.protocol.HtmlPageParams)
meth protected java.util.concurrent.CompletableFuture<java.lang.String> showInputBox(org.netbeans.modules.java.lsp.server.protocol.ShowInputBoxParams)
meth protected java.util.concurrent.CompletableFuture<java.util.List<org.netbeans.modules.java.lsp.server.protocol.QuickPickItem>> showQuickPick(org.netbeans.modules.java.lsp.server.protocol.ShowQuickPickParams)
meth public static org.netbeans.modules.java.lsp.server.ui.UIContext find()
anno 0 org.netbeans.api.annotations.common.NonNull()
meth public static org.netbeans.modules.java.lsp.server.ui.UIContext find(org.openide.util.Lookup)
anno 0 org.netbeans.api.annotations.common.NonNull()
supr java.lang.Object
hfds lastCtx
hcls LogImpl

CLSS public abstract interface org.netbeans.modules.progress.spi.ProgressEnvironment
meth public abstract org.netbeans.api.progress.ProgressHandle createHandle(java.lang.String,org.openide.util.Cancellable,boolean)
meth public abstract org.netbeans.modules.progress.spi.Controller getController()
Expand Down
2 changes: 1 addition & 1 deletion java/java.lsp.server/nbproject/project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

javac.source=1.8
javac.compilerargs=-Xlint -Xlint:-serial
spec.version.base=1.21.0
spec.version.base=2.0.0
javadoc.arch=${basedir}/arch.xml
requires.nb.javac=true
lsp.build.dir=vscode/nbcode
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import com.google.gson.JsonElement;
import org.eclipse.lsp4j.ClientCapabilities;
import org.eclipse.lsp4j.InitializeParams;
import org.netbeans.modules.java.lsp.server.ui.UIContext;

/**
* Encapsulates all nbcode-specific client capabilities. Need to be passed in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.netbeans.modules.java.lsp.server.ui;
package org.netbeans.modules.java.lsp.server.protocol;

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
Expand All @@ -30,12 +30,10 @@
import org.eclipse.lsp4j.ShowMessageRequestParams;
import org.eclipse.lsp4j.jsonrpc.messages.Either;
import org.netbeans.api.annotations.common.NonNull;
import org.netbeans.modules.java.lsp.server.protocol.HtmlPageParams;
import org.netbeans.modules.java.lsp.server.input.QuickPickItem;
import org.netbeans.modules.java.lsp.server.input.ShowInputBoxParams;
import org.netbeans.modules.java.lsp.server.input.ShowMutliStepInputParams;
import org.netbeans.modules.java.lsp.server.input.ShowQuickPickParams;
import org.netbeans.modules.java.lsp.server.protocol.ShowStatusMessageParams;
import org.openide.awt.StatusDisplayer.Message;
import org.openide.util.Lookup;

Expand Down Expand Up @@ -84,15 +82,15 @@ public static synchronized UIContext find() {
return find(Lookup.getDefault());
}

protected abstract boolean isValid();
protected abstract void showMessage(MessageParams msg);
protected CompletableFuture<String> showHtmlPage(HtmlPageParams msg) {
public abstract boolean isValid();
public abstract void showMessage(MessageParams msg);
public CompletableFuture<String> showHtmlPage(HtmlPageParams msg) {
showMessage(new MessageParams(MessageType.Log, msg.getUri()));
return CompletableFuture.completedFuture(null);
}
protected abstract CompletableFuture<MessageActionItem> showMessageRequest(ShowMessageRequestParams msg);
protected abstract void logMessage(MessageParams msg);
protected abstract Message showStatusMessage(ShowStatusMessageParams msg);
public abstract CompletableFuture<MessageActionItem> showMessageRequest(ShowMessageRequestParams msg);
public abstract void logMessage(MessageParams msg);
public abstract Message showStatusMessage(ShowStatusMessageParams msg);

/**
* Shows an input box to ask the user for a text input.
Expand All @@ -101,15 +99,15 @@ protected CompletableFuture<String> showHtmlPage(HtmlPageParams msg) {
* @return future that yields the entered value
* @since 1.18
*/
protected CompletableFuture<String> showInputBox(ShowInputBoxParams params) {
public CompletableFuture<String> showInputBox(ShowInputBoxParams params) {
throw new AbstractMethodError();
}

protected CompletableFuture<List<QuickPickItem>> showQuickPick(ShowQuickPickParams params) {
public CompletableFuture<List<QuickPickItem>> showQuickPick(ShowQuickPickParams params) {
throw new AbstractMethodError();
}

protected CompletableFuture<Map<String, Either<List<QuickPickItem>, String>>> showMultiStepInput(ShowMutliStepInputParams params) {
public CompletableFuture<Map<String, Either<List<QuickPickItem>, String>>> showMultiStepInput(ShowMutliStepInputParams params) {
throw new AbstractMethodError();
}

Expand All @@ -120,48 +118,48 @@ private LogImpl() {
}

@Override
protected CompletableFuture<MessageActionItem> showMessageRequest(ShowMessageRequestParams msg) {
public CompletableFuture<MessageActionItem> showMessageRequest(ShowMessageRequestParams msg) {
System.err.println(msg.getType() + ": " + msg.getMessage());
CompletableFuture<MessageActionItem> ai = CompletableFuture.completedFuture(null);
return ai;
}

@Override
protected void showMessage(MessageParams msg) {
public void showMessage(MessageParams msg) {
System.err.println(msg.getType() + ": " + msg.getMessage());
}

@Override
protected void logMessage(MessageParams msg) {
public void logMessage(MessageParams msg) {
System.err.println(msg.getType() + ": " + msg.getMessage());
}

@Override
protected Message showStatusMessage(ShowStatusMessageParams msg) {
public Message showStatusMessage(ShowStatusMessageParams msg) {
System.out.println(msg.getType() + ": " + msg.getMessage());
return (int timeInMillis) -> {};
}

@Override
protected boolean isValid() {
public boolean isValid() {
return true;
}

@Override
protected CompletableFuture<String> showHtmlPage(HtmlPageParams msg) {
public CompletableFuture<String> showHtmlPage(HtmlPageParams msg) {
System.out.println("Open in browser: " + msg.getUri());
return CompletableFuture.completedFuture(null);
}

@Override
protected CompletableFuture<String> showInputBox(ShowInputBoxParams params) {
public CompletableFuture<String> showInputBox(ShowInputBoxParams params) {
System.err.println("input: " + params.getPrompt());
CompletableFuture<String> ai = CompletableFuture.completedFuture(null);
return ai;
}

@Override
protected CompletableFuture<List<QuickPickItem>> showQuickPick(ShowQuickPickParams params) {
public CompletableFuture<List<QuickPickItem>> showQuickPick(ShowQuickPickParams params) {
System.err.println("quickPick: " + params.getPlaceHolder());
return CompletableFuture.completedFuture(Collections.emptyList());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import org.netbeans.modules.java.lsp.server.input.ShowQuickPickParams;
import org.netbeans.modules.java.lsp.server.input.ShowInputBoxParams;
import org.netbeans.modules.java.lsp.server.input.ShowMutliStepInputParams;
import org.netbeans.modules.java.lsp.server.ui.UIContext;
import org.openide.awt.StatusDisplayer;

/**
Expand All @@ -44,22 +43,22 @@ public WorkspaceUIContext(NbCodeLanguageClient client) {
}

@Override
protected boolean isValid() {
public boolean isValid() {
return true;
}

@Override
protected CompletableFuture<MessageActionItem> showMessageRequest(ShowMessageRequestParams msg) {
public CompletableFuture<MessageActionItem> showMessageRequest(ShowMessageRequestParams msg) {
return client.showMessageRequest(msg);
}

@Override
protected void showMessage(MessageParams msg) {
public void showMessage(MessageParams msg) {
client.showMessage(msg);
}

@Override
protected CompletableFuture<String> showInputBox(ShowInputBoxParams params) {
public CompletableFuture<String> showInputBox(ShowInputBoxParams params) {
return client.showInputBox(params);
}

Expand All @@ -74,12 +73,12 @@ public CompletableFuture<Map<String, Either<List<QuickPickItem>, String>>> showM
}

@Override
protected void logMessage(MessageParams msg) {
public void logMessage(MessageParams msg) {
client.logMessage(msg);
}

@Override
protected StatusDisplayer.Message showStatusMessage(ShowStatusMessageParams msg) {
public StatusDisplayer.Message showStatusMessage(ShowStatusMessageParams msg) {
if (client.getNbCodeCapabilities().hasStatusBarMessageSupport()) {
client.showStatusBarMessage(msg);
} else {
Expand All @@ -89,7 +88,7 @@ protected StatusDisplayer.Message showStatusMessage(ShowStatusMessageParams msg)
}

@Override
protected CompletableFuture<String> showHtmlPage(HtmlPageParams msg) {
public CompletableFuture<String> showHtmlPage(HtmlPageParams msg) {
return client.showHtmlPage(msg);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.awt.HeadlessException;
import java.util.concurrent.CompletableFuture;
import org.netbeans.modules.java.lsp.server.LspServerUtils;
import org.netbeans.modules.java.lsp.server.protocol.UIContext;
import org.openide.DialogDescriptor;
import org.openide.DialogDisplayer;
import org.openide.NotifyDescriptor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import static org.netbeans.modules.java.lsp.server.htmlui.Buttons.buttonText0;
import org.netbeans.modules.java.lsp.server.protocol.HtmlPageParams;
import org.netbeans.modules.java.lsp.server.protocol.NbCodeClientCapabilities;
import org.netbeans.modules.java.lsp.server.protocol.UIContext;
import org.openide.util.Exceptions;
import org.netbeans.spi.htmlui.HTMLViewerSpi;
import org.openide.util.NbBundle;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import javax.swing.event.ChangeListener;
import org.eclipse.lsp4j.MessageType;
import org.netbeans.modules.java.lsp.server.protocol.ShowStatusMessageParams;
import org.netbeans.modules.java.lsp.server.protocol.UIContext;
import org.openide.awt.StatusDisplayer;

public abstract class AbstractLspStatusDisplayer extends StatusDisplayer {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
import org.netbeans.modules.java.lsp.server.input.ShowInputBoxParams;
import org.netbeans.modules.java.lsp.server.input.ShowMutliStepInputParams;
import org.netbeans.modules.java.lsp.server.input.ShowQuickPickParams;
import org.netbeans.modules.java.lsp.server.protocol.UIContext;
import org.openide.NotificationLineSupport;
import org.openide.NotifyDescriptor;
import org.openide.awt.Actions;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import org.netbeans.modules.java.lsp.server.input.ShowMutliStepInputParams;
import org.netbeans.modules.java.lsp.server.input.ShowQuickPickParams;
import org.netbeans.modules.java.lsp.server.protocol.ShowStatusMessageParams;
import org.netbeans.modules.java.lsp.server.protocol.UIContext;
import org.openide.NotifyDescriptor;
import org.openide.awt.StatusDisplayer;
import org.openide.util.RequestProcessor;
Expand All @@ -59,40 +60,40 @@ public AbstractDialogDisplayerTest(String name) {

private static class MockUIContext extends UIContext {
@Override
protected boolean isValid() {
public boolean isValid() {
return true;
}

@Override
protected void showMessage(MessageParams msg) {
public void showMessage(MessageParams msg) {
}

@Override
protected CompletableFuture<MessageActionItem> showMessageRequest(ShowMessageRequestParams msg) {
public CompletableFuture<MessageActionItem> showMessageRequest(ShowMessageRequestParams msg) {
return CompletableFuture.completedFuture(null);
}

@Override
protected CompletableFuture<String> showInputBox(ShowInputBoxParams params) {
public CompletableFuture<String> showInputBox(ShowInputBoxParams params) {
return CompletableFuture.completedFuture(null);
}

@Override
protected CompletableFuture<List<QuickPickItem>> showQuickPick(ShowQuickPickParams params) {
public CompletableFuture<List<QuickPickItem>> showQuickPick(ShowQuickPickParams params) {
return CompletableFuture.completedFuture(Collections.emptyList());
}

@Override
protected CompletableFuture<Map<String, Either<List<QuickPickItem>, String>>> showMultiStepInput(ShowMutliStepInputParams params) {
public CompletableFuture<Map<String, Either<List<QuickPickItem>, String>>> showMultiStepInput(ShowMutliStepInputParams params) {
return CompletableFuture.completedFuture(Collections.emptyMap());
}

@Override
protected void logMessage(MessageParams msg) {
public void logMessage(MessageParams msg) {
}

@Override
protected StatusDisplayer.Message showStatusMessage(ShowStatusMessageParams msg) {
public StatusDisplayer.Message showStatusMessage(ShowStatusMessageParams msg) {
return null;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import org.netbeans.html.json.spi.PropertyBinding;
import org.netbeans.html.json.spi.Technology;
import org.netbeans.modules.java.lsp.server.protocol.HtmlPageParams;
import org.netbeans.modules.java.lsp.server.protocol.UIContext;
import org.openide.util.lookup.ServiceProvider;
import org.netbeans.spi.htmlui.HTMLViewerSpi;

Expand Down

0 comments on commit 4a5fcd7

Please sign in to comment.