use of org.eclipse.xtext.ide.server.ILanguageServerExtension in project xtext-core by eclipse.
the class LanguageServerImpl method supportedMethods.
@Override
public Map<String, JsonRpcMethod> supportedMethods() {
if ((this.supportedMethods != null)) {
return this.supportedMethods;
}
synchronized (this.extensionProviders) {
final LinkedHashMap<String, JsonRpcMethod> supportedMethods = CollectionLiterals.<String, JsonRpcMethod>newLinkedHashMap();
supportedMethods.putAll(ServiceEndpoints.getSupportedMethods(this.getClass()));
final LinkedHashMap<String, JsonRpcMethod> extensions = CollectionLiterals.<String, JsonRpcMethod>newLinkedHashMap();
Iterable<IResourceServiceProvider> _filter = Iterables.<IResourceServiceProvider>filter(IterableExtensions.<Object>toSet(this.languagesRegistry.getExtensionToFactoryMap().values()), IResourceServiceProvider.class);
for (final IResourceServiceProvider resourceServiceProvider : _filter) {
{
final ILanguageServerExtension ext = resourceServiceProvider.<ILanguageServerExtension>get(ILanguageServerExtension.class);
if ((ext != null)) {
ext.initialize(this.access);
Map<String, JsonRpcMethod> _xifexpression = null;
if ((ext instanceof JsonRpcMethodProvider)) {
_xifexpression = ((JsonRpcMethodProvider) ext).supportedMethods();
} else {
_xifexpression = ServiceEndpoints.getSupportedMethods(ext.getClass());
}
final Map<String, JsonRpcMethod> supportedExtensions = _xifexpression;
Set<Map.Entry<String, JsonRpcMethod>> _entrySet = supportedExtensions.entrySet();
for (final Map.Entry<String, JsonRpcMethod> entry : _entrySet) {
boolean _containsKey = supportedMethods.containsKey(entry.getKey());
if (_containsKey) {
String _key = entry.getKey();
String _plus = ("The json rpc method \'" + _key);
String _plus_1 = (_plus + "\' can not be an extension as it is already defined in the LSP standard.");
LanguageServerImpl.LOG.error(_plus_1);
} else {
final JsonRpcMethod existing = extensions.put(entry.getKey(), entry.getValue());
if (((existing != null) && (!Objects.equal(existing, entry.getValue())))) {
String _key_1 = entry.getKey();
String _plus_2 = ("An incompatible LSP extension \'" + _key_1);
String _plus_3 = (_plus_2 + "\' has already been registered. Using 1 ignoring 2. \n1 : ");
String _plus_4 = (_plus_3 + existing);
String _plus_5 = (_plus_4 + " \n2 : ");
JsonRpcMethod _value = entry.getValue();
String _plus_6 = (_plus_5 + _value);
LanguageServerImpl.LOG.error(_plus_6);
extensions.put(entry.getKey(), existing);
} else {
final Endpoint endpoint = ServiceEndpoints.toEndpoint(ext);
this.extensionProviders.put(entry.getKey(), endpoint);
supportedMethods.put(entry.getKey(), entry.getValue());
}
}
}
}
}
}
this.supportedMethods = supportedMethods;
return supportedMethods;
}
}
Aggregations