org.eclipse.lsp4j.ShowMessageRequestParams Java Examples

The following examples show how to use org.eclipse.lsp4j.ShowMessageRequestParams. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GroovyServicesTypeDefinitionTests.java    From groovy-language-server with Apache License 2.0 5 votes vote down vote up
@BeforeEach
void setup() {
	workspaceRoot = Paths.get(System.getProperty("user.dir")).resolve(PATH_WORKSPACE);
	srcRoot = workspaceRoot.resolve(PATH_SRC);
	if (!Files.exists(srcRoot)) {
		srcRoot.toFile().mkdirs();
	}

	services = new GroovyServices(new CompilationUnitFactory());
	services.setWorkspaceRoot(workspaceRoot);
	services.connect(new LanguageClient() {

		@Override
		public void telemetryEvent(Object object) {

		}

		@Override
		public CompletableFuture<MessageActionItem> showMessageRequest(ShowMessageRequestParams requestParams) {
			return null;
		}

		@Override
		public void showMessage(MessageParams messageParams) {

		}

		@Override
		public void publishDiagnostics(PublishDiagnosticsParams diagnostics) {

		}

		@Override
		public void logMessage(MessageParams message) {

		}
	});
}
 
Example #2
Source File: XMLExternalTest.java    From lemminx with Eclipse Public License 2.0 5 votes vote down vote up
private static XMLLanguageServer createServer(List<PublishDiagnosticsParams> actualDiagnostics) {

		XMLLanguageServer languageServer = new XMLLanguageServer();
		XMLLanguageClientAPI client = new XMLLanguageClientAPI() {

			@Override
			public CompletableFuture<MessageActionItem> showMessageRequest(ShowMessageRequestParams requestParams) {
				return null;
			}

			@Override
			public void showMessage(MessageParams messageParams) {

			}

			@Override
			public void publishDiagnostics(PublishDiagnosticsParams diagnostics) {
				actualDiagnostics.add(diagnostics);
			}

			@Override
			public void logMessage(MessageParams message) {

			}

			@Override
			public void telemetryEvent(Object object) {

			}

			@Override
			public void actionableNotification(ActionableNotification notification) {
				throw new UnsupportedOperationException();
			}
		};
		languageServer.setClient(client);
		return languageServer;
	}
 
Example #3
Source File: ServerMessageHandler.java    From intellij-quarkus with Eclipse Public License 2.0 5 votes vote down vote up
public static CompletableFuture<MessageActionItem> showMessageRequest(LanguageServerWrapper wrapper, ShowMessageRequestParams params) {
    String options[] = params.getActions().stream().map(MessageActionItem::getTitle).toArray(String[]::new);
    CompletableFuture<MessageActionItem> future = new CompletableFuture<>();

    ApplicationManager.getApplication().invokeLater(() -> {
        MessageActionItem result = new MessageActionItem();
        int dialogResult = Messages.showIdeaMessageDialog(null, params.getMessage(), wrapper.serverDefinition.label, options, 0, Messages.getInformationIcon(), null);
        if (dialogResult != -1) {
            result.setTitle(options[dialogResult]);
        }
        future.complete(result);
    });
    return future;
}
 
Example #4
Source File: GroovyServicesDefinitionTests.java    From groovy-language-server with Apache License 2.0 5 votes vote down vote up
@BeforeEach
void setup() {
	workspaceRoot = Paths.get(System.getProperty("user.dir")).resolve(PATH_WORKSPACE);
	srcRoot = workspaceRoot.resolve(PATH_SRC);
	if (!Files.exists(srcRoot)) {
		srcRoot.toFile().mkdirs();
	}

	services = new GroovyServices(new CompilationUnitFactory());
	services.setWorkspaceRoot(workspaceRoot);
	services.connect(new LanguageClient() {

		@Override
		public void telemetryEvent(Object object) {

		}

		@Override
		public CompletableFuture<MessageActionItem> showMessageRequest(ShowMessageRequestParams requestParams) {
			return null;
		}

		@Override
		public void showMessage(MessageParams messageParams) {

		}

		@Override
		public void publishDiagnostics(PublishDiagnosticsParams diagnostics) {

		}

		@Override
		public void logMessage(MessageParams message) {

		}
	});
}
 
Example #5
Source File: GroovyServicesSignatureHelpTests.java    From groovy-language-server with Apache License 2.0 5 votes vote down vote up
@BeforeEach
void setup() {
	workspaceRoot = Paths.get(System.getProperty("user.dir")).resolve(PATH_WORKSPACE);
	srcRoot = workspaceRoot.resolve(PATH_SRC);
	if (!Files.exists(srcRoot)) {
		srcRoot.toFile().mkdirs();
	}

	services = new GroovyServices(new CompilationUnitFactory());
	services.setWorkspaceRoot(workspaceRoot);
	services.connect(new LanguageClient() {

		@Override
		public void telemetryEvent(Object object) {

		}

		@Override
		public CompletableFuture<MessageActionItem> showMessageRequest(ShowMessageRequestParams requestParams) {
			return null;
		}

		@Override
		public void showMessage(MessageParams messageParams) {

		}

		@Override
		public void publishDiagnostics(PublishDiagnosticsParams diagnostics) {

		}

		@Override
		public void logMessage(MessageParams message) {

		}
	});
}
 
Example #6
Source File: GroovyServicesCompletionTests.java    From groovy-language-server with Apache License 2.0 5 votes vote down vote up
@BeforeEach
void setup() {
	workspaceRoot = Paths.get(System.getProperty("user.dir")).resolve(PATH_WORKSPACE);
	srcRoot = workspaceRoot.resolve(PATH_SRC);
	if (!Files.exists(srcRoot)) {
		srcRoot.toFile().mkdirs();
	}

	services = new GroovyServices(new CompilationUnitFactory());
	services.setWorkspaceRoot(workspaceRoot);
	services.connect(new LanguageClient() {

		@Override
		public void telemetryEvent(Object object) {

		}

		@Override
		public CompletableFuture<MessageActionItem> showMessageRequest(ShowMessageRequestParams requestParams) {
			return null;
		}

		@Override
		public void showMessage(MessageParams messageParams) {

		}

		@Override
		public void publishDiagnostics(PublishDiagnosticsParams diagnostics) {

		}

		@Override
		public void logMessage(MessageParams message) {

		}
	});
}
 
Example #7
Source File: DefaultLanguageClient.java    From lsp4intellij with Apache License 2.0 5 votes vote down vote up
@Override
public CompletableFuture<MessageActionItem> showMessageRequest(ShowMessageRequestParams showMessageRequestParams) {
    List<MessageActionItem> actions = showMessageRequestParams.getActions();
    String title = "Language Server message";
    String message = showMessageRequestParams.getMessage();
    MessageType msgType = showMessageRequestParams.getType();
    Icon icon;
    if (msgType == MessageType.Error) {
        icon = UIUtil.getErrorIcon();
    } else if (msgType == MessageType.Warning) {
        icon = UIUtil.getWarningIcon();
    } else if (msgType == MessageType.Info) {
        icon = UIUtil.getInformationIcon();
    } else if (msgType == MessageType.Log) {
        icon = UIUtil.getInformationIcon();
    } else {
        icon = null;
        LOG.warn("No message type for " + message);
    }

    List<String> titles = new ArrayList<>();
    for (MessageActionItem item : actions) {
        titles.add(item.getTitle());
    }
    FutureTask<Integer> task = new FutureTask<>(
            () -> Messages.showDialog(message, title, (String[]) titles.toArray(), 0, icon));
    ApplicationManager.getApplication().invokeAndWait(task);

    int exitCode = 0;
    try {
        exitCode = task.get();
    } catch (InterruptedException | ExecutionException e) {
        LOG.warn(e.getMessage());
    }

    return CompletableFuture.completedFuture(new MessageActionItem(actions.get(exitCode).getTitle()));
}
 
Example #8
Source File: LanguageClientImpl.java    From intellij-quarkus with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public final CompletableFuture<MessageActionItem> showMessageRequest(ShowMessageRequestParams requestParams) {
    return ServerMessageHandler.showMessageRequest(wrapper, requestParams);
}
 
Example #9
Source File: LoggerTest.java    From lemminx with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public CompletableFuture<MessageActionItem> showMessageRequest(ShowMessageRequestParams requestParams) {
	return null;
}
 
Example #10
Source File: XMLCapabilitiesTest.java    From lemminx with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public CompletableFuture<MessageActionItem> showMessageRequest(ShowMessageRequestParams requestParams) {
	return null;
}
 
Example #11
Source File: AbstractCamelLanguageServerTest.java    From camel-language-server with Apache License 2.0 4 votes vote down vote up
@Override
public CompletableFuture<MessageActionItem> showMessageRequest(ShowMessageRequestParams requestParams) {
	return null;
}
 
Example #12
Source File: AbstractN4JSLanguageClient.java    From n4js with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public CompletableFuture<MessageActionItem> showMessageRequest(ShowMessageRequestParams requestParams) {
	// ignored by default
	return null;
}
 
Example #13
Source File: LanguageClientImpl.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@Override
public CompletableFuture<MessageActionItem> showMessageRequest(ShowMessageRequestParams arg0) {
    System.err.println("showMessageRequest");
    return null; //???
}
 
Example #14
Source File: CommandRegistryTest.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
public CompletableFuture<MessageActionItem> showMessageRequest(ShowMessageRequestParams requestParams) {
	return noImpl3.showMessageRequest(requestParams);
}
 
Example #15
Source File: MockLanguageClient.java    From lsp4j with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public CompletableFuture<MessageActionItem> showMessageRequest(ShowMessageRequestParams requestParams) {
	throw new UnsupportedOperationException();
}
 
Example #16
Source File: JavaClientConnection.java    From eclipse.jdt.ls with Eclipse Public License 2.0 3 votes vote down vote up
/**
 * Sends the message to the client, to be displayed on a UI element.
 * Waits for an answer from the user and returns the selected
 * action.
 *
 * @param type
 * @param msg
 * @return
 */
public MessageActionItem showNotificationMessageRequest(MessageType type, String msg, List<MessageActionItem> actions){
	ShowMessageRequestParams $ = new ShowMessageRequestParams();
	$.setMessage(msg);
	$.setType(type);
	$.setActions(actions);
	return client.showMessageRequest($).join();
}
 
Example #17
Source File: LanguageClient.java    From lsp4j with Eclipse Public License 2.0 2 votes vote down vote up
/**
 * The show message request is sent from a server to a client to ask the
 * client to display a particular message in the user interface. In addition
 * to the show message notification the request allows to pass actions and
 * to wait for an answer from the client.
 */
@JsonRequest("window/showMessageRequest")
CompletableFuture<MessageActionItem> showMessageRequest(ShowMessageRequestParams requestParams);