public void testComputeEObjectDescriptionsForEmptyFile() throws Exception { Resource res = getResourceAndExpect(new StringInputStream(""), URI.createURI("foo.xtext"), 1); Manager manager = get(IResourceDescription.Manager.class); IResourceDescription description = manager.getResourceDescription(res); Iterable<IEObjectDescription> iterable = description.getExportedObjects(); assertTrue(Lists.newArrayList(iterable).isEmpty()); }
public void testGetExportedEObjectsErroneousResource() throws Exception { Resource res = getResourceAndExpect( new StringInputStream("grammar foo Start : 'main';"), URI.createURI("foo.xtext"), 1); Manager manager = get(IResourceDescription.Manager.class); IResourceDescription description = manager.getResourceDescription(res); Iterable<IEObjectDescription> iterable = description.getExportedObjects(); assertTrue(Lists.newArrayList(iterable).size() == 2); }
public void testBug350695() throws Exception { Resource res = getResource( new StringInputStream("grammar org.foo.Zonk generate x \"someURI\" Start : 'main';"), URI.createURI("foo.xtext")); Manager manager = get(IResourceDescription.Manager.class); IResourceDescription description = manager.getResourceDescription(res); assertTrue( Iterables.isEmpty( description.getExportedObjects( XtextPackage.Literals.GRAMMAR, QualifiedName.create("org.foo.Zonk"), false))); IEObjectDescription element = Iterables.getOnlyElement( description.getExportedObjects( XtextPackage.Literals.GRAMMAR, QualifiedName.create("org", "foo", "Zonk"), false)); assertNotNull(element); }