Class I18nFormatterTreeUtil
java.lang.Object
org.checkerframework.checker.i18nformatter.I18nFormatterTreeUtil
This class provides a collection of utilities to ease working with syntax trees that have
 something to do with I18nFormatters.
- See the Checker Framework Manual:
- Internationalization Format String Checker
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionstatic enumDescribe the format annotation type.classRepresents a format method invocation in the syntax tree.
- 
Field SummaryFieldsModifier and TypeFieldDescriptionfinal BaseTypeCheckerThe checker.protected final ExecutableElementThe value() element/field of an @I18nFormatFor annotation.protected final ExecutableElementThe value() element/field of an @I18nFormat annotation.protected final ExecutableElementThe value() element/field of an @I18nInvalidFormat annotation.final ProcessingEnvironmentThe processing environment.
- 
Constructor SummaryConstructorsConstructorDescriptionI18nFormatterTreeUtil(BaseTypeChecker checker) Creates a new I18nFormatterTreeUtil.
- 
Method SummaryModifier and TypeMethodDescriptionCreates a@I18nFormatannotation with the given list as its value.createFormatForCall(MethodInvocationTree tree, I18nFormatterAnnotatedTypeFactory atypeFactory) Returns an I18nFormatCall instance, only if there is an@I18nFormatForannotation.Takes an exception that describes an invalid formatter string and returns a syntax trees element that represents aI18nInvalidFormatannotation with the exception's error message as value.final voidfailure(FormatterTreeUtil.Result<?> res, @CompilerMessageKey String msgKey, Object... args) Reports an error.Takes a syntax tree element that represents aI18nInvalidFormatannotation, and returns its value.booleanisHasFormatCall(MethodInvocationNode node, AnnotatedTypeFactory atypeFactory) Returns true if the call is to a method with the @I18nChecksFormat annotation.booleanisIsFormatCall(MethodInvocationNode node, AnnotatedTypeFactory atypeFactory) Returns true if the call is to a method with the @I18nValidFormat annotation.booleanisMakeFormatCall(MethodInvocationNode node, AnnotatedTypeFactory atypeFactory) Returns true if the call is to a method with the @I18nMakeFormat annotation.makeFormatCallCategories(MethodInvocationNode node, I18nFormatterAnnotatedTypeFactory atypeFactory) final voidwarning(FormatterTreeUtil.Result<?> res, @CompilerMessageKey String msgKey, Object... args) Reports a warning.
- 
Field Details- 
checkerThe checker.
- 
processingEnvThe processing environment.
- 
i18nFormatValueElementThe value() element/field of an @I18nFormat annotation.
- 
i18nFormatForValueElementThe value() element/field of an @I18nFormatFor annotation.
- 
i18nInvalidFormatValueElementThe value() element/field of an @I18nInvalidFormat annotation.
 
- 
- 
Constructor Details- 
I18nFormatterTreeUtilCreates a new I18nFormatterTreeUtil.- Parameters:
- checker- the checker
 
 
- 
- 
Method Details- 
exceptionToInvalidFormatAnnotationTakes an exception that describes an invalid formatter string and returns a syntax trees element that represents aI18nInvalidFormatannotation with the exception's error message as value.
- 
invalidFormatAnnotationToErrorMessageTakes a syntax tree element that represents aI18nInvalidFormatannotation, and returns its value.- Parameters:
- anno- an I18nInvalidFormat annotation
- Returns:
- its value() element/field, within double-quotes
 
- 
categoriesToFormatAnnotationCreates a@I18nFormatannotation with the given list as its value.- Parameters:
- args- conversion categories for the- @Formatannotation
- Returns:
- a @I18nFormatannotation with the given list as its value
 
- 
formatAnnotationToCategories- Parameters:
- anno- an- @- I18nFormatannotation
- Returns:
- the @I18nFormatannotation'svalueelement
 
- 
isHasFormatCallReturns true if the call is to a method with the @I18nChecksFormat annotation. An example of such a method is I18nFormatUtil.hasFormat.
- 
isIsFormatCallReturns true if the call is to a method with the @I18nValidFormat annotation. An example of such a method is I18nFormatUtil.isFormat.
- 
isMakeFormatCallReturns true if the call is to a method with the @I18nMakeFormat annotation. An example of such a method is ResourceBundle.getString.
- 
failurepublic final void failure(FormatterTreeUtil.Result<?> res, @CompilerMessageKey String msgKey, Object... args) Reports an error.- Parameters:
- res- used for source location information
- msgKey- the diagnostic message key
- args- arguments to the diagnostic message
 
- 
warningpublic final void warning(FormatterTreeUtil.Result<?> res, @CompilerMessageKey String msgKey, Object... args) Reports a warning.- Parameters:
- res- used for source location information
- msgKey- the diagnostic message key
- args- arguments to the diagnostic message
 
- 
getHasFormatCallCategoriespublic FormatterTreeUtil.Result<I18nConversionCategory[]> getHasFormatCallCategories(MethodInvocationNode node) 
- 
makeFormatCallCategoriespublic FormatterTreeUtil.Result<I18nConversionCategory[]> makeFormatCallCategories(MethodInvocationNode node, I18nFormatterAnnotatedTypeFactory atypeFactory) 
- 
createFormatForCallpublic @Nullable I18nFormatterTreeUtil.I18nFormatCall createFormatForCall(MethodInvocationTree tree, I18nFormatterAnnotatedTypeFactory atypeFactory) Returns an I18nFormatCall instance, only if there is an@I18nFormatForannotation. Otherwise, returns null.- Parameters:
- tree- method invocation tree
- atypeFactory- type factory
- Returns:
- an I18nFormatCall instance, only if there is an @I18nFormatForannotation. Otherwise, returns null.
 
 
-