Class FormatterTreeUtil
java.lang.Object
org.checkerframework.checker.formatter.FormatterTreeUtil
This class provides a collection of utilities to ease working with syntax trees that have
 something to do with Formatters.
- 
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassRepresents a format method invocation in the syntax tree.static enumDescribes the ways a format method may be invoked.static classA wrapper around a value of type E, plus an ExpressionTree location. - 
Field Summary
FieldsModifier and TypeFieldDescriptionfinal BaseTypeCheckerThe checker.protected final ExecutableElementThe value() element/field of an @Format annotation.protected final ExecutableElementThe value() element/field of an @InvalidFormat annotation.final ProcessingEnvironmentThe processing environment. - 
Constructor Summary
Constructors - 
Method Summary
Modifier and TypeMethodDescriptionCreates a@Formatannotation with the given list as its value.create(MethodInvocationTree invocationTree, AnnotatedTypeFactory atypeFactory) Creates a new FormatCall, or returns null.Takes an exception that describes an invalid formatter string and, returns a syntax trees element that represents aInvalidFormatannotation with the exception's error message as value.final voidfailure(FormatterTreeUtil.Result<?> res, @CompilerMessageKey String msgKey, Object... args) Reports an error.Returns the value of a@Formatannotation.Takes a syntax tree element that represents aInvalidFormatannotation, and returns its value.booleanisAsFormatCall(MethodInvocationNode node, AnnotatedTypeFactory atypeFactory) Returns true if the call is to a method with the @ReturnsFormat annotation.booleanisFormatMethodCall(MethodInvocationTree tree, AnnotatedTypeFactory atypeFactory) Returns true iftreeis a call to a method annotated with@FormatMethod.final voidwarning(FormatterTreeUtil.Result<?> res, @CompilerMessageKey String msgKey, Object... args) Reports a warning. 
- 
Field Details
- 
checker
The checker. - 
processingEnv
The processing environment. - 
formatValueElement
The value() element/field of an @Format annotation. - 
invalidFormatValueElement
The value() element/field of an @InvalidFormat annotation. 
 - 
 - 
Constructor Details
- 
FormatterTreeUtil
 
 - 
 - 
Method Details
- 
isAsFormatCall
Returns true if the call is to a method with the @ReturnsFormat annotation. An example of such a method is FormatUtil.asFormat. - 
asFormatCallCategories
public FormatterTreeUtil.Result<ConversionCategory[]> asFormatCallCategories(MethodInvocationNode node)  - 
isFormatMethodCall
Returns true iftreeis a call to a method annotated with@FormatMethod.- Parameters:
 tree- a method callatypeFactory- a type factory- Returns:
 - true if 
treeis a call to a method annotated with@FormatMethod 
 - 
create
public @Nullable FormatterTreeUtil.FormatCall create(MethodInvocationTree invocationTree, AnnotatedTypeFactory atypeFactory) Creates a new FormatCall, or returns null.- Parameters:
 invocationTree- a method invocation, where the method is annotated @FormatMethodatypeFactory- the type factory- Returns:
 - a new FormatCall, or null if the invocation is of a method that is improperly annotated @FormatMethod
 
 - 
failure
public final void failure(FormatterTreeUtil.Result<?> res, @CompilerMessageKey String msgKey, Object... args) Reports an error.- Parameters:
 res- used for source location informationmsgKey- the diagnostic message keyargs- arguments to the diagnostic message
 - 
warning
public final void warning(FormatterTreeUtil.Result<?> res, @CompilerMessageKey String msgKey, Object... args) Reports a warning.- Parameters:
 res- used for source location informationmsgKey- the diagnostic message keyargs- arguments to the diagnostic message
 - 
exceptionToInvalidFormatAnnotation
Takes an exception that describes an invalid formatter string and, returns a syntax trees element that represents aInvalidFormatannotation with the exception's error message as value. - 
invalidFormatAnnotationToErrorMessage
Takes a syntax tree element that represents aInvalidFormatannotation, and returns its value.- Parameters:
 anno- an InvalidFormat annotation- Returns:
 - its value() element/field
 
 - 
categoriesToFormatAnnotation
Creates a@Formatannotation with the given list as its value.- Parameters:
 args- conversion categories for the@Formatannotation- Returns:
 - a 
@Formatannotation with the given list as its value 
 - 
formatAnnotationToCategories
Returns the value of a@Formatannotation.- Parameters:
 anno- a@Formatannotation- Returns:
 - the annotation's 
valueelement 
 
 -