Search in sources :

Example 61 with XtextResourceSet

use of org.eclipse.xtext.resource.XtextResourceSet in project xtext-xtend by eclipse.

the class URIsInEcoreFilesXtendTest method setUp.

@Before
public void setUp() throws Exception {
    resourceSet = new XtextResourceSet();
    resourceSet.getURIConverter().getURIMap().putAll(EcorePlugin.computePlatformURIMap(false));
    resourceSet.getLoadOptions().put(XMLResource.OPTION_URI_HANDLER, this);
}
Also used : XtextResourceSet(org.eclipse.xtext.resource.XtextResourceSet) Before(org.junit.Before)

Example 62 with XtextResourceSet

use of org.eclipse.xtext.resource.XtextResourceSet in project xtext-xtend by eclipse.

the class AbstractXbaseContentAssistTest method getResourceSet.

protected final XtextResourceSet getResourceSet() {
    XtextResourceSet resourceSet = get(XtextResourceSet.class);
    IJvmTypeProvider.Factory typeProviderFactory = new JdtTypeProviderFactory(this);
    typeProviderFactory.findOrCreateTypeProvider(resourceSet);
    resourceSet.setClasspathURIContext(getJavaProject(resourceSet));
    return resourceSet;
}
Also used : JdtTypeProviderFactory(org.eclipse.xtext.common.types.access.jdt.JdtTypeProviderFactory) XtextResourceSet(org.eclipse.xtext.resource.XtextResourceSet) IJvmTypeProvider(org.eclipse.xtext.common.types.access.IJvmTypeProvider)

Example 63 with XtextResourceSet

use of org.eclipse.xtext.resource.XtextResourceSet in project xtext-xtend by eclipse.

the class ActiveAnnotationsRuntimeTest method assertProcessing.

@Override
public void assertProcessing(final Pair<String, String> macroFile, final Pair<String, String> clientFile, final Procedure1<? super CompilationUnitImpl> expectations) {
    try {
        final XtextResourceSet resourceSet = this.compileMacroResourceSet(macroFile, clientFile);
        final Resource singleResource = IterableExtensions.<Resource>head(resourceSet.getResources());
        singleResource.load(CollectionLiterals.<Object, Object>emptyMap());
        final IAcceptor<CompilationTestHelper.Result> _function = (CompilationTestHelper.Result it) -> {
            it.getGeneratedCode();
            final CompilationUnitImpl unit = this.compilationUnitProvider.get();
            final XtendFile xtendFile = IterableExtensions.<XtendFile>head(Iterables.<XtendFile>filter(singleResource.getContents(), XtendFile.class));
            unit.setXtendFile(xtendFile);
            expectations.apply(unit);
        };
        this.compiler.compile(resourceSet, _function);
    } catch (Throwable _e) {
        throw Exceptions.sneakyThrow(_e);
    }
}
Also used : XtendFile(org.eclipse.xtend.core.xtend.XtendFile) CompilationTestHelper(org.eclipse.xtext.xbase.testing.CompilationTestHelper) CompilationUnitImpl(org.eclipse.xtend.core.macro.declaration.CompilationUnitImpl) XtextResourceSet(org.eclipse.xtext.resource.XtextResourceSet) XtextResource(org.eclipse.xtext.resource.XtextResource) Resource(org.eclipse.emf.ecore.resource.Resource)

Example 64 with XtextResourceSet

use of org.eclipse.xtext.resource.XtextResourceSet in project xtext-xtend by eclipse.

the class ActiveAnnotationsRuntimeTest method assertIssues.

public void assertIssues(final Pair<String, String> macroFile, final Pair<String, String> clientFile, final Procedure1<? super List<Issue>> expectations) {
    try {
        final XtextResourceSet resourceSet = this.compileMacroResourceSet(macroFile, clientFile);
        Resource _head = IterableExtensions.<Resource>head(resourceSet.getResources());
        final XtextResource singleResource = ((XtextResource) _head);
        boolean _isLoaded = singleResource.isLoaded();
        boolean _not = (!_isLoaded);
        if (_not) {
            singleResource.load(resourceSet.getLoadOptions());
        }
        final IResourceValidator validator = singleResource.getResourceServiceProvider().getResourceValidator();
        expectations.apply(validator.validate(singleResource, CheckMode.ALL, CancelIndicator.NullImpl));
    } catch (Throwable _e) {
        throw Exceptions.sneakyThrow(_e);
    }
}
Also used : IResourceValidator(org.eclipse.xtext.validation.IResourceValidator) XtextResourceSet(org.eclipse.xtext.resource.XtextResourceSet) XtextResource(org.eclipse.xtext.resource.XtextResource) Resource(org.eclipse.emf.ecore.resource.Resource) XtextResource(org.eclipse.xtext.resource.XtextResource)

Example 65 with XtextResourceSet

use of org.eclipse.xtext.resource.XtextResourceSet in project xtext-xtend by eclipse.

the class AbstractXtendTestCase method getResourceSet.

protected XtextResourceSet getResourceSet() {
    XtextResourceSet set = resourceSetProvider.get();
    set.setClasspathURIContext(getClass().getClassLoader());
    return set;
}
Also used : XtextResourceSet(org.eclipse.xtext.resource.XtextResourceSet)

Aggregations

XtextResourceSet (org.eclipse.xtext.resource.XtextResourceSet)123 Resource (org.eclipse.emf.ecore.resource.Resource)72 XtextResource (org.eclipse.xtext.resource.XtextResource)61 Test (org.junit.Test)44 StringInputStream (org.eclipse.xtext.util.StringInputStream)36 URI (org.eclipse.emf.common.util.URI)24 XtendFile (org.eclipse.xtend.core.xtend.XtendFile)19 ResourceSet (org.eclipse.emf.ecore.resource.ResourceSet)12 EObject (org.eclipse.emf.ecore.EObject)11 File (java.io.File)10 AbstractResourceSetTest (org.eclipse.xtext.resource.AbstractResourceSetTest)10 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)8 Issue (org.eclipse.xtext.validation.Issue)8 Grammar (org.eclipse.xtext.Grammar)7 IResourceDescription (org.eclipse.xtext.resource.IResourceDescription)7 ResourceDescriptionsData (org.eclipse.xtext.resource.impl.ResourceDescriptionsData)7 ArrayList (java.util.ArrayList)5 ClasspathTypeProvider (org.eclipse.xtext.common.types.access.impl.ClasspathTypeProvider)5 Before (org.junit.Before)5 Injector (com.google.inject.Injector)4