Search in sources :

Example 1 with AddTerminologyCommmand

use of com.nedap.openehr.lsp.commands.AddTerminologyCommmand in project archetype-languageserver by nedap.

the class ADL2TextDocumentService method executeCommand.

/**
 * The workspace/executeCommand request is sent from the client to the
 * server to trigger command execution on the server. In most cases the
 * server creates a WorkspaceEdit structure and applies the changes to the
 * workspace using the request workspace/applyEdit which is sent from the
 * server to the client.
 *
 * Registration Options: ExecuteCommandRegistrationOptions
 */
@JsonRequest
public CompletableFuture<Object> executeCommand(ExecuteCommandParams params) {
    switch(params.getCommand()) {
        case ADL2_COMMAND:
            {
                String documentUri = ((JsonPrimitive) params.getArguments().get(0)).getAsString();
                storage.convertAdl14(documentUri);
                break;
            }
        case ALL_ADL2_COMMAND:
            {
                String documentUri = ((JsonPrimitive) params.getArguments().get(0)).getAsString();
                storage.convertAllAdl14(documentUri);
                break;
            }
        case ADD_TO_TERMINOLOGY:
            new AddTerminologyCommmand(storage, this, params).apply();
            break;
        case WRITE_OPT_COMMAND:
            new ConvertToOptCommand(storage, this, params).apply();
            break;
        case WRITE_EXAMPLE_COMMAND:
            new GenerateExampleCommand(storage, this, params).apply();
            break;
        case SHOW_INFO_COMMAND:
            this.remoteProxy.showMessage(new MessageParams(MessageType.Info, params.getArguments().get(0).toString()));
            this.remoteEndPoint.notify("custom/showCodeLens", params.getArguments().get(0).toString());
            this.remoteEndPoint.request("custom/showCodeLens", params.getArguments().get(0).toString());
            break;
        default:
            throw new UnsupportedOperationException("unknown command: " + params.getCommand());
    }
    return CompletableFuture.completedFuture(null);
}
Also used : GenerateExampleCommand(com.nedap.openehr.lsp.commands.GenerateExampleCommand) AddTerminologyCommmand(com.nedap.openehr.lsp.commands.AddTerminologyCommmand) ConvertToOptCommand(com.nedap.openehr.lsp.commands.ConvertToOptCommand) JsonRequest(org.eclipse.lsp4j.jsonrpc.services.JsonRequest)

Aggregations

AddTerminologyCommmand (com.nedap.openehr.lsp.commands.AddTerminologyCommmand)1 ConvertToOptCommand (com.nedap.openehr.lsp.commands.ConvertToOptCommand)1 GenerateExampleCommand (com.nedap.openehr.lsp.commands.GenerateExampleCommand)1 JsonRequest (org.eclipse.lsp4j.jsonrpc.services.JsonRequest)1