All Downloads are FREE. Search and download functionalities are using the official Maven repository.

ai.vespa.schemals.lsp.common.command.ExecuteCommand Maven / Gradle / Ivy

There is a newer version: 8.441.21
Show newest version
package ai.vespa.schemals.lsp.common.command;

import java.util.Optional;

import ai.vespa.schemals.context.EventExecuteCommandContext;
import ai.vespa.schemals.lsp.common.command.commandtypes.SchemaCommand;

/**
 * Responsible for LSP workspace/executeCommand requests.
 */
public class ExecuteCommand {
    public static Object executeCommand(EventExecuteCommandContext context) {
        Optional command = CommandRegistry.getCommand(context.params);

        context.logger.info("Received command: " + context.params.getCommand());

        if (command.isEmpty()) {
            context.logger.error("Unknown command " + context.params.getCommand());
            context.logger.error("Arguments:");
            for (Object obj : context.params.getArguments()) {
                context.logger.info(obj.getClass().toString() + ": " + obj.toString());
            }
            return null;
        }

        Object resultOrNull = command.get().execute(context);
        return resultOrNull;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy