Search in sources :

Example 1 with CrossResourceContainerManyChildren

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

the class CrossContainmentTest method testCrossContainment_01.

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

Example 2 with CrossResourceContainerManyChildren

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

the class PartialParserCrossContainmentMultiTest method setCrossResourceContainer.

@Override
protected void setCrossResourceContainer(XtextResource resource) {
    ResourceSet resourceSet = resource.getResourceSet();
    Resource containerResource = resourceSet.createResource(URI.createFileURI("sample.xmi"));
    CrossResourceContainerManyChildren container = PartialParsingTestUtilFactory.eINSTANCE.createCrossResourceContainerManyChildren();
    containerResource.getContents().add(container);
    container.getChildren().addAll(resource.getContents());
}
Also used : CrossResourceContainerManyChildren(org.eclipse.xtext.parser.partialParsingTestUtil.CrossResourceContainerManyChildren) XtextResource(org.eclipse.xtext.resource.XtextResource) Resource(org.eclipse.emf.ecore.resource.Resource) ResourceSet(org.eclipse.emf.ecore.resource.ResourceSet)

Aggregations

Resource (org.eclipse.emf.ecore.resource.Resource)2 CrossResourceContainerManyChildren (org.eclipse.xtext.parser.partialParsingTestUtil.CrossResourceContainerManyChildren)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