use of org.eclipse.lsp4e.command.internal.CommandEventParameter in project lsp4e by eclipse.
the class CommandExecutor method createEclipseCoreCommand.
private static ParameterizedCommand createEclipseCoreCommand(@NonNull Command command, IPath context, @NonNull IWorkbench workbench) {
// Usually commands are defined via extension point, but we synthesize one on
// the fly for the command ID, since we do not want downstream users
// having to define them.
String commandId = command.getCommand();
@Nullable ICommandService commandService = workbench.getService(ICommandService.class);
org.eclipse.core.commands.Command coreCommand = commandService.getCommand(commandId);
if (!coreCommand.isDefined()) {
ParameterType commandParamType = commandService.getParameterType(LSP_COMMAND_PARAMETER_TYPE_ID);
ParameterType pathParamType = commandService.getParameterType(LSP_PATH_PARAMETER_TYPE_ID);
Category category = commandService.getCategory(LSP_COMMAND_CATEGORY_ID);
IParameter[] parameters = { new CommandEventParameter(commandParamType, command.getTitle(), LSP_COMMAND_PARAMETER_ID), new CommandEventParameter(pathParamType, command.getTitle(), LSP_PATH_PARAMETER_ID) };
coreCommand.define(commandId, null, category, parameters);
}
Map<Object, Object> parameters = new HashMap<>();
parameters.put(LSP_COMMAND_PARAMETER_ID, command);
parameters.put(LSP_PATH_PARAMETER_ID, context);
ParameterizedCommand parameterizedCommand = ParameterizedCommand.generateCommand(coreCommand, parameters);
return parameterizedCommand;
}
Aggregations