Java Queries

Enclosing Elements

encl_project(+Id, -ProjectId) is semidet
encl_project(-Id, +ProjectId) is nondet
Unifies ProjectId with the enclosing Project of the tree Id.
encl_project_for_package(+Package, -Project) is nondet
encl_project_for_package(-Package, +Project) is nondet
Unifies Project with all the enclosing Projects of Package.
encl_package(+Id, -PackageId) is semidet
encl_package(-Id, +PackageId) is nondet
Unifies PackageId with the enclosing Package of the tree Id.
declaring_file(+Tree:id, -File:id) is semidet
Is successfull if File is the declaring file of the AST-element Tree.
encl_compilation_unit(+Tree:id, -UnitId:id) is semidet
encl_compilation_unit(-Tree:id, +UnitId:id) is nondet
Unifies upon success UnitId with the enclosing compilation unit of the tree Id.
encl_toplevel_class(+Id:id, -Class:id) is semidet
encl_toplevel_class(-Id:id, +Class:id) is nondet
encl_toplevel_class(-Id:id, -Class:id) is nondet
Is successfull if Class is the enclosing toplevel class of the AST-element Id.
encl_class(+Tree:id, -ClassId:id) is semidet
encl_class(-Tree:id, +ClassId:id) is nondet
Unifies ClassId with the enclosing class of the tree Id.
encl_class_or_self(?Id, -ClassId) is semidet
Unifies ClassId with the enclosing class of the tree Id.
encl_method(+Tree:id, -MethodId:id) is semidet
encl_method(-Tree:id, +MethodId:id) is nondet
Unifies MethodId with the enclosing method of the tree Id.
encl_block(+Tree:id, -BlockId:id) is semidet
encl_block(-Tree:id, +BlockId:id) is nondet
BlockId is the enclosing block of Tree.
encl_block_member(+Id:id, -BlockMember:id) is semidet
encl_block_member(-Id:id, ?BlockMember:id) is nondet
BlockMember is the closest ancestor of ID that has a block as its parent.
encl_declaration(+Id:id, ?EnclId:id) is semidet
If Id denotes a method body element, EnclId is its enclosing declaration (method, constructor, initializer or field).

Typing

get_type(+PEF:id, ?Type) is semidet
Binds the second parameter to the type of the ast element.
element_references_type(+Type, ?TypeReferencedByElement, ?Element)
Finds elements which directly or indirectly reference the type Type.
subtype(?Sub, ?Super) is nondet
Binds Super to itself, any direct or indirect super type of Sub.
proper_subtype(?Sub, ?Super) is nondet
.
type_exists(+Type) is semidet
This predicate checks if the type exists.
ensure_types_exist(+TypeFacts) is det
TypeFacts is a list of type PEFs, i.

References

get_referenced(?Id:id, ?Declaration:id) is nondet
Binds Declaration to the ID of the element referenced by a fieldAccessT, callT, identT of selectT.
get_receiver(+Expr:id, -Receiver:id) is semidet
Receiver is the expression on which Expr is evaluated.

Source Elements

source_element(+Id) is semidet
Checks if Id is a pef defined in a source class.
source_toplevel_class(?Id) is nondet
True if Id is the id of a toplevel class defined in source code, i.
sourceClass(?Id) is nondet
True if Id is the id of a class defined in source code.
sourceMethod(?Id) is nondet
True if Id is the id of a method defined in source code.

Miscellaneous

fully_qualified_name(?Id, ?Fqn) is nondet
Binds Fqn to the fully qualified name of the class with id Id.
toplevel_class(+Class:id, ?Package:id, ?ClassName:atom, ?Members:[id]) is semidet
toplevel_class(-Class:id, ?Package:id, ?ClassName:atom, ?Members:[id]) is nondet
Suceeds if Class is the immediate child of a compilation unit, not nested within any other class.
anonymous_class(?Id) is nondet
True if Id is an anonymous class declaration.
local_class(?Id) is nondet
True if Id is an anonymous class declaration.
package_path(+Pckgname, -PckgPath) is det
Replaces dots with slashes in the package name Pckgname.

encl_project/2

encl_project(+Id, -ProjectId) is semidet
encl_project(-Id, +ProjectId) is nondet
Unifies ProjectId with the enclosing Project of the tree Id.

encl_project_for_package/2

encl_project_for_package(+Package, -Project) is nondet
encl_project_for_package(-Package, +Project) is nondet
Unifies Project with all the enclosing Projects of Package.

encl_package/2

encl_package(+Id, -PackageId) is semidet
encl_package(-Id, +PackageId) is nondet
Unifies PackageId with the enclosing Package of the tree Id. Fails if Id is a package id.

declaring_file/2

declaring_file(+Tree:id, -File:id) is semidet
Is successfull if File is the declaring file of the AST-element Tree.

encl_compilation_unit/2

encl_compilation_unit(+Tree:id, -UnitId:id) is semidet
encl_compilation_unit(-Tree:id, +UnitId:id) is nondet
Unifies upon success UnitId with the enclosing compilation unit of the tree Id.

encl_toplevel_class/2

encl_toplevel_class(+Id:id, -Class:id) is semidet
encl_toplevel_class(-Id:id, +Class:id) is nondet
encl_toplevel_class(-Id:id, -Class:id) is nondet
Is successfull if Class is the enclosing toplevel class of the AST-element Id.

encl_class/2

encl_class(+Tree:id, -ClassId:id) is semidet
encl_class(-Tree:id, +ClassId:id) is nondet
Unifies ClassId with the enclosing class of the tree Id.

encl_class_or_self/2

encl_class_or_self(?Id, -ClassId) is semidet
Unifies ClassId with the enclosing class of the tree Id. If Id is a class itself bind ClassID to Id. Fails if Id is a package id.

encl_method/2

encl_method(+Tree:id, -MethodId:id) is semidet
encl_method(-Tree:id, +MethodId:id) is nondet
Unifies MethodId with the enclosing method of the tree Id.

encl_block/2

encl_block(+Tree:id, -BlockId:id) is semidet
encl_block(-Tree:id, +BlockId:id) is nondet
BlockId is the enclosing block of Tree.

encl_block_member/2

encl_block_member(+Id:id, -BlockMember:id) is semidet
encl_block_member(-Id:id, ?BlockMember:id) is nondet
BlockMember is the closest ancestor of ID that has a block as its parent.

encl_declaration/2

encl_declaration(+Id:id, ?EnclId:id) is semidet
If Id denotes a method body element, EnclId is its enclosing declaration (method, constructor, initializer or field). Otherwise, if Id has a defined parent EnclId is the parent of Id. If the parent is not defined, EnclId is the same as Id!!!

get_type/2

get_type(+PEF:id, ?Type) is semidet
Binds the second parameter to the type of the ast element.

Legal PEFs: localT | fieldT | paramT | methodT | callT | identT | fieldAccessT | literalT | newClassT | operationT | typeCastT | indexedT |selectT | newArrayT | precedenceT typeTestT | assignopT | assignT

Doesn't work for:


element_references_type/3

element_references_type(+Type, ?TypeReferencedByElement, ?Element)
Finds elements which directly or indirectly reference the type Type. Element is the referencing PEF and TypeReferencedByElement is the type referenced by Element. Type and TypeReferencedByElement are equal in case of a direct references.

subtype/2

subtype(?Sub, ?Super) is nondet
Binds Super to itself, any direct or indirect super type of Sub.

Also for primitive types.


proper_subtype/2

proper_subtype(?Sub, ?Super) is nondet

type_exists/1

type_exists(+Type) is semidet
This predicate checks if the type exists.

ensure_types_exist/1

ensure_types_exist(+TypeFacts) is det
TypeFacts is a list of type PEFs, i.e. it may contain parameterizedTypeT/3, arrayTypeT/3, wildcardT/3 and outerTypeParamsT/3 facts.

The first argument of each PEF must be unbound, but the PEFs may contain references among each other. References to types not contained in TypeFacts must be bound.

The predicate will then bind the variables to the IDs of the type facts representing the given type. These type facts either already exist or will be created otherwise.


get_referenced/2

get_referenced(?Id:id, ?Declaration:id) is nondet
Binds Declaration to the ID of the element referenced by a fieldAccessT, callT, identT of selectT.

get_receiver/2

get_receiver(+Expr:id, -Receiver:id) is semidet
Receiver is the expression on which Expr is evaluated. E.g. f is a field access expression on the receiver r in the expression " r.f ". Receiver is null, if the receiver is implicit (this).

Only implemented for identT, selectT, fieldAccessT and callT.


source_element/1

source_element(+Id) is semidet
Checks if Id is a pef defined in a source class. The enclosing class is not marked with externT/1.

source_toplevel_class/1

source_toplevel_class(?Id) is nondet
True if Id is the id of a toplevel class defined in source code, i.e. the class is an immediate child of a compilation unit.

sourceClass/1

sourceClass(?Id) is nondet
True if Id is the id of a class defined in source code.

sourceMethod/1

sourceMethod(?Id) is nondet
True if Id is the id of a method defined in source code.

fully_qualified_name/2

fully_qualified_name(?Id, ?Fqn) is nondet
Binds Fqn to the fully qualified name of the class with id Id.

toplevel_class/4

toplevel_class(+Class:id, ?Package:id, ?ClassName:atom, ?Members:[id]) is semidet
toplevel_class(-Class:id, ?Package:id, ?ClassName:atom, ?Members:[id]) is nondet
Suceeds if Class is the immediate child of a compilation unit, not nested within any other class.

anonymous_class/1

anonymous_class(?Id) is nondet
True if Id is an anonymous class declaration.

local_class/1

local_class(?Id) is nondet
True if Id is an anonymous class declaration.

package_path/2

package_path(+Pckgname, -PckgPath) is det
Replaces dots with slashes in the package name Pckgname.