Personal tools
You are here: Home Projects CodeQuest Built-in CodeQuest predicates and rules
Document Actions

Built-in CodeQuest predicates and rules

 

This document contains information about the CodeQuest predefined predicates and rules. The type hierarchy and predicate names have been inspired by the JQuery tool.

Type Hierarchy

CodeQuest has the following type hierarchy:

  • Element
    • Package
    • CU
    • Field
    • Type
      • Primitive
      • RefType
        • Interface
        • Class
    • Block
      • Callable
        • Method
        • Constructor
  • Modifier
  • Parameter

A form of simple type checking of the underlying database types is performed. For example in the cus predicate the first and the second argument have types int and varchar respectively. These types are incompatible and a compile time error will be raised if a user is trying to compare such arguments.
>There is no check if a user is comparing two elements of the same database, but different CodeQuest types, i.e. packages vs. methods.p>

EDB Predicates

EDB Predicates constitute the extensional part of the deductive database system. These are the predicates that directly operate on the facts that are stored in the relational database. All other predicates are derived from these with rules. The predicate declarations are contained in the codequest.dbscheme file.

Predicates for code elements

Predicate Name Argument Type Description
cus CU, String cus(X,Name) means: "X is a Compilation Unit (.java file) with name Name"
packages Package, String packages(X,Name) means: "X is a package with full name Name"
primitives Primitive, String primitives(X,Name) means: "X is a primitive with full name Name"
classes Class, String classes(X,Name) means: "X is a class with name Name"
interfaces Interface, String interfaces(X,Name) means: "X is an interface with Name"
methods Method, String, String methods(X,Name,Signature) means: "X is a method with name Name and signature Signature"
constructors Constructor, String, String constructors(X,Name,Signature) means: "X is a constructor with name Name and signature Signature"
modifiers Modifier, String modifiers(M,Name) means: "M is a modifier, with name Name (i.e public, private, static, etc)"
params Parameter, String, Type, Integer, Callable params(X,Name,Type,N,C) means: "X is a Parameter with name Name, type T in callable C as its Nth argument"
fields Field, String, Type fields(X,Name,Type) means: "X is a field, with name Name and type Type"

Predicates for relations between elements

hasChild Element, Element hasChild(Sup,Sub) means: "Element Sup has a child Sub"
extends RefType, RefType extends(T1,T2) means: "Class (or Interface) T1 extends Class (or Interface) T2"
implements Class, Interface implements(C,I) means: "Class C implements Interface I"
hasModifier Element, Modifier hasModifier(E,M) means: "Element E has modifier M"
returns Callable, Type returns(C,T) means: "Callable C returns Type T"
reads Block, Field reads(B,F) means: "Block B reads field F"
writes Block, Field writes(B,F) means: "Block B writes to field F"
makesMethodCall Block, Method makesMethodCall(B,M) means: "Block B makes a "normal" call to Method M"
makesThisCall Constructor, Constructor makesThisCall(C1,C2) means: "Constructor C1 makes a "this" call to Constructor C2"
makesSuperCall Callable, Callable makesSuperCall(C1,C2) means: "Callable C1 makes a "super" call to Callable C2"
makesConstructorCall Block, Constructor makesConstructorCall(B,C) means: "Block B makes a call to Constructor C"

IDB Predicates

IDB Predicates constitute the intensional part of the deductive database system. These are useful predicates that have been derived from the EDB predicates using rules. Thus, IDB predicates operate on the facts that are not stored in the relational database, but are computed during the query evaluation as needed. The rule declarations are contained in the derived_preds.datalog file.

Predicate Name Argument Types Description
cu CU cu(X) means: "X is a Compilation Unit (.java file)"
package Package package(X) means: "X is a package"
isInPackage Element, Package isInPackage(E,P) means: "Element E is in package P"
class Class class(X) means: "X is a class"
interface Interface interfaces(X) means: "X is an interface"
reftype RefType reftype(X) means: "X is a class or an interface"
type Type type(T) means: "T is a type (a class, interface, or primitive)"
hasSubtype Type, Type hasSubtype(T1,T2) means: "T1 has a direct subtype T2"
hasSubtypePlus Type, Type hasSubtypePlus(T1,T2) means: "T1 has an indirect subtype T2"
hasSubtypeStar Type, Type hasSubtypeStar(T1,T2) means: "T1 has an indirect subtype T2 (T2 can equal T1)"
constructor Constructor constructor(X) means: "X is a constructor"
method Method method(X) means: "X is a method"
hasParam Callable, Type, Integer hasParam(C,T,N) means: "Callable C has an argument of type T as its Nth argument"
hasSignature Callable, Signature hasSignature(C,S) means: "Callable C has signature S "
hasStrModifier Element, String hasStrModifier(E,M) means: "Element E has modifier M (i.e public, private, static, etc)"
calls Block, Callable calls(B,C) means: "Block B calls Callable C"
makesStaticCall Block, Callable makesStaticCall(B,C) means: "Block B makes a static call to Callable C"
makesDynamicCall Block, Callable makesDynamicCall(B,C) means: "Block B makes a dynamic call to Callable C"
field Field field(X) means: "X is a field"
hasType Field, Type hasType(F,T) means: "Field F has type T"
hasName Element, String hasName(E,Name) means: "Element E has name Name "
accesses Block, Field accesses(B,F) means: "Block B accesses field F"
hasChildPlus Element, Element hasChildPlus(E1,E2) means: "E1 has E2 as one of its descendants"
declaresConstructor Class, Constructor declaresConstructor(CL,CON) means: "Class CL declares constructor CON"
declaresMethod Type, Method declaresMethod(T,M) means: "Type T declares method M"
declaresField Type, Field declaresField(T,F) means: "Type T declares field F"
implementsPlus Class, Interface implementsPlus(C,I) means: "Class C directly or indirectly (through one of its ancesters) implements interface I "
inheritableMethod Method inheritableMethod(M) means: "Method M is inheritable if it is neither private nor static"
strongLikeThis Callable, Callable strongLikeThis(C1,C1) means: "C1 and C2 have the same signature"
overrides Callable, Callable overrides(C1,C2) means: "Callable C1 overrides callable C2"
polyCalls Block, Callable polyCalls(B,C) means: "Block B calls polymorphic callable C"
hasCreator Class, Block hasCreator(C1, Ctor) means: "Class C1 is created by block Ctor"
outerType Type outerType(T) means: "T is an outer type"
hasMethod Type, Method, Type hasMethod(T,M,SUP) means: "Type T has method C either by declaring it or by inheriting it from Type SUP"

Powered by Plone CMS, the Open Source Content Management System

This site conforms to the following standards: