Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF-IncQuery » Simplification of Query
Simplification of Query [message #1404125] Tue, 29 July 2014 18:53 Go to next message
Mario Bauer is currently offline Mario BauerFriend
Messages: 21
Registered: May 2014
Junior Member
Hi,

could you please tell me, if there is any way of to simplify of shorten the following query:

pattern TooLargeMemberContainers(memberContainer : MemberContainer) {
	countClassMethods == count find classMethods(memberContainer, _AnyclassMethod);
	countConstructors == count find constructors(memberContainer, _Anyconstructor);
	countInterfaceMethods == count find interfaceMethods(memberContainer, _Anyinterface);
	totalCount == eval(countClassMethods + countConstructors + countInterfaceMethods);
	check(totalCount > 20);
}

private pattern classMethods(type, classMethod : ClassMethod) {
	MemberContainer.members(type, classMethod);
}

private pattern constructors(type, constructor : Constructor) {
	MemberContainer.members(type, constructor);
}

private pattern interfaceMethods(type, interfaceMethod : InterfaceMethod) {
	MemberContainer.members(type, interfaceMethod);
}


Thanks and Greetings, Mario
Re: Simplification of Query [message #1404155 is a reply to message #1404125] Wed, 30 July 2014 05:31 Go to previous messageGo to next message
Balázs Grill is currently offline Balázs GrillFriend
Messages: 8
Registered: July 2009
Junior Member
Are there any other type of member that you don't want to count? If not, it is not necessary to count all different members sparately:

pattern TooLargeMemberContainers(memberContainer : MemberContainer) {
	totalCount == count find members(memberContainer, _member);
	check(totalCount > 20);
}

private pattern members(type, member) {
	MemberContainer.members(type, member);
}



It's still possible to restrict counted members to certain types:

pattern TooLargeMemberContainers(memberContainer : MemberContainer) {
	totalCount == count find members(memberContainer, _member);
	check(totalCount > 20);
}

private pattern members(type, member) {
	MemberContainer.members(type, member);
	find counterMembers(member);
}

private pattern countedMembers(member){
	ClassMethod(member);
} or {
	Constructor(member);
} or {
	InterfaceMethod(member);
}



I hope this helps

Balázs;
Re: Simplification of Query [message #1404190 is a reply to message #1404155] Wed, 30 July 2014 10:23 Go to previous message
Mario Bauer is currently offline Mario BauerFriend
Messages: 21
Registered: May 2014
Junior Member
Thanks a lot, your version is more readable and easier to extend. I just fixed one bug.
In the checkType pattern, in the signature I had to add the Type of the parameter member.

pattern TooLargeMemberContainers(memberContainer : MemberContainer) {
	totalCount == count find members(memberContainer, _);
	check(totalCount > 20);
}

private pattern members(type, member) {
	MemberContainer.members(type, member);
	find checkType(member);
}

private pattern checkType(member : Member){
	ClassMethod(member);
} or {
	Constructor(member);
} or {
	InterfaceMethod(member);
}
Previous Topic:Compare values
Next Topic:get Eclass of EObject
Goto Forum:
  


Current Time: Sat May 23 13:46:10 GMT 2015

Powered by FUDForum. Page generated in 0.01605 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software