use of org.eclipse.xtext.resource.IResourceServiceProvider in project xtext-core by eclipse.
the class Bug406914TestLanguageStandaloneSetupGenerated method register.
public void register(Injector injector) {
IResourceFactory resourceFactory = injector.getInstance(IResourceFactory.class);
IResourceServiceProvider serviceProvider = injector.getInstance(IResourceServiceProvider.class);
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("bug406914testlanguage", resourceFactory);
IResourceServiceProvider.Registry.INSTANCE.getExtensionToFactoryMap().put("bug406914testlanguage", serviceProvider);
if (!EPackage.Registry.INSTANCE.containsKey("http://eclipse.org/xtext/Bug406914TestLanguage")) {
EPackage.Registry.INSTANCE.put("http://eclipse.org/xtext/Bug406914TestLanguage", Bug406914TestPackage.eINSTANCE);
}
}
use of org.eclipse.xtext.resource.IResourceServiceProvider in project xtext-core by eclipse.
the class MetamodelRefTestLanguageStandaloneSetupGenerated method register.
public void register(Injector injector) {
IResourceFactory resourceFactory = injector.getInstance(IResourceFactory.class);
IResourceServiceProvider serviceProvider = injector.getInstance(IResourceServiceProvider.class);
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("metamodelreftestlanguage", resourceFactory);
IResourceServiceProvider.Registry.INSTANCE.getExtensionToFactoryMap().put("metamodelreftestlanguage", serviceProvider);
if (!EPackage.Registry.INSTANCE.containsKey("http://eclipse.org/xtext/tests/AnotherSimpleTest")) {
EPackage.Registry.INSTANCE.put("http://eclipse.org/xtext/tests/AnotherSimpleTest", AnotherSimpleTestPackage.eINSTANCE);
}
}
use of org.eclipse.xtext.resource.IResourceServiceProvider in project xtext-core by eclipse.
the class Bug289524ExTestLanguageStandaloneSetupGenerated method register.
public void register(Injector injector) {
IResourceFactory resourceFactory = injector.getInstance(IResourceFactory.class);
IResourceServiceProvider serviceProvider = injector.getInstance(IResourceServiceProvider.class);
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("bug289524extestlanguage", resourceFactory);
IResourceServiceProvider.Registry.INSTANCE.getExtensionToFactoryMap().put("bug289524extestlanguage", serviceProvider);
if (!EPackage.Registry.INSTANCE.containsKey("http://eclipse.org/xtext/Bug289524ExTestLanguage")) {
EPackage.Registry.INSTANCE.put("http://eclipse.org/xtext/Bug289524ExTestLanguage", Bug289524ExTestPackage.eINSTANCE);
}
}
use of org.eclipse.xtext.resource.IResourceServiceProvider in project xtext-core by eclipse.
the class LanguageServerImpl method codeAction.
/**
* Compute the code action commands. Executed in a read request.
* @since 2.20
*/
protected List<Either<Command, CodeAction>> codeAction(CodeActionParams params, CancelIndicator cancelIndicator) {
URI uri = getURI(params.getTextDocument());
IResourceServiceProvider serviceProvider = getResourceServiceProvider(uri);
ICodeActionService2 service2 = getService(serviceProvider, ICodeActionService2.class);
if (service2 == null) {
return Collections.emptyList();
}
return workspaceManager.doRead(uri, (doc, resource) -> {
List<Either<Command, CodeAction>> result = new ArrayList<>();
if (service2 != null) {
ICodeActionService2.Options options = new ICodeActionService2.Options();
options.setDocument(doc);
options.setResource(resource);
options.setLanguageServerAccess(access);
options.setCodeActionParams(params);
options.setCancelIndicator(cancelIndicator);
List<Either<Command, CodeAction>> actions = service2.getCodeActions(options);
if (actions != null) {
result.addAll(actions);
}
}
return result;
});
}
use of org.eclipse.xtext.resource.IResourceServiceProvider in project xtext-core by eclipse.
the class LanguageServerImpl method supportedMethods.
@Override
public Map<String, JsonRpcMethod> supportedMethods() {
if (supportedMethods != null) {
return supportedMethods;
}
synchronized (extensionProviders) {
Map<String, JsonRpcMethod> supportedMethods = new LinkedHashMap<>();
supportedMethods.putAll(ServiceEndpoints.getSupportedMethods(getClass()));
Map<String, JsonRpcMethod> extensions = new LinkedHashMap<>();
for (IResourceServiceProvider resourceServiceProvider : getAllLanguages()) {
ILanguageServerExtension ext = resourceServiceProvider.get(ILanguageServerExtension.class);
if (ext != null) {
ext.initialize(access);
Map<String, JsonRpcMethod> supportedExtensions = ext instanceof JsonRpcMethodProvider ? ((JsonRpcMethodProvider) ext).supportedMethods() : ServiceEndpoints.getSupportedMethods(ext.getClass());
for (Map.Entry<String, JsonRpcMethod> entry : supportedExtensions.entrySet()) {
if (supportedMethods.containsKey(entry.getKey())) {
LOG.error("The json rpc method \'" + entry.getKey() + "\' can not be an extension as it is already defined in the LSP standard.");
} else {
JsonRpcMethod existing = extensions.put(entry.getKey(), entry.getValue());
if (existing != null && !Objects.equal(existing, entry.getValue())) {
LOG.error("An incompatible LSP extension \'" + entry.getKey() + "\' has already been registered. Using 1 ignoring 2. \n1 : " + existing + " \n2 : " + entry.getValue());
extensions.put(entry.getKey(), existing);
} else {
Endpoint endpoint = ServiceEndpoints.toEndpoint(ext);
extensionProviders.put(entry.getKey(), endpoint);
supportedMethods.put(entry.getKey(), entry.getValue());
}
}
}
}
}
this.supportedMethods = supportedMethods;
return supportedMethods;
}
}
Aggregations