use of org.eclipse.xtext.ide.server.commands.IExecutableCommandService in project xtext-core by eclipse.
the class ExecutableCommandRegistry method initialize.
public void initialize(final Iterable<? extends IResourceServiceProvider> allLanguages, final ClientCapabilities capabilities, final LanguageClient client) {
this.client = client;
this.registeredCommands = HashMultimap.<String, IExecutableCommandService>create();
Boolean _elvis = null;
WorkspaceClientCapabilities _workspace = capabilities.getWorkspace();
ExecuteCommandCapabilities _executeCommand = null;
if (_workspace != null) {
_executeCommand = _workspace.getExecuteCommand();
}
Boolean _dynamicRegistration = null;
if (_executeCommand != null) {
_dynamicRegistration = _executeCommand.getDynamicRegistration();
}
if (_dynamicRegistration != null) {
_elvis = _dynamicRegistration;
} else {
_elvis = Boolean.valueOf(false);
}
final boolean hasDynamicRegistration = (boolean) _elvis;
for (final IResourceServiceProvider lang : allLanguages) {
{
final IExecutableCommandService service = lang.<IExecutableCommandService>get(IExecutableCommandService.class);
if ((service != null)) {
final List<String> commands = service.initialize();
for (final String c : commands) {
this.registeredCommands.put(c, service);
}
if (hasDynamicRegistration) {
final Function1<String, IDisposable> _function = (String command) -> {
return this.register(command, service);
};
service.initializeDynamicRegistration(_function);
}
}
}
}
}
use of org.eclipse.xtext.ide.server.commands.IExecutableCommandService in project xtext-core by eclipse.
the class ExecutableCommandRegistry method executeCommand.
public Object executeCommand(final ExecuteCommandParams params, final ILanguageServerAccess access, final CancelIndicator cancelIndicator) {
Object result = null;
Collection<IExecutableCommandService> _get = this.registeredCommands.get(params.getCommand());
for (final IExecutableCommandService service : _get) {
{
final Object localResult = service.execute(params, access, cancelIndicator);
if ((localResult != null)) {
if ((result != null)) {
StringConcatenation _builder = new StringConcatenation();
_builder.append("Multiple commands \'");
String _command = params.getCommand();
_builder.append(_command);
_builder.append("\' have been registered. All are executed but only one result will be send back.");
ExecutableCommandRegistry.LOG.error(_builder);
} else {
result = localResult;
}
}
}
}
return result;
}
Aggregations