Search in sources :

Example 1 with AbstractResourceDescription

use of org.eclipse.xtext.resource.impl.AbstractResourceDescription in project xtext-eclipse by eclipse.

the class EObjectDescriptionBasedStubGeneratorTest method testNested.

@Test
public void testNested() {
    final EObjectDescription _top = new EObjectDescription(QualifiedName.create("foo", "Bar"), TypesFactory.eINSTANCE.createJvmGenericType(), Collections.<String, String>emptyMap());
    final EObjectDescription _nested0 = new EObjectDescription(QualifiedName.create("foo", "Bar$Baz0"), TypesFactory.eINSTANCE.createJvmGenericType(), Collections.singletonMap(JvmTypesResourceDescriptionStrategy.IS_NESTED_TYPE, Boolean.TRUE.toString()));
    final EObjectDescription _nested1 = new EObjectDescription(QualifiedName.create("foo", "Bar$Baz1"), TypesFactory.eINSTANCE.createJvmGenericType(), Collections.singletonMap(JvmTypesResourceDescriptionStrategy.IS_NESTED_TYPE, Boolean.TRUE.toString()));
    final EObjectDescription _nested10 = new EObjectDescription(QualifiedName.create("foo", "Bar$Baz1$FooBar0"), TypesFactory.eINSTANCE.createJvmGenericType(), Collections.singletonMap(JvmTypesResourceDescriptionStrategy.IS_NESTED_TYPE, Boolean.TRUE.toString()));
    final EObjectDescription _nested11 = new EObjectDescription(QualifiedName.create("foo", "Bar$Baz1$FooBar0"), TypesFactory.eINSTANCE.createJvmGenericType(), Collections.singletonMap(JvmTypesResourceDescriptionStrategy.IS_NESTED_TYPE, Boolean.TRUE.toString()));
    IResourceDescription resourceDescription = new AbstractResourceDescription() {

        @Override
        public URI getURI() {
            return null;
        }

        @Override
        public Iterable<IReferenceDescription> getReferenceDescriptions() {
            return Collections.emptyList();
        }

        @Override
        public Iterable<QualifiedName> getImportedNames() {
            return Collections.emptyList();
        }

        @Override
        protected List<IEObjectDescription> computeExportedObjects() {
            return Arrays.asList(new IEObjectDescription[] { _top, _nested0, _nested1, _nested10, _nested11 });
        }
    };
    assertEquals("package foo;\n" + "public class Bar{\n" + "public static class Baz0{\n" + "}\n" + "public static class Baz1{\n" + "public static class FooBar0{\n" + "}\n" + "public static class FooBar0{\n" + "}\n" + "}\n" + "}", gen.getJavaStubSource(_top, resourceDescription));
}
Also used : EObjectDescription(org.eclipse.xtext.resource.EObjectDescription) IEObjectDescription(org.eclipse.xtext.resource.IEObjectDescription) IResourceDescription(org.eclipse.xtext.resource.IResourceDescription) AbstractResourceDescription(org.eclipse.xtext.resource.impl.AbstractResourceDescription) QualifiedName(org.eclipse.xtext.naming.QualifiedName) IReferenceDescription(org.eclipse.xtext.resource.IReferenceDescription) IEObjectDescription(org.eclipse.xtext.resource.IEObjectDescription) Test(org.junit.Test)

Example 2 with AbstractResourceDescription

use of org.eclipse.xtext.resource.impl.AbstractResourceDescription in project xtext-eclipse by eclipse.

the class ValidationJobSchedulerTest method setUp.

@Override
public void setUp() throws Exception {
    super.setUp();
    referenceDescriptions = Lists.newArrayList();
    dirtyStateManager = new DirtyStateManager();
    testMe = new ValidationJobScheduler();
    testMe.setDirtyStateManager(dirtyStateManager);
    testMe.setDescriptionUtils(new DescriptionUtils());
    testMe.setResourceDescriptions(this);
    testMe.setResourceDescriptionManager(new DefaultResourceDescriptionManager());
    DocumentTokenSource nullSource = new DocumentTokenSource() {

        @Override
        protected IRegion computeDamageRegion(DocumentEvent e) {
            return new Region(0, 0);
        }
    };
    document = new XtextDocument(nullSource, null, outdatedStateManager, operationCanceledManager) {

        @Override
        public URI getResourceURI() {
            return documentURI;
        }

        @Override
        public void checkAndUpdateAnnotations() {
            validationScheduled = true;
        }
    };
    documentResource = new TestableDocumentResource();
    targetResource = new AbstractResourceDescription() {

        @Override
        public URI getURI() {
            return targetURI;
        }

        @Override
        public Iterable<IReferenceDescription> getReferenceDescriptions() {
            throw new UnsupportedOperationException();
        }

        @Override
        public Iterable<QualifiedName> getImportedNames() {
            throw new UnsupportedOperationException();
        }

        @Override
        protected List<IEObjectDescription> computeExportedObjects() {
            if (documentResource.importedName == null)
                throw new UnsupportedOperationException();
            return Collections.emptyList();
        }
    };
}
Also used : DescriptionUtils(org.eclipse.xtext.resource.DescriptionUtils) AbstractResourceDescription(org.eclipse.xtext.resource.impl.AbstractResourceDescription) ValidationJobScheduler(org.eclipse.xtext.ui.editor.ValidationJobScheduler) DefaultResourceDescriptionManager(org.eclipse.xtext.resource.impl.DefaultResourceDescriptionManager) XtextDocument(org.eclipse.xtext.ui.editor.model.XtextDocument) DocumentEvent(org.eclipse.jface.text.DocumentEvent) URI(org.eclipse.emf.common.util.URI) DirtyStateManager(org.eclipse.xtext.ui.editor.DirtyStateManager) DocumentTokenSource(org.eclipse.xtext.ui.editor.model.DocumentTokenSource) Region(org.eclipse.jface.text.Region) IRegion(org.eclipse.jface.text.IRegion) List(java.util.List)

Aggregations

AbstractResourceDescription (org.eclipse.xtext.resource.impl.AbstractResourceDescription)2 List (java.util.List)1 URI (org.eclipse.emf.common.util.URI)1 DocumentEvent (org.eclipse.jface.text.DocumentEvent)1 IRegion (org.eclipse.jface.text.IRegion)1 Region (org.eclipse.jface.text.Region)1 QualifiedName (org.eclipse.xtext.naming.QualifiedName)1 DescriptionUtils (org.eclipse.xtext.resource.DescriptionUtils)1 EObjectDescription (org.eclipse.xtext.resource.EObjectDescription)1 IEObjectDescription (org.eclipse.xtext.resource.IEObjectDescription)1 IReferenceDescription (org.eclipse.xtext.resource.IReferenceDescription)1 IResourceDescription (org.eclipse.xtext.resource.IResourceDescription)1 DefaultResourceDescriptionManager (org.eclipse.xtext.resource.impl.DefaultResourceDescriptionManager)1 DirtyStateManager (org.eclipse.xtext.ui.editor.DirtyStateManager)1 ValidationJobScheduler (org.eclipse.xtext.ui.editor.ValidationJobScheduler)1 DocumentTokenSource (org.eclipse.xtext.ui.editor.model.DocumentTokenSource)1 XtextDocument (org.eclipse.xtext.ui.editor.model.XtextDocument)1 Test (org.junit.Test)1