Search in sources :

Example 1 with CrossResourceContainerOneChild

use of org.eclipse.xtext.parser.partialParsingTestUtil.CrossResourceContainerOneChild in project xtext-core by eclipse.

the class CrossContainmentTest method testCrossContainment_02.

@Test
public void testCrossContainment_02() {
    XtextResourceSet resourceSet = get(XtextResourceSet.class);
    resourceSet.setClasspathURIContext(getClass());
    Resource resource = resourceSet.createResource(URI.createFileURI("container.xmi"));
    Resource childResource = resourceSet.createResource(URI.createFileURI("child.xmi"));
    CrossResourceContainerOneChild container = PartialParsingTestUtilFactory.eINSTANCE.createCrossResourceContainerOneChild();
    resource.getContents().add(container);
    Grammar grammar = XtextFactory.eINSTANCE.createGrammar();
    childResource.getContents().add(grammar);
    assertNull(grammar.eContainer());
    container.setChild(grammar);
    assertSame(container, grammar.eContainer());
    assertSame(childResource, grammar.eResource());
    assertSame(resource, container.eResource());
}
Also used : XtextResourceSet(org.eclipse.xtext.resource.XtextResourceSet) Resource(org.eclipse.emf.ecore.resource.Resource) CrossResourceContainerOneChild(org.eclipse.xtext.parser.partialParsingTestUtil.CrossResourceContainerOneChild) Grammar(org.eclipse.xtext.Grammar) Test(org.junit.Test)

Example 2 with CrossResourceContainerOneChild

use of org.eclipse.xtext.parser.partialParsingTestUtil.CrossResourceContainerOneChild in project xtext-core by eclipse.

the class PartialParserCrossContainmentSingleTest method setCrossResourceContainer.

@Override
protected void setCrossResourceContainer(XtextResource resource) {
    ResourceSet resourceSet = resource.getResourceSet();
    Resource containerResource = resourceSet.createResource(URI.createFileURI("sample.xmi"));
    CrossResourceContainerOneChild container = PartialParsingTestUtilFactory.eINSTANCE.createCrossResourceContainerOneChild();
    containerResource.getContents().add(container);
    assertEquals(1, resource.getContents().size());
    container.setChild(resource.getContents().get(0));
}
Also used : XtextResource(org.eclipse.xtext.resource.XtextResource) Resource(org.eclipse.emf.ecore.resource.Resource) CrossResourceContainerOneChild(org.eclipse.xtext.parser.partialParsingTestUtil.CrossResourceContainerOneChild) ResourceSet(org.eclipse.emf.ecore.resource.ResourceSet)

Aggregations

Resource (org.eclipse.emf.ecore.resource.Resource)2 CrossResourceContainerOneChild (org.eclipse.xtext.parser.partialParsingTestUtil.CrossResourceContainerOneChild)2 ResourceSet (org.eclipse.emf.ecore.resource.ResourceSet)1 Grammar (org.eclipse.xtext.Grammar)1 XtextResource (org.eclipse.xtext.resource.XtextResource)1 XtextResourceSet (org.eclipse.xtext.resource.XtextResourceSet)1 Test (org.junit.Test)1