damp.ekeko.jdt.ast documentation
Low-level relations of JDT AST nodes.
ast
(ast ?keyword ?node)
Reifies the relation between ASTNode instances ?node
and their kind ?keyword.
In general, ?keyword is the keyword that corresponds
to the capitalized, unqualified name of ?node's class.
Examples:
;; all method declarations
(ekeko* [?node] (ast :MethodDeclaration ?node))
;; all ast nodes of any kind
(ekeko* [?keyword ?node] (ast ?keyword ?node))
See also:
API documentation of org.eclipse.jdt.core.dom.ASTNode
ast-location
(ast-location ?ast ?locationVector)
Relation between ASTNode ?ast and Clojure vector ?locationVector
representing its location: [begin-character-index-in-file,
end-chararacter-index-in-file,
begin-line-number,
end-line-number]
ast-methoddeclaration|encompassing
(ast-methoddeclaration|encompassing ?ast ?m)
Relation between ASTNode ?ast and the MethodDeclaration ?m that encompasses it.
Operationally, performs a recursive ascend.
See also:
Predicate ast-encompassing-method-non-failing/2 unifies ?m with nil
if there is no encompassing method.
ast-methoddeclaration|encompassing|nonfailing
(ast-methoddeclaration|encompassing|nonfailing ?ast ?m-or-nil)
(ast-methoddeclaration|encompassing|nonfailing ?ast ?m ?ancestor)
Relation between ASTNode ?ast and either the MethodDeclaration ?m that encompasses it,
or nil if there is no encopassing MethodDeclaration.
Operationally, performs a recursive ascend.
See also:
Predicate ast-encompassing-method/2 which fails if there is no encompassing method.
ast-parent
(ast-parent ?ast ?parent)
Relation between an ASTNode instance ?ast and its parent node
?parent. Note that this predicate fails for CompilationUnit instances,
which function as the root of the AST.
See also:
- API documentation of org.eclipse.jdt.core.dom.ASTNode
- Condition (has ?property ?parent ?value),
which also works for primitive values and lists that stem from an AST.
ast-parent+
(ast-parent+ ?ast ?ancestor)
Relation between an ASTNode and one of its ancestor ASTNodes.
See also:
- binary predicate value-parent+/2 which works for property values that aren't nodes
- binary predicate astorvalue-parent+/2 which works for both
ast-root
(ast-root ?ast ?cu)
Relation between an ASTNode instance ?ast and the root of its tree ?cu,
an instance of CompilationUnit.
See also:
API documentation of org.eclipse.jdt.core.dom.ASTNode
ast-typedeclaration|encompassing
(ast-typedeclaration|encompassing ?ast ?t)
(ast-typedeclaration|encompassing ?ast ?t ?ancestor)
Relation between ASTNode ?ast and the TypeDeclaration ?t that encompasses it.
astorvalue-offspring+
(astorvalue-offspring+ ?astorlist ?offspring)
Relation between an ASTNode or a list that stems from an ASTNode
and one of its offspring nodes or their values (i.e., complete recursive descent).
Note that this predicate will produce bindings
?offspring->list
?offspring->list members
See also: binary predicate child+/2, which implements the sub-relation
between two ASTNodes only.
astorvalue-root
(astorvalue-root ?astorvalue ?root)
Relation between an ASTNode or a property value and their root CompilationUnit.
ast|declaration
(ast|declaration ?key ?ast)
Like binary ast/2 predicate, but ensures ?ast is
a declaration ASTNode instance.
See also:
Binary predicate ast/2
ast|declaration-modifier
(ast|declaration-modifier ?key ?ast ?mod)
Reifies the relation between a declaration AST node ?ast
of kind ?key and any of its modifiers ?mod.
See also:
Ternary predicate ast/3
ast|declaration|resolveable
(ast|declaration|resolveable ?key ?ast)
Like binary ast/2 predicate, but ensures ?ast
is a resolveable declaration ASTNode instance.
See also:
Binary predicates ast|resolveable/2 and ast|declaration/2.
ast|expression
(ast|expression ?key ?ast)
Relation between an Expression instance ?ast and
the keyword ?key representing its kind.
ast|expression|reference
(ast|expression|reference ?keyw ?ast)
Relation between a reference-valued Expression instance ?ast and
the keyword ?keyw representing its kind.
ast|fieldaccess
(ast|fieldaccess ?key ?node)
Like binary ast/2 predicate, but ensures ?ast is
an ASTNode that accesses a field.
Note that ?ast can be an instance of FieldAccess,
SuperFieldAccess, SimpleName or QualifiedName.
ast|invocation
(ast|invocation ?key ?node)
Like binary ast/2, but ensures ?ast is an ASTNode
that invokes a method or constructor.
Note that ?ast can be an instance of MethodInvocation,
SuperMethodInvocation, ClassInstanceCreation,
ConstructorInvocation or SuperConstructorInvocation
ast|localvariable
(ast|localvariable ?key ?ast)
Relation between a local variable ?ast (either a SimpleName or QualifiedName),
used as an expression,
and the keyword ?key corresponding to its kind.
ast|parameter|name
(ast|parameter|name ?keyw ?name)
Like ast/2, but ensures ?name is the SimpleName
of a formal parameter declaration.
ast|resolveable
(ast|resolveable ?key ?ast)
Like binary ast/2 predicate, but ensures ?ast is an ASTNode
instance that can be resolved to an IBinding
(i.e., implements method resolveBinding).
See also:
Binary predicate ast/2
API documentation of org.eclipse.jdt.core.dom.IBinding
ast|type
(ast|type ?key ?type)
Like ast/2, but ensures ?type is an
instance of one of the Type subclasses.
Note that these are references to types within the source code,
rather than a canonical representation of a type.
aux
(aux ?keyword ?node ?value)
Same behaviour as has if keyword is a ChildProperty of SimpleProperty.
Same behaviour as child if keyword is a ChildListProperty.
See also:
Ternary predicate has/3 and child/3
child
(child ?keyword ?node ?child)
Reifies the relation between an ASTNode instance ?node
and its ASTNode children ?child that are either the value
of the child property or an element of the child list
property named ?keyword.
In contrast to has/3, ?child is therefore always an
instance of ASTNode.
Note that ?keyword is the keyword that corresponds to
the decapitalized name of the property's PropertyDescriptor.
Examples:
;;?child is any of the arguments to the method invocation ?inv
(ekeko* [?inv ?child] (ast :MethodInvocation ?inv)
(child :arguments ?inv ?child))
See also:
Ternary predicate has/3
API documentation of org.eclipse.jdt.core.dom.ASTNode
and org.eclipse.jdt.core.dom.StructuralPropertyDescriptor
child+
(child+ ?node ?child)
Transitive closure of the child relation.
In other words, ?child is an ASTNode instance that resides at
an arbitrary depth within the ASTNode instance ?node.
Operationally, a recursive descent is performed through ?node.
Examples:
;;?exp is an expression within method declaration ?m
(ekeko* [?m ?ch] (ast :MethodDeclaration ?m)
(child+ ?m ?ch))
See also:
- Ternary predicate child/3.
- Binary predicate has+/2 which implements the super-relation
between any two values.
has
(has ?keyword ?node ?child)
Reifies the relation between an ASTNode instance ?node
and the value ?child of its property named ?keyword.
Here, ?keyword is the keyword that corresponds to the
decapitalized name of the property's PropertyDescriptor.
In general, ?child is either another ASTNode instance,
a primitive value or an instance of ASTNode$NodeList.
Examples:
;; method invocations and their receiver
(ekeko* [?inv ?exp]
(ast :MethodInvocation ?inv)
(has :expression ?inv exp))
;; all properties of all compilation units
(ekeko* [?cu ?key ?child]
(ast :CompilationUnit ?cu)
(has ?key ?cu ?child))
See also:
Ternary predicate child/3
API documentation of org.eclipse.jdt.core.dom.ASTNode
and org.eclipse.jdt.core.dom.StructuralPropertyDescriptor
method-cfg-entry-exit
(method-cfg-entry-exit ?m ?cfg ?entry ?exit)
Relation between a MethodDeclaration ?m, its control
flow graph ?cfg (an EclipseCFG),
and its entry and exit points (both EclipseCFGNode instances),
all in a format suitable to be queried with
the regular path expressions provided by the damp.qwal libraries.
Example:
Methods in which there is at least one path on which ?nodebefore is an AST
node evaluated immediately before a ?return statement. A synthetic CFG node is allowed
in between ?nodebefore and ?return. One transition to a synthetic node and the exit point
of the cfg is required.
See src-crystal/cfgthrows.png and src-crystal/cfguberreturn.png for
example visualiations of control flow graphs.
(ekeko* [?m ?cfg ?entry ?exit ?nodebefore ?return ?syntheticbetween ?syntheticend]
(method-cfg-entry-exit ?m ?cfg ?entry ?exit)
(fresh [?beforeReturn ?return]
(project [?cfg]
(qwal ?cfg ?entry ?exit
[]
(q=>*)
(qcurrent [cfgnode]
(node|cfg-node|ast cfgnode ?nodebefore))
q=>
(q? (qcurrent [cfgnode]
(equals ?syntheticbetween cfgnode)
(node|cfg|syntethic ?syntheticbetween)) q=>)
(qcurrent [cfgnode]
(node|cfg-node|ast cfgnode ?return)
(ast :ReturnStatement ?return))
q=>
(qcurrent [cfgnode]
(equals ?syntheticend cfgnode)
(node|cfg|syntethic ?syntheticend))
q=>))))
Equivalent, without information about synthetic nodes:
(ekeko* [?m ?cfg ?entry ?exit ?nodebefore ?return]
(method-cfg-entry-exit ?m ?cfg ?entry ?exit)
(fresh [?beforeReturn ?return]
(project [?cfg]
(qwal ?cfg ?entry ?exit
[]
(q=>*)
(qcurrent [cfgnode]
(node|cfg-node|ast cfgnode ?nodebefore))
q=>
(q? (qcurrent [cfgnode] (node|cfg|syntethic? cfgnode) q=>))
(qcurrent [cfgnode]
(node|cfg-node|ast cfgnode ?return)
(ast :ReturnStatement ?return))
q=>
(qcurrent [cfgnode] (node|cfg|syntethic? cfgnode))
q=>
))))
See also:
Documentation of the damp.qwal library.
method-statements
(method-statements ?m ?statements)
Relation between a MethodDeclaration ?m and its
ASTNode$NodeList list of statements ?slist in its body.
Note that abstract methods are not included in this relation,
but methods with en empty body are.
name-name|same|qualified
(name-name|same|qualified ?name-a ?name-b)
Relation between two (Simple/Qualified)Name instances whose qualified name as a string is the same.
name-string|qualified
(name-string|qualified ?name ?string)
Relation between a SimpleName or QualifiedName ASTNode and its fully qualified name as a string.
name|qualified-name
(name|qualified-name ?qname ?sname)
Relation between a QualifiedName ASTNode and its last SimpleName part.
name|qualified-qualifier
(name|qualified-qualifier ?qname ?sname)
Relation between a QualifiedName ASTNode and its qualifier QualiefiedName part .
name|qualified-string
(name|qualified-string ?name ?string)
Relation between a QualifiedName ASTNode and its identifier string.
name|simple-name|simple|same
(name|simple-name|simple|same ?name-a ?name-b)
Relation between two SimpleName instances that share the same identifier.
name|simple-string
(name|simple-string ?name ?string)
Relation between a SimpleName ASTNode and its identifier string.
node|cfg-node|ast
(node|cfg-node|ast ?cfgnode ?astnode)
Relation between a given EclipseCFGNode ?cfgnode and the ASTNode ?astnode that it wraps.
Non-relational.
node|cfg|syntethic
(node|cfg|syntethic ?cfgnode)
Logic goal that succeeds when a given CFGNode is synthetic. Non-relational.
Synthetic CFG nodes do not correspond to an AST node, but to a methods' uber return or throws node.
node|cfg|syntethic?
(node|cfg|syntethic? cfgnode)
Function for testing whether a given CFGNode is synthetic.
Synthetic CFG nodes do not correspond to an AST node, but to a methods' uber return or throws node.
value
(value ?val)
Relation of ASTNode property values that aren't ASTNode themselves:
nil, primitive values and lists.
value-parent+
(value-parent+ ?value ?ancestor)
Relation between an ASTNode property value that isn't an ASTNode itself
(a primitive value, null, or a list) and one of its ancestor ASTNodes.
See also:
- binary predicate ast-parent+/2 which works for ASTNodes
- binary predicate astorvalue-parent+/2 which works for both
value-raw
(value-raw ?val ?raw)
Relation of an ASTNode property value that isn't an ASTNode itself
and its raw value (either a primitive, nil, or a list).
value-root
(value-root ?value ?root)
Relation between a non-ASTNode property value and its root CompilationUnit.
value|list
(value|list ?val)
Relation of all list-valued ASTNode property values.
value|null
(value|null ?val)
Relation of all null-valued ASTNode property values.
value|primitive
(value|primitive ?val)
Relation of all primitive-valued ASTNode property values.