We've discussed filters and transforms as applying to specific kinds of set expressions: those returning classes, or those returning methods. This concept is expressed more formally in the language with expression types. A set expression has a type, which represents the type of objects that the expression returns (this type is distinct from any type within the analyzed system.) BBQ supports a hierarchy of types that is fully described in the reference: it includes: classes, methods, fields, method calls, field references, types (Java types), arguments, packages, and strings and numbers in expressions.
Most transforms can only be applied to certain types:
for example, methods in
can only be applied to a set expression with type class, and the resulting expression
has type method.
The reference page for each transform lists the types to which the transform
may be applied, as well as the type that will result from applying
the transform.
Similarly, most filters may only be applied to certain types, which are listed on the reference page for the filter. From the definition of filters you can see that the output type of a filter is always identical to its input type.
When you combine two set expressions with an operator,
the resulting expression is assigned the most specific type
that is a base type of both the constituent expressions.
Similarly, BBQ has rules for determining the applicable
and result types of
complex transforms and filters.
You probably don't need to know the details of the rules, but
BBQ uses them to determine if the expressions you
write make sense.
For example, the transform
calls to intersection fields in
can't work
because it
is combining the two transforms
calls to
and fields in
;the calls to
transform applies to methods
while the fields in
transform applies only to classes.
There is no set expression type
to which both transforms could sensibly be applied.
If you are using BBQ and receive an error message
about Incompatible types,
you've probably made this type of mistake in
writing your set expression.
The complete type resolution rules are listed in the
reference.
browse-by-query home | antlersoft free software | sourceforge project page |