Package org.checkerframework.common.util
Class TypeVisualizer
java.lang.Object
org.checkerframework.common.util.TypeVisualizer
TypeVisualizer prints AnnotatedTypeMirrors as a directed graph where each node is a type and an
arrow is a reference. Arrows are labeled with the relationship that reference represents (e.g. an
arrow marked "extends" starts from a type variable or wildcard type and points to the upper bound
of that type).
Currently, to use TypeVisualizer just insert an if statement somewhere that targets the type you would like to print: e.g.
if (type.getKind() == TypeKind.EXECUTABLE && type.toString().contains("methodToPrint")) {
TypeVisualizer.drawToPng("/Users/jburke/Documents/tmp/method.png", type);
}
Be sure to remove such statements before committing your changes.-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
drawToDot
(File dest, AnnotatedTypeMirror type) Creates a dot file at dest that contains a digraph for the structure oftype
.static void
drawToDot
(String dest, AnnotatedTypeMirror type) Creates a dot file at dest that contains a digraph for the structure oftype
.static void
drawToPng
(File dest, AnnotatedTypeMirror type) Draws a dot file for type in a temporary directory then calls the "dot" program to convert that file into a png at the location dest.static void
drawToPng
(String dest, AnnotatedTypeMirror type) Draws a dot file for type in a temporary directory then calls the "dot" program to convert that file into a png at the location dest.static void
execDotToPng
(File dotFile, File pngFile) Converts the given dot file to a png file at the specified location.static boolean
printTypevarToDotIfMatches
(AnnotatedTypeMirror.AnnotatedTypeVariable typeVariable, List<String> typeVarNames, String directory) If the name of typeVariable matches one in the list of typeVarNames, then print typeVariable to a dot file atdirectory/varName
.static boolean
printTypevarToPngIfMatches
(AnnotatedTypeMirror.AnnotatedTypeVariable typeVariable, List<String> typeVarNames, String directory) If the name of typeVariable matches one in the list of typeVarNames, then print typeVariable to a png file atdirectory/varName.png
.
-
Constructor Details
-
TypeVisualizer
public TypeVisualizer()
-
-
Method Details
-
drawToDot
Creates a dot file at dest that contains a digraph for the structure oftype
.- Parameters:
dest
- the destination dot filetype
- the type to be written
-
drawToDot
Creates a dot file at dest that contains a digraph for the structure oftype
.- Parameters:
dest
- the destination dot file, this string will be directly passed to new File(dest)type
- the type to be written
-
drawToPng
Draws a dot file for type in a temporary directory then calls the "dot" program to convert that file into a png at the location dest. This method will fail if a temp file can't be created.- Parameters:
dest
- the destination png filetype
- the type to be written
-
drawToPng
Draws a dot file for type in a temporary directory then calls the "dot" program to convert that file into a png at the location dest. This method will fail if a temp file can't be created.- Parameters:
dest
- the destination png file, this string will be directly passed to new File(dest)type
- the type to be written
-
execDotToPng
Converts the given dot file to a png file at the specified location. This method calls the program "dot" from Runtime.exec and will fail if "dot" is not on your class path.- Parameters:
dotFile
- the dot file to convertpngFile
- the destination of the resultant png file
-
printTypevarToDotIfMatches
public static boolean printTypevarToDotIfMatches(AnnotatedTypeMirror.AnnotatedTypeVariable typeVariable, List<String> typeVarNames, String directory) If the name of typeVariable matches one in the list of typeVarNames, then print typeVariable to a dot file atdirectory/varName
.- Returns:
- true if the type variable was printed, otherwise false
-
printTypevarToPngIfMatches
public static boolean printTypevarToPngIfMatches(AnnotatedTypeMirror.AnnotatedTypeVariable typeVariable, List<String> typeVarNames, String directory) If the name of typeVariable matches one in the list of typeVarNames, then print typeVariable to a png file atdirectory/varName.png
.- Returns:
- true if the type variable was printed, otherwise false
-