/** --- Package ---
Classes and predicates to deal with Java packages.
*/
import AST
import Element
import Type
import metrics.MetricPackage
/** is X somewhere in package P?
* put differently, is P an ancestor of X in the syntax tree? */
predicate isInPackage(@element X, @package P) {
hasChild+(P,X)
}
/** are X and Y in the same package? */
predicate inSamePackage(@element X, @element Y) {
exists (@package P | isInPackage(X, P) and isInPackage(Y, P))
}
/** A package may be used to abstract over all members of a package,
* regardless of which compilation unit they are defined in */
class Package extends Element, Annotatable, @package {
/** find top level types in this package */
TopLevelType getATopLevelType() { isTopLevelType(result, this) }
/** is there at least one reftype in this package that is populated
from source? */
predicate fromSource() {
exists(RefType t | t.fromSource() and t.getPackage() = this)
}
/** is there at least one reftype in this package that is populated
from bytecode? */
predicate fromLibrary() {
exists(RefType t | t.fromLibrary() and t.getPackage() = this)
}
/** get the URL of the package */
string getURL() { result = this.getName() }
/** select the icon to be used when displaying query results */
string getIconPath() { result = "icons/package.png" }
/** get the metrics delegate of this package */
MetricPackage getMetrics() { result = this }
}
|
|