Class Main
java org.checkerframework.afu.annotator.Main
or by using the shell script
insert-annotations-to-source
.
It takes as input
- annotation (index) files, which indicate the annotations to insert
- Java source files, into which the annotator inserts annotations
The command-line options are as follows:
- General options
- -d --outdir=directory. Directory in which output files are written. [default: annotated/]
- -i --in-place=boolean. If true, overwrite
original source files (making a backup first). Furthermore, if the backup files
already exist, they are used instead of the .java files. This behavior permits a user
to tweak the
.jaif
file and re-run the annotator.Note that if the user runs the annotator with --in-place, makes edits, and then re-runs the annotator with this --in-place option, those edits are lost. Similarly, if the user runs the annotator twice in a row with --in-place, only the last set of annotations will appear in the codebase at the end.
To preserve changes when using the --in-place option, first remove the backup files. Or, use the
-d .
option, which makes (and reads) no backup, instead of --in-place. [default: false] - -a --abbreviate=boolean. If true, insert
import
statements as necessary. [default: true] - -o --omit-annotation=string. Omit given annotation
- --nowarn=boolean. Suppress warnings about disallowed insertions [default: false]
- --convert-jaifs=boolean. Convert JAIFs to AST Path format, but do no insertion into source [default: false]
- -h --help=boolean. Print usage information and exit [default: false]
- Debugging options
- -v --verbose=boolean. Verbose (print progress information) [default: false]
- --debug=boolean. Debug (print debug information) [default: false]
- --print-error-stack=boolean. Print error stack [default: false]
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic boolean
If true, insertimport
statements as necessary.static boolean
static boolean
Maps from binary class name to whether the class has any explicit constructor.static boolean
static boolean
If true, overwrite original source files (making a backup first).static boolean
static String
Don't insert the given annotation.static String
Directory in which output files are written.static boolean
static boolean
static boolean
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic String
Returns the first 80 characters of the string, adding an ellipsis (...) if the string was truncated.static String
Returns the first non-empty line of the string, adding an ellipsis (...) if the string was truncated.static String
leafString
(TreePath path) Returns the representation of the leaf of the path.static void
Runs the annotator, parsing the source and spec files and applying the annotations.removeArgs
(String s) Separates the annotation class from its arguments.static String
treeToString
(Tree node) Returns the first 80 characters of the tree's printed representation, on one line.
-
Field Details
-
outdir
Directory in which output files are written. -
in_place
public static boolean in_placeIf true, overwrite original source files (making a backup first). Furthermore, if the backup files already exist, they are used instead of the .java files. This behavior permits a user to tweak the.jaif
file and re-run the annotator.Note that if the user runs the annotator with
--in-place
, makes edits, and then re-runs the annotator with this--in-place
option, those edits are lost. Similarly, if the user runs the annotator twice in a row with--in-place
, only the last set of annotations will appear in the codebase at the end.To preserve changes when using the
--in-place
option, first remove the backup files. Or, use the-d .
option, which makes (and reads) no backup, instead of--in-place
. -
abbreviate
public static boolean abbreviateIf true, insertimport
statements as necessary. -
omit_annotation
Don't insert the given annotation. -
nowarn
public static boolean nowarn -
convert_jaifs
public static boolean convert_jaifs -
help
public static boolean help -
verbose
public static boolean verbose -
debug
public static boolean debug -
print_error_stack
public static boolean print_error_stack -
temporaryDebug
public static boolean temporaryDebug -
hasExplicitConstructor
Maps from binary class name to whether the class has any explicit constructor.
-
-
Constructor Details
-
Main
public Main()
-
-
Method Details
-
main
Runs the annotator, parsing the source and spec files and applying the annotations.- Parameters:
args
- .jaif files and/or .java files and/or @arg-files, in any order- Throws:
IOException
-
leafString
Returns the representation of the leaf of the path.- Parameters:
path
- a path whose leaf to format- Returns:
- the representation of the leaf of the path
-
treeToString
Returns the first 80 characters of the tree's printed representation, on one line.- Parameters:
node
- a tree to format with truncation- Returns:
- the first 80 characters of the tree's printed representation, on one line
-
firstLine
Returns the first non-empty line of the string, adding an ellipsis (...) if the string was truncated.- Parameters:
s
- a string to truncate- Returns:
- the first non-empty line of the argument
-
first80
Returns the first 80 characters of the string, adding an ellipsis (...) if the string was truncated.- Parameters:
s
- a string to truncate- Returns:
- the first 80 characters of the string
-
removeArgs
Separates the annotation class from its arguments.- Parameters:
s
- the string representation of an annotation- Returns:
- given
@foo(bar)
it returns the pair{ @foo, (bar) }
-