Search in sources :

Example 11 with XtextResourceSet

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

the class DocumentLockerTest method testModifySetsOutdatedFalse.

@Test
public void testModifySetsOutdatedFalse() {
    DocumentTokenSource _createTokenSource = this.createTokenSource();
    ITextEditComposer _createTextEditComposer = this.createTextEditComposer();
    final XtextDocument document = new XtextDocument(_createTokenSource, _createTextEditComposer, this.outdatedStateManager, this.operationCanceledManager);
    XtextResource _xtextResource = new XtextResource();
    final Procedure1<XtextResource> _function = (XtextResource it) -> {
        EList<Resource> _resources = new XtextResourceSet().getResources();
        _resources.add(it);
    };
    final XtextResource resource = ObjectExtensions.<XtextResource>operator_doubleArrow(_xtextResource, _function);
    document.setInput(resource);
    final IUnitOfWork<Object, XtextResource> _function_1 = (XtextResource it) -> {
        Object _xblockexpression = null;
        {
            Assert.assertFalse(document.getCancelIndicator().isCanceled());
            _xblockexpression = null;
        }
        return _xblockexpression;
    };
    document.<Object>internalModify(_function_1);
    final CancelIndicator indicator = document.getCancelIndicator();
    Assert.assertFalse(indicator.isCanceled());
    document.set("fupp");
    Assert.assertTrue(indicator.isCanceled());
    final IUnitOfWork<Object, XtextResource> _function_2 = (XtextResource it) -> {
        Object _xblockexpression = null;
        {
            Assert.assertFalse(document.getCancelIndicator().isCanceled());
            _xblockexpression = null;
        }
        return _xblockexpression;
    };
    document.<Object>internalModify(_function_2);
}
Also used : EList(org.eclipse.emf.common.util.EList) DocumentTokenSource(org.eclipse.xtext.ui.editor.model.DocumentTokenSource) XtextResourceSet(org.eclipse.xtext.resource.XtextResourceSet) XtextDocument(org.eclipse.xtext.ui.editor.model.XtextDocument) IXtextDocument(org.eclipse.xtext.ui.editor.model.IXtextDocument) XtextResource(org.eclipse.xtext.resource.XtextResource) CancelIndicator(org.eclipse.xtext.util.CancelIndicator) ITextEditComposer(org.eclipse.xtext.ui.editor.model.edit.ITextEditComposer) AbstractXtextDocumentTest(org.eclipse.xtext.ui.tests.editor.model.AbstractXtextDocumentTest) Test(org.junit.Test)

Example 12 with XtextResourceSet

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

the class DocumentLockerTest method testNoUpdateContentProcessOnReentrant.

@Test
public void testNoUpdateContentProcessOnReentrant() {
    final ArrayList<String> s = CollectionLiterals.<String>newArrayList();
    DocumentTokenSource _createTokenSource = this.createTokenSource();
    ITextEditComposer _createTextEditComposer = this.createTextEditComposer();
    final XtextDocument document = new XtextDocument(_createTokenSource, _createTextEditComposer, this.outdatedStateManager, this.operationCanceledManager) {

        @Override
        protected boolean updateContentBeforeRead() {
            return s.add("x");
        }
    };
    XtextResource _xtextResource = new XtextResource();
    final Procedure1<XtextResource> _function = (XtextResource it) -> {
        EList<Resource> _resources = new XtextResourceSet().getResources();
        _resources.add(it);
    };
    XtextResource _doubleArrow = ObjectExtensions.<XtextResource>operator_doubleArrow(_xtextResource, _function);
    document.setInput(_doubleArrow);
    Assert.assertEquals(0, s.size());
    final IUnitOfWork<Object, XtextResource> _function_1 = (XtextResource it) -> {
        Assert.assertEquals(1, s.size());
        final IUnitOfWork<Object, XtextResource> _function_2 = (XtextResource it_1) -> {
            Assert.assertEquals(1, s.size());
            final IUnitOfWork<Object, XtextResource> _function_3 = (XtextResource it_2) -> {
                Assert.assertEquals(1, s.size());
                return null;
            };
            document.<Object>readOnly(_function_3);
            return null;
        };
        document.<Object>readOnly(_function_2);
        return null;
    };
    document.<Object>readOnly(_function_1);
    Assert.assertEquals(1, s.size());
}
Also used : IUnitOfWork(org.eclipse.xtext.util.concurrent.IUnitOfWork) EList(org.eclipse.emf.common.util.EList) DocumentTokenSource(org.eclipse.xtext.ui.editor.model.DocumentTokenSource) XtextResourceSet(org.eclipse.xtext.resource.XtextResourceSet) XtextDocument(org.eclipse.xtext.ui.editor.model.XtextDocument) IXtextDocument(org.eclipse.xtext.ui.editor.model.IXtextDocument) XtextResource(org.eclipse.xtext.resource.XtextResource) ITextEditComposer(org.eclipse.xtext.ui.editor.model.edit.ITextEditComposer) AbstractXtextDocumentTest(org.eclipse.xtext.ui.tests.editor.model.AbstractXtextDocumentTest) Test(org.junit.Test)

Example 13 with XtextResourceSet

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

the class AbstractHyperlinkingTest method getResourceSet.

public XtextResourceSet getResourceSet() {
    final XtextResourceSet rs = this.<XtextResourceSet>get(XtextResourceSet.class);
    this.initializeTypeProvider(rs);
    return rs;
}
Also used : XtextResourceSet(org.eclipse.xtext.resource.XtextResourceSet)

Example 14 with XtextResourceSet

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

the class GrammarGeneratorTest method checkGeneratedGrammarIsValid.

private void checkGeneratedGrammarIsValid(List<String> ePackageURIs) throws IOException {
    for (String nsURI : ePackageURIs) {
        System.out.print(nsURI);
        EPackage ePackage = EPackage.Registry.INSTANCE.getEPackage(nsURI);
        XtextProjectInfo xtextProjectInfo = new XtextProjectInfo();
        Set<EPackage> ePackages = new HashSet<EPackage>();
        if (!addImportedEPackages(ePackage, ePackages)) {
            System.out.println("...skipping");
        } else {
            List<EPackageInfo> ePackageInfos = Lists.newArrayList(Iterables.transform(ePackages, new Function<EPackage, EPackageInfo>() {

                @Override
                public EPackageInfo apply(EPackage from) {
                    return new EPackageInfo(from, URI.createURI(from.getNsURI()), null, null, null);
                }
            }));
            xtextProjectInfo.getEcore2Xtext().getEPackageInfos().addAll(ePackageInfos);
            String languageName = "org.eclipse.xtext.xtext.ui.tests." + ePackage.getName();
            xtextProjectInfo.getLanguage().setName(languageName);
            String grammarFileName = languageName.replaceAll("\\.", "/") + ".xtext";
            String xtextGrammar = createGrammar(xtextProjectInfo).toString();
            ResourceSet resourceSet = new XtextResourceSet();
            Resource xtextResource = resourceSet.createResource(URI.createFileURI(grammarFileName));
            xtextResource.load(new StringInputStream(xtextGrammar), null);
            checkErrors(ePackage, xtextResource, xtextGrammar);
            if (!WARNING_PACKAGE_NS_URIS.contains(ePackage.getNsURI())) {
                assertTrue("Warnings in grammar for " + ePackage.getNsURI(), xtextResource.getWarnings().isEmpty());
            }
            System.out.println(" ...OK");
        }
    }
}
Also used : Function(com.google.common.base.Function) StringInputStream(org.eclipse.xtext.util.StringInputStream) XtextResourceSet(org.eclipse.xtext.resource.XtextResourceSet) XtextProjectInfo(org.eclipse.xtext.xtext.ui.wizard.project.XtextProjectInfo) Resource(org.eclipse.emf.ecore.resource.Resource) ResourceSet(org.eclipse.emf.ecore.resource.ResourceSet) XtextResourceSet(org.eclipse.xtext.resource.XtextResourceSet) EPackageInfo(org.eclipse.xtext.xtext.wizard.EPackageInfo) EPackage(org.eclipse.emf.ecore.EPackage) HashSet(java.util.HashSet)

Example 15 with XtextResourceSet

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

the class XtextResourceSetBasedProjectProviderTest method setUp.

@Before
public void setUp() throws Exception {
    resourceSet = new XtextResourceSet();
    mockProjectProvider = new MockJavaProjectProvider();
    resourceSet.setClasspathURIContext(mockProjectProvider.getJavaProject(null));
    projectProvider = new XtextResourceSetBasedProjectProvider();
}
Also used : XtextResourceSet(org.eclipse.xtext.resource.XtextResourceSet) MockJavaProjectProvider(org.eclipse.xtext.common.types.access.jdt.MockJavaProjectProvider) XtextResourceSetBasedProjectProvider(org.eclipse.xtext.common.types.xtext.ui.XtextResourceSetBasedProjectProvider) Before(org.junit.Before)

Aggregations

XtextResourceSet (org.eclipse.xtext.resource.XtextResourceSet)177 Resource (org.eclipse.emf.ecore.resource.Resource)81 XtextResource (org.eclipse.xtext.resource.XtextResource)77 Test (org.junit.Test)57 StringInputStream (org.eclipse.xtext.util.StringInputStream)42 URI (org.eclipse.emf.common.util.URI)33 EObject (org.eclipse.emf.ecore.EObject)20 ResourceSet (org.eclipse.emf.ecore.resource.ResourceSet)19 XtendFile (org.eclipse.xtend.core.xtend.XtendFile)19 Grammar (org.eclipse.xtext.Grammar)10 Issue (org.eclipse.xtext.validation.Issue)10 IJavaProject (org.eclipse.jdt.core.IJavaProject)8 File (java.io.File)7 ArrayList (java.util.ArrayList)7 EList (org.eclipse.emf.common.util.EList)7 IResourceDescription (org.eclipse.xtext.resource.IResourceDescription)7 Before (org.junit.Before)7 Injector (com.google.inject.Injector)6 IOException (java.io.IOException)6 Diagnostic (org.eclipse.emf.common.util.Diagnostic)5