My bad, apparently I missent half of my messages
Begin forwarded message:
From: Simon Denier simon.denier@gmail.com Date: 25 janvier 2011 23:53:45 HNEC Cc: Simon Denier simon.denier@gmail.com Subject: MooseChef 2/4, querying objects and scaling
Once a primitive query has been sent to a Famix entity, you can transform the query result with more refined queries.
*** The other side of the dependencies Primitive queries retrieve the associations. However, since we already know the source, we might be interested only by the objects on the other side of the dependency. Chef provides the #opposites selector to directly retrieve the other side of the association: that is the #from side of an incoming dependency, and the #to side of an outgoing dependency.
For example: aMethod queryIncomingInvocations opposites retrieves the methods calling aMethod.
aMethod queryOutgoingReferences opposites retrieves the classes referenced by aMethod.
Reminder:
- Inheritance: from Class to Class
- Access: from Method to Variable
- Invocation: from Method to Method
- Reference: from Method to Class
(Class extension: ???)
*** Scoping (or scaling) dependencies Another interesting operation is to get the dependency information at a higher granularity by changing the scope. That is, one can ask for the dependencies coming from invocations as seen at the package level. This is querying for invoked or invoking packages.
Three scope operators are available on query results: atClassScope, atPackageScope, atNamespaceScope
aMethod queryOutgoingReferences atPackageScope retrieves packages which contain classes referenced by the method.
aPackage queryIncomingInvocations atClassScope retrieves classes which 'call' the package.
The scope operators exclude self loop by default (this was also the default in Moose Cook). That is, the query result will not contain the scope of the source (you will not get something like PackageX -> PackageX in the result) (the reason for this is that algorithms do not like graphs with self loops in general). However, this could be discussed and I could easily provide a default implementation with self loops included and a refined query #withoutSelfLoops
PS (mindnote) I might add some opposite operators to "scale down" results in some cases, like:
aFamixPackage queryAllOugoingDependencies sourceClasses retrieves classes from the packages which are involved in outgoing dependencies. Notice it returns the source, not the opposite side of the relationship.
-- Simon Denier
-- Simon Denier