Class DefaultAnnotatedTypeFormatter
- java.lang.Object
-
- org.checkerframework.framework.type.DefaultAnnotatedTypeFormatter
-
- All Implemented Interfaces:
AnnotatedTypeFormatter
- Direct Known Subclasses:
NullnessNoInitAnnotatedTypeFormatter
,UnitsAnnotatedTypeFormatter
public class DefaultAnnotatedTypeFormatter extends java.lang.Object implements AnnotatedTypeFormatter
An AnnotatedTypeFormatter used by default by all AnnotatedTypeFactory (and therefore all annotated types).
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
DefaultAnnotatedTypeFormatter.FormattingVisitor
A scanning visitor that prints the entire AnnotatedTypeMirror passed to visit.
-
Field Summary
Fields Modifier and Type Field Description protected static java.util.Map<javax.lang.model.type.TypeVariable,java.lang.Integer>
captureConversionIds
Maps from type variables to deterministic IDs.protected DefaultAnnotatedTypeFormatter.FormattingVisitor
formattingVisitor
The formatting visitor.protected static int
prevCaptureConversionId
The last deterministic capture conversion ID that was used.
-
Constructor Summary
Constructors Modifier Constructor Description DefaultAnnotatedTypeFormatter()
Constructs a DefaultAnnotatedTypeFormatter that does not print invisible annotations by default.DefaultAnnotatedTypeFormatter(boolean printVerboseGenerics, boolean defaultPrintInvisibleAnnos)
protected
DefaultAnnotatedTypeFormatter(DefaultAnnotatedTypeFormatter.FormattingVisitor visitor)
Used by subclasses and other constructors to specify the underlying implementation of this DefaultAnnotatedTypeFormatter.DefaultAnnotatedTypeFormatter(AnnotationFormatter formatter, boolean printVerboseGenerics, boolean defaultPrintInvisibleAnnos)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
format(AnnotatedTypeMirror type)
Formats type into a String.java.lang.String
format(AnnotatedTypeMirror type, boolean printVerbose)
Formats type into a String.protected static int
getCaptureConversionId(javax.lang.model.type.TypeVariable capturedType)
Returns a deterministic capture conversion ID for the given javac captured type.
-
-
-
Field Detail
-
formattingVisitor
protected final DefaultAnnotatedTypeFormatter.FormattingVisitor formattingVisitor
The formatting visitor.
-
captureConversionIds
protected static final java.util.Map<javax.lang.model.type.TypeVariable,java.lang.Integer> captureConversionIds
Maps from type variables to deterministic IDs. This is useful for comparing output across two runs of the Checker Framework.This map is necessary for deterministic and informative output. javac might print two distinct capture-converted variables as "capture#222" if the second is created after the first is garbage-collected, or if they just happen to have the same hash code based on memory layout. Such javac output is misleading because it looks like the two printed representations refer to the same variable.
This map contains type variables that have been formatted. Therefore, the numbers may differ between Checker Framework runs if the different runs print different values (say, one of them prints more type variables than the other).
-
prevCaptureConversionId
protected static int prevCaptureConversionId
The last deterministic capture conversion ID that was used.
-
-
Constructor Detail
-
DefaultAnnotatedTypeFormatter
public DefaultAnnotatedTypeFormatter()
Constructs a DefaultAnnotatedTypeFormatter that does not print invisible annotations by default.
-
DefaultAnnotatedTypeFormatter
public DefaultAnnotatedTypeFormatter(boolean printVerboseGenerics, boolean defaultPrintInvisibleAnnos)
- Parameters:
printVerboseGenerics
- for type parameters, their uses, and wildcards, print more informationdefaultPrintInvisibleAnnos
- whether or not this AnnotatedTypeFormatter should print invisible annotations
-
DefaultAnnotatedTypeFormatter
public DefaultAnnotatedTypeFormatter(AnnotationFormatter formatter, boolean printVerboseGenerics, boolean defaultPrintInvisibleAnnos)
- Parameters:
formatter
- an object that converts annotation mirrors to stringsprintVerboseGenerics
- for type parameters, their uses, and wildcards, print more informationdefaultPrintInvisibleAnnos
- whether or not this AnnotatedTypeFormatter should print invisible annotations
-
DefaultAnnotatedTypeFormatter
protected DefaultAnnotatedTypeFormatter(DefaultAnnotatedTypeFormatter.FormattingVisitor visitor)
Used by subclasses and other constructors to specify the underlying implementation of this DefaultAnnotatedTypeFormatter.
-
-
Method Detail
-
getCaptureConversionId
protected static int getCaptureConversionId(javax.lang.model.type.TypeVariable capturedType)
Returns a deterministic capture conversion ID for the given javac captured type.- Parameters:
capturedType
- a type variable, which must be a capture-converted type variable- Returns:
- a deterministic capture conversion ID
-
format
public java.lang.String format(AnnotatedTypeMirror type)
Description copied from interface:AnnotatedTypeFormatter
Formats type into a String. Uses an implementation specific default for printing "invisible annotations"- Specified by:
format
in interfaceAnnotatedTypeFormatter
- Parameters:
type
- the type to be converted- Returns:
- a string representation of type
- See Also:
InvisibleQualifier
-
format
public java.lang.String format(AnnotatedTypeMirror type, boolean printVerbose)
Description copied from interface:AnnotatedTypeFormatter
Formats type into a String.- Specified by:
format
in interfaceAnnotatedTypeFormatter
- Parameters:
type
- the type to be convertedprintVerbose
- whether or not to print verbosely- Returns:
- a string representation of type
- See Also:
InvisibleQualifier
-
-