Search in sources :

Example 1 with EObjectDescriptionImpl

use of org.eclipse.xtext.builder.builderState.impl.EObjectDescriptionImpl in project xtext-eclipse by eclipse.

the class BuilderStateUtil method create.

public static EObjectDescriptionImpl create(IEObjectDescription desc) {
    EObjectDescriptionImpl objectDescription = (EObjectDescriptionImpl) BuilderStateFactory.eINSTANCE.createEObjectDescription();
    objectDescription.setEClass(desc.getEClass());
    objectDescription.setFragment(desc.getEObjectURI().fragment());
    objectDescription.setName(desc.getName());
    for (String key : desc.getUserDataKeys()) {
        objectDescription.getUserData().put(key, desc.getUserData(key));
    }
    return objectDescription;
}
Also used : EObjectDescriptionImpl(org.eclipse.xtext.builder.builderState.impl.EObjectDescriptionImpl)

Example 2 with EObjectDescriptionImpl

use of org.eclipse.xtext.builder.builderState.impl.EObjectDescriptionImpl in project xtext-eclipse by eclipse.

the class AbstractEMFBasedPersisterTest method createObjectDescription.

public IEObjectDescription createObjectDescription(int idx) {
    EObjectDescriptionImpl result = (EObjectDescriptionImpl) BuilderStateFactory.eINSTANCE.createEObjectDescription();
    result.setEClass(BuilderStatePackage.eINSTANCE.getEObjectDescription());
    result.setFragment("newFragment" + idx);
    result.setName(createQualifiedName("name" + idx));
    return result;
}
Also used : EObjectDescriptionImpl(org.eclipse.xtext.builder.builderState.impl.EObjectDescriptionImpl)

Example 3 with EObjectDescriptionImpl

use of org.eclipse.xtext.builder.builderState.impl.EObjectDescriptionImpl in project xtext-xtend by eclipse.

the class BuilderStateUtilBenchmark method createExportedObjects.

private void createExportedObjects(ResourceDescriptionImpl resourceDescription) {
    List<IEObjectDescription> list = resourceDescription.getExportedObjects();
    for (int i = 0; i < objectDescriptions; i++) {
        final int idx = i;
        EObjectDescriptionImpl objectDescription = new EObjectDescriptionImpl() {

            URI uri = URI.createURI("myURI#myFragment/" + idx);

            @Override
            public URI getEObjectURI() {
                return uri;
            }
        };
        objectDescription.setEClass(BuilderStatePackage.Literals.EOBJECT_DESCRIPTION);
        objectDescription.setName(QualifiedName.create("myFragment", String.valueOf(i)));
        createUserData(objectDescription);
        list.add(objectDescription);
    }
}
Also used : URI(org.eclipse.emf.common.util.URI) IEObjectDescription(org.eclipse.xtext.resource.IEObjectDescription) EObjectDescriptionImpl(org.eclipse.xtext.builder.builderState.impl.EObjectDescriptionImpl)

Example 4 with EObjectDescriptionImpl

use of org.eclipse.xtext.builder.builderState.impl.EObjectDescriptionImpl in project xtext-eclipse by eclipse.

the class EObjectDescriptionImplTest method testContainerAndFragmentChange.

@Test
public void testContainerAndFragmentChange() {
    EObjectDescriptionImpl objectDescription = (EObjectDescriptionImpl) BuilderStateFactory.eINSTANCE.createEObjectDescription();
    objectDescription.setFragment("myFragment");
    ResourceDescriptionImpl resourceDescription = (ResourceDescriptionImpl) BuilderStateFactory.eINSTANCE.createResourceDescription();
    resourceDescription.getExportedObjects().add(objectDescription);
    resourceDescription.setURI(URI.createURI("some.uri"));
    assertEquals(URI.createURI("some.uri#myFragment"), objectDescription.getEObjectURI());
    resourceDescription.setURI(URI.createURI("some2.uri"));
    assertEquals(URI.createURI("some2.uri#myFragment"), objectDescription.getEObjectURI());
    objectDescription.setFragment("newFragment");
    assertEquals(URI.createURI("some2.uri#newFragment"), objectDescription.getEObjectURI());
}
Also used : ResourceDescriptionImpl(org.eclipse.xtext.builder.builderState.impl.ResourceDescriptionImpl) EObjectDescriptionImpl(org.eclipse.xtext.builder.builderState.impl.EObjectDescriptionImpl) Test(org.junit.Test)

Example 5 with EObjectDescriptionImpl

use of org.eclipse.xtext.builder.builderState.impl.EObjectDescriptionImpl in project xtext-eclipse by eclipse.

the class EObjectDescriptionImplTest method testNoNPE.

@Test
public void testNoNPE() {
    EObjectDescriptionImpl objectDescription = (EObjectDescriptionImpl) BuilderStateFactory.eINSTANCE.createEObjectDescription();
    objectDescription.setFragment("myFragment");
    ResourceDescriptionImpl resourceDescription = (ResourceDescriptionImpl) BuilderStateFactory.eINSTANCE.createResourceDescription();
    resourceDescription.getExportedObjects().add(objectDescription);
    resourceDescription.setURI(URI.createURI("does.not.matter"));
    EClass doesNotExist = EcoreFactory.eINSTANCE.createEClass();
    InternalEObject proxy = (InternalEObject) doesNotExist;
    proxy.eSetProxyURI(URI.createURI("does.not.exist"));
    objectDescription.setEClass(doesNotExist);
    assertSame(doesNotExist, objectDescription.getEClass());
    assertNull(objectDescription.getEObjectOrProxy());
    assertEquals("does.not.matter#myFragment", objectDescription.getEObjectURI().toString());
}
Also used : EClass(org.eclipse.emf.ecore.EClass) ResourceDescriptionImpl(org.eclipse.xtext.builder.builderState.impl.ResourceDescriptionImpl) InternalEObject(org.eclipse.emf.ecore.InternalEObject) EObjectDescriptionImpl(org.eclipse.xtext.builder.builderState.impl.EObjectDescriptionImpl) Test(org.junit.Test)

Aggregations

EObjectDescriptionImpl (org.eclipse.xtext.builder.builderState.impl.EObjectDescriptionImpl)5 ResourceDescriptionImpl (org.eclipse.xtext.builder.builderState.impl.ResourceDescriptionImpl)2 Test (org.junit.Test)2 URI (org.eclipse.emf.common.util.URI)1 EClass (org.eclipse.emf.ecore.EClass)1 InternalEObject (org.eclipse.emf.ecore.InternalEObject)1 IEObjectDescription (org.eclipse.xtext.resource.IEObjectDescription)1