Class CheckBundlesScanner
java.lang.Object
com.sun.source.util.TreeScanner<Object,Trees>
com.sun.source.util.TreePathScanner<Object,Trees>
org.tentackle.maven.plugin.check.CheckBundlesScanner
- All Implemented Interfaces:
TreeVisitor<Object,Trees>
Tree path scanner for bundle getString() method invocations.
Collects the invocations of
The key must be a compile-time constant expression of string literals and constant variables, such as
Invocations referring to the bundle of a class annotated with
Invocations within a declaration annotated with
A bundle class is annotated with an annotation that registers bundles, such as
Collects the invocations of
getString with a single argument that refer to a bundle,
i.e. a static method of a bundle class, such as AppBundle.getString("key"), or a method of a
ResourceBundle, such as getBundle().getString("key").The key must be a compile-time constant expression of string literals and constant variables, such as
"key", KEY, Keys.GREETING or PREFIX + "title".
Invocations with other keys cannot be verified and are listed in getUnverifiedKeys().Invocations referring to the bundle of a class annotated with
NoBundle are skipped.Invocations within a declaration annotated with
@SuppressWarnings("bundle")
(see Constants.SUPPRESS_WARNINGS_BUNDLE) are neither listed as unverified nor as unresolved.A bundle class is annotated with an annotation that registers bundles, such as
@Bundle,
i.e. one that is annotated with Analyze referring to a BundleAnalyzeHandler.
The trees must be attributed, see scan(JavacTask, Iterable). If the invoked method or the type
of the reference cannot be determined, the invocation is collected nevertheless and, in addition,
listed in getUnresolvedKeys().
- Author:
- harald
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGets the collected bundle keys.Gets thegetStringinvocations that were ignored because they don't refer to a bundle.
This includes the invocations referring to the bundle of a class annotated withNoBundle.Gets the collected bundle keys whose invocation could not be resolved, unless suppressed.
Those keys are checked nevertheless, i.e. they are contained ingetBundleKeys()as well.Gets thegetStringinvocations that refer to a bundle or could not be resolved, but whose argument is not a compile-time constant, unless suppressed.
The key of those bundle keys is the source text of the argument expression.voidscan(JavacTask task, Iterable<? extends CompilationUnitTree> units) Scans the attributed compilation units of a task.visitMethodInvocation(MethodInvocationTree mit, Trees trees) Methods inherited from class TreePathScanner
getCurrentPath, scan, scanMethods inherited from class TreeScanner
reduce, scan, visitAnnotatedType, visitAnnotation, visitAnyPattern, visitArrayAccess, visitArrayType, visitAssert, visitAssignment, visitBinary, visitBindingPattern, visitBlock, visitBreak, visitCase, visitCatch, visitClass, visitCompilationUnit, visitCompoundAssignment, visitConditionalExpression, visitConstantCaseLabel, visitContinue, visitDeconstructionPattern, visitDefaultCaseLabel, visitDoWhileLoop, visitEmptyStatement, visitEnhancedForLoop, visitErroneous, visitExports, visitExpressionStatement, visitForLoop, visitIdentifier, visitIf, visitImport, visitInstanceOf, visitIntersectionType, visitLabeledStatement, visitLambdaExpression, visitLiteral, visitMemberReference, visitMemberSelect, visitMethod, visitModifiers, visitModule, visitNewArray, visitNewClass, visitOpens, visitOther, visitPackage, visitParameterizedType, visitParenthesized, visitPatternCaseLabel, visitPrimitiveType, visitProvides, visitRequires, visitReturn, visitSwitch, visitSwitchExpression, visitSynchronized, visitThrow, visitTry, visitTypeCast, visitTypeParameter, visitUnary, visitUnionType, visitUses, visitVariable, visitWhileLoop, visitWildcard, visitYield
-
Constructor Details
-
CheckBundlesScanner
public CheckBundlesScanner()
-
-
Method Details
-
scan
Scans the attributed compilation units of a task.- Parameters:
task- the task, already analyzedunits- the compilation units of the task
-
visitMethodInvocation
- Specified by:
visitMethodInvocationin interfaceTreeVisitor<Object,Trees> - Overrides:
visitMethodInvocationin classTreeScanner<Object,Trees>
-
getBundleKeys
-
getSkippedKeys
-
getUnresolvedKeys
Gets the collected bundle keys whose invocation could not be resolved, unless suppressed.
Those keys are checked nevertheless, i.e. they are contained ingetBundleKeys()as well.- Returns:
- the unresolved keys, never null
-
getUnverifiedKeys
Gets thegetStringinvocations that refer to a bundle or could not be resolved, but whose argument is not a compile-time constant, unless suppressed.
The key of those bundle keys is the source text of the argument expression.- Returns:
- the unverified keys, never null
-