| 
| Can't get All sub-entities defined in different files(Xtext2.1.1) [message #759180] | Sun, 27 November 2011 07:56  |  | 
| Eclipse User  |  |  |  |  | Grammar: 
 
Entity:
	'entity' name=ValidID ('extends' superType=[Entity])? '{'
		features+=Feature*
	'}';
 I want to retrieve all sub-entities for a specific entity using following xtend functions
 
 
	def superEntities(Entity e){
		var ArrayList<Entity> superEntities = newArrayList()
		var curEntity = e.superType
		while(curEntity!=null){
			superEntities += curEntity
			curEntity = curEntity.superType	
		}
		superEntities
	}
	def subEntities(Entity e){
		var entities = Iterators::filter(e.eResource.resourceSet.allContents,typeof(Entity))
		entities = Iterators::filter(entities)[entity|
			entity.superEntities.contains(e)
		]
		newArrayList(Iterators::toArray(entities,typeof(Entity)))	
	}
 Define the following two models in different files:
 p1.dmodel:
 
 
package p1{
	entity A {
	}
	entity B extends A{
	}
}
 p2.dmodel:
 
 
package p2{
	
	import p1.*
	entity C extends A{
	}
}
 If p2.dmodel is not opened in an editor, function subEntities only returns B as A's sub entity, C is missing.
 
 
 How to implement subEntities(Entity e) correctly?
 
 Thanks.
 
 Tiange zhang
 
 
 
 |  |  |  | 
|  | 
|  | 
|  | 
|  | 
|  | 
|  | 
Powered by 
FUDForum. Page generated in 0.05120 seconds