Search in sources :

Example 1 with IResourceServiceProvider

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

the class ArithmeticsStandaloneSetupGenerated method register.

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

Example 2 with IResourceServiceProvider

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

the class DirtyStateEditorSupportIntegrationTest method setUpEditor.

@Before
public void setUpEditor() {
    try {
        final IResourceServiceProvider rsp = IResourceServiceProvider.Registry.INSTANCE.getResourceServiceProvider(URI.createURI("dummy.testlanguage"));
        rsp.<Injector>get(Injector.class).injectMembers(this);
        final IFile file = IResourcesSetupUtil.createFile("test/foo.testlanguage", "stuff foo");
        this.editor = this.openEditor(file);
        NullProgressMonitor _nullProgressMonitor = new NullProgressMonitor();
        this.syncUtil.yieldToQueuedDisplayJobs(_nullProgressMonitor);
        this.editor.getSite().getPage().activate(this.editor);
        NullProgressMonitor _nullProgressMonitor_1 = new NullProgressMonitor();
        this.syncUtil.yieldToQueuedDisplayJobs(_nullProgressMonitor_1);
        this.events = CollectionLiterals.<IResourceDescription.Event>newArrayList();
        final IResourceDescription.Event.Listener _function = (IResourceDescription.Event it) -> {
            this.events.add(it);
        };
        this.editor.getDirtyStateEditorSupport().getDirtyStateManager().addListener(_function);
        this.myDisplay = this.editor.getSite().getShell().getDisplay();
        IterableExtensions.<Shell>head(((Iterable<Shell>) Conversions.doWrapArray(this.myDisplay.getShells()))).forceActive();
        NullProgressMonitor _nullProgressMonitor_2 = new NullProgressMonitor();
        this.syncUtil.yieldToQueuedDisplayJobs(_nullProgressMonitor_2);
        this.styledText = this.editor.getInternalSourceViewer().getTextWidget();
        this.styledText.setCaretOffset(9);
        this.styledText.setFocus();
        this.syncUtil.waitForReconciler(this.editor);
        NullProgressMonitor _nullProgressMonitor_3 = new NullProgressMonitor();
        this.syncUtil.yieldToQueuedDisplayJobs(_nullProgressMonitor_3);
        Thread.sleep(20);
        Assert.assertTrue(this.events.isEmpty());
    } catch (Throwable _e) {
        throw Exceptions.sneakyThrow(_e);
    }
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IResourceServiceProvider(org.eclipse.xtext.resource.IResourceServiceProvider) Shell(org.eclipse.swt.widgets.Shell) IFile(org.eclipse.core.resources.IFile) IResourceDescription(org.eclipse.xtext.resource.IResourceDescription) Injector(com.google.inject.Injector) Event(org.eclipse.swt.widgets.Event) Before(org.junit.Before)

Example 3 with IResourceServiceProvider

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

the class XbaseBreakpointDetailPaneFactory method createDetailPane.

@Override
public IDetailPane createDetailPane(String paneID) {
    if (XBASE_DETAIL_PANE.equals(paneID)) {
        return new LineBreakpointDetailPane() {

            @Override
            public void display(IStructuredSelection selection) {
                super.display(selection);
                AbstractJavaBreakpointEditor editor = getEditor();
                Object input = null;
                if (selection != null && selection.size() == 1) {
                    input = selection.getFirstElement();
                }
                try {
                    if (input instanceof IJavaStratumLineBreakpoint) {
                        IJavaStratumLineBreakpoint stratumBreakpoint = (IJavaStratumLineBreakpoint) input;
                        URI uri = URI.createURI((String) stratumBreakpoint.getMarker().getAttribute(StratumBreakpointAdapterFactory.ORG_ECLIPSE_XTEXT_XBASE_SOURCE_URI));
                        IResourceServiceProvider resourceServiceProvider = registry.getResourceServiceProvider(uri);
                        if (resourceServiceProvider != null) {
                            JavaBreakPointProvider javaBreakPointProvider = resourceServiceProvider.get(JavaBreakPointProvider.class);
                            input = javaBreakPointProvider.getBreakpointWithJavaLocation(stratumBreakpoint);
                        }
                    }
                    editor.setInput(input);
                } catch (CoreException e) {
                    JDIDebugUIPlugin.log(e);
                }
            }
        };
    } else {
        return super.createDetailPane(paneID);
    }
}
Also used : IJavaStratumLineBreakpoint(org.eclipse.jdt.debug.core.IJavaStratumLineBreakpoint) IResourceServiceProvider(org.eclipse.xtext.resource.IResourceServiceProvider) CoreException(org.eclipse.core.runtime.CoreException) AbstractJavaBreakpointEditor(org.eclipse.jdt.internal.debug.ui.breakpoints.AbstractJavaBreakpointEditor) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) URI(org.eclipse.emf.common.util.URI) LineBreakpointDetailPane(org.eclipse.jdt.internal.debug.ui.breakpoints.LineBreakpointDetailPane)

Example 4 with IResourceServiceProvider

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

the class EPackageChooser method createResourceSet.

private ResourceSet createResourceSet(URI genModelUri) {
    ResourceSetImpl resourceSet;
    if (genModelUri.fileExtension().equals("xcore")) {
        IResourceServiceProvider resourceServiceProvider = IResourceServiceProvider.Registry.INSTANCE.getResourceServiceProvider(genModelUri);
        IStorage2UriMapper storage2UriMapper = resourceServiceProvider.get(IStorage2UriMapper.class);
        IProject project = storage2UriMapper.getStorages(genModelUri).iterator().next().getSecond();
        resourceSet = (ResourceSetImpl) resourceServiceProvider.get(IResourceSetProvider.class).get(project);
    } else {
        resourceSet = new ResourceSetImpl();
    }
    Resource ecorePackageResource = EcorePackage.eINSTANCE.eResource();
    Map<URI, Resource> uriResourceMap = Maps.newHashMap();
    uriResourceMap.put(URI.createPlatformResourceURI(PATH_TO_ECORE_ECORE, true), ecorePackageResource);
    uriResourceMap.put(URI.createPlatformPluginURI(PATH_TO_ECORE_ECORE, true), ecorePackageResource);
    resourceSet.setURIResourceMap(uriResourceMap);
    return resourceSet;
}
Also used : IResourceServiceProvider(org.eclipse.xtext.resource.IResourceServiceProvider) ResourceSetImpl(org.eclipse.emf.ecore.resource.impl.ResourceSetImpl) IStorage2UriMapper(org.eclipse.xtext.ui.resource.IStorage2UriMapper) IResource(org.eclipse.core.resources.IResource) Resource(org.eclipse.emf.ecore.resource.Resource) URI(org.eclipse.emf.common.util.URI) IProject(org.eclipse.core.resources.IProject) IResourceSetProvider(org.eclipse.xtext.ui.resource.IResourceSetProvider)

Example 5 with IResourceServiceProvider

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

the class ReferenceGrammarUiTestLanguageStandaloneSetupGenerated method register.

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

Aggregations

IResourceServiceProvider (org.eclipse.xtext.resource.IResourceServiceProvider)264 IResourceFactory (org.eclipse.xtext.resource.IResourceFactory)188 URI (org.eclipse.emf.common.util.URI)26 Resource (org.eclipse.emf.ecore.resource.Resource)21 IResourceDescription (org.eclipse.xtext.resource.IResourceDescription)21 XtextResource (org.eclipse.xtext.resource.XtextResource)13 ResourceSet (org.eclipse.emf.ecore.resource.ResourceSet)10 List (java.util.List)8 ArrayList (java.util.ArrayList)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