Search in sources :

Example 61 with IResourceServiceProvider

use of org.eclipse.xtext.resource.IResourceServiceProvider in project dsl-devkit by dsldevkit.

the class CheckCfgUtil method getAllLanguages.

/**
 * Gets the all languages available in the workbench.
 *
 * @return set of all languages
 */
public Set<String> getAllLanguages() {
    Set<String> languages = new HashSet<String>();
    for (String extension : Registry.INSTANCE.getExtensionToFactoryMap().keySet()) {
        final URI dummyUri = URI.createURI("foo:/foo." + extension);
        IResourceServiceProvider resourceServiceProvider = Registry.INSTANCE.getResourceServiceProvider(dummyUri);
        // By checking that description manager is AbstractCachingResourceDescriptionManager we exclude technical languages of the framework
        if (resourceServiceProvider != null && resourceServiceProvider.getResourceDescriptionManager() instanceof AbstractCachingResourceDescriptionManager) {
            try {
                IGrammarAccess grammarAccess = resourceServiceProvider.get(IGrammarAccess.class);
                if (grammarAccess != null && grammarAccess.getGrammar() != null) {
                    languages.add(grammarAccess.getGrammar().getName());
                }
            } catch (ConfigurationException e) {
            // Will happen if no binding for IGrammarAccess was present.
            }
        }
    }
    return languages;
}
Also used : AbstractCachingResourceDescriptionManager(com.avaloq.tools.ddk.xtext.resource.AbstractCachingResourceDescriptionManager) IResourceServiceProvider(org.eclipse.xtext.resource.IResourceServiceProvider) IGrammarAccess(org.eclipse.xtext.IGrammarAccess) ConfigurationException(com.google.inject.ConfigurationException) URI(org.eclipse.emf.common.util.URI) HashSet(java.util.HashSet)

Example 62 with IResourceServiceProvider

use of org.eclipse.xtext.resource.IResourceServiceProvider in project xtext-core by eclipse.

the class IndentationAwareUiTestLanguageStandaloneSetupGenerated method register.

public void register(Injector injector) {
    if (!EPackage.Registry.INSTANCE.containsKey("http://www.eclipse.org/xtext/ide/tests/testlanguage/IndentationAwareUiTestLanguage")) {
        EPackage.Registry.INSTANCE.put("http://www.eclipse.org/xtext/ide/tests/testlanguage/IndentationAwareUiTestLanguage", IndentationAwareUiTestLanguagePackage.eINSTANCE);
    }
    IResourceFactory resourceFactory = injector.getInstance(IResourceFactory.class);
    IResourceServiceProvider serviceProvider = injector.getInstance(IResourceServiceProvider.class);
    Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("indentationAwareUiTestLang", resourceFactory);
    IResourceServiceProvider.Registry.INSTANCE.getExtensionToFactoryMap().put("indentationAwareUiTestLang", serviceProvider);
}
Also used : IResourceServiceProvider(org.eclipse.xtext.resource.IResourceServiceProvider) IResourceFactory(org.eclipse.xtext.resource.IResourceFactory)

Example 63 with IResourceServiceProvider

use of org.eclipse.xtext.resource.IResourceServiceProvider in project xtext-core by eclipse.

the class FileAwareTestLanguageStandaloneSetupGenerated method register.

public void register(Injector injector) {
    if (!EPackage.Registry.INSTANCE.containsKey("http://www.eclipse.org/xtext/testlanguage/FileAware")) {
        EPackage.Registry.INSTANCE.put("http://www.eclipse.org/xtext/testlanguage/FileAware", FileAwarePackage.eINSTANCE);
    }
    IResourceFactory resourceFactory = injector.getInstance(IResourceFactory.class);
    IResourceServiceProvider serviceProvider = injector.getInstance(IResourceServiceProvider.class);
    Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("fileawaretestlanguage", resourceFactory);
    IResourceServiceProvider.Registry.INSTANCE.getExtensionToFactoryMap().put("fileawaretestlanguage", serviceProvider);
}
Also used : IResourceServiceProvider(org.eclipse.xtext.resource.IResourceServiceProvider) IResourceFactory(org.eclipse.xtext.resource.IResourceFactory)

Example 64 with IResourceServiceProvider

use of org.eclipse.xtext.resource.IResourceServiceProvider in project xtext-core by eclipse.

the class AssignmentsTestLanguageStandaloneSetupGenerated 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("assignmentstestlanguage", resourceFactory);
    IResourceServiceProvider.Registry.INSTANCE.getExtensionToFactoryMap().put("assignmentstestlanguage", serviceProvider);
    if (!EPackage.Registry.INSTANCE.containsKey("http://www.eclipse.org/2008/tmf/xtext/AssignmentsTest")) {
        EPackage.Registry.INSTANCE.put("http://www.eclipse.org/2008/tmf/xtext/AssignmentsTest", AssignmentsTestLanguagePackage.eINSTANCE);
    }
}
Also used : IResourceServiceProvider(org.eclipse.xtext.resource.IResourceServiceProvider) IResourceFactory(org.eclipse.xtext.resource.IResourceFactory)

Example 65 with IResourceServiceProvider

use of org.eclipse.xtext.resource.IResourceServiceProvider in project xtext-core by eclipse.

the class CommentAssociationTestLanguageStandaloneSetupGenerated 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("commentassociationtestlanguage", resourceFactory);
    IResourceServiceProvider.Registry.INSTANCE.getExtensionToFactoryMap().put("commentassociationtestlanguage", serviceProvider);
    if (!EPackage.Registry.INSTANCE.containsKey("http://www.eclipse.org/xtext/tests/CommentAssociation")) {
        EPackage.Registry.INSTANCE.put("http://www.eclipse.org/xtext/tests/CommentAssociation", CommentAssociationPackage.eINSTANCE);
    }
}
Also used : IResourceServiceProvider(org.eclipse.xtext.resource.IResourceServiceProvider) IResourceFactory(org.eclipse.xtext.resource.IResourceFactory)

Aggregations

IResourceServiceProvider (org.eclipse.xtext.resource.IResourceServiceProvider)267 IResourceFactory (org.eclipse.xtext.resource.IResourceFactory)190 URI (org.eclipse.emf.common.util.URI)25 Resource (org.eclipse.emf.ecore.resource.Resource)21 IResourceDescription (org.eclipse.xtext.resource.IResourceDescription)20 XtextResource (org.eclipse.xtext.resource.XtextResource)13 ResourceSet (org.eclipse.emf.ecore.resource.ResourceSet)10 ArrayList (java.util.ArrayList)7 List (java.util.List)7 Map (java.util.Map)5 IResource (org.eclipse.core.resources.IResource)5 EObject (org.eclipse.emf.ecore.EObject)5 Manager (org.eclipse.xtext.resource.IResourceDescription.Manager)5 Issue (org.eclipse.xtext.validation.Issue)5 Injector (com.google.inject.Injector)4 IProject (org.eclipse.core.resources.IProject)4 SubMonitor (org.eclipse.core.runtime.SubMonitor)4 SourceRelativeURI (org.eclipse.xtext.generator.trace.SourceRelativeURI)4 IEObjectDescription (org.eclipse.xtext.resource.IEObjectDescription)4 IResourceValidator (org.eclipse.xtext.validation.IResourceValidator)4