The Boa Programming Guide - Domain-Specific Functions

Boa provides several useful built-in functions designed to ease common software repository mining tasks. For reference, these functions are described in this section.

getast (file: ChangedFile) : ASTRoot?

Returns the ASTRoot of the specified file, if it exists. Otherwise returns undef.

getsnapshot (cr: CodeRepository [, t: time] [, filters: string...] ) : array of ChangedFile

Returns a snapshot of ChangedFiles. A snapshot is the last version of a file before a given time t (if no time is given, now() is used). If any filters are given, they are used to filter out files. The file kind is checked against each string and must one or more filters. Matches are performed by comparing the filter against the start of the file kind.

getsnapshot := function(cr: CodeRepository, t: time, filters: array of string) : array of ChangedFile { snapshot: map[string] of ChangedFile; visit(cr, visitor { before node: Revision -> if (node.commit_date > t) stop; before node: ChangedFile -> { filter := len(filters) > 0; exists (i: int; iskind(filters[i], node.kind)) filter = false; if (!filter) { if (node.change == ChangeKind.DELETED) remove(snapshot,; else snapshot[] = node; } } }); return values(snapshot); };
hasfiletype (data: dsl_type, extension: string) : bool

Does the data contain a file of the specified type? This compares based on the given file extension. Valid dsl_types are: Project, CodeRepository, and Revision.

hasfiletype := function(rev: Revision, ext: string) : bool { exists (i: int; match(format(`\.%s$`, ext), lowercase(rev.files[i].name))) return true; return false; };
isfixingrevision (rev: Revision) : bool

Is the given revision rev's log message indicating it is a fixing revision? A message is considered indicating a bug fix if it matches a set of regular expressions.

isfixingrevision := function(rev: Revision) : bool { return isfixingrevision(rev.log); };
iskind (s: string, k: dsl_type) : bool

Returns true if the kind k starts with the string s. Valid dsl_types are: FileKind.

iskind := function(s: string, k: FileKind) : bool { return match(format(`^%s`, s), string(k)); };
isliteral (e: Expression, s: string) : bool

Returns true if the expression e is of kind LITERAL and the literal matches the string s.

isliteral := function(e: Expression, s: string) : bool { return e.kind == ExpressionKind.LITERAL && def(e.literal) && e.literal == s; };