Search in sources :

Example 16 with IResourceServiceProvider

use of org.eclipse.xtext.resource.IResourceServiceProvider in project statecharts by Yakindu.

the class DirtyStateAwareDiagramDocumentEditor method createDirtyResource.

private void createDirtyResource(Resource resource) {
    IResourceServiceProvider resourceServiceProvider = IResourceServiceProvider.Registry.INSTANCE.getResourceServiceProvider(resource.getURI());
    if (resourceServiceProvider == null) {
        return;
    }
    final DirtyResourceAdapter dirtyResource = new DirtyResourceAdapter(resource, resourceServiceProvider);
    dirtyStateManager.manageDirtyState(dirtyResource);
    uri2dirtyResource.put(resource.getURI(), dirtyResource);
    if (EcoreUtil.getExistingAdapter(resource, DirtyResourceUpdater.class) == null)
        resource.eAdapters().add(new DirtyResourceUpdater(dirtyResource));
}
Also used : IResourceServiceProvider(org.eclipse.xtext.resource.IResourceServiceProvider)

Example 17 with IResourceServiceProvider

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

the class DslStandaloneSetupGenerated method register.

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

Example 18 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 19 with IResourceServiceProvider

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

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

Example 20 with IResourceServiceProvider

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

the class InheritanceTestLanguageStandaloneSetupGenerated 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("inheritancetestlanguage", resourceFactory);
    IResourceServiceProvider.Registry.INSTANCE.getExtensionToFactoryMap().put("inheritancetestlanguage", serviceProvider);
    if (!EPackage.Registry.INSTANCE.containsKey("http://www.eclipse.org/2009/tmf/xtext/InheritanceTestLanguage")) {
        EPackage.Registry.INSTANCE.put("http://www.eclipse.org/2009/tmf/xtext/InheritanceTestLanguage", InheritanceTestPackage.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