public class I18nFormatterTreeUtil extends Object
Modifier and Type | Class and Description |
---|---|
static class |
I18nFormatterTreeUtil.FormatType
Describe the format annotation type.
|
class |
I18nFormatterTreeUtil.I18nFormatCall
Represents a format method invocation in the syntax tree.
|
Modifier and Type | Field and Description |
---|---|
BaseTypeChecker |
checker
The checker.
|
protected ExecutableElement |
i18nFormatForValueElement
The value() element/field of an @I18nFormatFor annotation.
|
protected ExecutableElement |
i18nFormatValueElement
The value() element/field of an @I18nFormat annotation.
|
protected ExecutableElement |
i18nInvalidFormatValueElement
The value() element/field of an @I18nInvalidFormat annotation.
|
ProcessingEnvironment |
processingEnv
The processing environment.
|
Constructor and Description |
---|
I18nFormatterTreeUtil(BaseTypeChecker checker)
Creates a new I18nFormatterTreeUtil.
|
Modifier and Type | Method and Description |
---|---|
AnnotationMirror |
categoriesToFormatAnnotation(I18nConversionCategory[] args)
Creates a
@ I18nFormat annotation with the given list as its value. |
@Nullable I18nFormatterTreeUtil.I18nFormatCall |
createFormatForCall(MethodInvocationTree tree,
I18nFormatterAnnotatedTypeFactory atypeFactory)
Returns an I18nFormatCall instance, only if there is an
@I18nFormatFor annotation. |
AnnotationMirror |
exceptionToInvalidFormatAnnotation(IllegalArgumentException ex)
Takes an exception that describes an invalid formatter string and returns a syntax trees
element that represents a
I18nInvalidFormat annotation with the exception's error
message as value. |
void |
failure(FormatterTreeUtil.Result<?> res,
@CompilerMessageKey String msgKey,
Object... args)
Reports an error.
|
I18nConversionCategory[] |
formatAnnotationToCategories(AnnotationMirror anno)
|
FormatterTreeUtil.Result<I18nConversionCategory[]> |
getHasFormatCallCategories(MethodInvocationNode node) |
String |
invalidFormatAnnotationToErrorMessage(AnnotationMirror anno)
Takes a syntax tree element that represents a
I18nInvalidFormat annotation, and returns
its value. |
boolean |
isHasFormatCall(MethodInvocationNode node,
AnnotatedTypeFactory atypeFactory)
Returns true if the call is to a method with the @I18nChecksFormat annotation.
|
boolean |
isIsFormatCall(MethodInvocationNode node,
AnnotatedTypeFactory atypeFactory)
Returns true if the call is to a method with the @I18nValidFormat annotation.
|
boolean |
isMakeFormatCall(MethodInvocationNode node,
AnnotatedTypeFactory atypeFactory)
Returns true if the call is to a method with the @I18nMakeFormat annotation.
|
FormatterTreeUtil.Result<I18nConversionCategory[]> |
makeFormatCallCategories(MethodInvocationNode node,
I18nFormatterAnnotatedTypeFactory atypeFactory) |
void |
warning(FormatterTreeUtil.Result<?> res,
@CompilerMessageKey String msgKey,
Object... args)
Reports a warning.
|
public final BaseTypeChecker checker
public final ProcessingEnvironment processingEnv
protected final ExecutableElement i18nFormatValueElement
protected final ExecutableElement i18nFormatForValueElement
protected final ExecutableElement i18nInvalidFormatValueElement
public I18nFormatterTreeUtil(BaseTypeChecker checker)
checker
- the checkerpublic AnnotationMirror exceptionToInvalidFormatAnnotation(IllegalArgumentException ex)
I18nInvalidFormat
annotation with the exception's error
message as value.public String invalidFormatAnnotationToErrorMessage(AnnotationMirror anno)
I18nInvalidFormat
annotation, and returns
its value.anno
- an I18nInvalidFormat annotationpublic AnnotationMirror categoriesToFormatAnnotation(I18nConversionCategory[] args)
@
I18nFormat
annotation with the given list as its value.args
- conversion categories for the @Format
annotation@
I18nFormat
annotation with the given list as its valuepublic I18nConversionCategory[] formatAnnotationToCategories(AnnotationMirror anno)
anno
- an @
I18nFormat
annotation@
I18nFormat
annotation's value
elementpublic boolean isHasFormatCall(MethodInvocationNode node, AnnotatedTypeFactory atypeFactory)
public boolean isIsFormatCall(MethodInvocationNode node, AnnotatedTypeFactory atypeFactory)
public boolean isMakeFormatCall(MethodInvocationNode node, AnnotatedTypeFactory atypeFactory)
public final void failure(FormatterTreeUtil.Result<?> res, @CompilerMessageKey String msgKey, Object... args)
res
- used for source location informationmsgKey
- the diagnostic message keyargs
- arguments to the diagnostic messagepublic final void warning(FormatterTreeUtil.Result<?> res, @CompilerMessageKey String msgKey, Object... args)
res
- used for source location informationmsgKey
- the diagnostic message keyargs
- arguments to the diagnostic messagepublic FormatterTreeUtil.Result<I18nConversionCategory[]> getHasFormatCallCategories(MethodInvocationNode node)
public FormatterTreeUtil.Result<I18nConversionCategory[]> makeFormatCallCategories(MethodInvocationNode node, I18nFormatterAnnotatedTypeFactory atypeFactory)
public @Nullable I18nFormatterTreeUtil.I18nFormatCall createFormatForCall(MethodInvocationTree tree, I18nFormatterAnnotatedTypeFactory atypeFactory)
@I18nFormatFor
annotation.
Otherwise, returns null.tree
- method invocation treeatypeFactory
- type factory@I18nFormatFor
annotation.
Otherwise, returns null.