Search in sources :

Example 6 with ResourceDescriptionImpl

use of org.eclipse.xtext.builder.builderState.impl.ResourceDescriptionImpl 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 7 with ResourceDescriptionImpl

use of org.eclipse.xtext.builder.builderState.impl.ResourceDescriptionImpl 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

ResourceDescriptionImpl (org.eclipse.xtext.builder.builderState.impl.ResourceDescriptionImpl)7 Test (org.junit.Test)3 URI (org.eclipse.emf.common.util.URI)2 EObjectDescriptionImpl (org.eclipse.xtext.builder.builderState.impl.EObjectDescriptionImpl)2 IResourceDescription (org.eclipse.xtext.resource.IResourceDescription)2 IProject (org.eclipse.core.resources.IProject)1 CoreException (org.eclipse.core.runtime.CoreException)1 OperationCanceledException (org.eclipse.core.runtime.OperationCanceledException)1 SubMonitor (org.eclipse.core.runtime.SubMonitor)1 WrappedException (org.eclipse.emf.common.util.WrappedException)1 EClass (org.eclipse.emf.ecore.EClass)1 InternalEObject (org.eclipse.emf.ecore.InternalEObject)1 Resource (org.eclipse.emf.ecore.resource.Resource)1 ResourceSet (org.eclipse.emf.ecore.resource.ResourceSet)1 MonitorBasedCancelIndicator (org.eclipse.xtext.builder.MonitorBasedCancelIndicator)1 LoadOperation (org.eclipse.xtext.builder.resourceloader.IResourceLoader.LoadOperation)1 LoadOperationException (org.eclipse.xtext.builder.resourceloader.IResourceLoader.LoadOperationException)1 LoadResult (org.eclipse.xtext.builder.resourceloader.IResourceLoader.LoadResult)1 Delta (org.eclipse.xtext.resource.IResourceDescription.Delta)1 DefaultResourceDescriptionDelta (org.eclipse.xtext.resource.impl.DefaultResourceDescriptionDelta)1