summaryrefslogtreecommitdiff
path: root/thirdparty/checkstyle/contrib
diff options
context:
space:
mode:
Diffstat (limited to 'thirdparty/checkstyle/contrib')
-rwxr-xr-xthirdparty/checkstyle/contrib/JavadocCheckDefault.java62
-rwxr-xr-xthirdparty/checkstyle/contrib/bcel/docs/BCELConfig.xml15
-rwxr-xr-xthirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/AbstractCheckVisitor.java157
-rwxr-xr-xthirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/ClassFileSetCheck.java317
-rwxr-xr-xthirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/EmptyClassFileVisitor.java17
-rwxr-xr-xthirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/EmptyDeepVisitor.java86
-rwxr-xr-xthirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/EmptyGenericVisitor.java18
-rwxr-xr-xthirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/IDeepVisitor.java25
-rwxr-xr-xthirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/IObjectSetVisitor.java37
-rwxr-xr-xthirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/JavaClassWalker.java40
-rwxr-xr-xthirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/ReferenceVisitor.java194
-rwxr-xr-xthirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/VisitorSet.java149
-rwxr-xr-xthirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/checks/AbstractReferenceCheck.java150
-rwxr-xr-xthirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/checks/HiddenInheritedFieldCheck.java64
-rwxr-xr-xthirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/checks/HiddenStaticMethodCheck.java88
-rwxr-xr-xthirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/checks/UnreadFieldCheck.java58
-rwxr-xr-xthirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/checks/UnreadVariableCheck.java130
-rwxr-xr-xthirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/checks/UnusedMethodCheck.java64
-rwxr-xr-xthirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/checks/messages.properties5
-rwxr-xr-xthirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/classfile/FieldDefinition.java89
-rwxr-xr-xthirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/classfile/FieldOrMethodDefinition.java50
-rwxr-xr-xthirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/classfile/JavaClassDefinition.java188
-rwxr-xr-xthirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/classfile/MethodDefinition.java175
-rwxr-xr-xthirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/classfile/ReferenceDAO.java140
-rwxr-xr-xthirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/classfile/Utils.java39
-rwxr-xr-xthirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/generic/FieldOrMethodReference.java61
-rwxr-xr-xthirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/generic/FieldReference.java22
-rwxr-xr-xthirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/generic/GETFIELDReference.java28
-rwxr-xr-xthirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/generic/GETSTATICReference.java28
-rwxr-xr-xthirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/generic/InvokeReference.java38
-rwxr-xr-xthirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/generic/PUTFIELDReference.java28
-rwxr-xr-xthirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/generic/PUTSTATICReference.java28
-rwxr-xr-xthirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/generic/Utils.java71
-rwxr-xr-xthirdparty/checkstyle/contrib/bcel/src/testinputs/com/puppycrawl/tools/checkstyle/bcel/checks/InheritLibrary.java11
-rwxr-xr-xthirdparty/checkstyle/contrib/bcel/src/testinputs/com/puppycrawl/tools/checkstyle/bcel/checks/SubClass.java54
-rwxr-xr-xthirdparty/checkstyle/contrib/bcel/src/testinputs/com/puppycrawl/tools/checkstyle/bcel/checks/SuperClass.java46
-rwxr-xr-xthirdparty/checkstyle/contrib/bcel/src/tests/com/puppycrawl/tools/checkstyle/bcel/BcelCheckTestCase.java127
-rwxr-xr-xthirdparty/checkstyle/contrib/bcel/src/tests/com/puppycrawl/tools/checkstyle/bcel/checks/HiddenInheritedFieldTest.java22
-rwxr-xr-xthirdparty/checkstyle/contrib/bcel/src/tests/com/puppycrawl/tools/checkstyle/bcel/checks/HiddenStaticMethodTest.java22
-rwxr-xr-xthirdparty/checkstyle/contrib/checkstyle-author.xsl230
-rwxr-xr-xthirdparty/checkstyle/contrib/checkstyle-csv.xsl11
-rwxr-xr-xthirdparty/checkstyle/contrib/checkstyle-frames-errors.xsl394
-rwxr-xr-xthirdparty/checkstyle/contrib/checkstyle-frames.xsl382
-rwxr-xr-xthirdparty/checkstyle/contrib/checkstyle-noframes-severity-sorted.xsl210
-rwxr-xr-xthirdparty/checkstyle/contrib/checkstyle-noframes-sorted.xsl179
-rwxr-xr-xthirdparty/checkstyle/contrib/checkstyle-noframes.xsl179
-rwxr-xr-xthirdparty/checkstyle/contrib/checkstyle-simple.xsl71
-rwxr-xr-xthirdparty/checkstyle/contrib/checkstyle-text.xsl26
-rwxr-xr-xthirdparty/checkstyle/contrib/examples/XInclude/NamespacesSAXParserFactoryImpl.java21
-rwxr-xr-xthirdparty/checkstyle/contrib/examples/XInclude/config.xml26
-rwxr-xr-xthirdparty/checkstyle/contrib/examples/XInclude/index.html142
-rwxr-xr-xthirdparty/checkstyle/contrib/examples/XInclude/treewalker.xml7
-rwxr-xr-xthirdparty/checkstyle/contrib/examples/checks/com/mycompany/checks/LimitImplementationFiles.java69
-rwxr-xr-xthirdparty/checkstyle/contrib/examples/checks/com/mycompany/checks/MethodLimitCheck.java63
-rwxr-xr-xthirdparty/checkstyle/contrib/examples/checks/com/mycompany/checks/messages.properties2
-rwxr-xr-xthirdparty/checkstyle/contrib/examples/checks/com/puppycrawl/tools/checkstyle/checks/xpath/Attribute.java107
-rwxr-xr-xthirdparty/checkstyle/contrib/examples/checks/com/puppycrawl/tools/checkstyle/checks/xpath/AttributeAxisIterator.java98
-rwxr-xr-xthirdparty/checkstyle/contrib/examples/checks/com/puppycrawl/tools/checkstyle/checks/xpath/DocumentNavigator.java437
-rwxr-xr-xthirdparty/checkstyle/contrib/examples/checks/com/puppycrawl/tools/checkstyle/checks/xpath/NodeIterator.java122
-rwxr-xr-xthirdparty/checkstyle/contrib/examples/checks/com/puppycrawl/tools/checkstyle/checks/xpath/XPathCheck.java103
-rwxr-xr-xthirdparty/checkstyle/contrib/examples/checks/com/puppycrawl/tools/checkstyle/checks/xpath/jaxen_LICENSE.txt56
-rwxr-xr-xthirdparty/checkstyle/contrib/examples/checks/com/puppycrawl/tools/checkstyle/checks/xpath/messages.properties6
-rwxr-xr-xthirdparty/checkstyle/contrib/examples/checks/com/puppycrawl/tools/checkstyle/checks/xpath/package.html10
-rwxr-xr-xthirdparty/checkstyle/contrib/examples/checks/com/puppycrawl/tools/checkstyle/checks/xpath/saxpath_LICENSE.txt60
-rwxr-xr-xthirdparty/checkstyle/contrib/examples/checks/com/puppycrawl/tools/checkstyle/checks/xpath/xpath_config.xml44
-rwxr-xr-xthirdparty/checkstyle/contrib/examples/checks/mycompany_conf.xml44
-rwxr-xr-xthirdparty/checkstyle/contrib/examples/conf/BlochEffectiveJava.xml113
-rwxr-xr-xthirdparty/checkstyle/contrib/examples/conf/openorb.xml139
-rwxr-xr-xthirdparty/checkstyle/contrib/examples/conf/template_config.xml788
-rwxr-xr-xthirdparty/checkstyle/contrib/examples/filters/com/mycompany/filters/FilesFilter.java34
-rwxr-xr-xthirdparty/checkstyle/contrib/examples/linkErrors2Source/build.xml70
-rwxr-xr-xthirdparty/checkstyle/contrib/examples/linkErrors2Source/checkstyle-noframes.xsl190
-rwxr-xr-xthirdparty/checkstyle/contrib/examples/linkErrors2Source/readme.txt6
-rwxr-xr-xthirdparty/checkstyle/contrib/examples/listeners/com/mycompany/listeners/CommonsLoggingListener.java127
-rwxr-xr-xthirdparty/checkstyle/contrib/examples/listeners/com/mycompany/listeners/MailLogger.java241
-rwxr-xr-xthirdparty/checkstyle/contrib/examples/listeners/com/mycompany/listeners/VerboseListener.java111
-rwxr-xr-xthirdparty/checkstyle/contrib/hooks/git-pre-commit-hook.pl72
-rwxr-xr-xthirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/AbstractUsageCheck.java200
-rwxr-xr-xthirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/OneMethodPrivateFieldCheck.java139
-rwxr-xr-xthirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/UnusedLocalVariableCheck.java59
-rwxr-xr-xthirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/UnusedParameterCheck.java132
-rwxr-xr-xthirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/UnusedPrivateFieldCheck.java63
-rwxr-xr-xthirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/UnusedPrivateMethodCheck.java244
-rwxr-xr-xthirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/messages.properties5
-rwxr-xr-xthirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/messages_fi.properties5
-rwxr-xr-xthirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/messages_fr.properties5
-rwxr-xr-xthirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/package.html10
-rwxr-xr-xthirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/ASTManager.java228
-rwxr-xr-xthirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/ASTUtil.java220
-rwxr-xr-xthirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/AnonymousInnerClass.java62
-rwxr-xr-xthirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/ArrayDef.java154
-rwxr-xr-xthirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/ArrayLengthMember.java48
-rwxr-xr-xthirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/BaseScope.java100
-rwxr-xr-xthirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/BlockDef.java53
-rwxr-xr-xthirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/ClassDef.java362
-rwxr-xr-xthirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/ClassImportException.java35
-rwxr-xr-xthirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/ClassManager.java41
-rwxr-xr-xthirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/DefaultConstructor.java65
-rwxr-xr-xthirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/DefaultScope.java82
-rwxr-xr-xthirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/Definition.java203
-rwxr-xr-xthirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/DefinitionTraverser.java139
-rwxr-xr-xthirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/DotIterator.java108
-rwxr-xr-xthirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/ExternalClass.java373
-rwxr-xr-xthirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/ExternalConstructor.java101
-rwxr-xr-xthirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/ExternalDefinition.java50
-rwxr-xr-xthirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/ExternalMethod.java128
-rwxr-xr-xthirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/ExternalPackage.java95
-rwxr-xr-xthirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/ExternalSignature.java97
-rwxr-xr-xthirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/ExternalVariable.java76
-rwxr-xr-xthirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/IClass.java142
-rwxr-xr-xthirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/IDefinition.java84
-rwxr-xr-xthirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/IMethod.java67
-rwxr-xr-xthirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/IPackage.java63
-rwxr-xr-xthirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/ISignature.java58
-rwxr-xr-xthirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/IVariable.java39
-rwxr-xr-xthirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/InterfaceConstructor.java90
-rwxr-xr-xthirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/LabelDef.java48
-rwxr-xr-xthirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/LiteralResolver.java157
-rwxr-xr-xthirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/MethodDef.java157
-rwxr-xr-xthirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/MethodSignature.java138
-rwxr-xr-xthirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/MethodSpecificityComparator.java59
-rwxr-xr-xthirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/NullClass.java107
-rwxr-xr-xthirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/Occurrence.java131
-rwxr-xr-xthirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/PackageDef.java66
-rwxr-xr-xthirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/PrimitiveClasses.java107
-rwxr-xr-xthirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/QueryEngine.java185
-rwxr-xr-xthirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/Reference.java141
-rwxr-xr-xthirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/ReferenceCounter.java88
-rwxr-xr-xthirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/ReferenceThreshold.java78
-rwxr-xr-xthirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/ReferenceTool.java55
-rwxr-xr-xthirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/Resolver.java1893
-rwxr-xr-xthirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/Scope.java124
-rwxr-xr-xthirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/ScopeIndex.java140
-rwxr-xr-xthirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/Span.java153
-rwxr-xr-xthirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/SymTabAST.java554
-rwxr-xr-xthirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/SymTabASTFactory.java76
-rwxr-xr-xthirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/SymTabASTIterator.java95
-rwxr-xr-xthirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/SymbolTable.java274
-rwxr-xr-xthirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/SymbolTableException.java35
-rwxr-xr-xthirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/TableMaker.java1460
-rwxr-xr-xthirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/Typed.java45
-rwxr-xr-xthirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/UnknownClass.java174
-rwxr-xr-xthirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/VariableDef.java132
-rwxr-xr-xthirdparty/checkstyle/contrib/usage/src/testinputs/com/puppycrawl/tools/checkstyle/usage/InputEmptyFile.java2
-rwxr-xr-xthirdparty/checkstyle/contrib/usage/src/testinputs/com/puppycrawl/tools/checkstyle/usage/InputInnerUsedMethod.java23
-rwxr-xr-xthirdparty/checkstyle/contrib/usage/src/testinputs/com/puppycrawl/tools/checkstyle/usage/InputOneMethodPrivateField.java114
-rwxr-xr-xthirdparty/checkstyle/contrib/usage/src/testinputs/com/puppycrawl/tools/checkstyle/usage/InputUnusedField.java97
-rwxr-xr-xthirdparty/checkstyle/contrib/usage/src/testinputs/com/puppycrawl/tools/checkstyle/usage/InputUnusedLocal.java60
-rwxr-xr-xthirdparty/checkstyle/contrib/usage/src/testinputs/com/puppycrawl/tools/checkstyle/usage/InputUnusedMethod.java155
-rwxr-xr-xthirdparty/checkstyle/contrib/usage/src/testinputs/com/puppycrawl/tools/checkstyle/usage/InputUnusedParameter.java50
-rwxr-xr-xthirdparty/checkstyle/contrib/usage/src/tests/com/puppycrawl/tools/checkstyle/checks/usage/AllTests.java23
-rwxr-xr-xthirdparty/checkstyle/contrib/usage/src/tests/com/puppycrawl/tools/checkstyle/checks/usage/OneMethodPrivateFieldCheckTest.java46
-rwxr-xr-xthirdparty/checkstyle/contrib/usage/src/tests/com/puppycrawl/tools/checkstyle/checks/usage/UnusedLocalVariableCheckTest.java34
-rwxr-xr-xthirdparty/checkstyle/contrib/usage/src/tests/com/puppycrawl/tools/checkstyle/checks/usage/UnusedParameterCheckTest.java58
-rwxr-xr-xthirdparty/checkstyle/contrib/usage/src/tests/com/puppycrawl/tools/checkstyle/checks/usage/UnusedPrivateFieldCheckTest.java36
-rwxr-xr-xthirdparty/checkstyle/contrib/usage/src/tests/com/puppycrawl/tools/checkstyle/checks/usage/UnusedPrivateMethodCheckTest.java78
-rwxr-xr-xthirdparty/checkstyle/contrib/usage/src/xdocs/config_usage.xml359
157 files changed, 19965 insertions, 0 deletions
diff --git a/thirdparty/checkstyle/contrib/JavadocCheckDefault.java b/thirdparty/checkstyle/contrib/JavadocCheckDefault.java
new file mode 100755
index 000000000..11a126d90
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/JavadocCheckDefault.java
@@ -0,0 +1,62 @@
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+
+import com.puppycrawl.tools.checkstyle.api.Check;
+import com.puppycrawl.tools.checkstyle.api.TokenTypes;
+
+/**
+ * Tool that generates Javadoc description of the default tokens for a Check.
+ * @author Rick Giles
+ * @version 27-Nov-2002
+ */
+public class JavadocCheckDefault
+{
+
+ private static void usage()
+ {
+ System.out.println("Usage: java JavadocCheckDefault check element");
+ System.exit(0);
+ }
+
+ public static void main(String[] args)
+ {
+ if (args.length < 2) {
+ usage();
+ }
+ final String header =
+ " * <p> By default the check will check the following "
+ + args[1] + ":\n";
+ final String footer = ".\n * </p>\n";
+ final String prefix = " * {@link TokenTypes#";
+
+ try {
+ final Class clazz = Class.forName(args[0]);
+ final Check check = (Check) clazz.newInstance();
+ final int[] defaultTokens = check.getDefaultTokens();
+ if (defaultTokens.length > 0) {
+ final StringBuffer buf = new StringBuffer();
+ buf.append(header);
+ final ArrayList tokenNames = new ArrayList();
+ for (int i = 0; i < defaultTokens.length; i++) {
+ tokenNames.add(TokenTypes.getTokenName(defaultTokens[i]));
+ }
+ Collections.sort(tokenNames);
+ final Iterator it = tokenNames.iterator();
+ String token = (String) it.next();
+ buf.append(prefix + token + " " + token + "}");
+ while (it.hasNext()) {
+ token = (String) it.next();
+ buf.append(",\n" + prefix + token + " " + token + "}");
+ }
+ buf.append(footer);
+ System.out.println(buf);
+ }
+ }
+ catch (Exception ex) {
+ ex.printStackTrace();
+ System.exit(0);
+ }
+ }
+}
diff --git a/thirdparty/checkstyle/contrib/bcel/docs/BCELConfig.xml b/thirdparty/checkstyle/contrib/bcel/docs/BCELConfig.xml
new file mode 100755
index 000000000..023c9d5e6
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/bcel/docs/BCELConfig.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0"?>
+<!DOCTYPE module PUBLIC
+ "-//Puppy Crawl//DTD Check Configuration 1.1//EN"
+ "http://www.puppycrawl.com/dtds/configuration_1_1.dtd">
+<module name="Checker">
+ <metadata name="com.atlas-sw.eclipse" value="I like Sydney"/>
+ <property name="severity" value="error"/>
+
+ <module name="bcel.ClassFileSet">
+ <module name="bcel.checks.UnusedMethod">
+ </module>
+ <module name="bcel.checks.UnreadPrivateField">
+ </module>
+ </module>
+</module>
diff --git a/thirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/AbstractCheckVisitor.java b/thirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/AbstractCheckVisitor.java
new file mode 100755
index 000000000..4641d2b5a
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/AbstractCheckVisitor.java
@@ -0,0 +1,157 @@
+//Tested with BCEL-5.1
+//http://jakarta.apache.org/builds/jakarta-bcel/release/v5.1/
+
+package com.puppycrawl.tools.checkstyle.bcel;
+
+import java.util.Set;
+
+import com.puppycrawl.tools.checkstyle.api.AbstractViolationReporter;
+import com.puppycrawl.tools.checkstyle.api.LocalizedMessage;
+import com.puppycrawl.tools.checkstyle.api.LocalizedMessages;
+import java.util.HashMap;
+import org.apache.bcel.classfile.JavaClass;
+
+/**
+ * Abstract class for checks with visitors.
+ * @author Rick Giles
+ */
+//TODO: Refactor with class Check
+public abstract class AbstractCheckVisitor
+ extends AbstractViolationReporter
+ implements IObjectSetVisitor,
+ IDeepVisitor
+{
+ /** the object for collecting messages. */
+ private HashMap mMessageMap; // <String fileName, LocalizedMessages msg>
+ /** Filename for when no file can be found */
+ private String NO_FILE = "File not available";
+
+ /** @see com.puppycrawl.tools.checkstyle.bcel.IDeepVisitor */
+ public org.apache.bcel.classfile.Visitor getClassFileVisitor()
+ {
+ return new EmptyClassFileVisitor();
+ }
+
+ /**
+ * @see com.puppycrawl.tools.checkstyle.bcel.IDeepVisitor
+ */
+ public org.apache.bcel.generic.Visitor getGenericVisitor()
+ {
+ return new EmptyGenericVisitor();
+ }
+
+ /**
+ * Initialse the check. This is the time to verify that the check has
+ * everything required to perform it job.
+ */
+ public void init()
+ {
+ }
+
+ /**
+ * Destroy the check. It is being retired from service.
+ */
+ public void destroy()
+ {
+ }
+
+ /**
+ * Set the global object used to collect messages.
+ * @param aMessages the messages to log with
+ */
+ public final void setMessageMap(HashMap aMessageMap)
+ {
+ mMessageMap = aMessageMap;
+ }
+
+ /**
+ * Log an error message.
+ *
+ * @param aLine the line number where the error was found
+ * @param aKey the message that describes the error
+ * @param aArgs the details of the message
+ *
+ * @see java.text.MessageFormat
+ */
+ protected final void log(JavaClass javaClass, int aLine, String aKey, Object aArgs[])
+ {
+ // Should this be on the .java file instead of the .class file?
+ final String file = javaClass.getFileName();
+ log(file, aLine, aKey, aArgs);
+ }
+
+ /**
+ * Log an error message.
+ *
+ * @param aLine the line number where the error was found
+ * @param aKey the message that describes the error
+ * @param aArgs the details of the message
+ *
+ * @see java.text.MessageFormat
+ */
+ private final void log(String fileName, int aLine, String aKey, Object aArgs[])
+ {
+ LocalizedMessages localizedMessages = (LocalizedMessages) mMessageMap.get(fileName);
+ if (localizedMessages == null) {
+ localizedMessages = new LocalizedMessages();
+ mMessageMap.put(fileName, localizedMessages);
+ }
+ localizedMessages.add(
+ new LocalizedMessage(
+ aLine,
+ getMessageBundle(),
+ aKey,
+ aArgs,
+ getSeverityLevel(),
+ this.getClass()));
+ }
+
+ /**
+ * Log an error message.
+ *
+ * @param aLine the line number where the error was found
+ * @param aKey the message that describes the error
+ * @param aArgs the details of the message
+ *
+ * @see java.text.MessageFormat
+ */
+ protected final void log(int aLine, String aKey, Object aArgs[])
+ {
+ log(NO_FILE, aLine, aKey, aArgs);
+ }
+
+ /**
+ * @see com.puppycrawl.tools.checkstyle.api.AbstractViolationReporter
+ */
+ protected void log(int aLine, int aCol, String aKey, Object[] aArgs)
+ {
+ // Ignore the column, it is not relevant for .class files
+ log(aLine, aKey, aArgs);
+ }
+
+ /** @see com.puppycrawl.tools.checkstyle.bcel.IObjectSetVisitor */
+ public void visitObject(Object aObject)
+ {
+ }
+
+ /** @see com.puppycrawl.tools.checkstyle.bcel.IObjectSetVisitor */
+ public void leaveObject(Object aObject)
+ {
+ }
+
+ /** @see com.puppycrawl.tools.checkstyle.bcel.IObjectSetVisitor */
+ public void visitSet(Set aJavaClassDefs)
+ {
+ }
+
+ /** @see com.puppycrawl.tools.checkstyle.bcel.IObjectSetVisitor */
+ public void leaveSet(Set aJavaClassDefs)
+ {
+ }
+
+ /**
+ * Gets the deep BCEL visitor.
+ * @return the deep BCEL visitor for this check.
+ */
+ public abstract IDeepVisitor getVisitor();
+}
diff --git a/thirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/ClassFileSetCheck.java b/thirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/ClassFileSetCheck.java
new file mode 100755
index 000000000..1393e86a5
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/ClassFileSetCheck.java
@@ -0,0 +1,317 @@
+//Tested with BCEL-5.1
+//http://jakarta.apache.org/builds/jakarta-bcel/release/v5.1/
+
+package com.puppycrawl.tools.checkstyle.bcel;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipFile;
+
+import org.apache.bcel.Repository;
+import org.apache.bcel.classfile.ClassParser;
+import org.apache.bcel.classfile.JavaClass;
+import org.apache.bcel.classfile.Visitor;
+import org.apache.bcel.util.ClassLoaderRepository;
+import com.puppycrawl.tools.checkstyle.DefaultContext;
+import com.puppycrawl.tools.checkstyle.ModuleFactory;
+import com.puppycrawl.tools.checkstyle.api.AbstractFileSetCheck;
+import com.puppycrawl.tools.checkstyle.api.CheckstyleException;
+import com.puppycrawl.tools.checkstyle.api.Configuration;
+import com.puppycrawl.tools.checkstyle.api.Context;
+import com.puppycrawl.tools.checkstyle.api.LocalizedMessage;
+import com.puppycrawl.tools.checkstyle.api.LocalizedMessages;
+
+/**
+ * Checks a set of class files using BCEL
+ * @author Rick Giles
+ */
+//TODO: Refactor with AbstractFileSetCheck and TreeWalker
+public class ClassFileSetCheck
+ extends AbstractFileSetCheck
+ implements IObjectSetVisitor
+{
+ /** visitors for BCEL parse tree walk */
+ private final Set mTreeVisitors = new HashSet();
+
+ /** all the registered checks */
+ private final Set mAllChecks = new HashSet();
+
+ /** all visitors for IObjectSetVisitor visits */
+ private final Set mObjectSetVisitors = new HashSet();
+
+ /** class loader to resolve classes with. **/
+ private ClassLoader mClassLoader;
+
+ /** context of child components */
+ private Context mChildContext;
+
+ /** a factory for creating submodules (i.e. the Checks) */
+ private ModuleFactory mModuleFactory;
+
+ /** Error messages */
+ HashMap mMessageMap = new HashMap();
+
+ /**
+ * Creates a new <code>ClassFileSetCheck</code> instance.
+ * Initializes the acceptable file extensions.
+ */
+ public ClassFileSetCheck()
+ {
+ setFileExtensions(new String[]{"class", "jar", "zip"});
+ }
+
+ /**
+ * Stores the class loader and makes it the Repository's class loader.
+ * @param aClassLoader class loader to resolve classes with.
+ */
+ public void setClassLoader(ClassLoader aClassLoader)
+ {
+ Repository.setRepository(new ClassLoaderRepository(aClassLoader));
+ mClassLoader = aClassLoader;
+ }
+
+ /**
+ * Sets the module factory for creating child modules (Checks).
+ * @param aModuleFactory the factory
+ */
+ public void setModuleFactory(ModuleFactory aModuleFactory)
+ {
+ mModuleFactory = aModuleFactory;
+ }
+
+ /**
+ * Instantiates, configures and registers a Check that is specified
+ * in the provided configuration.
+ * @see com.puppycrawl.tools.checkstyle.api.AutomaticBean
+ */
+ public void setupChild(Configuration aChildConf)
+ throws CheckstyleException
+ {
+ // TODO: improve the error handing
+ final String name = aChildConf.getName();
+ final Object module = mModuleFactory.createModule(name);
+ if (!(module instanceof AbstractCheckVisitor)) {
+ throw new CheckstyleException(
+ "ClassFileSet is not allowed as a parent of " + name);
+ }
+ final AbstractCheckVisitor c = (AbstractCheckVisitor) module;
+ c.contextualize(mChildContext);
+ c.configure(aChildConf);
+ c.init();
+
+ registerCheck(c);
+ }
+
+ /** @see com.puppycrawl.tools.checkstyle.api.Configurable */
+ public void finishLocalSetup()
+ {
+ DefaultContext checkContext = new DefaultContext();
+ checkContext.add("classLoader", mClassLoader);
+ checkContext.add("messageMap", mMessageMap);
+ checkContext.add("severity", getSeverity());
+
+ mChildContext = checkContext;
+ }
+
+ /**
+ * Register a check.
+ * @param aCheck the check to register
+ */
+ private void registerCheck(AbstractCheckVisitor aCheck)
+ {
+ mAllChecks.add(aCheck);
+ }
+
+ /**
+ * @see com.puppycrawl.tools.checkstyle.api.FileSetCheck
+ */
+ public void process(File[] aFiles)
+ {
+ registerVisitors();
+
+ // get all the JavaClasses in the files
+ final Set javaClasses = extractJavaClasses(aFiles);
+
+ visitSet(javaClasses);
+
+ // walk each Java class parse tree
+ final JavaClassWalker walker = new JavaClassWalker();
+ walker.setVisitor(getTreeVisitor());
+ final Iterator it = javaClasses.iterator();
+ while (it.hasNext()) {
+ final JavaClass clazz = (JavaClass) it.next();
+ visitObject(clazz);
+ walker.walk(clazz);
+ leaveObject(clazz);
+ }
+
+ leaveSet(javaClasses);
+ fireErrors();
+ }
+
+ /**
+ * Gets the visitor for a parse tree walk.
+ * @return the visitor for a parse tree walk.
+ */
+ private Visitor getTreeVisitor()
+ {
+ return new VisitorSet(mTreeVisitors);
+ }
+
+ /**
+ * Registers all the visitors for IObjectSetVisitor visits, and for
+ * tree walk visits.
+ */
+ private void registerVisitors()
+ {
+ mObjectSetVisitors.addAll(mAllChecks);
+ final Iterator it = mAllChecks.iterator();
+ while (it.hasNext()) {
+ final AbstractCheckVisitor check = (AbstractCheckVisitor) it.next();
+ final IDeepVisitor visitor = check.getVisitor();
+ mObjectSetVisitors.add(visitor);
+ mTreeVisitors.add(visitor);
+ }
+ }
+
+ /**
+ * Gets the set of all visitors for all the checks.
+ * @return the set of all visitors for all the checks.
+ */
+ private Set getObjectSetVisitors()
+ {
+ return mObjectSetVisitors;
+ }
+
+ /**
+ * Gets the set of all JavaClasses within a set of Files.
+ * @param aFiles the set of files to extract from.
+ * @return the set of all JavaClasses within aFiles.
+ */
+ private Set extractJavaClasses(File[] aFiles)
+ {
+ final Set result = new HashSet();
+ final File[] classFiles = filter(aFiles);
+ // get Java classes from each filtered file
+ for (int i = 0; i < classFiles.length; i++) {
+ try {
+ final Set extracted = extractJavaClasses(classFiles[i]);
+ result.addAll(extracted);
+ }
+ catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ return result;
+ }
+
+ /** @see com.puppycrawl.tools.checkstyle.bcel.IObjectSetVisitor */
+ public void visitSet(Set aSet)
+ {
+ // register the JavaClasses in the Repository
+ Repository.clearCache();
+ Iterator it = aSet.iterator();
+ while (it.hasNext()) {
+ final JavaClass javaClass = (JavaClass) it.next();
+ Repository.addClass(javaClass);
+ }
+
+ // visit the visitors
+ it = getObjectSetVisitors().iterator();
+ while (it.hasNext()) {
+ final IObjectSetVisitor visitor = (IObjectSetVisitor) it.next();
+ visitor.visitSet(aSet);
+ }
+ }
+
+ /** @see com.puppycrawl.tools.checkstyle.bcel.IObjectSetVisitor */
+ public void visitObject(Object aObject)
+ {
+ final Iterator it = getObjectSetVisitors().iterator();
+ while (it.hasNext()) {
+ final IObjectSetVisitor visitor = (IObjectSetVisitor) it.next();
+ visitor.visitObject(aObject);
+ }
+ }
+
+ /** @see com.puppycrawl.tools.checkstyle.bcel.IObjectSetVisitor */
+ public void leaveObject(Object aObject)
+ {
+ final Iterator it = getObjectSetVisitors().iterator();
+ while (it.hasNext()) {
+ final IObjectSetVisitor visitor = (IObjectSetVisitor) it.next();
+ visitor.leaveObject(aObject);
+ }
+ }
+
+ /** @see com.puppycrawl.tools.checkstyle.bcel.IObjectSetVisitor */
+ public void leaveSet(Set aSet)
+ {
+ final Iterator it = getObjectSetVisitors().iterator();
+ while (it.hasNext()) {
+ final IObjectSetVisitor visitor = (IObjectSetVisitor) it.next();
+ visitor.leaveSet(aSet);
+ }
+ }
+
+ /**
+ * Extracts the JavaClasses from .class, .zip, and .jar files.
+ * @param aFile the file to extract from.
+ * @return the set of JavaClasses from aFile.
+ * @throws IOException if there is an error.
+ */
+ private Set extractJavaClasses(File aFile)
+ throws IOException
+ {
+ final Set result = new HashSet();
+ final String fileName = aFile.getPath();
+ if (fileName.endsWith(".jar") || fileName.endsWith(".zip")) {
+ final ZipFile zipFile = new ZipFile(fileName);
+ final Enumeration entries = zipFile.entries();
+ while (entries.hasMoreElements()) {
+ final ZipEntry entry = (ZipEntry) entries.nextElement();
+ final String entryName = entry.getName();
+ if (entryName.endsWith(".class")) {
+ final InputStream in = zipFile.getInputStream(entry);
+ final JavaClass javaClass =
+ new ClassParser(in, entryName).parse();
+ result.add(javaClass);
+ }
+ }
+ }
+ else {
+ final JavaClass javaClass = new ClassParser(fileName).parse();
+ result.add(javaClass);
+ }
+ return result;
+ }
+
+ /**
+ * Notify all listeners about the errors in a file.
+ * Calls <code>MessageDispatcher.fireErrors()</code> with
+ * all logged errors and than clears errors' list.
+ */
+ private void fireErrors()
+ {
+ Set keys = mMessageMap.keySet();
+ Iterator iter = keys.iterator();
+ while (iter.hasNext()) {
+ String key = (String) iter.next();
+ getMessageDispatcher().fireFileStarted(key);
+ LocalizedMessages localizedMessages = (LocalizedMessages) mMessageMap.get(key);
+ final LocalizedMessage[] errors = localizedMessages.getMessages();
+ localizedMessages.reset();
+ getMessageDispatcher().fireErrors(key, errors);
+ getMessageDispatcher().fireFileFinished(key);
+ }
+ }
+
+}
diff --git a/thirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/EmptyClassFileVisitor.java b/thirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/EmptyClassFileVisitor.java
new file mode 100755
index 000000000..8fa0dc93b
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/EmptyClassFileVisitor.java
@@ -0,0 +1,17 @@
+//Tested with BCEL-5.1
+//http://jakarta.apache.org/builds/jakarta-bcel/release/v5.1/
+
+package com.puppycrawl.tools.checkstyle.bcel;
+
+/**
+ * Default classfile visitor.
+ * @author Rick Giles
+ */
+public class EmptyClassFileVisitor
+ extends org.apache.bcel.classfile.EmptyVisitor
+{
+ /** restrict client creation */
+ protected EmptyClassFileVisitor()
+ {
+ }
+} \ No newline at end of file
diff --git a/thirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/EmptyDeepVisitor.java b/thirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/EmptyDeepVisitor.java
new file mode 100755
index 000000000..24ffc7175
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/EmptyDeepVisitor.java
@@ -0,0 +1,86 @@
+//Tested with BCEL-5.1
+//http://jakarta.apache.org/builds/jakarta-bcel/release/v5.1/
+
+package com.puppycrawl.tools.checkstyle.bcel;
+
+import java.util.Set;
+
+
+/**
+ * Default deep visitor
+ * @author Rick Giles
+ * @version 17-Jun-2003
+ */
+public class EmptyDeepVisitor
+ implements IDeepVisitor
+{
+ /** the classfile visitor */
+ private org.apache.bcel.classfile.Visitor mClassFileVisitor =
+ new EmptyClassFileVisitor();
+
+ /** the generic visitor */
+ private org.apache.bcel.generic.Visitor mGenericVisitor =
+ new EmptyGenericVisitor();
+
+ /**
+ * @see com.puppycrawl.tools.checkstyle.bcel.IDeepVisitor
+ */
+ public org.apache.bcel.classfile.Visitor getClassFileVisitor()
+ {
+ return mClassFileVisitor;
+ }
+
+ /**
+ * @see com.puppycrawl.tools.checkstyle.bcel.IDeepVisitor
+ */
+ public org.apache.bcel.generic.Visitor getGenericVisitor()
+ {
+ return mGenericVisitor;
+ }
+
+ /**
+ * Sets the classfile visitor.
+ * @param aVisitor the classfile visitor.
+ */
+ public void setClassFileVisitor(org.apache.bcel.classfile.Visitor aVisitor)
+ {
+ mClassFileVisitor = aVisitor;
+ }
+
+ /**
+ * Sets the generic visitor.
+ * @param aVisitor the generic visitor.
+ */
+ public void setGenericVisitor(org.apache.bcel.generic.Visitor aVisitor)
+ {
+ mGenericVisitor = aVisitor;
+ }
+
+ /**
+ * @see com.puppycrawl.tools.checkstyle.bcel.IObjectSetVisitor
+ */
+ public void visitObject(Object aObject)
+ {
+ }
+
+ /**
+ * @see com.puppycrawl.tools.checkstyle.bcel.IObjectSetVisitor
+ */
+ public void leaveObject(Object aObject)
+ {
+ }
+
+ /**
+ * @see com.puppycrawl.tools.checkstyle.bcel.IObjectSetVisitor
+ */
+ public void visitSet(Set aSet)
+ {
+ }
+
+ /**
+ * @see com.puppycrawl.tools.checkstyle.bcel.IObjectSetVisitor
+ */
+ public void leaveSet(Set aSet)
+ {
+ }
+}
diff --git a/thirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/EmptyGenericVisitor.java b/thirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/EmptyGenericVisitor.java
new file mode 100755
index 000000000..c7f01d895
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/EmptyGenericVisitor.java
@@ -0,0 +1,18 @@
+//Tested with BCEL-5.1
+//http://jakarta.apache.org/builds/jakarta-bcel/release/v5.1/
+
+package com.puppycrawl.tools.checkstyle.bcel;
+
+/**
+ * Default generic visitor
+ * @author Rick Giles
+ */
+public class EmptyGenericVisitor
+ extends org.apache.bcel.generic.EmptyVisitor
+{
+ /** Restrict client creation */
+ protected EmptyGenericVisitor()
+ {
+ }
+}
+
diff --git a/thirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/IDeepVisitor.java b/thirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/IDeepVisitor.java
new file mode 100755
index 000000000..57163d112
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/IDeepVisitor.java
@@ -0,0 +1,25 @@
+//Tested with BCEL-5.1
+//http://jakarta.apache.org/builds/jakarta-bcel/release/v5.1/
+
+package com.puppycrawl.tools.checkstyle.bcel;
+
+/**
+ * Deep visitor for classfile and generic traversals. A ClassFile traversal
+ * visits all classfile and all generic nodes.
+ * @author Rick Giles
+ */
+public interface IDeepVisitor
+ extends IObjectSetVisitor
+{
+ /**
+ * Returns the classfile visitor.
+ * @return the classfile visitor.
+ */
+ org.apache.bcel.classfile.Visitor getClassFileVisitor();
+
+ /**
+ * Returns the generic visitor.
+ * @return the generic visitor.
+ */
+ org.apache.bcel.generic.Visitor getGenericVisitor();
+}
diff --git a/thirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/IObjectSetVisitor.java b/thirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/IObjectSetVisitor.java
new file mode 100755
index 000000000..42ea1171e
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/IObjectSetVisitor.java
@@ -0,0 +1,37 @@
+//Tested with BCEL-5.1
+//http://jakarta.apache.org/builds/jakarta-bcel/release/v5.1/
+
+package com.puppycrawl.tools.checkstyle.bcel;
+
+import java.util.Set;
+
+/**
+ * Object set visitor for a general set.
+ * @author Rick Giles
+ */
+public interface IObjectSetVisitor
+{
+ /**
+ * Visit a set itself.
+ * @param aSet the set.
+ */
+ void visitSet(Set aSet);
+
+ /**
+ * Finish the visit of a set.
+ * @param aSet the set.
+ */
+ void leaveSet(Set aSet);
+
+ /**
+ * Visit an object. Normally this is an object of the set.
+ * @param aObject the object.
+ */
+ void visitObject(Object aObject);
+
+ /**
+ * Finish the visit an object. Normally this is an object of the set.
+ * @param aObject the object.
+ */
+ void leaveObject(Object aObject);
+}
diff --git a/thirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/JavaClassWalker.java b/thirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/JavaClassWalker.java
new file mode 100755
index 000000000..fc26305cc
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/JavaClassWalker.java
@@ -0,0 +1,40 @@
+//Tested with BCEL-5.1
+//http://jakarta.apache.org/builds/jakarta-bcel/release/v5.1/
+
+package com.puppycrawl.tools.checkstyle.bcel;
+
+import org.apache.bcel.classfile.DescendingVisitor;
+import org.apache.bcel.classfile.JavaClass;
+import org.apache.bcel.classfile.Visitor;
+
+/**
+ * Walks a JavaClass parse tree.
+ * @author Rick Giles
+ * @version 15-Jun-2003
+ */
+public final class JavaClassWalker
+{
+ /** visitor to be accepted during a traversal */
+ private Visitor mVisitor = new EmptyClassFileVisitor();
+
+ /**
+ * Sets a visitor to be accepted during a traversal.
+ * @param aVisitor the visitor to be accepted during a traversal.
+ */
+ public void setVisitor(Visitor aVisitor)
+ {
+ mVisitor = aVisitor;
+ }
+
+ /**
+ * Traverses a JavaClass parse tree and accepts all registered
+ * visitors.
+ * @param aJavaClass the root of the tree.
+ */
+ public void walk(JavaClass aJavaClass)
+ {
+ DescendingVisitor visitor =
+ new DescendingVisitor(aJavaClass, mVisitor);
+ aJavaClass.accept(visitor);
+ }
+}
diff --git a/thirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/ReferenceVisitor.java b/thirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/ReferenceVisitor.java
new file mode 100755
index 000000000..7db15d78e
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/ReferenceVisitor.java
@@ -0,0 +1,194 @@
+//Tested with BCEL-5.1
+//http://jakarta.apache.org/builds/jakarta-bcel/release/v5.1/
+
+package com.puppycrawl.tools.checkstyle.bcel;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.bcel.classfile.ConstantPool;
+import org.apache.bcel.classfile.JavaClass;
+import org.apache.bcel.generic.ConstantPoolGen;
+import org.apache.bcel.generic.GETFIELD;
+import org.apache.bcel.generic.GETSTATIC;
+import org.apache.bcel.generic.INVOKESPECIAL;
+import org.apache.bcel.generic.INVOKESTATIC;
+import org.apache.bcel.generic.INVOKEVIRTUAL;
+import org.apache.bcel.generic.PUTFIELD;
+import org.apache.bcel.generic.PUTSTATIC;
+
+import com.puppycrawl.tools.checkstyle.api.Scope;
+import com.puppycrawl.tools.checkstyle.bcel.classfile.JavaClassDefinition;
+import com.puppycrawl.tools.checkstyle.bcel.classfile.ReferenceDAO;
+import com.puppycrawl.tools.checkstyle.bcel.generic.FieldReference;
+import com.puppycrawl.tools.checkstyle.bcel.generic.GETFIELDReference;
+import com.puppycrawl.tools.checkstyle.bcel.generic.GETSTATICReference;
+import com.puppycrawl.tools.checkstyle.bcel.generic.InvokeReference;
+import com.puppycrawl.tools.checkstyle.bcel.generic.PUTFIELDReference;
+import com.puppycrawl.tools.checkstyle.bcel.generic.PUTSTATICReference;
+
+/**
+ * Records references during a deep parse tree traversal.
+ * @author Rick Giles
+ */
+public final class ReferenceVisitor extends EmptyDeepVisitor
+{
+ /** singleton */
+ private static ReferenceVisitor sInstance = new ReferenceVisitor();
+
+ /** scope for checking field references */
+ private Set mFieldScopes = new HashSet();
+
+ /** scope for checking method references */
+ private Set mMethodScopes = new HashSet();
+
+ /** maps a JavaClass to a JavaClassDefinition */
+ private ReferenceDAO mReferenceDAO;
+
+ /** access to current constant pool */
+ private ConstantPoolGen mCurrentPoolGen;
+
+ /**
+ * Adds a reference when it visits an instruction that invokes
+ * a method or references a field.
+ * @author Rick Giles
+ * @version 18-Jun-2003
+ */
+ private class GenericVisitor extends org.apache.bcel.generic.EmptyVisitor
+ {
+ /** @see org.apache.bcel.generic.Visitor */
+ public void visitINVOKESPECIAL(INVOKESPECIAL aINVOKESPECIAL)
+ {
+ addInvokeReference(
+ new InvokeReference(aINVOKESPECIAL, mCurrentPoolGen));
+ }
+
+ /** @see org.apache.bcel.generic.Visitor */
+ public void visitINVOKESTATIC(INVOKESTATIC aINVOKESTATIC)
+ {
+ addInvokeReference(
+ new InvokeReference(aINVOKESTATIC, mCurrentPoolGen));
+ }
+
+ /** @see org.apache.bcel.generic.Visitor */
+ public void visitINVOKEVIRTUAL(INVOKEVIRTUAL aINVOKEVIRTUAL)
+ {
+ addInvokeReference(
+ new InvokeReference(aINVOKEVIRTUAL, mCurrentPoolGen));
+ }
+
+ /** @see org.apache.bcel.generic.Visitor */
+ public void visitGETSTATIC(GETSTATIC aGETSTATIC)
+ {
+ addFieldReference(
+ new GETSTATICReference(aGETSTATIC, mCurrentPoolGen));
+ }
+
+ /** @see org.apache.bcel.generic.Visitor */
+ public void visitGETFIELD(GETFIELD aGETFIELD)
+ {
+ addFieldReference(
+ new GETFIELDReference(aGETFIELD, mCurrentPoolGen));
+ }
+
+ /** @see org.apache.bcel.generic.Visitor */
+ public void visitPUTSTATIC(PUTSTATIC aPUTSTATIC)
+ {
+ addFieldReference(
+ new PUTSTATICReference(aPUTSTATIC, mCurrentPoolGen));
+ }
+
+ /** @see org.apache.bcel.generic.Visitor */
+ public void visitPUTFIELD(PUTFIELD aPUTFIELD)
+ {
+ addFieldReference(
+ new PUTFIELDReference(aPUTFIELD, mCurrentPoolGen));
+ }
+ }
+
+ /** prevent client construction */
+ private ReferenceVisitor()
+ {
+ setGenericVisitor(new GenericVisitor());
+ addFieldScope(Scope.PRIVATE);
+ }
+
+ /**
+ * Returns the singleton ReferencesVisitor
+ * @return the singleton
+ */
+ public static ReferenceVisitor getInstance()
+ {
+ return sInstance;
+ }
+
+ /**
+ * Adds an invoke reference to the reference DAO.
+ * @param aReference the reference.
+ */
+ private void addInvokeReference(InvokeReference aReference)
+ {
+ getReferenceDAO().addInvokeReference(aReference);
+ }
+
+ /**
+ * Adds an field reference to the reference DAO.
+ * @param aReference the reference.
+ */
+ private void addFieldReference(FieldReference aReference)
+ {
+ getReferenceDAO().addFieldReference(aReference);
+ }
+
+ /** @see com.puppycrawl.tools.checkstyle.bcel.IDeepVisitor */
+ public void visitSet(Set aJavaClasses)
+ {
+ mReferenceDAO =
+ new ReferenceDAO(aJavaClasses, mFieldScopes, mMethodScopes);
+ }
+
+ /**
+ * Gets the reference DAO.
+ * @return the reference DAO.
+ */
+ public ReferenceDAO getReferenceDAO()
+ {
+ return mReferenceDAO;
+ }
+
+ /** @see com.puppycrawl.tools.checkstyle.bcel.IDeepVisitor */
+ public void visitObject(Object aObject)
+ {
+ final JavaClass javaClass = (JavaClass) aObject;
+ final ConstantPool pool = javaClass.getConstantPool();
+ mCurrentPoolGen = new ConstantPoolGen(pool);
+ }
+
+ /**
+ * Finds the JavaClassDefinition for a given JavaClass.
+ * @param aJavaClass the JavaClass.
+ * @return the JavaClassDefinition for aJavaClass.
+ */
+ public JavaClassDefinition findJavaClassDef(JavaClass aJavaClass)
+ {
+ return getReferenceDAO().findJavaClassDef(aJavaClass);
+ }
+
+ /**
+ * Includes a scope in the scope for checking field references.
+ * @param aScope the scope to include.
+ */
+ public void addFieldScope(Scope aScope)
+ {
+ mFieldScopes.add(aScope);
+ }
+
+ /**
+ * Includes a scope in the scope for checking method references.
+ * @param aScope the scope to include.
+ */
+ public void addMethodScope(Scope aScope)
+ {
+ mMethodScopes.add(aScope);
+ }
+}
diff --git a/thirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/VisitorSet.java b/thirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/VisitorSet.java
new file mode 100755
index 000000000..084ebd89a
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/VisitorSet.java
@@ -0,0 +1,149 @@
+//Tested with BCEL-5.1
+//http://jakarta.apache.org/builds/jakarta-bcel/release/v5.1/
+
+package com.puppycrawl.tools.checkstyle.bcel;
+
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+import org.apache.bcel.classfile.Code;
+import org.apache.bcel.classfile.ConstantPool;
+import org.apache.bcel.classfile.EmptyVisitor;
+import org.apache.bcel.classfile.Field;
+import org.apache.bcel.classfile.JavaClass;
+import org.apache.bcel.classfile.LocalVariable;
+import org.apache.bcel.classfile.LocalVariableTable;
+import org.apache.bcel.classfile.Method;
+import org.apache.bcel.classfile.Visitor;
+import org.apache.bcel.generic.InstructionHandle;
+import org.apache.bcel.generic.InstructionList;
+
+/**
+ * Manages a set of visitors that are accepted by nodes visited by
+ * a VisitorSet. Any visit to this object is passed on to its managed
+ * visitors.
+ * @author Rick Giles
+ */
+// TODO: review visitXXX
+public class VisitorSet
+ extends EmptyVisitor
+{
+ /** the managed visitors */
+ private Set mVisitors = new HashSet();
+
+ /** Creates a <code>VisitorSet</code> for a set of visitors.
+ * @param aVisitors the set of managed visitors.
+ */
+ public VisitorSet(Set aVisitors)
+ {
+ mVisitors = aVisitors;
+ }
+
+ /**
+ * @see org.apache.bcel.classfile.Visitor#visitCode
+ */
+ public void visitCode(Code aCode)
+ {
+ for (Iterator iter = mVisitors.iterator(); iter.hasNext();) {
+ IDeepVisitor visitor = (IDeepVisitor) iter.next();
+ Visitor v = visitor.getClassFileVisitor();
+ aCode.accept(v);
+ }
+
+ // perform a deep visit
+ final byte[] code = aCode.getCode();
+ final InstructionList list = new InstructionList(code);
+ final Iterator it = list.iterator();
+ for (Iterator iter = list.iterator(); iter.hasNext();) {
+ InstructionHandle instruction = (InstructionHandle) iter.next();
+ visitInstructionHandle(instruction);
+ }
+ }
+
+ /**
+ * Deep visit of an InstructionHandle
+ * @param aInstruction the InstructionHandle
+ */
+ private void visitInstructionHandle(InstructionHandle aInstruction)
+ {
+ for (Iterator iter = mVisitors.iterator(); iter.hasNext();) {
+ final IDeepVisitor visitor = (IDeepVisitor) iter.next();
+ org.apache.bcel.generic.Visitor v =
+ visitor.getGenericVisitor();
+ aInstruction.accept(v);
+ }
+ }
+
+ /**
+ * @see org.apache.bcel.classfile.Visitor
+ */
+ public void visitConstantPool(ConstantPool aConstantPool)
+ {
+ for (Iterator iter = mVisitors.iterator(); iter.hasNext();) {
+ IDeepVisitor visitor = (IDeepVisitor) iter.next();
+ Visitor v = visitor.getClassFileVisitor();
+ aConstantPool.accept(v);
+ }
+ }
+
+ /**
+ * @see org.apache.bcel.classfile.Visitor
+ */
+ public void visitField(Field aField)
+ {
+ for (Iterator iter = mVisitors.iterator(); iter.hasNext();) {
+ IDeepVisitor visitor = (IDeepVisitor) iter.next();
+ Visitor v = visitor.getClassFileVisitor();
+ aField.accept(v);
+ }
+ }
+
+ /**
+ * @see org.apache.bcel.classfile.Visitor
+ */
+ public void visitJavaClass(JavaClass aJavaClass)
+ {
+ for (Iterator iter = mVisitors.iterator(); iter.hasNext();) {
+ IDeepVisitor visitor = (IDeepVisitor) iter.next();
+ Visitor v = visitor.getClassFileVisitor();
+ aJavaClass.accept(v);
+ }
+ }
+
+// /**
+// * @see org.apache.bcel.classfile.Visitor
+// */
+// public void visitLocalVariable(LocalVariable aLocalVariable)
+// {
+// for (Iterator iter = mVisitors.iterator(); iter.hasNext();) {
+// IDeepVisitor visitor = (IDeepVisitor) iter.next();
+// Visitor v = visitor.getClassFileVisitor();
+// aLocalVariable.accept(v);
+// }
+// }
+//
+ /**
+ * @see org.apache.bcel.classfile.Visitor
+ */
+ public void visitLocalVariableTable(LocalVariableTable aTable)
+ {
+ for (Iterator iter = mVisitors.iterator(); iter.hasNext();) {
+ IDeepVisitor visitor = (IDeepVisitor) iter.next();
+ Visitor v = visitor.getClassFileVisitor();
+ aTable.accept(v);
+ }
+ }
+
+ /**
+ * @see org.apache.bcel.classfile.Visitor
+ */
+ public void visitMethod(Method aMethod)
+ {
+ for (Iterator iter = mVisitors.iterator(); iter.hasNext();) {
+ IDeepVisitor visitor = (IDeepVisitor) iter.next();
+ Visitor v = visitor.getClassFileVisitor();
+ aMethod.accept(v);
+ }
+ }
+}
diff --git a/thirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/checks/AbstractReferenceCheck.java b/thirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/checks/AbstractReferenceCheck.java
new file mode 100755
index 000000000..723a8356d
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/checks/AbstractReferenceCheck.java
@@ -0,0 +1,150 @@
+//Tested with BCEL-5.1
+//http://jakarta.apache.org/builds/jakarta-bcel/release/v5.1/
+
+package com.puppycrawl.tools.checkstyle.bcel.checks;
+
+import org.apache.bcel.classfile.FieldOrMethod;
+import org.apache.bcel.classfile.JavaClass;
+import org.apache.commons.beanutils.ConversionException;
+import java.util.regex.Pattern;
+import java.util.regex.PatternSyntaxException;
+
+import com.puppycrawl.tools.checkstyle.api.Scope;
+import com.puppycrawl.tools.checkstyle.api.Utils;
+import com.puppycrawl.tools.checkstyle.bcel.AbstractCheckVisitor;
+import com.puppycrawl.tools.checkstyle.bcel.IDeepVisitor;
+import com.puppycrawl.tools.checkstyle.bcel.ReferenceVisitor;
+import com.puppycrawl.tools.checkstyle.bcel.classfile.JavaClassDefinition;
+import com.puppycrawl.tools.checkstyle.bcel.classfile.ReferenceDAO;
+
+/**
+ * Abstract class for checks that require reference information.
+ * @author Rick Giles
+ */
+public abstract class AbstractReferenceCheck
+ extends AbstractCheckVisitor
+{
+ /** the scope for recorded references */
+ private Scope mScope = Scope.PRIVATE;
+
+ /** the regexp to match class names against */
+ private Pattern mIgnoreClassNameRegexp;
+
+ /** the regexp to match names against */
+ private Pattern mIgnoreNameRegexp;
+
+ /**
+ * Creates a <code>AbstractReferenceCheck</code>.
+ *
+ */
+ public AbstractReferenceCheck()
+ {
+ setIgnoreClassName("^$");
+ setIgnoreName("^$");
+ }
+
+ /**
+ * Sets the scope for recorded references.
+ * @param aScopeName the scope for recorded references.
+ */
+ public void setScope(String aScopeName)
+ {
+ mScope = Scope.getInstance(aScopeName);
+ }
+
+ /**
+ * Determines whether a class name, and field or method should be ignored.
+ * @param aClassName the class name to consider.
+ * @param aFieldOrMethod the field or method to consider.
+ * @return true if aClassName, and field or method should be ignored.
+ */
+ protected boolean ignore(String aClassName, FieldOrMethod aFieldOrMethod)
+ {
+ final String fieldOrMethodName = aFieldOrMethod.getName();
+ return (!equalScope(aFieldOrMethod)
+ || mIgnoreClassNameRegexp.matcher(aClassName).matches()
+ || mIgnoreNameRegexp.matcher(fieldOrMethodName).matches());
+ }
+
+ /**
+ * Tests whether the scope of a field or method is compatible
+ * with the scope of this check. References for compatible
+ * fields or methods should be checked.
+ * @param aFieldOrMethod the field or method to check.
+ * @return true if the scope of aFieldOrMethod is compatible
+ * with the scope of this check.
+ */
+ private boolean equalScope(FieldOrMethod aFieldOrMethod)
+ {
+ if (aFieldOrMethod.isPrivate()) {
+ return (mScope == Scope.PRIVATE);
+ }
+ else if (aFieldOrMethod.isProtected()) {
+ return (mScope == Scope.PROTECTED);
+ }
+ else if (aFieldOrMethod.isPublic()) {
+ return (mScope == Scope.PUBLIC);
+ }
+ else {
+ return (mScope == Scope.PACKAGE);
+ }
+ }
+
+
+ /**
+ * Set the ignore class name to the specified regular expression.
+ * @param aFormat a <code>String</code> value
+ * @throws ConversionException unable to parse aFormat
+ */
+ public void setIgnoreClassName(String aFormat)
+ throws ConversionException
+ {
+ try {
+ mIgnoreClassNameRegexp = Utils.getPattern(aFormat);
+ }
+ catch (PatternSyntaxException e) {
+ throw new ConversionException("unable to parse " + aFormat, e);
+ }
+ }
+
+ /**
+ * Set the ignore name format to the specified regular expression.
+ * @param aFormat a <code>String</code> value
+ * @throws ConversionException unable to parse aFormat
+ */
+ public void setIgnoreName(String aFormat)
+ throws ConversionException
+ {
+ try {
+ mIgnoreNameRegexp = Utils.getPattern(aFormat);
+ }
+ catch (PatternSyntaxException e) {
+ throw new ConversionException("unable to parse " + aFormat, e);
+ }
+ }
+
+ /** @see com.puppycrawl.tools.checkstyle.bcel.AbstractCheckVisitor */
+ public IDeepVisitor getVisitor()
+ {
+ return ReferenceVisitor.getInstance();
+ }
+
+ /**
+ * Gets the DAO that manages references for this check.
+ * @return the the DAO that manages references for this check.
+ */
+ public ReferenceDAO getReferenceDAO()
+ {
+ return ((ReferenceVisitor) getVisitor()).getReferenceDAO();
+ }
+
+ /**
+ * Finds a JavaClassDefinition for a JavaClass.
+ * @param aJavaClass the JavaClass.
+ * @return the JavaClassDefinition for aJavaClass.
+ */
+ protected JavaClassDefinition findJavaClassDef(JavaClass aJavaClass)
+ {
+ return getReferenceDAO().findJavaClassDef(aJavaClass);
+ }
+}
diff --git a/thirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/checks/HiddenInheritedFieldCheck.java b/thirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/checks/HiddenInheritedFieldCheck.java
new file mode 100755
index 000000000..cd3d1615c
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/checks/HiddenInheritedFieldCheck.java
@@ -0,0 +1,64 @@
+//Tested with BCEL-5.1
+//http://jakarta.apache.org/builds/jakarta-bcel/release/v5.1/
+
+package com.puppycrawl.tools.checkstyle.bcel.checks;
+
+import org.apache.bcel.classfile.Field;
+import org.apache.bcel.classfile.JavaClass;
+import com.puppycrawl.tools.checkstyle.api.Scope;
+import com.puppycrawl.tools.checkstyle.bcel.ReferenceVisitor;
+
+/**
+ * Checks for fields that hide fields in superclasses
+ * @author Daniel Grenner
+ */
+public class HiddenInheritedFieldCheck
+ extends AbstractReferenceCheck
+{
+ /** @see AbstractReferenceCheck */
+ public void setScope(String aFrom)
+ {
+ super.setScope(aFrom);
+ ((ReferenceVisitor) getVisitor()).addFieldScope(
+ Scope.getInstance(aFrom));
+ }
+
+ /** @see com.puppycrawl.tools.checkstyle.bcel.IObjectSetVisitor */
+ public void visitObject(Object aJavaClass)
+ {
+ final JavaClass javaClass = (JavaClass) aJavaClass;
+ final String className = javaClass.getClassName();
+ final JavaClass[] superClasses = javaClass.getSuperClasses();
+ final Field[] fields = javaClass.getFields();
+ // Check all fields
+ for (int i = 0; i < fields.length; i++) {
+ final Field field = fields[i];
+ // Go through all superclasses
+ for (int j = 0; j < superClasses.length; j++) {
+ final JavaClass superClass = superClasses[j];
+ final String superClassName = superClass.getClassName();
+ final Field[] superClassFields = superClass.getFields();
+ // Go through the filds of the superclasses
+ for (int k = 0; k < superClassFields.length; k++) {
+ final Field superClassField = superClassFields[k];
+ if (!superClassField.isPrivate() &&
+ superClassField.getName().equals(field.getName()) &&
+ !ignore(className, field)) {
+ log(
+ javaClass,
+ 0,
+ "hidden.inherited.field",
+ new Object[] {fields[i], superClassName});
+ }
+ }
+ }
+ }
+ }
+
+ /** @see AbstractReferenceCheck */
+ public boolean ignore(String aClassName, Field aField) {
+ final String fieldName = aField.toString();
+ return (/*super.ignore(aClassName, aField)
+ || */fieldName.indexOf("[Synthetic]") > -1);
+ }
+}
diff --git a/thirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/checks/HiddenStaticMethodCheck.java b/thirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/checks/HiddenStaticMethodCheck.java
new file mode 100755
index 000000000..37b8ec412
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/checks/HiddenStaticMethodCheck.java
@@ -0,0 +1,88 @@
+//Tested with BCEL-5.1
+//http://jakarta.apache.org/builds/jakarta-bcel/release/v5.1/
+
+package com.puppycrawl.tools.checkstyle.bcel.checks;
+
+import java.util.Iterator;
+import java.util.Set;
+
+import org.apache.bcel.classfile.JavaClass;
+import org.apache.bcel.classfile.Method;
+import org.apache.bcel.generic.Type;
+import com.puppycrawl.tools.checkstyle.api.Scope;
+import com.puppycrawl.tools.checkstyle.bcel.ReferenceVisitor;
+
+/**
+ * Checks for fields that hide fields in superclasses
+ * @author Daniel Grenner
+ */
+public class HiddenStaticMethodCheck
+ extends AbstractReferenceCheck
+{
+ /** @see AbstractReferenceCheck */
+ public void setScope(String aFrom)
+ {
+ super.setScope(aFrom);
+ ((ReferenceVisitor) getVisitor()).addFieldScope(
+ Scope.getInstance(aFrom));
+ }
+
+ /** @see com.puppycrawl.tools.checkstyle.bcel.IObjectSetVisitor */
+ public void visitObject(Object aJavaClass)
+ {
+ final JavaClass javaClass = (JavaClass) aJavaClass;
+ final String className = javaClass.getClassName();
+ final JavaClass[] superClasses = javaClass.getSuperClasses();
+ final Method[] methods = javaClass.getMethods();
+ // Check all methods
+ for (int i = 0; i < methods.length; i++) {
+ final Method method = methods[i];
+ // Check that the method is a possible match
+ if (!method.isPrivate() && method.isStatic()) {
+ // Go through all their superclasses
+ for (int j = 0; j < superClasses.length; j++) {
+ final JavaClass superClass = superClasses[j];
+ final String superClassName = superClass.getClassName();
+ final Method[] superClassMethods = superClass.getMethods();
+ // Go through the methods of the superclasses
+ for (int k = 0; k < superClassMethods.length; k++) {
+ final Method superClassMethod = superClassMethods[k];
+ if (superClassMethod.getName().equals(method.getName()) &&
+ !ignore(className, method)) {
+ Type[] methodTypes = method.getArgumentTypes();
+ Type[] superTypes = superClassMethod.
+ getArgumentTypes();
+ if (methodTypes.length == superTypes.length) {
+ boolean match = true;
+ for (int arg = 0; arg < methodTypes.length; arg++) {
+ if (!methodTypes[arg].equals(superTypes[arg])) {
+ match = false;
+ }
+ }
+ // Same method parameters
+ if (match) {
+ log(
+ javaClass,
+ 0,
+ "hidden.static.method",
+ new Object[] {method, superClassName});
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ /** @see AbstractReferenceCheck */
+ public boolean ignore(String aClassName, Method aMethod) {
+ final String methodName = aMethod.getName();
+ return (/*super.ignore(aClassName, aMethod)
+ || */methodName.equals("<init>")
+ || methodName.equals("<clinit>")
+ || methodName.equals("class$")
+ || aMethod.toString().indexOf("[Synthetic]") > -1);
+ }
+
+}
diff --git a/thirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/checks/UnreadFieldCheck.java b/thirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/checks/UnreadFieldCheck.java
new file mode 100755
index 000000000..0ef64bc6e
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/checks/UnreadFieldCheck.java
@@ -0,0 +1,58 @@
+//Tested with BCEL-5.1
+//http://jakarta.apache.org/builds/jakarta-bcel/release/v5.1/
+
+package com.puppycrawl.tools.checkstyle.bcel.checks;
+
+import java.util.Iterator;
+import java.util.Set;
+
+import org.apache.bcel.classfile.Field;
+import org.apache.bcel.classfile.JavaClass;
+
+import com.puppycrawl.tools.checkstyle.api.Scope;
+import com.puppycrawl.tools.checkstyle.bcel.ReferenceVisitor;
+import com.puppycrawl.tools.checkstyle.bcel.classfile.FieldDefinition;
+import com.puppycrawl.tools.checkstyle.bcel.classfile.JavaClassDefinition;
+
+/**
+ * Checks for unread, non-final fields
+ * @author Rick Giles
+ */
+public class UnreadFieldCheck
+ extends AbstractReferenceCheck
+{
+ /** @see AbstractReferenceCheck */
+ public void setScope(String aFrom)
+ {
+ super.setScope(aFrom);
+ ((ReferenceVisitor) getVisitor()).addFieldScope(
+ Scope.getInstance(aFrom));
+ }
+
+ /** @see com.puppycrawl.tools.checkstyle.bcel.IObjectSetVisitor */
+ public void leaveSet(Set aJavaClasses)
+ {
+ final Iterator it = aJavaClasses.iterator();
+ while (it.hasNext()) {
+ final JavaClass javaClass = (JavaClass) it.next();
+ final String className = javaClass.getClassName();
+ final JavaClassDefinition classDef = findJavaClassDef(javaClass);
+ final FieldDefinition[] fieldDefs = classDef.getFieldDefs();
+ for (int i = 0; i < fieldDefs.length; i++) {
+ if (fieldDefs[i].getReadReferenceCount() == 0) {
+ final Field field = fieldDefs[i].getField();
+ if (!field.isFinal()
+ && (!ignore(className, field))
+ )
+ {
+ log(
+ javaClass,
+ 0,
+ "unread.field",
+ new Object[] {fieldDefs[i]});
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/thirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/checks/UnreadVariableCheck.java b/thirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/checks/UnreadVariableCheck.java
new file mode 100755
index 000000000..2ba3ca01d
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/checks/UnreadVariableCheck.java
@@ -0,0 +1,130 @@
+package com.puppycrawl.tools.checkstyle.bcel.checks;
+
+import java.io.File;
+import java.util.BitSet;
+import java.util.Set;
+
+import org.apache.bcel.classfile.Code;
+import org.apache.bcel.classfile.JavaClass;
+import org.apache.bcel.classfile.LocalVariable;
+import org.apache.bcel.classfile.LocalVariableTable;
+import org.apache.bcel.classfile.Method;
+import org.apache.bcel.generic.LoadInstruction;
+
+import com.puppycrawl.tools.checkstyle.bcel.AbstractCheckVisitor;
+import com.puppycrawl.tools.checkstyle.bcel.EmptyClassFileVisitor;
+import com.puppycrawl.tools.checkstyle.bcel.EmptyDeepVisitor;
+import com.puppycrawl.tools.checkstyle.bcel.EmptyGenericVisitor;
+import com.puppycrawl.tools.checkstyle.bcel.IDeepVisitor;
+
+/**
+ * Checks for unread variables, i.e. unread formal parameters and local
+ * variables.
+ * Each class file must have a LocalVariableTable.
+ * To generate a LocalVariableTable, compile with debug information,
+ * as with option -g.
+ * @author Rick Giles
+ */
+public class UnreadVariableCheck
+ extends AbstractCheckVisitor
+{
+ private final DeepVisitor mDeepVisitor = new DeepVisitor();
+
+ private final org.apache.bcel.classfile.Visitor mClassFileVisitor =
+ new ClassFileVisitor();
+
+ private final org.apache.bcel.generic.Visitor mGenericVisitor =
+ new GenericVisitor();
+
+ private JavaClass mCurrentJavaClass = null;
+
+ private Method mCurrentMethod = null;
+
+ private LocalVariableTable mLocalVariableTable = null;
+
+ private final BitSet mLocalVariableBitSet = new BitSet();
+
+ private class DeepVisitor
+ extends EmptyDeepVisitor
+ {
+ public org.apache.bcel.classfile.Visitor getClassFileVisitor()
+ {
+ return mClassFileVisitor;
+ }
+
+ public org.apache.bcel.generic.Visitor getGenericVisitor()
+ {
+ return mGenericVisitor;
+ }
+
+ public void visitObject(Object aObj)
+ {
+ mCurrentJavaClass = (JavaClass) aObj;
+ }
+
+ public void leaveSet(Set aSet)
+ {
+ checkReferences();
+ }
+ }
+
+ private class GenericVisitor
+ extends EmptyGenericVisitor
+ {
+ public void visitLoadInstruction(LoadInstruction aInstruction)
+ {
+ mLocalVariableBitSet.set(aInstruction.getIndex());
+ }
+ }
+
+ private class ClassFileVisitor
+ extends EmptyClassFileVisitor
+ {
+ public void visitMethod(Method aMethod)
+ {
+
+// check references from previous method
+ checkReferences();
+ mCurrentMethod = aMethod;
+ // update reference recording
+
+ mLocalVariableTable = aMethod.getLocalVariableTable();
+ mLocalVariableBitSet.clear();
+ }
+
+ public void visitLocalVariableTable(LocalVariableTable aTable)
+ {
+
+
+ }
+ }
+
+ private void checkReferences()
+ {
+ if (mLocalVariableTable != null) {
+ for (int i = 0; i < mLocalVariableTable.getLength(); i++) {
+ if (!mLocalVariableBitSet.get(i)) {
+ final LocalVariable localVariable =
+ mLocalVariableTable.getLocalVariable(i);
+ if (localVariable != null
+ && !localVariable.getName().equals("this"))
+ {
+ log(0,
+ "unread.variable",
+ new Object[] {
+ mCurrentJavaClass.getClassName(),
+ mCurrentMethod.getName(),
+ localVariable.getName(),});
+ }
+ }
+ }
+ }
+ }
+
+
+ /** @see com.puppycrawl.tools.checkstyle.bcel.AbstractCheckVisitor */
+ public IDeepVisitor getVisitor()
+ {
+ return mDeepVisitor;
+ }
+}
diff --git a/thirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/checks/UnusedMethodCheck.java b/thirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/checks/UnusedMethodCheck.java
new file mode 100755
index 000000000..8f047d5ea
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/checks/UnusedMethodCheck.java
@@ -0,0 +1,64 @@
+//Tested with BCEL-5.1
+//http://jakarta.apache.org/builds/jakarta-bcel/release/v5.1/
+
+package com.puppycrawl.tools.checkstyle.bcel.checks;
+
+import java.util.Iterator;
+import java.util.Set;
+
+import org.apache.bcel.classfile.JavaClass;
+import org.apache.bcel.classfile.Method;
+
+import com.puppycrawl.tools.checkstyle.api.Scope;
+import com.puppycrawl.tools.checkstyle.bcel.ReferenceVisitor;
+import com.puppycrawl.tools.checkstyle.bcel.classfile.JavaClassDefinition;
+import com.puppycrawl.tools.checkstyle.bcel.classfile.MethodDefinition;
+
+/**
+ * Checks for unused methods
+ * @author Rick Giles
+ */
+public class UnusedMethodCheck
+ extends AbstractReferenceCheck
+{
+ /** @see AbstractReferenceCheck */
+ public void setScope(String aScopeName)
+ {
+ super.setScope(aScopeName);
+ ((ReferenceVisitor) getVisitor()).addMethodScope(
+ Scope.getInstance(aScopeName));
+ }
+
+ /** @see com.puppycrawl.tools.checkstyle.bcel.IObjectSetVisitor */
+ public void leaveSet(Set aJavaClasses)
+ {
+ final Iterator it = aJavaClasses.iterator();
+ while (it.hasNext()) {
+ final JavaClass javaClass = (JavaClass) it.next();
+ final String className = javaClass.getClassName();
+ final JavaClassDefinition classDef = findJavaClassDef(javaClass);
+ final MethodDefinition[] methodDefs = classDef.getMethodDefs();
+ for (int i = 0; i < methodDefs.length; i++) {
+ if (!classDef.hasReference(methodDefs[i], getReferenceDAO())) {
+ final Method method = methodDefs[i].getMethod();
+ if (!ignore(className, method)) {
+ log(
+ javaClass,
+ 0,
+ "unused.method",
+ new Object[] {methodDefs[i]});
+ }
+ }
+ }
+ }
+ }
+
+ /** @see AbstractReferenceCheck */
+ public boolean ignore(String aClassName, Method aMethod)
+ {
+ final String methodName = aMethod.getName();
+ return (super.ignore(aClassName, aMethod)
+ || methodName.equals("<init>")
+ || methodName.equals("<clinit>"));
+ }
+}
diff --git a/thirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/checks/messages.properties b/thirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/checks/messages.properties
new file mode 100755
index 000000000..88bb0b40a
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/checks/messages.properties
@@ -0,0 +1,5 @@
+unread.field=Unread field ''{0}''.
+unused.method=Unused method ''{0}''.
+hidden.inherited.field=Field ''{0}'' hides field in class ''{1}''.
+hidden.static.method=Static method ''{0}'' hides method in class ''{1}''.
+unread.variable=Class ''{0}'', method ''{1}'', unread variable ''{2}''. \ No newline at end of file
diff --git a/thirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/classfile/FieldDefinition.java b/thirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/classfile/FieldDefinition.java
new file mode 100755
index 000000000..795a63627
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/classfile/FieldDefinition.java
@@ -0,0 +1,89 @@
+//Tested with BCEL-5.1
+//http://jakarta.apache.org/builds/jakarta-bcel/release/v5.1/
+
+package com.puppycrawl.tools.checkstyle.bcel.classfile;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.bcel.classfile.Field;
+
+import com.puppycrawl.tools.checkstyle.bcel.generic.FieldReference;
+import com.puppycrawl.tools.checkstyle.bcel.generic.PUTFIELDReference;
+import com.puppycrawl.tools.checkstyle.bcel.generic.PUTSTATICReference;
+
+/**
+ * Contains the definition of a Field and its references.
+ * @author Rick Giles
+ */
+public class FieldDefinition
+ extends FieldOrMethodDefinition
+{
+ /** the GET references for the Field */
+ private final Set mGetReferences = new HashSet();
+
+ /** the PUT references for the FSield */
+ private final Set mPutReferences = new HashSet();
+
+ /**
+ * Creates a <code>FieldDefinition</code> for a Field.
+ * @param aField the Field.
+ */
+ public FieldDefinition(Field aField)
+ {
+ super(aField);
+ }
+
+ /**
+ * Returns the Field for this definition.
+ * @return the Field for this definition.
+ */
+ public Field getField()
+ {
+ return (Field) getFieldOrMethod();
+ }
+
+ /**
+ * Determines the number of read, or GET, references to the Field.
+ * @return the number of read references to the Field.
+ */
+ public int getReadReferenceCount()
+ {
+ return mGetReferences.size();
+ }
+
+ /**
+ * Determines the number of write, or PUT, references to the Field.
+ * @return the number of write references to the Field.
+ */
+ public int getWriteReferenceCount()
+ {
+ return mPutReferences.size();
+ }
+
+ /**
+ * Determines the total number of references to the Field.
+ * @return the number of references to the Field.
+ */
+ public int getReferenceCount()
+ {
+ return getReadReferenceCount() + getWriteReferenceCount();
+ }
+
+ /**
+ * Adds a reference to the Field.
+ * @param aFieldRef the reference.
+ */
+ public void addReference(FieldReference aFieldRef)
+ {
+ // TODO Polymorphize
+ if ((aFieldRef instanceof PUTFIELDReference)
+ || (aFieldRef instanceof PUTSTATICReference))
+ {
+ mPutReferences.add(aFieldRef);
+ }
+ else {
+ mGetReferences.add(aFieldRef);
+ }
+ }
+}
diff --git a/thirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/classfile/FieldOrMethodDefinition.java b/thirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/classfile/FieldOrMethodDefinition.java
new file mode 100755
index 000000000..d5398010e
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/classfile/FieldOrMethodDefinition.java
@@ -0,0 +1,50 @@
+//Tested with BCEL-5.1
+//http://jakarta.apache.org/builds/jakarta-bcel/release/v5.1/
+
+package com.puppycrawl.tools.checkstyle.bcel.classfile;
+
+import org.apache.bcel.classfile.FieldOrMethod;
+
+/**
+ * Contains the definition of a Field or a Method.
+ * @author Rick Giles
+ */
+public class FieldOrMethodDefinition
+{
+ /** the Field or Method */
+ private FieldOrMethod mFieldOrMethod;
+
+ /**
+ * Constructs a <code>FieldOrMethodDefinition</code> for a Field
+ * or a Method.
+ * @param aFieldOrMethod the Field or Method
+ */
+ protected FieldOrMethodDefinition(FieldOrMethod aFieldOrMethod)
+ {
+ mFieldOrMethod = aFieldOrMethod;
+ }
+
+ /**
+ * Returns the FieldOrMethod.
+ * @return the FieldOrMethod.
+ */
+ protected FieldOrMethod getFieldOrMethod()
+ {
+ return mFieldOrMethod;
+ }
+
+ /**
+ * Returns the name of the Field or Method.
+ * @return the name of the Field or Method.
+ */
+ public String getName()
+ {
+ return mFieldOrMethod.getName();
+ }
+
+ /** @see java.lang.Object#toString() */
+ public String toString()
+ {
+ return mFieldOrMethod.toString();
+ }
+}
diff --git a/thirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/classfile/JavaClassDefinition.java b/thirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/classfile/JavaClassDefinition.java
new file mode 100755
index 000000000..031b58fe5
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/classfile/JavaClassDefinition.java
@@ -0,0 +1,188 @@
+//Tested with BCEL-5.1
+//http://jakarta.apache.org/builds/jakarta-bcel/release/v5.1/
+
+package com.puppycrawl.tools.checkstyle.bcel.classfile;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.bcel.Repository;
+import org.apache.bcel.classfile.Field;
+import org.apache.bcel.classfile.JavaClass;
+import org.apache.bcel.classfile.Method;
+import org.apache.bcel.generic.Type;
+
+
+/**
+ * Contains the definition of a org.apache.bcel.classfile.JavaClass and
+ * the definitions of Methods and Fields of the JavaClass
+ * @author Rick Giles
+ */
+public class JavaClassDefinition
+{
+ /** the JavaClass */
+ private JavaClass mJavaClass;
+
+ /** the method definitions */
+ private MethodDefinition[] mMethodDefs;
+
+ /** field definitions, keyed on field name */
+ private Map mFieldDefs;
+
+ /**
+ * Creates a JavaClassDefinition from a JavaClass. The fields and
+ * methods of the JavaClassDefinition are those whose scopes are
+ * in restricted sets of Scopes.
+ * @param aJavaClass the JavaClass for the definition.
+ * @param aFieldScopes the restricted set of field scopes.
+ * @param aMethodScopes the restriced set of method scopes.
+ */
+ public JavaClassDefinition(
+ JavaClass aJavaClass,
+ Set aFieldScopes,
+ Set aMethodScopes)
+ {
+ mJavaClass = aJavaClass;
+
+ // create method definitions, restricted by scope
+ final Method[] methods = aJavaClass.getMethods();
+ final Set methodSet = new HashSet();
+ mMethodDefs = new MethodDefinition[methods.length];
+ for (int i = 0; i < methods.length; i++) {
+ if (Utils.inScope(methods[i], aMethodScopes)) {
+ methodSet.add(new MethodDefinition(methods[i]));
+ }
+ }
+ mMethodDefs =
+ (MethodDefinition[]) methodSet.toArray(
+ new MethodDefinition[methodSet.size()]);
+
+ // create field definitions, restricted by scope
+ final Field[] fields = aJavaClass.getFields();
+ mFieldDefs = new HashMap(fields.length);
+ for (int i = 0; i < fields.length; i++) {
+ if (Utils.inScope(fields[i], aFieldScopes)) {
+ mFieldDefs.put(
+ fields[i].getName(),
+ new FieldDefinition(fields[i]));
+ }
+ }
+ }
+
+ /**
+ * Gets the JavaClass for this definition.
+ * @return the JavaClass
+ */
+ public JavaClass getJavaClass()
+ {
+ return mJavaClass;
+ }
+
+ /**
+ * Gets the method definitions for Methods of the JavaClass.
+ * @return the method definitions for Methods of the JavaClass.
+ */
+ public MethodDefinition[] getMethodDefs()
+ {
+ return mMethodDefs;
+ }
+
+ /**
+ * Gets the field definitions for Fields of the JavaClass.
+ * @return the method definitions for Fields of the JavaClass.
+ */
+ public FieldDefinition[] getFieldDefs()
+ {
+ return (FieldDefinition[]) mFieldDefs.values().toArray(
+ new FieldDefinition[mFieldDefs.size()]);
+ }
+
+ /**
+ * Finds the narrowest method that is compatible with a method.
+ * An invocation of the given method can be resolved as an invocation
+ * of the narrowest method.
+ * @param aClassName the class for the method.
+ * @param aMethodName the name of the method.
+ * @param aArgTypes the types for the method.
+ * @return the narrowest compatible method.
+ */
+ public MethodDefinition findNarrowestMethod(
+ String aClassName,
+ String aMethodName,
+ Type[] aArgTypes)
+ {
+ MethodDefinition result = null;
+ final String javaClassName = mJavaClass.getClassName();
+ if (Repository.instanceOf(aClassName, javaClassName)) {
+ // check all
+ for (int i = 0; i < mMethodDefs.length; i++) {
+ // TODO: check access privileges
+ if (mMethodDefs[i].isCompatible(aMethodName, aArgTypes)) {
+ if (result == null) {
+ result = mMethodDefs[i];
+ }
+ //else if (mMethodDefs[i].isAsNarrow(result)) {
+ else if (result.isCompatible(mMethodDefs[i])) {
+ result = mMethodDefs[i];
+ }
+ }
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Finds a field definition.
+ * @param aFieldName the name of the field.
+ * @return the field definition named aFieldName.
+ */
+ public FieldDefinition findFieldDef(String aFieldName)
+ {
+ return (FieldDefinition) mFieldDefs.get(aFieldName);
+ }
+
+ /**
+ * Determines whether there is reference to a given Method in this JavaClass
+ * definition or a definition in a superclass.
+ * @param aMethodDef the Method to check.
+ * @param aReferenceDAO reference DAO.
+ * @return true if there is a reference to the method of aMethodDef in
+ * this JavaClass or a superclass.
+ */
+ public boolean hasReference(
+ MethodDefinition aMethodDef,
+ ReferenceDAO aReferenceDAO)
+ {
+ final String methodName = aMethodDef.getName();
+ final Type[] argTypes = aMethodDef.getArgumentTypes();
+
+ // search the inheritance hierarchy
+ JavaClass currentJavaClass = getJavaClass();
+ while (currentJavaClass != null) {
+ final JavaClassDefinition javaClassDef =
+ aReferenceDAO.findJavaClassDef(currentJavaClass);
+ if (javaClassDef != null) {
+ final MethodDefinition methodDef =
+ javaClassDef.findNarrowestMethod(
+ getJavaClass().getClassName(),
+ methodName,
+ argTypes);
+ if ((methodDef != null)
+ && (methodDef.hasReference(getJavaClass())))
+ {
+ return true;
+ }
+ }
+ currentJavaClass = currentJavaClass.getSuperClass();
+ }
+ return false;
+ }
+
+ /** @see java.lang.Object#toString() */
+ public String toString()
+ {
+ return getJavaClass().toString();
+ }
+}
diff --git a/thirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/classfile/MethodDefinition.java b/thirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/classfile/MethodDefinition.java
new file mode 100755
index 000000000..e2378be1b
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/classfile/MethodDefinition.java
@@ -0,0 +1,175 @@
+//Tested with BCEL-5.1
+//http://jakarta.apache.org/builds/jakarta-bcel/release/v5.1/
+
+package com.puppycrawl.tools.checkstyle.bcel.classfile;
+
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+import org.apache.bcel.Repository;
+import org.apache.bcel.classfile.JavaClass;
+import org.apache.bcel.classfile.Method;
+import org.apache.bcel.generic.Type;
+
+import com.puppycrawl.tools.checkstyle.bcel.generic.InvokeReference;
+import com.puppycrawl.tools.checkstyle.bcel.generic.Utils;
+
+/**
+ * Contains the definition of a Method and its references.
+ * @author Rick Giles
+ */
+public class MethodDefinition
+ extends FieldOrMethodDefinition
+{
+ /** the references to the Method */
+ private Set mReferences = new HashSet();
+
+ /**
+ * Creates a <code>MethodDefinition</code> for a Method.
+ * @param aMethod the Method.
+ */
+ public MethodDefinition(Method aMethod)
+ {
+ super(aMethod);
+ }
+
+ /**
+ * Gets the references to the Method.
+ * @return the references to the Method.
+ */
+ public Set getReferences()
+ {
+ return mReferences;
+ }
+
+ /**
+ * Determines the number of references to the Method.
+ * @return the number of references to the Method.
+ */
+ public int getReferenceCount()
+ {
+ return mReferences.size();
+ }
+
+ /**
+ * Returns the Method for this definition.
+ * @return the Method for this definition.
+ */
+ public Method getMethod()
+ {
+ return (Method) getFieldOrMethod();
+ }
+
+ /**
+ * Adds a reference to the Method.
+ * @param aRef the reference.
+ */
+
+ public void addReference(InvokeReference aRef)
+ {
+ mReferences.add(aRef);
+ }
+
+ /**
+ * Gets the Types of the Method's arguments.
+ * @return the argument Types.
+ */
+ public Type[] getArgumentTypes()
+ {
+ return getMethod().getArgumentTypes();
+ }
+
+ /**
+ * Determines whether a Method is compatible with the
+ * Method of this definition.
+ * @param aMethod the Method to check.
+ * @return true if aMethod is compatible with the Method
+ * of this definition.
+ */
+ public boolean isCompatible(Method aMethod)
+ {
+ return isCompatible(aMethod.getName(), aMethod.getArgumentTypes());
+ }
+
+ /**
+ * Determines whether a MethodDefinition is compatible with the
+ * Method of this definition.
+ * @param aMethodDef the Method definition to check.
+ * @return true if aMethod is compatible with the Method
+ * of this definition.
+ */
+ public boolean isCompatible(MethodDefinition aMethodDef)
+ {
+ return isCompatible(aMethodDef.getMethod());
+ }
+
+ /**
+ * Determines whether the Method of a MethodDefinition is as narrow
+ * as the method for this definition.
+ * Precondition: the method for this has the same name and the same
+ * number of arguments as the Method for the given MethodDefinition.
+ * @param aMethodDef the MethodDefinition to check.
+ * @return true if the Method of aMethodDef is as narrow
+ * as the method for this definition.
+ */
+ public boolean isAsNarrow(MethodDefinition aMethodDef)
+ {
+ return aMethodDef.isCompatible(this);
+// final Type[] types1 = getArgumentTypes();
+// final Type[] types2 = aMethodDef.getArgumentTypes();
+// for (int i = 0; i < types2.length; i++) {
+// if (!Utils.isCompatible(types1[i], types2[i])) {
+// return false;
+// }
+// }
+// return true;
+ }
+
+ /**
+ * Determines whether a method is compatible with the Method of
+ * this definition.
+ * @param aMethodName the name of the method to check.
+ * @param aArgTypes the method argument types.
+ * @return true if the method is compatible with the Method of
+ * this definition.
+ */
+ public boolean isCompatible(String aMethodName, Type[] aArgTypes)
+ {
+ // same name?
+ if (!getName().equals(aMethodName)) {
+ return false;
+ }
+ // compatible argument types?
+ final Type[] methodTypes = getArgumentTypes();
+ if (methodTypes.length != aArgTypes.length) {
+ return false;
+ }
+ for (int i = 0; i < aArgTypes.length; i++) {
+ if (!Utils.isCompatible(aArgTypes[i], methodTypes[i])) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Determine whether this method definition has a reference from a class or
+ * a superclass.
+ * @param aJavaClass the JavaClass to check against.
+ * @return true if there is a reference to this method definition from a
+ * aJavaClass or a superclass of aJavaClass.
+ */
+ public boolean hasReference(JavaClass aJavaClass)
+ {
+ final Iterator it = getReferences().iterator();
+ while (it.hasNext()) {
+ final InvokeReference invokeRef = (InvokeReference) it.next();
+ final String invokeClassName = invokeRef.getClassName();
+ if (Repository.instanceOf(aJavaClass, invokeClassName)) {
+ return true;
+ }
+ }
+ return false;
+ }
+}
diff --git a/thirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/classfile/ReferenceDAO.java b/thirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/classfile/ReferenceDAO.java
new file mode 100755
index 000000000..26329bb72
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/classfile/ReferenceDAO.java
@@ -0,0 +1,140 @@
+//Tested with BCEL-5.1
+//http://jakarta.apache.org/builds/jakarta-bcel/release/v5.1/
+
+package com.puppycrawl.tools.checkstyle.bcel.classfile;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.bcel.Repository;
+import org.apache.bcel.classfile.JavaClass;
+import org.apache.bcel.generic.Type;
+
+import com.puppycrawl.tools.checkstyle.bcel.generic.FieldReference;
+import com.puppycrawl.tools.checkstyle.bcel.generic.InvokeReference;
+
+/**
+ * Accesses Method and Field references for a set of JavaClasses.
+ * @author Rick Giles
+ */
+public class ReferenceDAO
+{
+ /**
+ * Creates a <code>ReferenceDAO</code> from a set of JavaClasses.
+ * @param aJavaClasses the set of JavaClasses for this DAO.
+ * @param aFieldScopes the scopes for field references.
+ * @param aMethodScopes the scopes for method references.
+ */
+ public ReferenceDAO(Set aJavaClasses, Set aFieldScopes, Set aMethodScopes)
+ {
+ mJavaClasses = new HashMap(aJavaClasses.size());
+ final Iterator it = aJavaClasses.iterator();
+ while (it.hasNext()) {
+ final JavaClass javaClass = (JavaClass) it.next();
+ final JavaClassDefinition javaClassDef =
+ new JavaClassDefinition(javaClass, aFieldScopes, aMethodScopes);
+ mJavaClasses.put(javaClass, javaClassDef);
+ }
+ }
+
+ /** maps a JavaClass to a JavaClassDefinition */
+ private Map mJavaClasses = null;
+
+ /**
+ * Finds the JavaClassDefinition for a given JavaClass.
+ * @param aJavaClass the JavaClass.
+ * @return the JavaClassDefinition keyed on aJavaClass.
+ */
+ public JavaClassDefinition findJavaClassDef(JavaClass aJavaClass)
+ {
+ return (JavaClassDefinition) mJavaClasses.get(aJavaClass);
+ }
+
+ /**
+ * Adds a reference for an invocation in the invoked method definition.
+ * The invocation is of the form class.method(args).
+ * @param aInvokeRef the invocation reference.
+ */
+ public void addInvokeReference(InvokeReference aInvokeRef)
+ {
+ // find the class for the instruction
+ final String className = aInvokeRef.getClassName();
+ JavaClass javaClass = Repository.lookupClass(className);
+ final String methodName = aInvokeRef.getName();
+ final Type[] argTypes = aInvokeRef.getArgTypes();
+
+ // search up the class hierarchy for the class containing the
+ // method definition.
+ MethodDefinition narrowest = null;
+ while ((javaClass != null) && (narrowest == null)) {
+ final JavaClassDefinition javaClassDef =
+ (JavaClassDefinition) mJavaClasses.get(javaClass);
+ if (javaClassDef != null) {
+ // find narrowest compatible in the current class
+ narrowest =
+ javaClassDef.findNarrowestMethod(
+ className,
+ methodName,
+ argTypes);
+ if (narrowest != null) {
+ narrowest.addReference(aInvokeRef);
+ }
+ }
+ // search the parent
+ javaClass = javaClass.getSuperClass();
+ }
+ }
+
+ /**
+ * Adds a reference to a field.
+ * @param aFieldRef the field reference.
+ */
+ public void addFieldReference(FieldReference aFieldRef)
+ {
+ final String className = aFieldRef.getClassName();
+ JavaClass javaClass = Repository.lookupClass(className);
+ final String fieldName = aFieldRef.getName();
+ // search up the class hierarchy for the class containing the
+ // method definition.
+ FieldDefinition fieldDef = null;
+ while ((javaClass != null) && (fieldDef == null)) {
+ final JavaClassDefinition javaClassDef =
+ (JavaClassDefinition) mJavaClasses.get(javaClass);
+ if (javaClassDef != null) {
+ fieldDef = javaClassDef.findFieldDef(fieldName);
+ if (fieldDef != null) {
+ fieldDef.addReference(aFieldRef);
+ }
+ }
+ //search the parent
+ javaClass = javaClass.getSuperClass();
+ }
+ }
+
+ /**
+ * Finds the definition of the field of a field reference.
+ * @param aFieldRef the reference to a field.
+ * @return the definition of the field for aFieldRef.
+ */
+ public FieldDefinition findFieldDef(FieldReference aFieldRef)
+ {
+ final String className = aFieldRef.getClassName();
+ JavaClass javaClass = Repository.lookupClass(className);
+ final String fieldName = aFieldRef.getName();
+ // search up the class hierarchy for the class containing the
+ // method definition.
+ FieldDefinition result = null;
+ while ((javaClass != null) && (result == null)) {
+ final JavaClassDefinition javaClassDef =
+ (JavaClassDefinition) mJavaClasses.get(javaClass);
+ if (javaClassDef != null) {
+ result = javaClassDef.findFieldDef(fieldName);
+ }
+ //search the parent
+ javaClass = javaClass.getSuperClass();
+ }
+ return result;
+ }
+}
diff --git a/thirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/classfile/Utils.java b/thirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/classfile/Utils.java
new file mode 100755
index 000000000..9ce6e0940
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/classfile/Utils.java
@@ -0,0 +1,39 @@
+package com.puppycrawl.tools.checkstyle.bcel.classfile;
+
+import java.util.Set;
+
+import org.apache.bcel.classfile.FieldOrMethod;
+
+import com.puppycrawl.tools.checkstyle.api.Scope;
+
+/**
+ * Utility methods for BCEL classfile package
+ * @author Rick Giles
+ */
+public class Utils
+{
+ /**
+ * Determines whether the declared scope of a field or method is in
+ * a set of scopes.
+ * @param aFieldOrMethod the field or method to test.
+ * @param aScopes the set of scopes to test against.
+ * @return true if the declared scope of aFieldOrMethod is in aScopes.
+ */
+ public static boolean inScope(FieldOrMethod aFieldOrMethod, Set aScopes)
+ {
+ if (aFieldOrMethod.isPrivate()) {
+ return (aScopes.contains(Scope.PRIVATE));
+ }
+ else if (aFieldOrMethod.isProtected()) {
+ return (aScopes.contains(Scope.PROTECTED));
+ }
+ else if (aFieldOrMethod.isPublic()) {
+ return (aScopes.contains(Scope.PUBLIC));
+ }
+ else {
+ return (aScopes.contains(Scope.PACKAGE));
+ }
+ }
+
+
+}
diff --git a/thirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/generic/FieldOrMethodReference.java b/thirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/generic/FieldOrMethodReference.java
new file mode 100755
index 000000000..f8e3734bd
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/generic/FieldOrMethodReference.java
@@ -0,0 +1,61 @@
+//Tested with BCEL-5.1
+//http://jakarta.apache.org/builds/jakarta-bcel/release/v5.1/
+
+package com.puppycrawl.tools.checkstyle.bcel.generic;
+
+import org.apache.bcel.generic.ConstantPoolGen;
+import org.apache.bcel.generic.FieldOrMethod;
+import org.apache.bcel.generic.ObjectType;
+
+/**
+ * Describe class InstructionReference
+ * @author Rick Giles
+ * @version 18-Jun-2003
+ */
+public class FieldOrMethodReference
+{
+ protected FieldOrMethod mInstruction;
+
+ protected ConstantPoolGen mPoolGen;
+
+ protected FieldOrMethodReference(
+ FieldOrMethod aInstruction,
+ ConstantPoolGen aPoolGen)
+ {
+ mInstruction = aInstruction;
+ mPoolGen = aPoolGen;
+ }
+
+ /**
+ * @return
+ */
+ public FieldOrMethod getInstruction()
+ {
+ return mInstruction;
+ }
+
+ public String getClassName()
+ {
+ return mInstruction.getClassName(mPoolGen);
+ }
+
+ public ObjectType getClassType()
+ {
+ return mInstruction.getClassType(mPoolGen);
+ }
+
+ public ObjectType getLoadClassType()
+ {
+ return mInstruction.getLoadClassType(mPoolGen);
+ }
+
+ public String getName()
+ {
+ return mInstruction.getName(mPoolGen);
+ }
+
+ public String toString()
+ {
+ return mInstruction.toString(mPoolGen.getConstantPool());
+ }
+}
diff --git a/thirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/generic/FieldReference.java b/thirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/generic/FieldReference.java
new file mode 100755
index 000000000..06d618fe1
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/generic/FieldReference.java
@@ -0,0 +1,22 @@
+//Tested with BCEL-5.1
+//http://jakarta.apache.org/builds/jakarta-bcel/release/v5.1/
+
+package com.puppycrawl.tools.checkstyle.bcel.generic;
+
+import org.apache.bcel.generic.ConstantPoolGen;
+import org.apache.bcel.generic.FieldInstruction;
+
+/**
+ * Describe class FieldReference
+ * @author Rick Giles
+ * @version 18-Jun-2003
+ */
+public class FieldReference extends FieldOrMethodReference
+{
+ protected FieldReference(
+ FieldInstruction aInstruction,
+ ConstantPoolGen aPoolGen)
+ {
+ super(aInstruction, aPoolGen);
+ }
+}
diff --git a/thirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/generic/GETFIELDReference.java b/thirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/generic/GETFIELDReference.java
new file mode 100755
index 000000000..bb8feac66
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/generic/GETFIELDReference.java
@@ -0,0 +1,28 @@
+//Tested with BCEL-5.1
+//http://jakarta.apache.org/builds/jakarta-bcel/release/v5.1/
+
+package com.puppycrawl.tools.checkstyle.bcel.generic;
+
+import org.apache.bcel.generic.ConstantPoolGen;
+import org.apache.bcel.generic.GETFIELD;
+
+/**
+ * Describe class GETFIELDReference
+ * @author Rick Giles
+ * @version 18-Jun-2003
+ */
+public class GETFIELDReference
+ extends FieldReference
+{
+
+ /**
+ * @param aInstruction
+ * @param aPoolGen
+ */
+ public GETFIELDReference(
+ GETFIELD aInstruction,
+ ConstantPoolGen aPoolGen)
+ {
+ super(aInstruction, aPoolGen);
+ }
+}
diff --git a/thirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/generic/GETSTATICReference.java b/thirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/generic/GETSTATICReference.java
new file mode 100755
index 000000000..9e9ed1b07
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/generic/GETSTATICReference.java
@@ -0,0 +1,28 @@
+//Tested with BCEL-5.1
+//http://jakarta.apache.org/builds/jakarta-bcel/release/v5.1/
+
+package com.puppycrawl.tools.checkstyle.bcel.generic;
+
+import org.apache.bcel.generic.ConstantPoolGen;
+import org.apache.bcel.generic.GETSTATIC;
+
+/**
+ * Describe class GETSTATICReference
+ * @author Rick Giles
+ * @version 18-Jun-2003
+ */
+public class GETSTATICReference
+ extends FieldReference
+{
+
+ /**
+ * @param aInstruction
+ * @param aPoolGen
+ */
+ public GETSTATICReference(
+ GETSTATIC aInstruction,
+ ConstantPoolGen aPoolGen)
+ {
+ super(aInstruction, aPoolGen);
+ }
+}
diff --git a/thirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/generic/InvokeReference.java b/thirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/generic/InvokeReference.java
new file mode 100755
index 000000000..7f444681d
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/generic/InvokeReference.java
@@ -0,0 +1,38 @@
+//Tested with BCEL-5.1
+//http://jakarta.apache.org/builds/jakarta-bcel/release/v5.1/
+
+package com.puppycrawl.tools.checkstyle.bcel.generic;
+
+import org.apache.bcel.generic.ConstantPoolGen;
+import org.apache.bcel.generic.InvokeInstruction;
+import org.apache.bcel.generic.Type;
+
+
+/**
+ * Describe class MethodReference
+ * @author Rick Giles
+ * @version 18-Jun-2003
+ */
+public class InvokeReference
+ extends FieldOrMethodReference
+{
+
+ /**
+ * @param aInstruction
+ * @param aPoolGen
+ */
+ public InvokeReference(
+ InvokeInstruction aInstruction,
+ ConstantPoolGen aPoolGen)
+ {
+ super(aInstruction, aPoolGen);
+ }
+
+ /**
+ * @return
+ */
+ public Type[] getArgTypes()
+ {
+ return ((InvokeInstruction) mInstruction).getArgumentTypes(mPoolGen);
+ }
+}
diff --git a/thirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/generic/PUTFIELDReference.java b/thirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/generic/PUTFIELDReference.java
new file mode 100755
index 000000000..a15a9a439
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/generic/PUTFIELDReference.java
@@ -0,0 +1,28 @@
+//Tested with BCEL-5.1
+//http://jakarta.apache.org/builds/jakarta-bcel/release/v5.1/
+
+package com.puppycrawl.tools.checkstyle.bcel.generic;
+
+import org.apache.bcel.generic.ConstantPoolGen;
+import org.apache.bcel.generic.PUTFIELD;
+
+/**
+ * Describe class GETFIELDReference
+ * @author Rick Giles
+ * @version 18-Jun-2003
+ */
+public class PUTFIELDReference
+ extends FieldReference
+{
+
+ /**
+ * @param aInstruction
+ * @param aPoolGen
+ */
+ public PUTFIELDReference(
+ PUTFIELD aInstruction,
+ ConstantPoolGen aPoolGen)
+ {
+ super(aInstruction, aPoolGen);
+ }
+}
diff --git a/thirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/generic/PUTSTATICReference.java b/thirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/generic/PUTSTATICReference.java
new file mode 100755
index 000000000..20f1b15f3
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/generic/PUTSTATICReference.java
@@ -0,0 +1,28 @@
+//Tested with BCEL-5.1
+//http://jakarta.apache.org/builds/jakarta-bcel/release/v5.1/
+
+package com.puppycrawl.tools.checkstyle.bcel.generic;
+
+import org.apache.bcel.generic.ConstantPoolGen;
+import org.apache.bcel.generic.PUTSTATIC;
+
+/**
+ * Describe class GETSTATICReference
+ * @author Rick Giles
+ * @version 18-Jun-2003
+ */
+public class PUTSTATICReference
+ extends FieldReference
+{
+
+ /**
+ * @param aInstruction
+ * @param aPoolGen
+ */
+ public PUTSTATICReference(
+ PUTSTATIC aInstruction,
+ ConstantPoolGen aPoolGen)
+ {
+ super(aInstruction, aPoolGen);
+ }
+}
diff --git a/thirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/generic/Utils.java b/thirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/generic/Utils.java
new file mode 100755
index 000000000..4fbfaf1a2
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/bcel/src/checkstyle/com/puppycrawl/tools/checkstyle/bcel/generic/Utils.java
@@ -0,0 +1,71 @@
+//Tested with BCEL-5.1
+//http://jakarta.apache.org/builds/jakarta-bcel/release/v5.1/
+
+package com.puppycrawl.tools.checkstyle.bcel.generic;
+
+import org.apache.bcel.generic.ReferenceType;
+import org.apache.bcel.generic.Type;
+
+/**
+ * Utility methods.
+ * @author Rick Giles
+ * @version 17-Jun-2003
+ */
+public class Utils
+{
+ /**
+ * Tests whether one type is compatible with another for method
+ * invocation conversion. This includes assignment conversion,
+ * except the implicit narrowing of integer constants.
+ * JLS Section 5.2
+ * @param aSubType the type to be converted.
+ * @param aSuperType the converted type.
+ * @return true if aSubType can be converted to aSuperType.
+ */
+ public static boolean isCompatible(Type aSubType, Type aSuperType)
+ {
+ boolean result = false;
+
+ if (aSubType.equals(aSuperType)) {
+ // identity conversion
+ result = true;
+ }
+ else if ((aSubType instanceof ReferenceType)
+ && (aSuperType instanceof ReferenceType))
+ {
+ // widening reference conversion?
+ final ReferenceType aSubRefType = (ReferenceType) aSubType;
+ result = aSubRefType.isAssignmentCompatibleWith(aSuperType);
+ }
+ // widening primitive conversion?
+ else if (aSubType.equals(Type.BYTE)) {
+ result =
+ aSuperType.equals(Type.SHORT)
+ || aSuperType.equals(Type.INT)
+ || aSuperType.equals(Type.LONG)
+ || aSuperType.equals(Type.FLOAT)
+ || aSuperType.equals(Type.DOUBLE);
+ }
+ else if (aSubType.equals(Type.SHORT)) {
+ result =
+ aSuperType.equals(Type.INT)
+ || aSuperType.equals(Type.LONG)
+ || aSuperType.equals(Type.FLOAT)
+ || aSuperType.equals(Type.DOUBLE);
+ }
+ else if (aSubType.equals(Type.INT)) {
+ result =
+ aSuperType.equals(Type.LONG)
+ || aSuperType.equals(Type.FLOAT)
+ || aSuperType.equals(Type.DOUBLE);
+ }
+ else if (aSubType.equals(Type.LONG)) {
+ result =
+ aSuperType.equals(Type.FLOAT) || aSuperType.equals(Type.DOUBLE);
+ }
+ else if (aSubType.equals(Type.DOUBLE)) {
+ result = aSuperType.equals(Type.DOUBLE);
+ }
+ return result;
+ }
+}
diff --git a/thirdparty/checkstyle/contrib/bcel/src/testinputs/com/puppycrawl/tools/checkstyle/bcel/checks/InheritLibrary.java b/thirdparty/checkstyle/contrib/bcel/src/testinputs/com/puppycrawl/tools/checkstyle/bcel/checks/InheritLibrary.java
new file mode 100755
index 000000000..8bf9a8cb3
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/bcel/src/testinputs/com/puppycrawl/tools/checkstyle/bcel/checks/InheritLibrary.java
@@ -0,0 +1,11 @@
+package com.puppycrawl.tools.checkstyle.bcel.checks;
+
+import org.apache.bcel.classfile.AccessFlags ;
+/**
+ * Test data for checking that fields with the same name as fields in
+ * superclasses work, when the superclass is inside an external library.
+ */
+public abstract class InheritLibrary extends AccessFlags
+{
+ protected int access_flags;
+}
diff --git a/thirdparty/checkstyle/contrib/bcel/src/testinputs/com/puppycrawl/tools/checkstyle/bcel/checks/SubClass.java b/thirdparty/checkstyle/contrib/bcel/src/testinputs/com/puppycrawl/tools/checkstyle/bcel/checks/SubClass.java
new file mode 100755
index 000000000..9d0a90eb9
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/bcel/src/testinputs/com/puppycrawl/tools/checkstyle/bcel/checks/SubClass.java
@@ -0,0 +1,54 @@
+package com.puppycrawl.tools.checkstyle.bcel.checks;
+
+public class SubClass extends SuperClass
+{
+ protected int reusedName;
+ private int subClassPrivate;
+ protected int superClassPrivate;
+ protected int differentType;
+ public static String S="S";
+ public static int staticMethod() {
+ return 1;
+ }
+ public int nonStaticMethod() {
+ return 1;
+ }
+ public static int staticMethodSameParamName(int i) {
+ return 1;
+ }
+ public static int staticMethodSameParamType(int x) {
+ return 1;
+ }
+ public static int staticMethodDifferentParamNum(int i) {
+ return 1;
+ }
+ public static int staticMethodDifferentParamType(String i) {
+ return 1;
+ }
+ public static int staticMethodDifferentObjectType(String i) {
+ return 1;
+ }
+ public static int staticMethodSuperParamType(String i) {
+ return 1;
+ }
+ public void callStaticMethodWithObject() {
+ SubClass s = new SubClass();
+ s.staticMethod();
+ }
+ public void callStaticMethodWithClass() {
+ SubClass.staticMethod();
+ }
+ public void callStaticMethodWithThis() {
+ this.staticMethod();
+ }
+ public String callStaticFieldWithObject() {
+ SubClass s = new SubClass();
+ return s.S;
+ }
+ public String callStaticFieldWithClass() {
+ return SubClass.S;
+ }
+ public String callStaticFieldWithThis() {
+ return this.S;
+ }
+}
diff --git a/thirdparty/checkstyle/contrib/bcel/src/testinputs/com/puppycrawl/tools/checkstyle/bcel/checks/SuperClass.java b/thirdparty/checkstyle/contrib/bcel/src/testinputs/com/puppycrawl/tools/checkstyle/bcel/checks/SuperClass.java
new file mode 100755
index 000000000..2108a0972
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/bcel/src/testinputs/com/puppycrawl/tools/checkstyle/bcel/checks/SuperClass.java
@@ -0,0 +1,46 @@
+package com.puppycrawl.tools.checkstyle.bcel.checks;
+
+public class SuperClass
+{
+ // Name reused in subclass
+ protected int reusedName;
+ // Subclass uses private name, still conflict
+ protected int subClassPrivate;
+ // This is a private field, subclass does not shadow
+ private int superClassPrivate;
+ // Test for different data types
+ protected String differentType;
+
+ // Hidden
+ public static int staticMethod() {
+ return 0;
+ }
+ // Not hidden
+ public int nonStaticMethod() {
+ return 0;
+ }
+ // Hidden
+ public static int staticMethodSameParamName(int i) {
+ return 0;
+ }
+ // Hidden
+ public static int staticMethodSameParamType(int i) {
+ return 0;
+ }
+ // Not hidden
+ public static int staticMethodDifferentParamNum(int i, int j) {
+ return 0;
+ }
+ // Not hidden
+ public static int staticMethodDifferentParamType(int i) {
+ return 0;
+ }
+ // Not hidden
+ public static int staticMethodDifferentObjectType(Integer i) {
+ return 0;
+ }
+ // Not hidden (?)
+ public static int staticMethodSuperParamType(Object i) {
+ return 0;
+ }
+}
diff --git a/thirdparty/checkstyle/contrib/bcel/src/tests/com/puppycrawl/tools/checkstyle/bcel/BcelCheckTestCase.java b/thirdparty/checkstyle/contrib/bcel/src/tests/com/puppycrawl/tools/checkstyle/bcel/BcelCheckTestCase.java
new file mode 100755
index 000000000..4a8d22486
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/bcel/src/tests/com/puppycrawl/tools/checkstyle/bcel/BcelCheckTestCase.java
@@ -0,0 +1,127 @@
+package com.puppycrawl.tools.checkstyle.bcel;
+
+import com.puppycrawl.tools.checkstyle.api.AuditEvent;
+import com.puppycrawl.tools.checkstyle.api.Configuration;
+import com.puppycrawl.tools.checkstyle.*;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.LineNumberReader;
+import java.io.OutputStream;
+import java.io.PrintStream;
+import java.util.Locale;
+import java.util.Properties;
+
+import junit.framework.TestCase;
+
+public abstract class BcelCheckTestCase
+ extends TestCase
+{
+ /** a brief logger that only display info about errors */
+ protected static class BriefLogger
+ extends DefaultLogger
+ {
+ public BriefLogger(OutputStream out)
+ {
+ super(out, true);
+ }
+ public void auditStarted(AuditEvent evt) {}
+ public void fileFinished(AuditEvent evt) {}
+ public void fileStarted(AuditEvent evt) {}
+ }
+
+ private final ByteArrayOutputStream mBAOS = new ByteArrayOutputStream();
+ protected final PrintStream mStream = new PrintStream(mBAOS);
+ protected final Properties mProps = new Properties();
+
+ public static DefaultConfiguration createCheckConfig(Class aClazz)
+ {
+ final DefaultConfiguration checkConfig =
+ new DefaultConfiguration(aClazz.getName());
+ return checkConfig;
+ }
+
+ protected Checker createChecker(Configuration aCheckConfig)
+ throws Exception
+ {
+ final DefaultConfiguration dc = createCheckerConfig(aCheckConfig);
+ final Checker c = new Checker();
+ // make sure the tests always run with english error messages
+ // so the tests don't fail in supported locales like german
+ final Locale locale = Locale.ENGLISH;
+ c.setLocaleCountry(locale.getCountry());
+ c.setLocaleLanguage(locale.getLanguage());
+ c.configure(dc);
+ c.addListener(new BriefLogger(mStream));
+ return c;
+ }
+
+ protected DefaultConfiguration createCheckerConfig(Configuration aConfig)
+ {
+ final DefaultConfiguration dc =
+ new DefaultConfiguration("configuration");
+ final DefaultConfiguration twConf = createCheckConfig(ClassFileSetCheck.class);
+ dc.addChild(twConf);
+ twConf.addChild(aConfig);
+ return dc;
+ }
+
+ protected static String getPath(String aFilename)
+ throws IOException
+ {
+ final File f = new File(System.getProperty("testinputs.compiled.dir"),
+ aFilename);
+ return f.getCanonicalPath();
+ }
+
+ protected void verify(Configuration aConfig, String aFileName, String[] aExpected)
+ throws Exception
+ {
+ verify(createChecker(aConfig), aFileName, aFileName, aExpected);
+ }
+
+ protected void verify(Checker aC, String aFileName, String[] aExpected)
+ throws Exception
+ {
+ verify(aC, aFileName, aFileName, aExpected);
+ }
+
+ protected void verify(Checker aC,
+ String aProcessedFilename,
+ String aMessageFileName,
+ String[] aExpected)
+ throws Exception
+ {
+ verify(aC,
+ new File[] {new File(aProcessedFilename)},
+ aMessageFileName, aExpected);
+ }
+
+ protected void verify(Checker aC,
+ File[] aProcessedFiles,
+ String aMessageFileName,
+ String[] aExpected)
+ throws Exception
+ {
+ mStream.flush();
+ final int errs = aC.process(aProcessedFiles);
+
+ // process each of the lines
+ final ByteArrayInputStream bais =
+ new ByteArrayInputStream(mBAOS.toByteArray());
+ final LineNumberReader lnr =
+ new LineNumberReader(new InputStreamReader(bais));
+
+ for (int i = 0; i < aExpected.length; i++) {
+ final String expected = aMessageFileName + ":" + aExpected[i];
+ final String actual = lnr.readLine();
+ assertEquals("error message " + i, expected, actual);
+ }
+
+ assertEquals("unexpected output: " + lnr.readLine(),
+ aExpected.length, errs);
+ aC.destroy();
+ }
+}
diff --git a/thirdparty/checkstyle/contrib/bcel/src/tests/com/puppycrawl/tools/checkstyle/bcel/checks/HiddenInheritedFieldTest.java b/thirdparty/checkstyle/contrib/bcel/src/tests/com/puppycrawl/tools/checkstyle/bcel/checks/HiddenInheritedFieldTest.java
new file mode 100755
index 000000000..14838179b
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/bcel/src/tests/com/puppycrawl/tools/checkstyle/bcel/checks/HiddenInheritedFieldTest.java
@@ -0,0 +1,22 @@
+package com.puppycrawl.tools.checkstyle.bcel.checks;
+
+import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
+import com.puppycrawl.tools.checkstyle.bcel.BcelCheckTestCase;
+
+public class HiddenInheritedFieldTest
+ extends BcelCheckTestCase
+{
+ public void testIt()
+ throws Exception
+ {
+ final DefaultConfiguration checkConfig =
+ createCheckConfig(HiddenInheritedFieldCheck.class);
+
+ final String[] expected = {
+ "0: Field 'private int subClassPrivate' hides field in class 'com.puppycrawl.tools.checkstyle.bcel.checks.SuperClass'.",
+ "0: Field 'protected int differentType' hides field in class 'com.puppycrawl.tools.checkstyle.bcel.checks.SuperClass'.",
+ "0: Field 'protected int reusedName' hides field in class 'com.puppycrawl.tools.checkstyle.bcel.checks.SuperClass'.",
+ };
+ verify(checkConfig, getPath("com\\puppycrawl\\tools\\checkstyle\\bcel\\checks\\SubClass.class"), expected);
+ }
+}
diff --git a/thirdparty/checkstyle/contrib/bcel/src/tests/com/puppycrawl/tools/checkstyle/bcel/checks/HiddenStaticMethodTest.java b/thirdparty/checkstyle/contrib/bcel/src/tests/com/puppycrawl/tools/checkstyle/bcel/checks/HiddenStaticMethodTest.java
new file mode 100755
index 000000000..a80ee430d
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/bcel/src/tests/com/puppycrawl/tools/checkstyle/bcel/checks/HiddenStaticMethodTest.java
@@ -0,0 +1,22 @@
+package com.puppycrawl.tools.checkstyle.bcel.checks;
+
+import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
+import com.puppycrawl.tools.checkstyle.bcel.BcelCheckTestCase;
+
+public class HiddenStaticMethodTest
+ extends BcelCheckTestCase
+{
+ public void testIt()
+ throws Exception
+ {
+ final DefaultConfiguration checkConfig =
+ createCheckConfig(HiddenStaticMethodCheck.class);
+
+ final String[] expected = {
+ "0: Static method 'public static int staticMethod()' hides method in class 'com.puppycrawl.tools.checkstyle.bcel.checks.SuperClass'.",
+ "0: Static method 'public static int staticMethodSameParamName(int i)' hides method in class 'com.puppycrawl.tools.checkstyle.bcel.checks.SuperClass'.",
+ "0: Static method 'public static int staticMethodSameParamType(int x)' hides method in class 'com.puppycrawl.tools.checkstyle.bcel.checks.SuperClass'.",
+ };
+ verify(checkConfig, getPath("com\\puppycrawl\\tools\\checkstyle\\bcel\\checks\\SubClass.class"), expected);
+ }
+}
diff --git a/thirdparty/checkstyle/contrib/checkstyle-author.xsl b/thirdparty/checkstyle/contrib/checkstyle-author.xsl
new file mode 100755
index 000000000..59eb6619b
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/checkstyle-author.xsl
@@ -0,0 +1,230 @@
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
+ <xsl:output method="html" indent="yes"/>
+ <xsl:decimal-format decimal-separator="." grouping-separator=","/>
+ <!--
+ Checkstyle XML Style Sheet by Daniel Grenner
+ <daniel DOT grenner AT enea DOT se>
+ This stylesheet groups the errors by author name, if used in combination
+ with the WriteTag check:
+
+ <module name="WriteTag">
+ <property name="tag" value="@author"/>
+ <property name="tagFormat" value="\S"/>
+ <property name="severity" value="ignore"/>
+ </module>
+
+ The output contains both error and warning messages.
+ Files without errors or warnings are not included.
+ This stylesheet is based on checkstyle-noframes.xsl.
+ -->
+
+ <xsl:key name="keyAuthorID" match="//file/error[contains(@message,'@author')]" use="@message" />
+ <xsl:key name="keySeverityID" match="//file/error" use="@severity" />
+ <xsl:template match="checkstyle">
+ <html>
+ <head>
+ <style type="text/css">
+ .bannercell {
+ border: 0px;
+ padding: 0px;
+ }
+ body {
+ margin-left: 10;
+ margin-right: 10;
+ font:normal 68% verdana,arial,helvetica;
+ background-color:#FFFFFF;
+ color:#000000;
+ }
+ .a td {
+ background: #efefef;
+ }
+ .b td {
+ background: #fff;
+ }
+ th, td {
+ text-align: left;
+ vertical-align: top;
+ }
+ th {
+ font-weight:bold;
+ background: #ccc;
+ color: black;
+ }
+ table, th, td {
+ font-size:100%;
+ border: none
+ }
+ table.log tr td, tr th {
+
+ }
+ h2 {
+ font-weight:bold;
+ font-size:140%;
+ margin-bottom: 5;
+ }
+ h3 {
+ font-size:100%;
+ font-weight:bold;
+ background: #525D76;
+ color: white;
+ text-decoration: none;
+ padding: 5px;
+ margin-right: 2px;
+ margin-left: 2px;
+ margin-bottom: 0;
+ }
+ </style>
+ </head>
+ <body>
+ <a name="#top"/>
+ <!-- jakarta logo -->
+ <table border="0" cellpadding="0" cellspacing="0" width="100%">
+ <tr>
+ <td class="bannercell" rowspan="2">
+ <!--a href="http://jakarta.apache.org/">
+ <img src="http://jakarta.apache.org/images/jakarta-logo.gif" alt="http://jakarta.apache.org" align="left" border="0"/>
+ </a-->
+ </td>
+ <td class="text-align:right">
+ <h2>CheckStyle Audit</h2>
+ </td>
+ </tr>
+ <tr>
+ <td class="text-align:right">Designed for use with <a href="http://checkstyle.sourceforge.net/">CheckStyle</a> and <a href="http://jakarta.apache.org">Ant</a>.</td>
+ </tr>
+ </table>
+ <hr size="1"/>
+
+ <!-- Summary part -->
+ <xsl:apply-templates select="." mode="summary"/>
+ <hr size="1" width="100%" align="left"/>
+
+ <!-- Author List part -->
+ <xsl:apply-templates select="." mode="authorlist"/>
+ <hr size="1" width="100%" align="left"/>
+
+ <!-- For each package create its part -->
+ <xsl:for-each select="file">
+ <xsl:sort select="./error[contains(@message,'@author=')]/@message"/>
+ <xsl:apply-templates select="."/>
+ <p/>
+ <p/>
+ </xsl:for-each>
+ <hr size="1" width="100%" align="left"/>
+ </body>
+ </html>
+ </xsl:template>
+ <xsl:template match="checkstyle" mode="summary">
+ <h3>Summary</h3>
+ <xsl:variable name="fileCount" select="count(file)"/>
+ <xsl:variable name="errorCount" select="count(key('keySeverityID', 'error'))"/>
+ <xsl:variable name="warningCount" select="count(key('keySeverityID', 'warning'))"/>
+ <table class="log" border="0" cellpadding="5" cellspacing="2" width="100%">
+ <tr>
+ <th>Files</th>
+ <th>Errors</th>
+ <th>Warnings</th>
+ </tr>
+ <tr>
+ <xsl:call-template name="alternated-row"/>
+ <td>
+ <xsl:value-of select="$fileCount"/>
+ </td>
+ <td>
+ <xsl:value-of select="$errorCount"/>
+ </td>
+ <td>
+ <xsl:value-of select="$warningCount"/>
+ </td>
+ </tr>
+ </table>
+ </xsl:template>
+ <xsl:template match="checkstyle" mode="authorlist">
+ <h3>Authors</h3>
+
+ <table class="log" border="0" cellpadding="5" cellspacing="2" width="100%">
+ <tr>
+ <th>Name</th>
+ <th>Errors</th>
+ <th>Warnings</th>
+ </tr>
+
+ <!-- Process each Author -->
+ <xsl:for-each select="file/error[generate-id(.) = generate-id(key('keyAuthorID', @message)[1])]">
+ <xsl:sort select="@message" />
+
+ <xsl:variable name="authorFull" select="@message"/>
+ <xsl:variable name="author" select="substring-after($authorFull,'@author=')"/>
+ <xsl:variable name="errors" select="count(key('keyAuthorID', @message)/../error[@severity='error'])"/>
+ <xsl:variable name="warnings" select="count(key('keyAuthorID', @message)/../error[@severity='warning'])"/>
+ <xsl:if test = "not ($author='' or ($errors + $warnings = 0))">
+ <tr>
+ <xsl:call-template name="alternated-row"/>
+ <td>
+ <a href="#{$author}">
+ <xsl:value-of select="$author"/>
+ </a>
+ </td>
+ <td><xsl:value-of select="$errors"/></td>
+ <td><xsl:value-of select="$warnings"/></td>
+ </tr>
+ </xsl:if>
+ </xsl:for-each>
+
+ </table>
+ </xsl:template>
+
+ <xsl:template match="file">
+ <xsl:variable name="errorCount" select="count(error[@severity='error']) + count(error[@severity='warning'])"/>
+ <xsl:if test="not ($errorCount=0)">
+
+ <xsl:variable name="author" select="substring-after(./error[contains(@message,'@author')]/@message,'@author=')"/>
+
+ <a name="#{$author}"/>
+ <h3>File <xsl:value-of select="@name"/>
+ <br/>
+ Author <xsl:value-of select="$author"/>
+ </h3>
+ <table class="log" border="0" cellpadding="5" cellspacing="2" width="100%">
+ <tr>
+ <th>Error Description</th>
+ <th>Line</th>
+ </tr>
+ <xsl:for-each select="error[not(@severity='info')]">
+ <xsl:sort select="@line" data-type="number"/>
+ <tr>
+ <xsl:call-template name="alternated-row"/>
+ <td>
+ <xsl:value-of select="@message"/>
+ </td>
+ <td>
+ <xsl:value-of select="@line"/>
+ </td>
+ </tr>
+ </xsl:for-each>
+ </table>
+ <a href="#top">Back to top</a>
+ </xsl:if>
+ </xsl:template>
+
+
+<xsl:template name="basename">
+ <xsl:param name="path"/>
+ <xsl:choose>
+ <xsl:when test="contains($path, '\')">
+ <xsl:call-template name="basename">
+ <xsl:with-param name="path">substring-after($path, '\')</xsl:with-param>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$path"/>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+
+ <xsl:template name="alternated-row">
+ <xsl:attribute name="class"><xsl:if test="position() mod 2 = 1">a</xsl:if><xsl:if test="position() mod 2 = 0">b</xsl:if></xsl:attribute>
+ </xsl:template>
+
+</xsl:stylesheet>
diff --git a/thirdparty/checkstyle/contrib/checkstyle-csv.xsl b/thirdparty/checkstyle/contrib/checkstyle-csv.xsl
new file mode 100755
index 000000000..e6aa2ce41
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/checkstyle-csv.xsl
@@ -0,0 +1,11 @@
+<?xml version="1.0"?>
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+<xsl:output method="text" />
+<xsl:strip-space elements="*"/>
+<xsl:template match="error">
+<xsl:value-of select="../@name"/>, <xsl:value-of select="@line"/>, <xsl:value-of select="@column"/>, <xsl:value-of select="@severity"/>, <xsl:value-of select="@message"/>, <xsl:value-of select="@source"/>
+<xsl:text>
+</xsl:text>
+</xsl:template>
+</xsl:stylesheet>
+
diff --git a/thirdparty/checkstyle/contrib/checkstyle-frames-errors.xsl b/thirdparty/checkstyle/contrib/checkstyle-frames-errors.xsl
new file mode 100755
index 000000000..9f06c5020
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/checkstyle-frames-errors.xsl
@@ -0,0 +1,394 @@
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
+ xmlns:lxslt="http://xml.apache.org/xslt"
+ xmlns:redirect="http://xml.apache.org/xalan/redirect"
+ extension-element-prefixes="redirect">
+
+<!--
+ The Apache Software License, Version 1.1
+
+ Copyright (c) 2002 The Apache Software Foundation. All rights
+ reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in
+ the documentation and/or other materials provided with the
+ distribution.
+
+ 3. The end-user documentation included with the redistribution, if
+ any, must include the following acknowlegement:
+ "This product includes software developed by the
+ Apache Software Foundation (http://www.apache.org/)."
+ Alternately, this acknowlegement may appear in the software itself,
+ if and wherever such third-party acknowlegements normally appear.
+
+ 4. The names "The Jakarta Project", "Ant", and "Apache Software
+ Foundation" must not be used to endorse or promote products derived
+ from this software without prior written permission. For written
+ permission, please contact apache@apache.org.
+
+ 5. Products derived from this software may not be called "Apache"
+ nor may "Apache" appear in their names without prior written
+ permission of the Apache Group.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ SUCH DAMAGE.
+ ====================================================================
+
+ This software consists of voluntary contributions made by many
+ individuals on behalf of the Apache Software Foundation. For more
+ information on the Apache Software Foundation, please see
+ <http://www.apache.org/>.
+ -->
+
+ <xsl:output method="html" indent="yes" encoding="US-ASCII"/>
+ <xsl:decimal-format decimal-separator="." grouping-separator="," />
+
+ <xsl:key name="files" match="file" use="@name"/>
+ <xsl:key name="errorfiles" match="file[count(error)>0]" use="@name"/>
+ <xsl:key name="violations" match="file/error" use="@source"/>
+
+ <xsl:param name="output.dir" select="'.'"/>
+
+ <xsl:variable name="allFiles" select="/checkstyle/file[@name and generate-id(.) = generate-id(key('files', @name))]"/>
+ <xsl:variable name="allFilesWithError" select="/checkstyle/file[@name and generate-id(.) = generate-id(key('errorfiles', @name))]"/>
+
+ <xsl:template match="checkstyle">
+ <!-- create the index.html -->
+ <redirect:write file="{$output.dir}/index.html">
+ <xsl:call-template name="index.html"/>
+ </redirect:write>
+
+ <!-- create the stylesheet.css -->
+ <redirect:write file="{$output.dir}/stylesheet.css">
+ <xsl:call-template name="stylesheet.css"/>
+ </redirect:write>
+
+ <!-- create the overview-summary.html at the root -->
+ <redirect:write file="{$output.dir}/overview-frame.html">
+ <xsl:apply-templates select="." mode="overview"/>
+ </redirect:write>
+
+ <!-- create the all-classes.html at the root -->
+ <redirect:write file="{$output.dir}/allclasses-frame.html">
+ <xsl:apply-templates select="." mode="all.classes"/>
+ </redirect:write>
+
+ <!-- process all files -->
+ <xsl:apply-templates select="$allFilesWithError"/>
+ </xsl:template>
+
+ <xsl:template name="index.html">
+ <html>
+ <head>
+ <title>CheckStyle Audit</title>
+ </head>
+ <frameset cols="20%,80%">
+ <frame src="allclasses-frame.html" name="fileListFrame"/>
+ <frame src="overview-frame.html" name="fileFrame"/>
+ </frameset>
+ <noframes>
+ <h2>Frame Alert</h2>
+ <p>
+ This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client.
+ </p>
+ </noframes>
+ </html>
+ </xsl:template>
+
+ <xsl:template name="pageHeader">
+ <table border="0" cellpadding="0" cellspacing="0" width="100%">
+ <tr>
+ <td class="text-align:right"><h2>CheckStyle Audit</h2></td>
+ </tr>
+ <tr>
+ <td class="text-align:right">Designed for use with <a href='http://checkstyle.sourceforge.net/'>CheckStyle</a> and <a href='http://jakarta.apache.org'>Ant</a>.</td>
+ </tr>
+ </table>
+ <hr size="1"/>
+ </xsl:template>
+
+ <xsl:template match="checkstyle" mode="overview">
+ <html>
+ <head>
+ <link rel="stylesheet" type="text/css" href="stylesheet.css"/>
+ </head>
+ <body>
+ <!-- page header -->
+ <xsl:call-template name="pageHeader"/>
+
+ <!-- Summary part -->
+ <xsl:apply-templates select="." mode="summary"/>
+ <hr size="1" width="100%" align="left"/>
+
+ <!-- File list part -->
+ <xsl:apply-templates select="." mode="filelist"/>
+ </body>
+ </html>
+ </xsl:template>
+
+ <xsl:template name="stylesheet.css">
+ .bannercell {
+ border: 0px;
+ padding: 0px;
+ }
+ body {
+ margin-left: 10;
+ margin-right: 10;
+ font:normal 80% arial,helvetica,sanserif;
+ background-color:#FFFFFF;
+ color:#000000;
+ }
+ .a td {
+ background: #efefef;
+ }
+ .b td {
+ background: #fff;
+ }
+ th, td {
+ text-align: left;
+ vertical-align: top;
+ }
+ th {
+ font-weight:bold;
+ background: #ccc;
+ color: black;
+ }
+ table, th, td {
+ font-size:100%;
+ border: none
+ }
+ table.log tr td, tr th {
+
+ }
+ h2 {
+ font-weight:bold;
+ font-size:140%;
+ margin-bottom: 5;
+ }
+ h3 {
+ font-size:100%;
+ font-weight:bold;
+ background: #525D76;
+ color: white;
+ text-decoration: none;
+ padding: 5px;
+ margin-right: 2px;
+ margin-left: 2px;
+ margin-bottom: 0;
+ }
+ </xsl:template>
+
+ <!--
+ Replace DOS characters in a path.
+ Replace '\' with '/', ':' with '_'.
+ -->
+ <xsl:template name="from-dos">
+ <xsl:param name="path"/>
+ <xsl:value-of select="translate($path, '\:', '/_')"/>
+ </xsl:template>
+
+ <!--
+ Creates an all-classes.html file that contains a link to all files.
+ -->
+ <xsl:template match="checkstyle" mode="all.classes">
+ <html>
+ <head>
+ <link rel="stylesheet" type="text/css" href="stylesheet.css"/>
+ </head>
+ <body>
+ <h2>Files</h2>
+ <p><a href="overview-frame.html" target="fileFrame">Summary</a></p>
+ <p>
+ <table width="100%">
+ <!-- For each file create its part -->
+ <xsl:apply-templates select="$allFilesWithError" mode="all.classes">
+ <xsl:sort select="@name"/>
+ </xsl:apply-templates>
+ </table>
+ </p>
+ </body>
+ </html>
+ </xsl:template>
+
+ <xsl:template match="checkstyle" mode="filelist">
+ <h3>Files</h3>
+ <table class="log" border="0" cellpadding="5" cellspacing="2" width="100%">
+ <tr>
+ <th>Name</th>
+ <th>Errors</th>
+ </tr>
+ <xsl:apply-templates select="$allFilesWithError" mode="filelist">
+ <xsl:sort select="@name"/>
+ </xsl:apply-templates>
+ </table>
+ </xsl:template>
+
+ <xsl:template match="file" mode="filelist">
+ <xsl:variable name="name" select="@name" />
+
+ <!--<xsl:if test="$first = 'true'">-->
+ <xsl:variable name="new-name">
+ <xsl:call-template name="from-dos">
+ <xsl:with-param name="path" select="@name"/>
+ </xsl:call-template>
+ </xsl:variable>
+ <tr>
+ <xsl:call-template name="alternated-row" />
+ <td nowrap="nowrap">
+ <a>
+ <xsl:attribute name="href">
+ <xsl:text>files/</xsl:text><xsl:value-of select="$new-name"/><xsl:text>.html</xsl:text>
+ </xsl:attribute>
+ <xsl:value-of select="@name"/>
+ </a>
+ </td>
+ <td><xsl:value-of select="count(../file[@name = $name]/error)"/></td>
+ </tr>
+ <!--</xsl:if>-->
+ </xsl:template>
+
+ <xsl:template match="file" mode="all.classes">
+
+ <xsl:variable name="new-name">
+ <xsl:call-template name="from-dos">
+ <xsl:with-param name="path" select="@name"/>
+ </xsl:call-template>
+ </xsl:variable>
+ <tr>
+ <td nowrap="nowrap">
+ <a target="fileFrame">
+ <xsl:attribute name="href">
+ <xsl:text>files/</xsl:text>
+ <xsl:value-of select="$new-name"/>
+ <xsl:text>.html</xsl:text>
+ </xsl:attribute>
+ <xsl:value-of select="@name"/>
+ </a>
+ </td>
+ </tr>
+ </xsl:template>
+
+ <!--
+ transform string like a/b/c to ../../../
+ @param path the path to transform into a descending directory path
+ -->
+ <xsl:template name="path">
+ <xsl:param name="path"/>
+ <xsl:if test="contains($path,'/')">
+ <xsl:text>../</xsl:text>
+ <xsl:call-template name="path">
+ <xsl:with-param name="path"><xsl:value-of select="substring-after($path,'/')"/></xsl:with-param>
+ </xsl:call-template>
+ </xsl:if>
+ <xsl:if test="not(contains($path,'/')) and not($path = '')">
+ <xsl:text>../</xsl:text>
+ </xsl:if>
+ </xsl:template>
+
+ <xsl:template match="file">
+ <xsl:variable name="name" select="@name"/>
+
+ <xsl:variable name="new-name">
+ <xsl:call-template name="from-dos">
+ <xsl:with-param name="path" select="@name"/>
+ </xsl:call-template>
+ </xsl:variable>
+ <redirect:write file="{$output.dir}/files/{$new-name}.html">
+ <html>
+ <head>
+ <link rel="stylesheet" type="text/css">
+ <xsl:attribute name="href">
+ <xsl:call-template name="path">
+ <xsl:with-param name="path" select="$new-name"/>
+ </xsl:call-template>
+ <xsl:text>stylesheet.css</xsl:text>
+ </xsl:attribute>
+ </link>
+ </head>
+ <body>
+ <xsl:call-template name="pageHeader"/>
+ <h3>File <xsl:value-of select="@name"/> </h3>
+ <table class="log" border="0" cellpadding="5" cellspacing="2" width="100%">
+ <tr>
+ <th>Error Description</th>
+ <th>Line</th>
+ </tr>
+ <xsl:for-each select="../file[@name = $name]/error">
+ <tr>
+ <xsl:call-template name="alternated-row"/>
+ <td>
+ <xsl:value-of select="@message"/>
+ </td>
+ <td>
+ <xsl:value-of select="@line"/>
+ </td>
+ </tr>
+ </xsl:for-each>
+ </table>
+ </body>
+ </html>
+ </redirect:write>
+ </xsl:template>
+
+ <xsl:template match="checkstyle" mode="summary">
+ <h3>Summary</h3>
+ <table class="log" border="0" cellpadding="5" cellspacing="2" width="100%">
+ <tr>
+ <th>Files</th>
+ <th>Files with Errors</th>
+ <th>Errors</th>
+ </tr>
+ <tr>
+ <xsl:call-template name="alternated-row"/>
+ <td><xsl:value-of select="count($allFiles)"/></td>
+ <td><xsl:value-of select="count($allFilesWithError)"/></td>
+ <td><xsl:value-of select="count(file/error)"/></td>
+ </tr>
+ </table>
+ <table class="log" border="0" cellpadding="5" cellspacing="2" width="100%">
+ <tr>
+ <th>Check</th>
+ <th>Number of Violations</th>
+ </tr>
+ <xsl:for-each select="file/error[@source and generate-id(.) = generate-id(key('violations', @source))]">
+ <xsl:sort select="@source"/>
+ <xsl:variable name="source" select="@source"/>
+ <tr>
+ <xsl:call-template name="alternated-row"/>
+ <td>
+ <xsl:value-of select="$source"/>
+ </td>
+ <td>
+ <xsl:value-of select="count(/checkstyle/file/error[@source=$source])"/>
+ </td>
+ </tr>
+ </xsl:for-each>
+ </table>
+ </xsl:template>
+
+ <xsl:template name="alternated-row">
+ <xsl:attribute name="class">
+ <xsl:if test="position() mod 2 = 1">a</xsl:if>
+ <xsl:if test="position() mod 2 = 0">b</xsl:if>
+ </xsl:attribute>
+ </xsl:template>
+
+</xsl:stylesheet>
+
diff --git a/thirdparty/checkstyle/contrib/checkstyle-frames.xsl b/thirdparty/checkstyle/contrib/checkstyle-frames.xsl
new file mode 100755
index 000000000..44c96e0c7
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/checkstyle-frames.xsl
@@ -0,0 +1,382 @@
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
+ xmlns:lxslt="http://xml.apache.org/xslt"
+ xmlns:redirect="http://xml.apache.org/xalan/redirect"
+ extension-element-prefixes="redirect">
+
+<!--
+ The Apache Software License, Version 1.1
+
+ Copyright (c) 2002 The Apache Software Foundation. All rights
+ reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in
+ the documentation and/or other materials provided with the
+ distribution.
+
+ 3. The end-user documentation included with the redistribution, if
+ any, must include the following acknowlegement:
+ "This product includes software developed by the
+ Apache Software Foundation (http://www.apache.org/)."
+ Alternately, this acknowlegement may appear in the software itself,
+ if and wherever such third-party acknowlegements normally appear.
+
+ 4. The names "The Jakarta Project", "Ant", and "Apache Software
+ Foundation" must not be used to endorse or promote products derived
+ from this software without prior written permission. For written
+ permission, please contact apache@apache.org.
+
+ 5. Products derived from this software may not be called "Apache"
+ nor may "Apache" appear in their names without prior written
+ permission of the Apache Group.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ SUCH DAMAGE.
+ ====================================================================
+
+ This software consists of voluntary contributions made by many
+ individuals on behalf of the Apache Software Foundation. For more
+ information on the Apache Software Foundation, please see
+ <http://www.apache.org/>.
+ -->
+
+ <xsl:output method="html" indent="yes" encoding="US-ASCII"/>
+ <xsl:decimal-format decimal-separator="." grouping-separator="," />
+
+ <xsl:param name="output.dir" select="'.'"/>
+
+ <xsl:template match="checkstyle">
+ <!-- create the index.html -->
+ <redirect:write file="{$output.dir}/index.html">
+ <xsl:call-template name="index.html"/>
+ </redirect:write>
+
+ <!-- create the stylesheet.css -->
+ <redirect:write file="{$output.dir}/stylesheet.css">
+ <xsl:call-template name="stylesheet.css"/>
+ </redirect:write>
+
+ <!-- create the overview-summary.html at the root -->
+ <redirect:write file="{$output.dir}/overview-frame.html">
+ <xsl:apply-templates select="." mode="overview"/>
+ </redirect:write>
+
+ <!-- create the all-classes.html at the root -->
+ <redirect:write file="{$output.dir}/allclasses-frame.html">
+ <xsl:apply-templates select="." mode="all.classes"/>
+ </redirect:write>
+
+ <!-- process all files -->
+ <xsl:apply-templates select="file"/>
+ </xsl:template>
+
+ <xsl:template name="index.html">
+ <html>
+ <head>
+ <title>CheckStyle Audit</title>
+ </head>
+ <frameset cols="20%,80%">
+ <frame src="allclasses-frame.html" name="fileListFrame"/>
+ <frame src="overview-frame.html" name="fileFrame"/>
+ </frameset>
+ <noframes>
+ <h2>Frame Alert</h2>
+ <p>
+ This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client.
+ </p>
+ </noframes>
+ </html>
+ </xsl:template>
+
+ <xsl:template name="pageHeader">
+ <table border="0" cellpadding="0" cellspacing="0" width="100%">
+ <tr>
+ <td class="text-align:right"><h2>CheckStyle Audit</h2></td>
+ </tr>
+ <tr>
+ <td class="text-align:right">Designed for use with <a href='http://checkstyle.sourceforge.net/'>CheckStyle</a> and <a href='http://jakarta.apache.org'>Ant</a>.</td>
+ </tr>
+ </table>
+ <hr size="1"/>
+ </xsl:template>
+
+ <xsl:template match="checkstyle" mode="overview">
+ <html>
+ <head>
+ <link rel="stylesheet" type="text/css" href="stylesheet.css"/>
+ </head>
+ <body>
+ <!-- page header -->
+ <xsl:call-template name="pageHeader"/>
+
+ <!-- Summary part -->
+ <xsl:apply-templates select="." mode="summary"/>
+ <hr size="1" width="100%" align="left"/>
+
+ <!-- File list part -->
+ <xsl:apply-templates select="." mode="filelist"/>
+ </body>
+ </html>
+ </xsl:template>
+
+ <xsl:template name="stylesheet.css">
+ .bannercell {
+ border: 0px;
+ padding: 0px;
+ }
+ body {
+ margin-left: 10;
+ margin-right: 10;
+ font:normal 80% arial,helvetica,sanserif;
+ background-color:#FFFFFF;
+ color:#000000;
+ }
+ .a td {
+ background: #efefef;
+ }
+ .b td {
+ background: #fff;
+ }
+ th, td {
+ text-align: left;
+ vertical-align: top;
+ }
+ th {
+ font-weight:bold;
+ background: #ccc;
+ color: black;
+ }
+ table, th, td {
+ font-size:100%;
+ border: none
+ }
+ table.log tr td, tr th {
+
+ }
+ h2 {
+ font-weight:bold;
+ font-size:140%;
+ margin-bottom: 5;
+ }
+ h3 {
+ font-size:100%;
+ font-weight:bold;
+ background: #525D76;
+ color: white;
+ text-decoration: none;
+ padding: 5px;
+ margin-right: 2px;
+ margin-left: 2px;
+ margin-bottom: 0;
+ }
+ </xsl:template>
+
+ <!--
+ Replace DOS characters in a path.
+ Replace '\' with '/', ':' with '_'.
+ -->
+ <xsl:template name="from-dos">
+ <xsl:param name="path"/>
+ <xsl:value-of select="translate($path, '\:', '/_')"/>
+ </xsl:template>
+
+ <!--
+ Creates an all-classes.html file that contains a link to all files.
+ -->
+ <xsl:template match="checkstyle" mode="all.classes">
+ <html>
+ <head>
+ <link rel="stylesheet" type="text/css" href="stylesheet.css"/>
+ </head>
+ <body>
+ <h2>Files</h2>
+ <p><a href="overview-frame.html" target="fileFrame">Summary</a></p>
+ <p>
+ <table width="100%">
+ <!-- For each file create its part -->
+ <xsl:apply-templates select="file" mode="all.classes">
+ <xsl:sort select="@name"/>
+ </xsl:apply-templates>
+ </table>
+ </p>
+ </body>
+ </html>
+ </xsl:template>
+
+ <xsl:template match="checkstyle" mode="filelist">
+ <h3>Files</h3>
+ <table class="log" border="0" cellpadding="5" cellspacing="2" width="100%">
+ <tr>
+ <th>Name</th>
+ <th>Errors</th>
+ </tr>
+ <xsl:apply-templates select="file" mode="filelist">
+ <xsl:sort select="@name"/>
+ </xsl:apply-templates>
+ </table>
+ </xsl:template>
+
+ <xsl:template match="file" mode="filelist">
+ <xsl:variable name="first">
+ <xsl:call-template name="isfirst">
+ <xsl:with-param name="name" select="@name"/>
+ </xsl:call-template>
+ </xsl:variable>
+ <xsl:variable name="name" select="@name" />
+
+ <xsl:if test="$first = 'true'">
+ <xsl:variable name="new-name">
+ <xsl:call-template name="from-dos">
+ <xsl:with-param name="path" select="@name"/>
+ </xsl:call-template>
+ </xsl:variable>
+ <tr>
+ <xsl:call-template name="alternated-row" />
+ <td nowrap="nowrap">
+ <a>
+ <xsl:attribute name="href">
+ <xsl:text>files/</xsl:text><xsl:value-of select="$new-name"/><xsl:text>.html</xsl:text>
+ </xsl:attribute>
+ <xsl:value-of select="@name"/>
+ </a>
+ </td>
+ <td><xsl:value-of select="count(../file[@name = $name]/error)"/></td>
+ </tr>
+ </xsl:if>
+ </xsl:template>
+
+ <xsl:template match="file" mode="all.classes">
+ <xsl:variable name="first">
+ <xsl:call-template name="isfirst">
+ <xsl:with-param name="name" select="@name"/>
+ </xsl:call-template>
+ </xsl:variable>
+
+ <xsl:if test="$first = 'true'">
+ <xsl:variable name="new-name">
+ <xsl:call-template name="from-dos">
+ <xsl:with-param name="path" select="@name"/>
+ </xsl:call-template>
+ </xsl:variable>
+ <tr>
+ <td nowrap="nowrap">
+ <a target="fileFrame">
+ <xsl:attribute name="href">
+ <xsl:text>files/</xsl:text><xsl:value-of select="$new-name"/><xsl:text>.html</xsl:text>
+ </xsl:attribute>
+ <xsl:value-of select="@name"/>
+ </a>
+ </td>
+ </tr>
+ </xsl:if>
+ </xsl:template>
+
+ <!--
+ transform string like a/b/c to ../../../
+ @param path the path to transform into a descending directory path
+ -->
+ <xsl:template name="path">
+ <xsl:param name="path"/>
+ <xsl:if test="contains($path,'/')">
+ <xsl:text>../</xsl:text>
+ <xsl:call-template name="path">
+ <xsl:with-param name="path"><xsl:value-of select="substring-after($path,'/')"/></xsl:with-param>
+ </xsl:call-template>
+ </xsl:if>
+ <xsl:if test="not(contains($path,'/')) and not($path = '')">
+ <xsl:text>../</xsl:text>
+ </xsl:if>
+ </xsl:template>
+
+ <xsl:template match="file">
+ <xsl:variable name="first">
+ <xsl:call-template name="isfirst">
+ <xsl:with-param name="name" select="@name"/>
+ </xsl:call-template>
+ </xsl:variable>
+ <xsl:variable name="name" select="@name" />
+
+ <xsl:if test="$first = 'true'">
+ <xsl:variable name="new-name">
+ <xsl:call-template name="from-dos">
+ <xsl:with-param name="path" select="@name"/>
+ </xsl:call-template>
+ </xsl:variable>
+ <redirect:write file="{$output.dir}/files/{$new-name}.html">
+ <html>
+ <head>
+ <link rel="stylesheet" type="text/css">
+ <xsl:attribute name="href"><xsl:call-template name="path"><xsl:with-param name="path" select="$new-name"/></xsl:call-template><xsl:text>stylesheet.css</xsl:text></xsl:attribute>
+ </link>
+ </head>
+ <body>
+ <xsl:call-template name="pageHeader"/>
+ <h3>File <xsl:value-of select="@name"/></h3>
+ <table class="log" border="0" cellpadding="5" cellspacing="2" width="100%">
+ <tr>
+ <th>Error Description</th>
+ <th>Line</th>
+ </tr>
+ <xsl:for-each select="../file[@name = $name]/error">
+ <tr>
+ <xsl:call-template name="alternated-row"/>
+ <td><xsl:value-of select="@message"/></td>
+ <td><xsl:value-of select="@line"/></td>
+ </tr>
+ </xsl:for-each>
+ </table>
+ </body>
+ </html>
+ </redirect:write>
+ </xsl:if>
+ </xsl:template>
+
+ <xsl:template match="checkstyle" mode="summary">
+ <h3>Summary</h3>
+ <xsl:variable name="fileCount" select="count(file)"/>
+ <xsl:variable name="errorCount" select="count(file/error)"/>
+ <table class="log" border="0" cellpadding="5" cellspacing="2" width="100%">
+ <tr>
+ <th>Files</th>
+ <th>Errors</th>
+ </tr>
+ <tr>
+ <xsl:call-template name="alternated-row"/>
+ <td><xsl:value-of select="$fileCount"/></td>
+ <td><xsl:value-of select="$errorCount"/></td>
+ </tr>
+ </table>
+ </xsl:template>
+
+ <xsl:template name="alternated-row">
+ <xsl:attribute name="class">
+ <xsl:if test="position() mod 2 = 1">a</xsl:if>
+ <xsl:if test="position() mod 2 = 0">b</xsl:if>
+ </xsl:attribute>
+ </xsl:template>
+
+ <!-- determine if this is the first occurance of the given name in the input -->
+ <xsl:template name="isfirst">
+ <xsl:param name="name"/>
+ <xsl:value-of select="count(preceding-sibling::file[@name=$name]) = 0"/>
+ </xsl:template>
+
+</xsl:stylesheet>
+
diff --git a/thirdparty/checkstyle/contrib/checkstyle-noframes-severity-sorted.xsl b/thirdparty/checkstyle/contrib/checkstyle-noframes-severity-sorted.xsl
new file mode 100755
index 000000000..fb1acd85f
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/checkstyle-noframes-severity-sorted.xsl
@@ -0,0 +1,210 @@
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
+<xsl:output method="html" indent="yes"/>
+<xsl:decimal-format decimal-separator="." grouping-separator="," />
+
+<xsl:key name="files" match="file" use="@name" />
+
+<!-- Checkstyle XML Style Sheet by Rolf Wojtech <rolf@wojtech.de> -->
+<!-- (based on checkstyle-noframe-sorted.xsl by Stephane Bailliez -->
+<!-- <sbailliez@apache.org> and sf-patch 1721291 by Leo Liang) -->
+<!-- Changes: -->
+<!-- * Outputs seperate columns for error/warning/info -->
+<!-- * Sorts primarily by #error, secondarily by #warning, tertiary by #info -->
+<!-- * Compatible with windows path names (converts '\' to '/' for html anchor) -->
+<!-- -->
+<!-- Part of the Checkstyle distribution found at http://checkstyle.sourceforge.net -->
+<!-- Usage (generates checkstyle_report.html): -->
+<!-- <checkstyle failonviolation="false" config="${check.config}"> -->
+<!-- <fileset dir="${src.dir}" includes="**/*.java"/> -->
+<!-- <formatter type="xml" toFile="${doc.dir}/checkstyle_report.xml"/> -->
+<!-- </checkstyle> -->
+<!-- <style basedir="${doc.dir}" destdir="${doc.dir}" -->
+<!-- includes="checkstyle_report.xml" -->
+<!-- style="${doc.dir}/checkstyle-noframes-severity-sorted.xsl"/> -->
+
+<xsl:template match="checkstyle">
+ <html>
+ <head>
+ <style type="text/css">
+ .bannercell {
+ border: 0px;
+ padding: 0px;
+ }
+ body {
+ margin-left: 10;
+ margin-right: 10;
+ font:normal 80% arial,helvetica,sanserif;
+ background-color:#FFFFFF;
+ color:#000000;
+ }
+ .a td {
+ background: #efefef;
+ }
+ .b td {
+ background: #fff;
+ }
+ th, td {
+ text-align: left;
+ vertical-align: top;
+ }
+ th {
+ font-weight:bold;
+ background: #ccc;
+ color: black;
+ }
+ table, th, td {
+ font-size:100%;
+ border: none
+ }
+ table.log tr td, tr th {
+
+ }
+ h2 {
+ font-weight:bold;
+ font-size:140%;
+ margin-bottom: 5;
+ }
+ h3 {
+ font-size:100%;
+ font-weight:bold;
+ background: #525D76;
+ color: white;
+ text-decoration: none;
+ padding: 5px;
+ margin-right: 2px;
+ margin-left: 2px;
+ margin-bottom: 0;
+ }
+ </style>
+ </head>
+ <body>
+ <a name="top"></a>
+ <!-- jakarta logo -->
+ <table border="0" cellpadding="0" cellspacing="0" width="100%">
+ <tr>
+ <td class="bannercell" rowspan="2">
+ <!--a href="http://jakarta.apache.org/">
+ <img src="http://jakarta.apache.org/images/jakarta-logo.gif" alt="http://jakarta.apache.org" align="left" border="0"/>
+ </a-->
+ </td>
+ <td class="text-align:right"><h2>CheckStyle Audit</h2></td>
+ </tr>
+ <tr>
+ <td class="text-align:right">Designed for use with <a href='http://checkstyle.sourceforge.net/'>CheckStyle</a> and <a href='http://jakarta.apache.org'>Ant</a>.</td>
+ </tr>
+ </table>
+ <hr size="1"/>
+
+ <!-- Summary part -->
+ <xsl:apply-templates select="." mode="summary"/>
+ <hr size="1" width="100%" align="left"/>
+
+ <!-- Package List part -->
+ <xsl:apply-templates select="." mode="filelist"/>
+ <hr size="1" width="100%" align="left"/>
+
+ <!-- For each package create its part -->
+ <xsl:apply-templates select="file[@name and generate-id(.) = generate-id(key('files', @name))]" />
+
+ <hr size="1" width="100%" align="left"/>
+
+
+ </body>
+ </html>
+</xsl:template>
+
+
+
+ <xsl:template match="checkstyle" mode="filelist">
+ <h3>Files</h3>
+ <table class="log" border="0" cellpadding="5" cellspacing="2" width="100%">
+ <tr>
+ <th>Name</th>
+ <th>Errors</th>
+ <th>Warnings</th>
+ <th>Infos</th>
+ </tr>
+ <xsl:for-each select="file[@name and generate-id(.) = generate-id(key('files', @name))]">
+
+ <!-- Sort method 1: Primary by #error, secondary by #warning, tertiary by #info -->
+ <xsl:sort data-type="number" order="descending" select="count(key('files', @name)/error[@severity='error'])"/>
+ <xsl:sort data-type="number" order="descending" select="count(key('files', @name)/error[@severity='warning'])"/>
+ <xsl:sort data-type="number" order="descending" select="count(key('files', @name)/error[@severity='info'])"/>
+
+ <!-- Sort method 1: Sum(#error+#info+#warning) (uncomment to use, comment method 1) -->
+ <!--
+ <xsl:sort data-type="number" order="descending" select="count(key('files', @name)/error)"/>
+ -->
+
+ <xsl:variable name="errorCount" select="count(key('files', @name)/error[@severity='error'])"/>
+ <xsl:variable name="warningCount" select="count(key('files', @name)/error[@severity='warning'])"/>
+ <xsl:variable name="infoCount" select="count(key('files', @name)/error[@severity='info'])"/>
+
+ <tr>
+ <xsl:call-template name="alternated-row"/>
+ <td><a href="#f-{translate(@name,'\','/')}"><xsl:value-of select="@name"/></a></td>
+ <td><xsl:value-of select="$errorCount"/></td>
+ <td><xsl:value-of select="$warningCount"/></td>
+ <td><xsl:value-of select="$infoCount"/></td>
+ </tr>
+ </xsl:for-each>
+ </table>
+ </xsl:template>
+
+
+ <xsl:template match="file">
+ <a name="f-{translate(@name,'\','/')}"></a>
+ <h3>File <xsl:value-of select="@name"/></h3>
+
+ <table class="log" border="0" cellpadding="5" cellspacing="2" width="100%">
+ <tr>
+ <th>Severity</th>
+ <th>Error Description</th>
+ <th>Line</th>
+ </tr>
+ <xsl:for-each select="key('files', @name)/error">
+ <xsl:sort data-type="number" order="ascending" select="@line"/>
+ <tr>
+ <xsl:call-template name="alternated-row"/>
+ <td><xsl:value-of select="@severity"/></td>
+ <td><xsl:value-of select="@message"/></td>
+ <td><xsl:value-of select="@line"/></td>
+ </tr>
+ </xsl:for-each>
+ </table>
+ <a href="#top">Back to top</a>
+ </xsl:template>
+
+
+ <xsl:template match="checkstyle" mode="summary">
+ <h3>Summary</h3>
+ <xsl:variable name="fileCount" select="count(file[@name and generate-id(.) = generate-id(key('files', @name))])"/>
+ <xsl:variable name="errorCount" select="count(file/error[@severity='error'])"/>
+ <xsl:variable name="warningCount" select="count(file/error[@severity='warning'])"/>
+ <xsl:variable name="infoCount" select="count(file/error[@severity='info'])"/>
+ <table class="log" border="0" cellpadding="5" cellspacing="2" width="100%">
+ <tr>
+ <th>Files</th>
+ <th>Errors</th>
+ <th>Warnings</th>
+ <th>Infos</th>
+ </tr>
+ <tr>
+ <xsl:call-template name="alternated-row"/>
+ <td><xsl:value-of select="$fileCount"/></td>
+ <td><xsl:value-of select="$errorCount"/></td>
+ <td><xsl:value-of select="$warningCount"/></td>
+ <td><xsl:value-of select="$infoCount"/></td>
+ </tr>
+ </table>
+ </xsl:template>
+
+ <xsl:template name="alternated-row">
+ <xsl:attribute name="class">
+ <xsl:if test="position() mod 2 = 1">a</xsl:if>
+ <xsl:if test="position() mod 2 = 0">b</xsl:if>
+ </xsl:attribute>
+ </xsl:template>
+</xsl:stylesheet>
+
+
diff --git a/thirdparty/checkstyle/contrib/checkstyle-noframes-sorted.xsl b/thirdparty/checkstyle/contrib/checkstyle-noframes-sorted.xsl
new file mode 100755
index 000000000..cf62deb5b
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/checkstyle-noframes-sorted.xsl
@@ -0,0 +1,179 @@
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
+<xsl:output method="html" indent="yes"/>
+<xsl:decimal-format decimal-separator="." grouping-separator="," />
+
+<xsl:key name="files" match="file" use="@name" />
+
+<!-- Checkstyle XML Style Sheet by Stephane Bailliez <sbailliez@apache.org> -->
+<!-- Part of the Checkstyle distribution found at http://checkstyle.sourceforge.net -->
+<!-- Usage (generates checkstyle_report.html): -->
+<!-- <checkstyle failonviolation="false" config="${check.config}"> -->
+<!-- <fileset dir="${src.dir}" includes="**/*.java"/> -->
+<!-- <formatter type="xml" toFile="${doc.dir}/checkstyle_report.xml"/> -->
+<!-- </checkstyle> -->
+<!-- <style basedir="${doc.dir}" destdir="${doc.dir}" -->
+<!-- includes="checkstyle_report.xml" -->
+<!-- style="${doc.dir}/checkstyle-noframes-sorted.xsl"/> -->
+
+<xsl:template match="checkstyle">
+ <html>
+ <head>
+ <style type="text/css">
+ .bannercell {
+ border: 0px;
+ padding: 0px;
+ }
+ body {
+ margin-left: 10;
+ margin-right: 10;
+ font:normal 80% arial,helvetica,sanserif;
+ background-color:#FFFFFF;
+ color:#000000;
+ }
+ .a td {
+ background: #efefef;
+ }
+ .b td {
+ background: #fff;
+ }
+ th, td {
+ text-align: left;
+ vertical-align: top;
+ }
+ th {
+ font-weight:bold;
+ background: #ccc;
+ color: black;
+ }
+ table, th, td {
+ font-size:100%;
+ border: none
+ }
+ table.log tr td, tr th {
+
+ }
+ h2 {
+ font-weight:bold;
+ font-size:140%;
+ margin-bottom: 5;
+ }
+ h3 {
+ font-size:100%;
+ font-weight:bold;
+ background: #525D76;
+ color: white;
+ text-decoration: none;
+ padding: 5px;
+ margin-right: 2px;
+ margin-left: 2px;
+ margin-bottom: 0;
+ }
+ </style>
+ </head>
+ <body>
+ <a name="top"></a>
+ <!-- jakarta logo -->
+ <table border="0" cellpadding="0" cellspacing="0" width="100%">
+ <tr>
+ <td class="bannercell" rowspan="2">
+ <!--a href="http://jakarta.apache.org/">
+ <img src="http://jakarta.apache.org/images/jakarta-logo.gif" alt="http://jakarta.apache.org" align="left" border="0"/>
+ </a-->
+ </td>
+ <td class="text-align:right"><h2>CheckStyle Audit</h2></td>
+ </tr>
+ <tr>
+ <td class="text-align:right">Designed for use with <a href='http://checkstyle.sourceforge.net/'>CheckStyle</a> and <a href='http://jakarta.apache.org'>Ant</a>.</td>
+ </tr>
+ </table>
+ <hr size="1"/>
+
+ <!-- Summary part -->
+ <xsl:apply-templates select="." mode="summary"/>
+ <hr size="1" width="100%" align="left"/>
+
+ <!-- Package List part -->
+ <xsl:apply-templates select="." mode="filelist"/>
+ <hr size="1" width="100%" align="left"/>
+
+ <!-- For each package create its part -->
+ <xsl:apply-templates select="file[@name and generate-id(.) = generate-id(key('files', @name))]" />
+
+ <hr size="1" width="100%" align="left"/>
+
+
+ </body>
+ </html>
+</xsl:template>
+
+
+
+ <xsl:template match="checkstyle" mode="filelist">
+ <h3>Files</h3>
+ <table class="log" border="0" cellpadding="5" cellspacing="2" width="100%">
+ <tr>
+ <th>Name</th>
+ <th>Errors</th>
+ </tr>
+ <xsl:for-each select="file[@name and generate-id(.) = generate-id(key('files', @name))]">
+ <xsl:sort data-type="number" order="descending" select="count(key('files', @name)/error)"/>
+ <xsl:variable name="currentName" select="@name" />
+ <xsl:variable name="errorCount" select="count(key('files', @name)/error)"/>
+ <tr>
+ <xsl:call-template name="alternated-row"/>
+ <td><a href="#f-{@name}"><xsl:value-of select="@name"/></a></td>
+ <td><xsl:value-of select="$errorCount"/></td>
+ </tr>
+ </xsl:for-each>
+ </table>
+ </xsl:template>
+
+
+ <xsl:template match="file">
+ <a name="f-{@name}"></a>
+ <h3>File <xsl:value-of select="@name"/></h3>
+
+ <table class="log" border="0" cellpadding="5" cellspacing="2" width="100%">
+ <tr>
+ <th>Error Description</th>
+ <th>Line</th>
+ </tr>
+ <xsl:for-each select="key('files', @name)/error">
+ <xsl:sort data-type="number" order="ascending" select="@line"/>
+ <tr>
+ <xsl:call-template name="alternated-row"/>
+ <td><xsl:value-of select="@message"/></td>
+ <td><xsl:value-of select="@line"/></td>
+ </tr>
+ </xsl:for-each>
+ </table>
+ <a href="#top">Back to top</a>
+ </xsl:template>
+
+
+ <xsl:template match="checkstyle" mode="summary">
+ <h3>Summary</h3>
+ <xsl:variable name="fileCount" select="count(file[@name and generate-id(.) = generate-id(key('files', @name))])"/>
+ <xsl:variable name="errorCount" select="count(file/error)"/>
+ <table class="log" border="0" cellpadding="5" cellspacing="2" width="100%">
+ <tr>
+ <th>Files</th>
+ <th>Errors</th>
+ </tr>
+ <tr>
+ <xsl:call-template name="alternated-row"/>
+ <td><xsl:value-of select="$fileCount"/></td>
+ <td><xsl:value-of select="$errorCount"/></td>
+ </tr>
+ </table>
+ </xsl:template>
+
+ <xsl:template name="alternated-row">
+ <xsl:attribute name="class">
+ <xsl:if test="position() mod 2 = 1">a</xsl:if>
+ <xsl:if test="position() mod 2 = 0">b</xsl:if>
+ </xsl:attribute>
+ </xsl:template>
+</xsl:stylesheet>
+
+
diff --git a/thirdparty/checkstyle/contrib/checkstyle-noframes.xsl b/thirdparty/checkstyle/contrib/checkstyle-noframes.xsl
new file mode 100755
index 000000000..5f18134b4
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/checkstyle-noframes.xsl
@@ -0,0 +1,179 @@
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
+<xsl:output method="html" indent="yes"/>
+<xsl:decimal-format decimal-separator="." grouping-separator="," />
+
+<!-- Checkstyle XML Style Sheet by Stephane Bailliez <sbailliez@apache.org> -->
+<!-- Part of the Checkstyle distribution found at http://checkstyle.sourceforge.net -->
+<!-- Usage (generates checkstyle_report.html): -->
+<!-- <checkstyle failonviolation="false" config="${check.config}"> -->
+<!-- <fileset dir="${src.dir}" includes="**/*.java"/> -->
+<!-- <formatter type="xml" toFile="${doc.dir}/checkstyle_report.xml"/> -->
+<!-- </checkstyle> -->
+<!-- <style basedir="${doc.dir}" destdir="${doc.dir}" -->
+<!-- includes="checkstyle_report.xml" -->
+<!-- style="${doc.dir}/checkstyle-noframes.xsl"/> -->
+
+<xsl:template match="checkstyle">
+ <html>
+ <head>
+ <style type="text/css">
+ .bannercell {
+ border: 0px;
+ padding: 0px;
+ }
+ body {
+ margin-left: 10;
+ margin-right: 10;
+ font:normal 80% arial,helvetica,sanserif;
+ background-color:#FFFFFF;
+ color:#000000;
+ }
+ .a td {
+ background: #efefef;
+ }
+ .b td {
+ background: #fff;
+ }
+ th, td {
+ text-align: left;
+ vertical-align: top;
+ }
+ th {
+ font-weight:bold;
+ background: #ccc;
+ color: black;
+ }
+ table, th, td {
+ font-size:100%;
+ border: none
+ }
+ table.log tr td, tr th {
+
+ }
+ h2 {
+ font-weight:bold;
+ font-size:140%;
+ margin-bottom: 5;
+ }
+ h3 {
+ font-size:100%;
+ font-weight:bold;
+ background: #525D76;
+ color: white;
+ text-decoration: none;
+ padding: 5px;
+ margin-right: 2px;
+ margin-left: 2px;
+ margin-bottom: 0;
+ }
+ </style>
+ </head>
+ <body>
+ <a name="top"></a>
+ <!-- jakarta logo -->
+ <table border="0" cellpadding="0" cellspacing="0" width="100%">
+ <tr>
+ <td class="bannercell" rowspan="2">
+ <!--a href="http://jakarta.apache.org/">
+ <img src="http://jakarta.apache.org/images/jakarta-logo.gif" alt="http://jakarta.apache.org" align="left" border="0"/>
+ </a-->
+ </td>
+ <td class="text-align:right"><h2>CheckStyle Audit</h2></td>
+ </tr>
+ <tr>
+ <td class="text-align:right">Designed for use with <a href='http://checkstyle.sourceforge.net/'>CheckStyle</a> and <a href='http://jakarta.apache.org'>Ant</a>.</td>
+ </tr>
+ </table>
+ <hr size="1"/>
+
+ <!-- Summary part -->
+ <xsl:apply-templates select="." mode="summary"/>
+ <hr size="1" width="100%" align="left"/>
+
+ <!-- Package List part -->
+ <xsl:apply-templates select="." mode="filelist"/>
+ <hr size="1" width="100%" align="left"/>
+
+ <!-- For each package create its part -->
+ <xsl:for-each select="file">
+ <xsl:sort select="@name"/>
+ <xsl:apply-templates select="."/>
+ <p/>
+ <p/>
+ </xsl:for-each>
+ <hr size="1" width="100%" align="left"/>
+
+
+ </body>
+ </html>
+</xsl:template>
+
+
+
+ <xsl:template match="checkstyle" mode="filelist">
+ <h3>Files</h3>
+ <table class="log" border="0" cellpadding="5" cellspacing="2" width="100%">
+ <tr>
+ <th>Name</th>
+ <th>Errors</th>
+ </tr>
+ <xsl:for-each select="file">
+ <xsl:sort select="@name"/>
+ <xsl:variable name="errorCount" select="count(error)"/>
+ <tr>
+ <xsl:call-template name="alternated-row"/>
+ <td><a href="#f-{@name}"><xsl:value-of select="@name"/></a></td>
+ <td><xsl:value-of select="$errorCount"/></td>
+ </tr>
+ </xsl:for-each>
+ </table>
+ </xsl:template>
+
+
+ <xsl:template match="file">
+ <a name="f-{@name}"></a>
+ <h3>File <xsl:value-of select="@name"/></h3>
+
+ <table class="log" border="0" cellpadding="5" cellspacing="2" width="100%">
+ <tr>
+ <th>Error Description</th>
+ <th>Line</th>
+ </tr>
+ <xsl:for-each select="error">
+ <tr>
+ <xsl:call-template name="alternated-row"/>
+ <td><xsl:value-of select="@message"/></td>
+ <td><xsl:value-of select="@line"/></td>
+ </tr>
+ </xsl:for-each>
+ </table>
+ <a href="#top">Back to top</a>
+ </xsl:template>
+
+
+ <xsl:template match="checkstyle" mode="summary">
+ <h3>Summary</h3>
+ <xsl:variable name="fileCount" select="count(file)"/>
+ <xsl:variable name="errorCount" select="count(file/error)"/>
+ <table class="log" border="0" cellpadding="5" cellspacing="2" width="100%">
+ <tr>
+ <th>Files</th>
+ <th>Errors</th>
+ </tr>
+ <tr>
+ <xsl:call-template name="alternated-row"/>
+ <td><xsl:value-of select="$fileCount"/></td>
+ <td><xsl:value-of select="$errorCount"/></td>
+ </tr>
+ </table>
+ </xsl:template>
+
+ <xsl:template name="alternated-row">
+ <xsl:attribute name="class">
+ <xsl:if test="position() mod 2 = 1">a</xsl:if>
+ <xsl:if test="position() mod 2 = 0">b</xsl:if>
+ </xsl:attribute>
+ </xsl:template>
+</xsl:stylesheet>
+
+
diff --git a/thirdparty/checkstyle/contrib/checkstyle-simple.xsl b/thirdparty/checkstyle/contrib/checkstyle-simple.xsl
new file mode 100755
index 000000000..d98cbcbe3
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/checkstyle-simple.xsl
@@ -0,0 +1,71 @@
+<?xml version="1.0"?>
+
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+
+<xsl:template match="/">
+ <html>
+ <head>
+ <title>Sun Coding Style Violations</title>
+ </head>
+ <body bgcolor="#FFFFEF">
+ <p><b>Coding Style Check Results</b></p>
+ <table border="1" cellspacing="0" cellpadding="2">
+ <tr bgcolor="#CC9966">
+ <th colspan="2"><b>Summary</b></th>
+ </tr>
+ <tr bgcolor="#CCF3D0">
+ <td>Total files checked</td>
+ <td><xsl:number level="any" value="count(descendant::file)"/></td>
+ </tr>
+ <tr bgcolor="#F3F3E1">
+ <td>Files with errors</td>
+ <td><xsl:number level="any" value="count(descendant::file[error])"/></td>
+ </tr>
+ <tr bgcolor="#CCF3D0">
+ <td>Total errors</td>
+ <td><xsl:number level="any" value="count(descendant::error)"/></td>
+ </tr>
+ <tr bgcolor="#F3F3E1">
+ <td>Errors per file</td>
+ <td><xsl:number level="any" value="count(descendant::error) div count(descendant::file)"/></td>
+ </tr>
+ </table>
+ <hr align="left" width="95%" size="1"/>
+ <p>The following are violations of the Sun Coding-Style Standards:</p>
+ <p/>
+ <xsl:apply-templates/>
+ </body>
+ </html>
+</xsl:template>
+
+<xsl:template match="file[error]">
+ <table bgcolor="#AFFFFF" width="95%" border="1" cellspacing="0" cellpadding="2">
+ <tr>
+ <th> File: </th>
+ <td>
+ <xsl:value-of select="@name"/>
+ </td>
+ </tr>
+ </table>
+ <table bgcolor="#DFFFFF" width="95%" border="1" cellspacing="0" cellpadding="2">
+ <tr>
+ <th> Line Number </th>
+ <th> Error Message </th>
+ </tr>
+ <xsl:apply-templates select="error"/>
+ </table>
+ <p/>
+</xsl:template>
+
+<xsl:template match="error">
+ <tr>
+ <td>
+ <xsl:value-of select="@line"/>
+ </td>
+ <td>
+ <xsl:value-of select="@message"/>
+ </td>
+ </tr>
+</xsl:template>
+
+</xsl:stylesheet>
diff --git a/thirdparty/checkstyle/contrib/checkstyle-text.xsl b/thirdparty/checkstyle/contrib/checkstyle-text.xsl
new file mode 100755
index 000000000..299c98d5b
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/checkstyle-text.xsl
@@ -0,0 +1,26 @@
+<?xml version="1.0"?>
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+<xsl:output method="text" omit-xml-declaration="yes"/>
+
+<xsl:template match="/">
+Coding Style Check Results
+--------------------------
+Total files checked: <xsl:number level="any" value="count(descendant::file)"/>
+ Files with errors: <xsl:number level="any" value="count(descendant::file[error])"/>
+ Total errors: <xsl:number level="any" value="count(descendant::error)"/>
+ Errors per file: <xsl:number level="any" value="count(descendant::error) div count(descendant::file)"/>
+<xsl:apply-templates/>
+</xsl:template>
+
+<xsl:template match="file[error]">
+File: <xsl:value-of select="@name"/><xsl:text>
+</xsl:text>
+<xsl:apply-templates select="error"/>
+</xsl:template>
+
+<xsl:template match="error">
+<xsl:value-of select="@line"/>:<xsl:value-of select="@column"/><xsl:text> - </xsl:text><xsl:value-of select="@message"/><xsl:text>
+</xsl:text>
+</xsl:template>
+
+</xsl:stylesheet> \ No newline at end of file
diff --git a/thirdparty/checkstyle/contrib/examples/XInclude/NamespacesSAXParserFactoryImpl.java b/thirdparty/checkstyle/contrib/examples/XInclude/NamespacesSAXParserFactoryImpl.java
new file mode 100755
index 000000000..13bce881d
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/examples/XInclude/NamespacesSAXParserFactoryImpl.java
@@ -0,0 +1,21 @@
+package com.puppycrawl.tools.checkstyle;
+
+import org.apache.xerces.jaxp.SAXParserFactoryImpl;
+
+/**
+ * A parser factory that produces parsers that support XML namespaces.
+ * @author Rick Giles
+ * @version May 28, 2004
+ */
+public class NamespacesSAXParserFactoryImpl extends SAXParserFactoryImpl
+{
+ /**
+ * Constructs a NamespacesSAXParserFactoryImpl. Initializes
+ * it to produce parsers that support XML namespaces.
+ */
+ public NamespacesSAXParserFactoryImpl()
+ {
+ super();
+ setNamespaceAware(true);
+ }
+}
diff --git a/thirdparty/checkstyle/contrib/examples/XInclude/config.xml b/thirdparty/checkstyle/contrib/examples/XInclude/config.xml
new file mode 100755
index 000000000..ca0979c6d
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/examples/XInclude/config.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0"?>
+<!DOCTYPE module [
+<!ELEMENT module (module|property|xi:include)*>
+<!ATTLIST module name NMTOKEN #REQUIRED>
+
+<!ELEMENT xi:include EMPTY>
+<!ATTLIST xi:include
+ href CDATA #REQUIRED
+ xmlns:xi CDATA #REQUIRED
+>
+
+<!ELEMENT property EMPTY>
+<!ATTLIST property
+ name NMTOKEN #REQUIRED
+ value CDATA #REQUIRED
+ default CDATA #IMPLIED
+>
+
+]>
+<module name="Checker">
+ <module name="TreeWalker">
+ <xi:include
+ href="T:/checkstyle/test/xiinclude/treewalker.xml"
+ xmlns:xi="http://www.w3.org/2003/XInclude"/>
+ </module>
+</module>
diff --git a/thirdparty/checkstyle/contrib/examples/XInclude/index.html b/thirdparty/checkstyle/contrib/examples/XInclude/index.html
new file mode 100755
index 000000000..3be0dc549
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/examples/XInclude/index.html
@@ -0,0 +1,142 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE html
+ PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+ "DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+ <title>XInclude Processing</title>
+ <link rel="stylesheet" type="text/css" href="../../../docs/mystyle.css"/>
+</head>
+
+<body>
+<h1>XInclude Processing</h1>
+<h3>Description</h3>
+<p>This is an example of how you can separate a Checkstyle configuration file
+into several files and process the configuration using
+<a href="http://www.w3.org/TR/2003/WD-xinclude-20031110/">XInclude processing</a>.
+This requires a SAX parser that supports XML namespaces.
+First we give an example a SAX parser factory that produces parsers supporting XML namespaces
+and indicate how to configure your system to use this factory.
+Then we give an example XML configuration files with XInclude processing and
+an ant target that uses the <a href="../../../docs/anttask.html">Checkstyle ant task</a>
+to check a Java source file with the configuration files.
+</p>
+<h3>Parsers</h3>
+<p>SAX parser factory <a href="NamespacesSAXParserFactoryImpl.java"><span class="code">NamespacesSAXParserFactoryImpl</span></a>
+is an example of a factory that produces parsers
+supporting XML namespaces:
+<pre>
+package com.puppycrawl.tools.checkstyle;
+
+import org.apache.xerces.jaxp.SAXParserFactoryImpl;
+
+/**
+ * A parser factory that produces parsers that support XML namespaces.
+ * @author Rick Giles
+ * @version May 28, 2004
+ */
+public class NamespacesSAXParserFactoryImpl extends SAXParserFactoryImpl
+{
+ /**
+ * Constructs a NamespacesSAXParserFactoryImpl. Initializes
+ * it to produce parsers that support XML namespaces.
+ */
+ public NamespacesSAXParserFactoryImpl()
+ {
+ super();
+ setNamespaceAware(true);
+ }
+}
+</pre>
+</p>
+<p>
+In order to use <span class="code">NamespacesSAXParserFactoryImpl</span> as the
+SAX parser factory, place <span class="code">NamespacesSAXParserFactoryImpl</span>
+in the classpath and
+<a href="http://java.sun.com/j2se/1.4.2/docs/api/javax/xml/parsers/SAXParserFactory.html#newInstance()">configure your system</a>
+to load
+<span class="code">NamespacesSAXParserFactoryImpl</span>
+as the <span class="code">SAXParserFactory</span>.
+For example, you can create a file called <span class="code">jaxp.properties</span>
+in the lib subdirectory of the JRE installation with contents
+<pre>
+javax.xml.parsers.SAXParserFactory=com.puppycrawl.tools.checkstyle.NamespacesSAXParserFactoryImpl
+</pre>
+</p>
+<p>
+XInclude processing requires an XML parser that implements XML inclusions.
+Here we use the <a href="http://xml.apache.org/xerces2-j/index.html">Xerces parser</a>
+that is in the ant distribution. In order
+to <a href="http://xml.apache.org/xerces2-j/faq-xinclude.html">enable Xinclude processing</a>,
+you can change the parser configuration by creating a file called <span class="code">xerces.properties</span>
+in the lib subdirectory of the JRE installation with contents
+<pre>
+org.apache.xerces.xni.parser.XMLParserConfiguration=org.apache.xerces.parsers.XIncludeParserConfiguration
+</pre>
+<h3>Checkstyle Configuration</h3>
+</p>
+<p>The Checkstyle configuration of this example is in two files.
+File <a href="config.xml"><span class="code">config.xml</span></a> has an internal DTD that supports
+<span class="code">xi:include</span> elements:
+<pre>
+&lt;?xml version=&quot;1.0&quot;?&gt;
+&lt;!DOCTYPE module [
+&lt;!ELEMENT module (module|property|xi:include)*&gt;
+&lt;!ATTLIST module name NMTOKEN #REQUIRED&gt;
+
+&lt;!ELEMENT xi:include EMPTY&gt;
+&lt;!ATTLIST xi:include
+ href CDATA #REQUIRED
+ xmlns:xi CDATA #REQUIRED
+&gt;
+
+&lt;!ELEMENT property EMPTY&gt;
+&lt;!ATTLIST property
+ name NMTOKEN #REQUIRED
+ value CDATA #REQUIRED
+ default CDATA #IMPLIED
+&gt;
+]&gt;
+&lt;module name=&quot;Checker&quot;&gt;
+ &lt;module name=&quot;TreeWalker&quot;&gt;
+ &lt;xi:include
+ href=&quot;treewalker.xml&quot;
+ xmlns:xi=&quot;http://www.w3.org/2003/XInclude&quot;/&gt;
+ &lt;/module&gt;
+&lt;/module&gt;
+</pre>
+</p>
+<p>
+The configuration in <span class="code">config.xml</span> includes a second
+configuration file, <a href="treewalker.xml"><span class="code">treewalker.xml</span></a>, that applies
+the <span class="code">TypeName</span> module:
+<pre>
+&lt;?xml version=&quot;1.0&quot;?&gt;
+&lt;!DOCTYPE module PUBLIC
+ &quot;-//Puppy Crawl//DTD Check Configuration 1.2//EN&quot;
+ &quot;http://www.puppycrawl.com/dtds/configuration_1_2.dtd&quot;&gt;
+&lt;module name=&quot;TypeName&quot;&gt;
+ &lt;property name=&quot;format&quot; value=&quot;${typename.format}&quot;/&gt;
+&lt;/module&gt;
+</pre>
+</p>
+<p>
+Notice that the configuration of <span class="code">treewalker.xml</span>
+applies property <span class="code">${typename.format}</span>.
+That propery is set in the following segment of an ant build file that uses the
+Checkstyle ant task to check file <span class="code">InputHeader.java</span>
+with the configuration of <span class="code">config.xml</span>:
+<pre>
+ &lt;taskdef
+ resource=&quot;checkstyletask.properties&quot;
+ classpath=&quot;/path/to/checkstyle-all-@CHECKSTYLE_VERSION@.jar&quot; /&gt;
+ &lt;target name=&quot;checkstyle&quot; description=&quot;run checkstyle&quot;&gt;
+ &lt;checkstyle file=&quot;InputHeader.java&quot; config=&quot;config.xml&quot;&gt;
+ &lt;property key=&quot;typename.format&quot; value=&quot;xyz&quot; /&gt;
+ &lt;/checkstyle&gt;
+ &lt;/target&gt;
+</pre>
+</p>
+</body>
+</html> \ No newline at end of file
diff --git a/thirdparty/checkstyle/contrib/examples/XInclude/treewalker.xml b/thirdparty/checkstyle/contrib/examples/XInclude/treewalker.xml
new file mode 100755
index 000000000..fc2b6ceed
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/examples/XInclude/treewalker.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0"?>
+<!DOCTYPE module PUBLIC
+ "-//Puppy Crawl//DTD Check Configuration 1.2//EN"
+ "http://www.puppycrawl.com/dtds/configuration_1_2.dtd">
+<module name="TypeName">
+ <property name="format" value="${typename.format}"/>
+</module>
diff --git a/thirdparty/checkstyle/contrib/examples/checks/com/mycompany/checks/LimitImplementationFiles.java b/thirdparty/checkstyle/contrib/examples/checks/com/mycompany/checks/LimitImplementationFiles.java
new file mode 100755
index 000000000..f70d282f5
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/examples/checks/com/mycompany/checks/LimitImplementationFiles.java
@@ -0,0 +1,69 @@
+package com.mycompany.checks;
+
+import java.io.File;
+import com.puppycrawl.tools.checkstyle.api.*;
+
+/**
+ * An example for a user provided FileSetCheck,
+ * checks that the number of files does not excced a certain limit.
+ *
+ * This Class is provided for educational purposes only, we do not
+ * consider it useful to check your production code.
+ *
+ * @author lkuehne
+ */
+public class LimitImplementationFiles
+ extends AbstractFileSetCheck
+{
+ /**
+ * the maximium number of implementation files,
+ * default is 100.
+ */
+ private int max = 100;
+
+ /**
+ * Give user a chance to configure max in the
+ * config file.
+ *
+ * @param aMax the user specified maximum.
+ */
+ public void setMax(int aMax)
+ {
+ max = aMax;
+ }
+
+ /**
+ * @see FileSetCheck
+ */
+ public void process(File[] files)
+ {
+ if (files != null && files.length > max) {
+
+ // figure out the file that contains the error
+ final String path = files[max].getPath();
+
+ // message collector is used to collect error messages,
+ // needs to be reset before starting to collect error messages
+ // for a file.
+ getMessageCollector().reset();
+
+ // message dispatcher is used to fire AuditEvents
+ MessageDispatcher dispatcher = getMessageDispatcher();
+
+ // signal start of file to AuditListeners
+ dispatcher.fireFileStarted(path);
+
+ // log the message
+ log(0, "max.files.exceeded", new Integer(max));
+
+ // you can call log() multiple times to flag multiple
+ // errors in the same file
+
+ // fire the errors for this file to the AuditListeners
+ fireErrors(path);
+
+ // signal end of file to AuditListeners
+ dispatcher.fireFileFinished(path);
+ }
+ }
+}
diff --git a/thirdparty/checkstyle/contrib/examples/checks/com/mycompany/checks/MethodLimitCheck.java b/thirdparty/checkstyle/contrib/examples/checks/com/mycompany/checks/MethodLimitCheck.java
new file mode 100755
index 000000000..e9469441f
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/examples/checks/com/mycompany/checks/MethodLimitCheck.java
@@ -0,0 +1,63 @@
+package com.mycompany.checks;
+
+import com.puppycrawl.tools.checkstyle.api.*;
+
+public class MethodLimitCheck extends Check
+{
+ /** the maximum number of methods per class/interface */
+ private int max = 30;
+
+ /**
+ * Give user a chance to configure max in the config file.
+ * @param aMax the user specified maximum parsed from configuration property.
+ */
+ public void setMax(int aMax)
+ {
+ max = aMax;
+ }
+
+ /**
+ * We are interested in CLASS_DEF and INTERFACE_DEF Tokens.
+ * @see Check
+ */
+ public int[] getDefaultTokens()
+ {
+ return new int[]{TokenTypes.CLASS_DEF, TokenTypes.INTERFACE_DEF};
+ }
+
+ /**
+ * @see Check
+ */
+ public void visitToken(DetailAST ast)
+ {
+ // the tree below a CLASS_DEF/INTERFACE_DEF looks like this:
+
+ // CLASS_DEF
+ // MODIFIERS
+ // class name (IDENT token type)
+ // EXTENDS_CLAUSE
+ // IMPLEMENTS_CLAUSE
+ // OBJBLOCK
+ // {
+ // some other stuff like variable declarations etc.
+ // METHOD_DEF
+ // more stuff, the users might mix methods, variables, etc.
+ // METHOD_DEF
+ // ...and so on
+ // }
+
+ // We use helper methods to navigate in the syntax tree
+
+ // find the OBJBLOCK node below the CLASS_DEF/INTERFACE_DEF
+ DetailAST objBlock = ast.findFirstToken(TokenTypes.OBJBLOCK);
+
+ // count the number of direct children of the OBJBLOCK
+ // that are METHOD_DEFS
+ int methodDefs = objBlock.getChildCount(TokenTypes.METHOD_DEF);
+
+ // report error if limit is reached
+ if (methodDefs > max) {
+ log(ast.getLineNo(), "too.many.methods", new Integer(max));
+ }
+ }
+}
diff --git a/thirdparty/checkstyle/contrib/examples/checks/com/mycompany/checks/messages.properties b/thirdparty/checkstyle/contrib/examples/checks/com/mycompany/checks/messages.properties
new file mode 100755
index 000000000..48f862da0
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/examples/checks/com/mycompany/checks/messages.properties
@@ -0,0 +1,2 @@
+max.files.exceeded=Too many implementation files, only {0} are allowed
+too.many.methods=Too many methods, only {0} are allowed
diff --git a/thirdparty/checkstyle/contrib/examples/checks/com/puppycrawl/tools/checkstyle/checks/xpath/Attribute.java b/thirdparty/checkstyle/contrib/examples/checks/com/puppycrawl/tools/checkstyle/checks/xpath/Attribute.java
new file mode 100755
index 000000000..50e04eef1
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/examples/checks/com/puppycrawl/tools/checkstyle/checks/xpath/Attribute.java
@@ -0,0 +1,107 @@
+////////////////////////////////////////////////////////////////////////////////
+// checkstyle: Checks Java source code for adherence to a set of rules.
+// Copyright (C) 2001-2003 Oliver Burn
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+////////////////////////////////////////////////////////////////////////////////
+package com.puppycrawl.tools.checkstyle.checks.xpath;
+
+import com.puppycrawl.tools.checkstyle.api.DetailAST;
+
+
+/**
+ * Data holder for an XPath attribute of an element. The parent
+ * element of an Attribute is a DetailAST. The name and value
+ * of an Attribute are Strings.
+ * @author Rick Giles
+ */
+public class Attribute
+{
+ /** element owning this attribute */
+ private DetailAST mParent;
+
+ /** name */
+ private String mName;
+
+ /** value */
+ private String mValue;
+
+ /**
+ * Constructs an <code>Attribute</code>.
+ * @param aParent the parent element.
+ * @param aName the name.
+ * @param aValue the value.
+ */
+ public Attribute(DetailAST aParent, String aName, String aValue)
+ {
+ mParent = aParent;
+ mName = aName;
+ mValue = aValue;
+ }
+
+ /** Returns the name of the attribute.
+ * @return the name of the attribute.
+ */
+ public String getName()
+ {
+ return mName;
+ }
+
+ /**
+ * Returns the value of the attribute.
+ * @return the value of the attribute.
+ */
+ public String getValue()
+ {
+ return mValue;
+ }
+
+ /**
+ * Sets the name of the attribute.
+ * @param aName The name to set.
+ */
+ public void setName(String aName)
+ {
+ mName = aName;
+ }
+
+ /**
+ * Sets the value of the attribute.
+ * @param aValue The value to set.
+ */
+ public void setValue(String aValue)
+ {
+ mValue = aValue;
+ }
+
+ /**
+ * Returns the parent of the attribute.
+ * @return the parent of the attribute.
+ */
+ public DetailAST getParent()
+ {
+ return mParent;
+ }
+
+ /**
+ * Sets the parent of the attribute.
+ * @param aParent the parent of the attribute.
+ */
+ public void setParent(DetailAST aParent)
+ {
+ mParent = aParent;
+ }
+
+}
diff --git a/thirdparty/checkstyle/contrib/examples/checks/com/puppycrawl/tools/checkstyle/checks/xpath/AttributeAxisIterator.java b/thirdparty/checkstyle/contrib/examples/checks/com/puppycrawl/tools/checkstyle/checks/xpath/AttributeAxisIterator.java
new file mode 100755
index 000000000..8f0dca2c3
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/examples/checks/com/puppycrawl/tools/checkstyle/checks/xpath/AttributeAxisIterator.java
@@ -0,0 +1,98 @@
+////////////////////////////////////////////////////////////////////////////////
+// checkstyle: Checks Java source code for adherence to a set of rules.
+// Copyright (C) 2001-2003 Oliver Burn
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+////////////////////////////////////////////////////////////////////////////////
+package com.puppycrawl.tools.checkstyle.checks.xpath;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.commons.beanutils.BeanUtils;
+
+import com.puppycrawl.tools.checkstyle.api.DetailAST;
+
+/**
+ * Iterator for an attribute axis of an XPath element. The XPath
+ * element is a DetailAST. Attributes correspond to bean
+ * properties of the DetailAST.
+ * @author Rick Giles
+ */
+public class AttributeAxisIterator
+ implements Iterator
+{
+ /** actual iterator */
+ private Iterator mIter = (new ArrayList()).iterator();
+
+ /**
+ * Constructs a <code>AttributeAxisIterator</code> for a
+ * DetailAST element.
+ * @param aAST the DetailAST element
+ */
+ public AttributeAxisIterator(DetailAST aAST)
+ {
+ Map props = new HashMap();
+ //use BeanUtils to get the properties
+ try {
+ props = BeanUtils.describe(aAST);
+ }
+ catch (IllegalAccessException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ catch (InvocationTargetException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ catch (NoSuchMethodException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ // add attributes for the properties to a list and
+ // set the iterator to an iterator over that list.
+ final List attributes = new ArrayList(props.size());
+ final Set values = props.keySet();
+ for (Iterator iter = values.iterator(); iter.hasNext();) {
+ final String name = (String) iter.next();
+ final String value = (String) props.get(name);
+ attributes.add(new Attribute(aAST, name, value));
+ }
+ mIter = attributes.iterator();
+ }
+
+ /**@see java.util.Iterator#next() */
+ public Object next()
+ {
+ return mIter.next();
+ }
+
+ /** @see java.util.Iterator#hasNext() */
+ public boolean hasNext()
+ {
+ return mIter.hasNext();
+ }
+
+ /** @see java.util.Iterator#remove() */
+ public void remove()
+ {
+ mIter.remove();
+ }
+} \ No newline at end of file
diff --git a/thirdparty/checkstyle/contrib/examples/checks/com/puppycrawl/tools/checkstyle/checks/xpath/DocumentNavigator.java b/thirdparty/checkstyle/contrib/examples/checks/com/puppycrawl/tools/checkstyle/checks/xpath/DocumentNavigator.java
new file mode 100755
index 000000000..e582f380d
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/examples/checks/com/puppycrawl/tools/checkstyle/checks/xpath/DocumentNavigator.java
@@ -0,0 +1,437 @@
+////////////////////////////////////////////////////////////////////////////////
+// checkstyle: Checks Java source code for adherence to a set of rules.
+// Copyright (C) 2001-2003 Oliver Burn
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+////////////////////////////////////////////////////////////////////////////////
+package com.puppycrawl.tools.checkstyle.checks.xpath;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import org.jaxen.DefaultNavigator;
+import org.jaxen.XPath;
+import org.jaxen.util.SingleObjectIterator;
+import org.saxpath.SAXPathException;
+
+import com.puppycrawl.tools.checkstyle.api.DetailAST;
+import com.puppycrawl.tools.checkstyle.api.TokenTypes;
+
+/**
+ * Navigates around a DetailAST, using XPath semantics.
+ * Requires jaxen, http://jaxen.sourceforge.net and
+ * saxpath, http://sourceforge.net/projects/saxpath/.
+ * Idea shamelessly stolen from the equivalent PMD code (pmd.sourceforge.net).
+ * @author Rick Giles
+ */
+public class DocumentNavigator
+ extends DefaultNavigator
+{
+ /** Iterator for an empty sequence */
+ private static final Iterator EMPTY_ITERATOR = new ArrayList().iterator();
+
+ /**
+ * @see org.jaxen.DefaultNavigator#getAttributeName(java.lang.Object)
+ */
+ public String getAttributeName(Object aObject)
+ {
+ return ((Attribute) aObject).getName();
+ }
+
+ /**
+ * @see org.jaxen.DefaultNavigator#getAttributeNamespaceUri
+ */
+ public String getAttributeNamespaceUri(Object aObject)
+ {
+ return null;
+ }
+
+ /**
+ * @see org.jaxen.DefaultNavigator#getAttributeQName(java.lang.Object)
+ */
+ public String getAttributeQName(Object aObject)
+ {
+ return ((Attribute) aObject).getName();
+ }
+
+ /**
+ * @see org.jaxen.DefaultNavigator#getAttributeStringValue(java.lang.Object)
+ */
+ public String getAttributeStringValue(Object aObject)
+ {
+ return ((Attribute) aObject).getValue();
+ }
+
+ /**
+ * @see org.jaxen.DefaultNavigator#getCommentStringValue(java.lang.Object)
+ */
+ public String getCommentStringValue(Object aObject)
+ {
+ return null;
+ }
+
+ /**
+ * @see org.jaxen.DefaultNavigator#getElementName(java.lang.Object)
+ */
+ public String getElementName(Object aObject)
+ {
+ final int type = ((DetailAST) aObject).getType();
+ return TokenTypes.getTokenName(type);
+ }
+
+ /**
+ * @see org.jaxen.DefaultNavigator#getElementNamespaceUri(java.lang.Object)
+ */
+ public String getElementNamespaceUri(Object aObject)
+ {
+ return null;
+ }
+
+ /**
+ * @see org.jaxen.DefaultNavigator#getElementQName(java.lang.Object)
+ */
+ public String getElementQName(Object aObject)
+ {
+ return getElementName(aObject);
+ }
+
+ /**
+ * @see org.jaxen.DefaultNavigator#getElementStringValue(java.lang.Object)
+ */
+ public String getElementStringValue(Object aObject)
+ {
+ return null;
+ }
+
+ /**
+ * @see org.jaxen.DefaultNavigator#getNamespacePrefix(java.lang.Object)
+ */
+ public String getNamespacePrefix(Object aObject)
+ {
+ return null;
+ }
+
+ /**
+ * @see org.jaxen.DefaultNavigator#getNamespaceStringValue(java.lang.Object)
+ */
+ public String getNamespaceStringValue(Object aObject)
+ {
+ return null;
+ }
+
+ /**
+ * @see org.jaxen.DefaultNavigator#getTextStringValue(java.lang.Object)
+ */
+ public String getTextStringValue(Object aObject)
+ {
+ return null;
+ }
+
+ /**
+ * @see org.jaxen.DefaultNavigator#isAttribute(java.lang.Object)
+ */
+ public boolean isAttribute(Object aObject)
+ {
+ return aObject instanceof Attribute;
+ }
+
+ /**
+ * @see org.jaxen.DefaultNavigator#isComment(java.lang.Object)
+ */
+ public boolean isComment(Object aObject)
+ {
+ return false;
+ }
+
+ /**
+ * @see org.jaxen.DefaultNavigator#isDocument(java.lang.Object)
+ */
+ public boolean isDocument(Object aObject)
+ {
+ if (aObject instanceof DetailAST) {
+ final DetailAST node = (DetailAST) aObject;
+ return (node.getType() == TokenTypes.EOF);
+ }
+ else {
+ return false;
+ }
+ }
+
+ /**
+ * @see org.jaxen.DefaultNavigator#isElement(java.lang.Object)
+ */
+ public boolean isElement(Object aObject)
+ {
+ return aObject instanceof DetailAST;
+ }
+
+ /**
+ * @see org.jaxen.DefaultNavigator#isNamespace(java.lang.Object)
+ */
+ public boolean isNamespace(Object aObject)
+ {
+ return false;
+ }
+
+ /**
+ * @see org.jaxen.DefaultNavigator#isProcessingInstruction(java.lang.Object)
+ */
+ public boolean isProcessingInstruction(Object aObject)
+ {
+ return false;
+ }
+
+ /**
+ * @see org.jaxen.DefaultNavigator#isText(java.lang.Object)
+ */
+ public boolean isText(Object aObject)
+ {
+ return false;
+ }
+
+ /**
+ * @see org.jaxen.DefaultNavigator#parseXPath(java.lang.String)
+ */
+ public XPath parseXPath(String aObject)
+ throws SAXPathException
+ {
+ return null;
+ }
+
+ /**
+ * @see org.jaxen.Navigator#getParentNode(java.lang.Object)
+ */
+ public Object getParentNode(Object aObject)
+ {
+ if (aObject instanceof DetailAST) {
+ return ((DetailAST) aObject).getParent();
+ }
+ else {
+ return ((Attribute) aObject).getParent();
+ }
+ }
+
+ /**
+ * @see org.jaxen.Navigator#getAttributeAxisIterator(java.lang.Object)
+ */
+ public Iterator getAttributeAxisIterator(Object aObject)
+ {
+ final DetailAST contextNode = (DetailAST) aObject;
+ return new AttributeAxisIterator(contextNode);
+ }
+
+ /**
+ * Get an iterator over all of this node's children.
+ *
+ * @param aObject The context node for the child axis.
+ * @return A possibly-empty iterator (not null).
+ */
+ public Iterator getChildAxisIterator(Object aObject)
+ {
+ return new NodeIterator((DetailAST) aObject)
+ {
+ /** @see NodeIterator */
+ protected DetailAST getFirstNode(DetailAST aAST)
+ {
+ return getFirstChild(aAST);
+ }
+
+ /** @see NodeIterator */
+ protected DetailAST getNextNode(DetailAST aAST)
+ {
+ return getNextSibling(aAST);
+ }
+ };
+ }
+
+ /**
+ * Get a (single-member) iterator over this node's parent.
+ *
+ * @param aObject the context node for the parent axis.
+ * @return A possibly-empty iterator (not null).
+ */
+ public Iterator getParentAxisIterator(Object aObject)
+ {
+ if (isAttribute(aObject)) {
+ return new SingleObjectIterator(((Attribute) aObject).getParent());
+ }
+ else {
+ DetailAST parent = ((DetailAST) aObject).getParent();
+ if (parent != null) {
+ return new SingleObjectIterator(parent);
+ }
+ else {
+ return EMPTY_ITERATOR;
+ }
+ }
+ }
+
+ /**
+ * Get an iterator over all following siblings.
+ *
+ * @param aObject the context node for the sibling iterator.
+ * @return A possibly-empty iterator (not null).
+ */
+ public Iterator getFollowingSiblingAxisIterator(Object aObject)
+ {
+ return new NodeIterator((DetailAST) aObject)
+ {
+ /** @see NodeIterator */
+ protected DetailAST getFirstNode(DetailAST aAST)
+ {
+ return getNextNode(aAST);
+ }
+
+ /** @see NodeIterator */
+ protected DetailAST getNextNode(DetailAST aAST)
+ {
+ return getNextSibling(aAST);
+ }
+ };
+ }
+
+ /**
+ * Get an iterator over all preceding siblings.
+ *
+ * @param aObject The context node for the preceding sibling axis.
+ * @return A possibly-empty iterator (not null).
+ */
+ public Iterator getPrecedingSiblingAxisIterator(Object aObject)
+ {
+ return new NodeIterator((DetailAST) aObject)
+ {
+ /** @see NodeIterator */
+ protected DetailAST getFirstNode(DetailAST aAST)
+ {
+ return getNextNode(aAST);
+ }
+
+ /** @see NodeIterator */
+ protected DetailAST getNextNode(DetailAST aAST)
+ {
+ return getPreviousSibling(aAST);
+ }
+ };
+ }
+
+ /**
+ * Get an iterator over all following nodes, depth-first.
+ *
+ * @param aObject The context node for the following axis.
+ * @return A possibly-empty iterator (not null).
+ */
+ public Iterator getFollowingAxisIterator(Object aObject)
+ {
+ return new NodeIterator((DetailAST) aObject)
+ {
+ /** @see NodeIterator */
+ protected DetailAST getFirstNode(DetailAST aAST)
+ {
+ if (aAST == null) {
+ return null;
+ }
+ else {
+ final DetailAST sibling = getNextSibling(aAST);
+ if (sibling == null) {
+ return getFirstNode(aAST.getParent());
+ }
+ else {
+ return sibling;
+ }
+ }
+ }
+
+ /** @see NodeIterator */
+ protected DetailAST getNextNode(DetailAST aAST)
+ {
+ if (aAST == null) {
+ return null;
+ }
+ else {
+ DetailAST n = getFirstChild(aAST);
+ if (n == null) {
+ n = getNextSibling(aAST);
+ }
+ if (n == null) {
+ return getFirstNode(aAST.getParent());
+ }
+ else {
+ return n;
+ }
+ }
+ }
+ };
+ }
+
+ /**
+ * Get an iterator over all preceding nodes, depth-first.
+ *
+ * @param aObject The context node for the preceding axis.
+ * @return A possibly-empty iterator (not null).
+ */
+ public Iterator getPrecedingAxisIterator(Object aObject)
+ {
+ return new NodeIterator((DetailAST) aObject)
+ {
+ /** @see NodeIterator */
+ protected DetailAST getFirstNode(DetailAST aAST)
+ {
+ if (aAST == null) {
+ return null;
+ }
+ else {
+ final DetailAST sibling = getPreviousSibling(aAST);
+ if (sibling == null) {
+ return getFirstNode(aAST.getParent());
+ }
+ else {
+ return sibling;
+ }
+ }
+ }
+
+ /** @see NodeIterator */
+ protected DetailAST getNextNode(DetailAST aAST)
+ {
+ if (aAST == null) {
+ return null;
+ }
+ else {
+ DetailAST n = getLastChild(aAST);
+ if (n == null) {
+ n = getPreviousSibling(aAST);
+ }
+ if (n == null) {
+ return getFirstNode(aAST.getParent());
+ }
+ else {
+ return n;
+ }
+ }
+ }
+ };
+ }
+
+ /** @see org.jaxen.Navigator#getDocumentNode(java.lang.Object) */
+ public Object getDocumentNode(Object aObject)
+ {
+ if (isDocument(aObject)) {
+ return aObject;
+ }
+ else {
+ return getDocumentNode(getParentNode(aObject));
+ }
+ }
+}
diff --git a/thirdparty/checkstyle/contrib/examples/checks/com/puppycrawl/tools/checkstyle/checks/xpath/NodeIterator.java b/thirdparty/checkstyle/contrib/examples/checks/com/puppycrawl/tools/checkstyle/checks/xpath/NodeIterator.java
new file mode 100755
index 000000000..12bdcd972
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/examples/checks/com/puppycrawl/tools/checkstyle/checks/xpath/NodeIterator.java
@@ -0,0 +1,122 @@
+////////////////////////////////////////////////////////////////////////////////
+// checkstyle: Checks Java source code for adherence to a set of rules.
+// Copyright (C) 2001-2003 Oliver Burn
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+////////////////////////////////////////////////////////////////////////////////
+package com.puppycrawl.tools.checkstyle.checks.xpath;
+
+import java.util.Iterator;
+import java.util.NoSuchElementException;
+
+import com.puppycrawl.tools.checkstyle.api.DetailAST;
+
+/**
+ * Iterator for DetailAST nodes in a syntax tree.
+ * @author Rick Giles
+ */
+public abstract class NodeIterator
+ implements Iterator
+{
+
+ /** The DetailAST for this iterator */
+ private DetailAST mNode;
+
+ /**
+ * Constructs a <code>NodeIterator</code> for a DetailAST.
+ * @param aAST the DetailAST.
+ */
+ public NodeIterator(DetailAST aAST)
+ {
+ this.mNode = getFirstNode(aAST);
+ }
+
+ /** @see java.util.Iterator#hasNext() */
+ public boolean hasNext()
+ {
+ return mNode != null;
+ }
+
+ /** @see java.util.Iterator#next() */
+ public Object next()
+ {
+ if (mNode == null) {
+ throw new NoSuchElementException();
+ }
+ final DetailAST ret = mNode;
+ mNode = getNextNode(mNode);
+ return ret;
+ }
+
+ /** @see java.util.Iterator#remove() */
+ public void remove()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Gets the first node of an iterator over a DetailAST.
+ * @param aAST the DetailAST.
+ * @return the first node of an iterator over aAST.
+ */
+ protected abstract DetailAST getFirstNode(DetailAST aAST);
+
+ /**
+ * Gets the next node for an iterator over a DetailAST.
+ * @param aAST the DetailAST.
+ * @return the next node of aAST.
+ */
+ protected abstract DetailAST getNextNode(DetailAST aAST);
+
+ /**
+ * Gets the previous sibling of a DetailAST.
+ * @param aAST the DetailAST.
+ * @return the previous sibling of aAST.
+ */
+ protected DetailAST getPreviousSibling(DetailAST aAST)
+ {
+ return aAST.getPreviousSibling();
+ }
+
+ /**
+ * Get the next sibling of a DetailAST.
+ * @param aAST the DetailAST.
+ * @return the next sibling of aAST.
+ */
+ protected DetailAST getNextSibling(DetailAST aAST)
+ {
+ return (DetailAST) aAST.getNextSibling();
+ }
+
+ /**
+ * Get the first child of a DetailAST.
+ * @param aAST the DetailAST.
+ * @return the first child of aAST.
+ */
+ protected DetailAST getFirstChild(DetailAST aAST)
+ {
+ return (DetailAST) aAST.getFirstChild();
+ }
+
+ /**
+ * Get the last child of a DetailAST.
+ * @param aAST the DetailAST.
+ * @return the last child of aAST.
+ */
+ protected DetailAST getLastChild(DetailAST aAST)
+ {
+ return aAST.getLastChild();
+ }
+} \ No newline at end of file
diff --git a/thirdparty/checkstyle/contrib/examples/checks/com/puppycrawl/tools/checkstyle/checks/xpath/XPathCheck.java b/thirdparty/checkstyle/contrib/examples/checks/com/puppycrawl/tools/checkstyle/checks/xpath/XPathCheck.java
new file mode 100755
index 000000000..875255a16
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/examples/checks/com/puppycrawl/tools/checkstyle/checks/xpath/XPathCheck.java
@@ -0,0 +1,103 @@
+////////////////////////////////////////////////////////////////////////////////
+// checkstyle: Checks Java source code for adherence to a set of rules.
+// Copyright (C) 2001-2003 Oliver Burn
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+////////////////////////////////////////////////////////////////////////////////
+package com.puppycrawl.tools.checkstyle.checks.xpath;
+
+import java.util.Iterator;
+
+import org.jaxen.BaseXPath;
+import org.jaxen.JaxenException;
+import org.jaxen.XPath;
+
+import antlr.ASTFactory;
+
+import com.puppycrawl.tools.checkstyle.api.Check;
+import com.puppycrawl.tools.checkstyle.api.DetailAST;
+import com.puppycrawl.tools.checkstyle.api.TokenTypes;
+
+/**
+ * Checks for an XPath in the root AST. Path elements are named
+ * according to token types. Attributes of an element are bean
+ * properties.
+ * Requires jaxen, http://jaxen.sourceforge.net and
+ * saxpath, http://sourceforge.net/projects/saxpath/.
+ * Idea shamelessly stolen from the equivalent PMD rule (pmd.sourceforge.net).
+ * @author Rick Giles
+ */
+public class XPathCheck extends Check
+{
+ /** XPath for this check */
+ private XPath mXPath;
+
+ /** error message */
+ private String mMessage = "illegal.xpath";
+
+ /** @see com.puppycrawl.tools.checkstyle.api.Check#getDefaultTokens() */
+ public int[] getDefaultTokens()
+ {
+ return new int[0];
+ }
+
+ /** @see com.puppycrawl.tools.checkstyle.api.Check */
+ public void beginTree(DetailAST aAST)
+ {
+ if (mXPath != null) {
+ final ASTFactory factory = new ASTFactory();
+ factory.setASTNodeType(DetailAST.class.getName());
+ // TODO: Need to resolve if need a fake root node....
+ final DetailAST root =
+ (DetailAST) factory.create(TokenTypes.EOF, "ROOT");
+ root.setFirstChild(aAST);
+ try {
+ final Iterator it = mXPath.selectNodes(aAST).iterator();
+ while (it.hasNext()) {
+ final DetailAST node = (DetailAST) it.next();
+ log(
+ node.getLineNo(),
+ node.getColumnNo(),
+ mMessage,
+ new String[] {node.getText()});
+ }
+ }
+ catch (JaxenException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ }
+
+ /**
+ * Sets the error message for this check.
+ * @param aMessage error message for this check.
+ */
+ public void setMessage(String aMessage)
+ {
+ mMessage = aMessage;
+ }
+
+ /**
+ * Sets the XPath for this check.
+ * @param aXPath the XPath for this check.
+ * @throws JaxenException if there is an error.
+ */
+ public void setXPath(String aXPath)
+ throws JaxenException
+ {
+ mXPath = new BaseXPath(aXPath, new DocumentNavigator());
+ }
+}
diff --git a/thirdparty/checkstyle/contrib/examples/checks/com/puppycrawl/tools/checkstyle/checks/xpath/jaxen_LICENSE.txt b/thirdparty/checkstyle/contrib/examples/checks/com/puppycrawl/tools/checkstyle/checks/xpath/jaxen_LICENSE.txt
new file mode 100755
index 000000000..d38f80e8c
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/examples/checks/com/puppycrawl/tools/checkstyle/checks/xpath/jaxen_LICENSE.txt
@@ -0,0 +1,56 @@
+/*--
+
+ $Id: jaxen_LICENSE.txt,v 1.1 2003-07-23 14:22:41 rickgiles Exp $
+
+ Copyright (C) 2000-2002 bob mcwhirter & James Strachan.
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions, and the disclaimer that follows
+ these conditions in the documentation and/or other materials
+ provided with the distribution.
+
+ 3. The name "Jaxen" must not be used to endorse or promote products
+ derived from this software without prior written permission. For
+ written permission, please contact license@jaxen.org.
+
+ 4. Products derived from this software may not be called "Jaxen", nor
+ may "Jaxen" appear in their name, without prior written permission
+ from the Jaxen Project Management (pm@jaxen.org).
+
+ In addition, we request (but do not require) that you include in the
+ end-user documentation provided with the redistribution and/or in the
+ software itself an acknowledgement equivalent to the following:
+ "This product includes software developed by the
+ Jaxen Project (http://www.jaxen.org/)."
+ Alternatively, the acknowledgment may be graphical using the logos
+ available at http://www.jaxen.org/
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ DISCLAIMED. IN NO EVENT SHALL THE Jaxen AUTHORS OR THE PROJECT
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ SUCH DAMAGE.
+
+ This software consists of voluntary contributions made by many
+ individuals on behalf of the Jaxen Project and was originally
+ created by bob mcwhirter <bob@werken.com> and
+ James Strachan <jstrachan@apache.org>. For more information on the
+ Jaxen Project, please see <http://www.jaxen.org/>.
+
+ */
+
diff --git a/thirdparty/checkstyle/contrib/examples/checks/com/puppycrawl/tools/checkstyle/checks/xpath/messages.properties b/thirdparty/checkstyle/contrib/examples/checks/com/puppycrawl/tools/checkstyle/checks/xpath/messages.properties
new file mode 100755
index 000000000..813e980da
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/examples/checks/com/puppycrawl/tools/checkstyle/checks/xpath/messages.properties
@@ -0,0 +1,6 @@
+block.empty=Empty {0} block.
+hex.case.constant="Case constant ''{0}'' must not start with ''0x'' or ''0X''.
+needBraces=''{0}'' construct must use '''{}'''s.
+short.variable.name=Short variable name ''{0}''.
+string.conditional=String literal {0} must not be an operand.
+
diff --git a/thirdparty/checkstyle/contrib/examples/checks/com/puppycrawl/tools/checkstyle/checks/xpath/package.html b/thirdparty/checkstyle/contrib/examples/checks/com/puppycrawl/tools/checkstyle/checks/xpath/package.html
new file mode 100755
index 000000000..db5f95c86
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/examples/checks/com/puppycrawl/tools/checkstyle/checks/xpath/package.html
@@ -0,0 +1,10 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head></head>
+
+<body>
+
+<p>Contains a Check for XPath semantics in a syntac tree.</p>
+
+</body>
+</html>
diff --git a/thirdparty/checkstyle/contrib/examples/checks/com/puppycrawl/tools/checkstyle/checks/xpath/saxpath_LICENSE.txt b/thirdparty/checkstyle/contrib/examples/checks/com/puppycrawl/tools/checkstyle/checks/xpath/saxpath_LICENSE.txt
new file mode 100755
index 000000000..ad03b6aee
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/examples/checks/com/puppycrawl/tools/checkstyle/checks/xpath/saxpath_LICENSE.txt
@@ -0,0 +1,60 @@
+/*
+ * $Header: /opt/shared/tmp/checkstyle-cvsbackup/checkstyle/contrib/examples/checks/com/puppycrawl/tools/checkstyle/checks/xpath/saxpath_LICENSE.txt,v 1.1 2003-07-23 14:22:41 rickgiles Exp $
+ * $Revision: 1.1 $
+ * $Date: 2003-07-23 14:22:41 $
+ *
+ * ====================================================================
+ *
+ * Copyright (C) 2000-2002 werken digital.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions, and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions, and the disclaimer that follows
+ * these conditions in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. The name "SAXPath" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact license@saxpath.org.
+ *
+ * 4. Products derived from this software may not be called "SAXPath", nor
+ * may "SAXPath" appear in their name, without prior written permission
+ * from the SAXPath Project Management (pm@saxpath.org).
+ *
+ * In addition, we request (but do not require) that you include in the
+ * end-user documentation provided with the redistribution and/or in the
+ * software itself an acknowledgement equivalent to the following:
+ * "This product includes software developed by the
+ * SAXPath Project (http://www.saxpath.org/)."
+ * Alternatively, the acknowledgment may be graphical using the logos
+ * available at http://www.saxpath.org/
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE SAXPath AUTHORS OR THE PROJECT
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * ====================================================================
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the SAXPath Project and was originally
+ * created by bob mcwhirter <bob@werken.com> and
+ * James Strachan <jstrachan@apache.org>. For more information on the
+ * SAXPath Project, please see <http://www.saxpath.org/>.
+ *
+ * $Id: saxpath_LICENSE.txt,v 1.1 2003-07-23 14:22:41 rickgiles Exp $
+ */
diff --git a/thirdparty/checkstyle/contrib/examples/checks/com/puppycrawl/tools/checkstyle/checks/xpath/xpath_config.xml b/thirdparty/checkstyle/contrib/examples/checks/com/puppycrawl/tools/checkstyle/checks/xpath/xpath_config.xml
new file mode 100755
index 000000000..e4fd615f2
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/examples/checks/com/puppycrawl/tools/checkstyle/checks/xpath/xpath_config.xml
@@ -0,0 +1,44 @@
+<?xml version="1.0"?>
+<!DOCTYPE module PUBLIC
+ "-//Puppy Crawl//DTD Check Configuration 1.1//EN"
+ "http://www.puppycrawl.com/dtds/configuration_1_1.dtd">
+<module name="Checker">
+ <metadata name="com.atlas-sw.eclipse" value="I like Sydney"/>
+ <property name="severity" value="error"/>
+ <module name="TreeWalker">
+ <!-- empty if statement -->
+ <module name="xpath.XPath">
+ <property name="XPath" value="//LITERAL_IF/SLIST[count(*) = 1]"/>
+ <property name="message" value="block.empty"/>
+ </module>
+
+ <!-- if statement must use braces-->
+ <module name="xpath.XPath">
+ <property name="XPath" value="//LITERAL_IF[not(SLIST)]"/>
+ <property name="message" value="needBraces"/>
+ </module>
+
+ <!-- String conditional -->
+ <module name="xpath.XPath">
+ <property name="XPath" value="//EQUAL/STRING_LITERAL"/>
+ <property name="message" value="string.conditional"/>
+ </module>
+ <module name="xpath.XPath">
+ <property name="XPath" value="//NOT_EQUAL/STRING_LITERAL"/>
+ <property name="message" value="string.conditional"/>
+ </module>
+
+ <!-- Short variable name -->
+ <module name="xpath.XPath">
+ <property name="XPath" value="//VARIABLE_DEF/IDENT[string-length(@text) &lt; 3][not(ancestor::FOR_INIT)]"/>
+ <property name="message" value="short.variable.name"/>
+ </module>
+
+ <!-- Hex case constant -->
+ <module name="xpath.XPath">
+ <property name="XPath" value="//LITERAL_CASE/EXPR/*[starts-with(@text,&quot;0x&quot;) or starts-with(@text,&quot;0X&quot;)]"/>
+ <property name="message" value="hex.case.constant"/>
+ </module>
+ </module>
+</module>
+
diff --git a/thirdparty/checkstyle/contrib/examples/checks/mycompany_conf.xml b/thirdparty/checkstyle/contrib/examples/checks/mycompany_conf.xml
new file mode 100755
index 000000000..56bf57484
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/examples/checks/mycompany_conf.xml
@@ -0,0 +1,44 @@
+<?xml version="1.0"?>
+<!DOCTYPE module PUBLIC
+ "-//Puppy Crawl//DTD Check Configuration 1.1//EN"
+ "http://www.puppycrawl.com/dtds/configuration_1_1.dtd">
+
+<!--
+
+ A Checkstyle configuration that demonstrates the integeration
+ of user checks.
+
+-->
+
+<module name="Checker">
+
+ <!-- Add the TreeWalker that is required as a container for Checks -->
+ <module name="TreeWalker">
+
+ <!--
+ register our Check class twice with different
+ configurations for different tokens
+ -->
+
+ <!-- interfaces are limited to 10 methods -->
+ <module name="com.mycompany.checks.MethodLimitCheck">
+ <property name="tokens" value="INTERFACE_DEF"/>
+ <property name="max" value="10"/>
+ </module>
+
+ <!-- classes are limited to 25 methods -->
+ <module name="com.mycompany.checks.MethodLimitCheck">
+ <property name="tokens" value="CLASS_DEF"/>
+ <property name="max" value="25"/>
+ </module>
+
+ </module>
+
+
+ <!-- register our FileSetCheck -->
+ <module name="com.mycompany.checks.LimitImplementationFiles">
+ <!-- here you could also set the "max" property, just like in the examples above -->
+ </module>
+
+
+</module>
diff --git a/thirdparty/checkstyle/contrib/examples/conf/BlochEffectiveJava.xml b/thirdparty/checkstyle/contrib/examples/conf/BlochEffectiveJava.xml
new file mode 100755
index 000000000..08f894369
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/examples/conf/BlochEffectiveJava.xml
@@ -0,0 +1,113 @@
+<?xml version="1.0"?>
+<!DOCTYPE module PUBLIC
+ "-//Puppy Crawl//DTD Check Configuration 1.1//EN"
+ "http://www.puppycrawl.com/dtds/configuration_1_1.dtd">
+
+<!--
+
+ A Checkstyle configuration that checks against the recommendations
+ in Joshua Bloch, Effective Java (highliy recommended read!)
+
+ This file does NOT duplicate the checks for whitespace settings,
+ placement of curly braces, etc. Only the rules that are explicitly
+ mentioned in the book are enforced.
+
+ Currently the amount of rules that can be automatically checked by
+ Checkstyle is not very large, but adding more checks of this quality
+ is a high priority goal for the development team.
+
+-->
+
+<module name="Checker">
+
+ <module name="TreeWalker">
+
+ <!-- Item 4 - Avoid creating duplicate objects -->
+ <module name="IllegalInstantiation">
+ <property name="classes" value="java.lang.Boolean, java.lang.String"/>
+ </module>
+
+ <!-- Item 6 - Avoid finalizers -->
+ <!-- this will not find violations that contain linebreaks -->
+ <module name="GenericIllegalRegexp">
+ <property name="format"
+ value="((public)|(protected))\s+void\s+finalize\(\s*\)"/>
+ </module>
+
+ <!-- Item 8 - Always override hashCode when you override equals -->
+ <module name="EqualsHashCode"/>
+
+ <!-- Item 12 - Make all fields private -->
+ <module name="VisibilityModifier"/>
+
+ <!-- Item 15 - Design and document for inheritance or else prohibit it -->
+ <!-- the module actually implements a very strict rule, it would be
+ interesting to know whether Joshua meant what checkstyle implements.
+ We feel this implementation is well suited as a warning,
+ i.e. if you get error messages from this check you should be
+ able to name a good reason to implement your code the way you do it,
+ especially if you are designing a library and not an application. -->
+ <module name="DesignForExtension">
+ <property name="severity" value="warning"/>
+ </module>
+
+ <!-- Item 17 - Use interfaces only to define types -->
+ <module name="InterfaceIsType"/>
+
+ <!-- Item 25 - Design method signatures carefully -->
+ <!-- Avoid long parameter lists -->
+ <module name="ParameterNumber">
+ <property name="max" value="3"/>
+ </module>
+
+ <!-- Item 26 - Use overloading judiciously -->
+ <!-- rfe #659735 -->
+
+ <!-- Item 27 - Return zero-length array, not nulls -->
+ <!-- no rfe yet -->
+
+ <!-- Item 28 - Write doc comments for all exposed API elements -->
+ <module name="JavadocType">
+ <property name="scope" value="protected"/>
+ </module>
+ <module name="JavadocMethod"> <!-- also covers Item 44 -->
+ <property name="scope" value="protected"/>
+ </module>
+ <module name="JavadocVariable">
+ <property name="scope" value="protected"/>
+ </module>
+
+ <!-- Item 29 - Minimize the scope of local variables -->
+ <!-- no rfe yet -->
+
+
+ <!-- Item 38 - Adhere to generally accepted naming conventions -->
+ <module name="PackageName">
+ <!-- no uppercase letters, between 2 and 8 characters -->
+ <property name="format" value="^[a-z]+(\.[a-z][a-z0-9]{1,7})*$"/>
+ </module>
+ <module name="TypeName"/>
+ <module name="ConstantName"/>
+ <module name="LocalFinalVariableName"/>
+ <module name="LocalVariableName"/>
+ <module name="MemberName"/>
+ <module name="MethodName"/>
+ <module name="ParameterName"/>
+ <module name="StaticVariableName"/>
+
+ <!-- Item 47 - Don't ignore exceptions -->
+ <module name="EmptyBlock">
+ <property name="tokens" value="LITERAL_CATCH"/>
+ <!-- require a comment, change to stmt to require a statement -->
+ <property name="option" value="text"/>
+ </module>
+
+ <!-- Item 50 - Never invoke wait outside a loop -->
+ <!-- rfe #712798 -->
+
+ <!-- Item 57 - Provide a readResolve method when necessary -->
+ <!-- no rfe yet -->
+
+ </module>
+
+</module>
diff --git a/thirdparty/checkstyle/contrib/examples/conf/openorb.xml b/thirdparty/checkstyle/contrib/examples/conf/openorb.xml
new file mode 100755
index 000000000..7ec6dcfef
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/examples/conf/openorb.xml
@@ -0,0 +1,139 @@
+<?xml version="1.0"?>
+<!DOCTYPE module PUBLIC
+ "-//Puppy Crawl//DTD Check Configuration 1.1//EN"
+ "http://www.puppycrawl.com/dtds/configuration_1_1.dtd">
+
+<!--
+
+ A Checkstyle configuration that checks the coding conventions of
+ the Community OpenORB project (openorb.sourceforge.net)
+
+ Many Apache Jakarta projects like
+ Avalon or Turbine use very similar conventions.
+
+ Interesting techniques in this configuration:
+ - use property expansion to find the header file
+ - multiple instantiation of the MethodLengthCheck for different Token types
+
+ This configuration includes rules taken from
+
+ the Java Language Specification at
+ http://java.sun.com/docs/books/jls/second_edition/html/index.html
+
+ the Sun Code Conventions at
+ http://java.sun.com/docs/codeconv/
+
+ the Javadoc guidelines at
+ http://java.sun.com/j2se/javadoc/writingdoccomments/index.html
+
+ the JDK Api documentation
+ http://java.sun.com/j2se/docs/api/index.html
+
+ the OpenORB coding conventions at
+ http://jakarta.apache.org/turbine/common/code-standards.html
+
+ some best practices
+
+-->
+
+<module name="Checker">
+
+ <property name="basedir" value="${basedir}"/>
+
+ <module name="TreeWalker">
+
+ <!-- naming conventions, the CORBA spec includes method names with underscores so we allow them here -->
+ <module name="ConstantName"> <property name="format" value="^[A-Z](_?[A-Z0-9]+)*$"/></module>
+ <module name="MethodName"> <property name="format" value="^[a-z](_?[a-zA-Z0-9]+)*$"/></module>
+ <module name="LocalFinalVariableName"> <property name="format" value="^[a-z](_?[a-zA-Z0-9]+)*$"/></module>
+ <module name="LocalVariableName"> <property name="format" value="^[a-z](_?[a-zA-Z0-9]+)*$"/></module>
+ <module name="MemberName"> <property name="format" value="^m_[a-z](_?[a-zA-Z0-9])*$"/></module>
+ <module name="ParameterName"> <property name="format" value="^[a-z](_?[a-zA-Z0-9]+)*$"/></module>
+ <module name="TypeName"> <property name="format" value="^[A-Z][a-zA-Z0-9]*$"/></module>
+ <module name="StaticVariableName"> <property name="format" value="^s_[a-z](_?[a-zA-Z0-9])*$"/></module>
+ <module name="PackageName"> <property name="format" value="^[a-z]+(\.[a-zA-Z_][a-zA-Z_0-9]*)*$"/></module>
+
+ <!-- code layout -->
+ <module name="LeftCurly"> <property name="option" value="nl"/></module>
+ <module name="RightCurly"> <property name="option" value="alone"/></module>
+ <module name="NeedBraces"/>
+ <module name="OperatorWrap"/>
+
+ <!-- whitespace settings -->
+ <module name="NoWhitespaceAfter"/>
+ <module name="NoWhitespaceBefore"/>
+ <module name="WhitespaceAfter"/>
+ <module name="WhitespaceAround"/>
+
+
+
+ <!-- JavaDoc guidelines -->
+ <!-- <module name="JavadocMethod"><property name="scope" value="protected"/></module> -->
+ <!-- <module name="JavadocVariable"><property name="scope" value="protected"/></module> -->
+ <module name="JavadocType">
+ <property name="scope" value="protected"/>
+ <property name="authorFormat" value="^.+$"/> <!-- don't require email to avoid spam -->
+ <property name="versionFormat" value="^\$Revision.*\$$"/> <!-- CVS Keyword -->
+ </module>
+
+
+
+ <!-- JLS -->
+ <module name="RedundantModifier"/>
+ <module name="ModifierOrder"/>
+ <module name="UpperEll"/>
+
+
+
+ <!-- Api Doc -->
+
+ <!-- override hashCode whenever you override equals() -->
+ <module name="EqualsHashCode"/>
+
+ <!-- don't create new instances of Boolean, use Boolean.TRUE/FALSE or Boolean.valueOf() instead -->
+ <module name="IllegalInstantiation"><property name="classes" value="java.lang.Boolean"/></module>
+
+
+
+ <!-- best practices -->
+
+ <!-- don't allow empty blocks (in particular catch blocks) -->
+ <module name="EmptyBlock"><property name="option" value="text"/></module>
+
+ <!-- avoid inner assignments -->
+ <module name="InnerAssignment"/>
+
+ <!-- don't allow imports from the sun.* package hierarchy -->
+ <module name="IllegalImport"/>
+
+ <!-- don't allow public members except in private record like classes,
+ the members have special names there -->
+ <module name="VisibilityModifier"><property name="publicMemberPattern" value ="^f[a-zA-Z0-9]*$"/></module>
+
+ <!-- simplify your code -->
+ <module name="RedundantImport"/>
+ <module name="UnusedImports"/>
+ <module name="SimplifyBooleanExpression"/>
+ <module name="SimplifyBooleanReturn"/>
+
+ <!-- flag reminder comments -->
+ <module name="TodoComment"/>
+
+ <!-- enforce length limits, different settings for method and ctor length -->
+ <module name="LineLength"><property name="max" value="100"/></module>
+ <module name="MethodLength"><property name="tokens" value="METHOD_DEF"/><property name="max" value="300"/></module>
+ <module name="MethodLength"><property name="tokens" value="CTOR_DEF"/><property name="max" value="500"/></module>
+ <module name="FileLength"><property name="max" value="2800"/></module>
+
+ <!-- don't allow tabs -->
+ <module name="TabCharacter"/>
+
+ <!-- enforce License Header -->
+ <module name="Header"><property name="headerFile" value="${basedir}/../../tools/etc/LICENSE.txt"/></module>
+
+ </module>
+
+ <!-- enforce package documentation -->
+ <module name="PackageHtml"/>
+
+</module>
diff --git a/thirdparty/checkstyle/contrib/examples/conf/template_config.xml b/thirdparty/checkstyle/contrib/examples/conf/template_config.xml
new file mode 100755
index 000000000..4bc4b7273
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/examples/conf/template_config.xml
@@ -0,0 +1,788 @@
+<?xml version="1.0"?>
+<!--
+ CheckStyle 3.4 template configuration file
+ @author Oleg Estehin
+-->
+
+<!DOCTYPE module PUBLIC
+ "-//Puppy Crawl//DTD Check Configuration 1.1//EN"
+ "http://www.puppycrawl.com/dtds/configuration_1_1.dtd">
+
+<module name="Checker">
+
+ <!-- See http://checkstyle.sf.net/config_javadoc.html#PackageHtml -->
+ <!-- Checks that a package.html file exists for each package. -->
+ <!-- <property name="fileExtensions" value="java"/> -->
+ <module name="PackageHtml">
+ </module>
+
+ <module name="TreeWalker">
+
+ <!-- See http://checkstyle.sf.net/config_javadoc.html#JavadocType -->
+ <!-- Checks Javadoc comments for class and interface definitions. -->
+ <!-- <property name="scope" value="private"/> -->
+ <!-- <property name="excludeScope" value=""/> -->
+ <!-- <property name="authorFormat" value=""/> -->
+ <!-- <property name="versionFormat" value=""/> -->
+ <!-- <property name="tokens" value="INTERFACE_DEF, CLASS_DEF"/> -->
+ <module name="JavadocType">
+ </module>
+
+ <!-- See http://checkstyle.sf.net/config_javadoc.html#JavadocMethod -->
+ <!-- Checks to ensure that the javadoc tags exist (if required) -->
+ <!-- <property name="scope" value="private"/> -->
+ <!-- <property name="excludeScope" value=""/> -->
+ <!-- <property name="allowUndeclaredRTE" value="false"/> -->
+ <!-- <property name="allowThrowsTagsForSubclasses" value="false"/> -->
+ <!-- <property name="allowMissingParamTags" value="false"/> -->
+ <!-- <property name="allowMissingThrowsTags" value="false"/> -->
+ <!-- <property name="allowMissingReturnTag" value="false"/> -->
+ <!-- <property name="tokens" value="METHOD_DEF, CTOR_DEF"/> -->
+ <module name="JavadocMethod">
+ </module>
+
+ <!-- See http://checkstyle.sf.net/config_javadoc.html#JavadocVariable -->
+ <!-- Checks that variables have Javadoc comments. -->
+ <!-- <property name="scope" value="private"/> -->
+ <!-- <property name="excludeScope" value=""/> -->
+ <module name="JavadocVariable">
+ </module>
+
+ <!-- See http://checkstyle.sf.net/config_javadoc.html#JavadocStyle -->
+ <!-- Validates Javadoc comments to help ensure they are well formed. -->
+ <!-- <property name="scope" value="private"/> -->
+ <!-- <property name="excludeScope" value=""/> -->
+ <!-- <property name="checkFirstSentence" value="true"/> -->
+ <!-- <property name="checkEmptyJavadoc" value="false"/> -->
+ <!-- <property name="checkHtml" value="true"/> -->
+ <!-- <property name="tokens" value="INTERFACE_DEF, CLASS_DEF,
+ METHOD_DEF, CTOR_DEF, VARIABLE_DEF"/> -->
+ <module name="JavadocStyle">
+ </module>
+
+
+ <!-- See http://checkstyle.sf.net/config_naming.html -->
+ <!-- Checks for Naming Conventions. -->
+ <!-- <property name="format" value="^Abstract.*$|^.*Factory$"/> -->
+ <module name="AbstractClassName">
+ </module>
+
+ <!-- See http://checkstyle.sf.net/config_naming.html -->
+ <!-- Checks for Naming Conventions. -->
+ <!-- <property name="format" value="^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$"/> -->
+ <module name="ConstantName">
+ </module>
+
+ <!-- See http://checkstyle.sf.net/config_naming.html -->
+ <!-- Checks for Naming Conventions. -->
+ <!-- <property name="format" value="^[a-z][a-zA-Z0-9]*$"/> -->
+ <!-- <property name="tokens" value="VARIABLE_DEF, PARAMETER_DEF"/> -->
+ <module name="LocalFinalVariableName">
+ </module>
+
+ <!-- See http://checkstyle.sf.net/config_naming.html -->
+ <!-- Checks for Naming Conventions. -->
+ <!-- <property name="format" value="^[a-z][a-zA-Z0-9]*$"/> -->
+ <module name="LocalVariableName">
+ </module>
+
+ <!-- See http://checkstyle.sf.net/config_naming.html -->
+ <!-- Checks for Naming Conventions. -->
+ <module name="MemberName">
+ <!-- <property name="format" value="^[a-z][a-zA-Z0-9]*$"/> -->
+ </module>
+
+ <!-- See http://checkstyle.sf.net/config_naming.html -->
+ <!-- Checks for Naming Conventions. -->
+ <!-- <property name="format" value="^[a-z][a-zA-Z0-9]*$"/> -->
+ <module name="MethodName">
+ </module>
+
+ <!-- See http://checkstyle.sf.net/config_naming.html -->
+ <!-- Checks for Naming Conventions. -->
+ <!-- <property name="format" value="^[a-z]+(\.[a-zA-Z_][a-zA-Z0-9_]*)*$"/> -->
+ <module name="PackageName">
+ </module>
+
+ <!-- See http://checkstyle.sf.net/config_naming.html -->
+ <!-- Checks for Naming Conventions. -->
+ <!-- <property name="format" value="^[a-z][a-zA-Z0-9]*$"/> -->
+ <module name="ParameterName">
+ </module>
+
+ <!-- See http://checkstyle.sf.net/config_naming.html -->
+ <!-- Checks for Naming Conventions. -->
+ <!-- <property name="format" value="^[a-z][a-zA-Z0-9]*$"/> -->
+ <module name="StaticVariableName">
+ </module>
+
+ <!-- See http://checkstyle.sf.net/config_naming.html -->
+ <!-- Checks for Naming Conventions. -->
+ <!-- <property name="format" value="^[a-z][a-zA-Z0-9]*$"/> -->
+ <!-- <property name="tokens" value="CLASS_DEF, INTERFACE_DEF"/> -->
+ <!-- <property name="applyToPublic" value="true"/> -->
+ <!-- <property name="applyToProtected" value="true"/> -->
+ <!-- <property name="applyToPackage" value="true"/> -->
+ <!-- <property name="applyToPrivate" value="true"/> -->
+ <module name="TypeName">
+ </module>
+
+
+ <!-- See http://checkstyle.sf.net/config_header.html -->
+ <!-- Checks that a source file begins with a specified header. -->
+ <!-- <property name="headerFile" value=""/> -->
+ <!-- <property name="ignoreLines" value=""/> -->
+<!--
+ <module name="Header">
+ </module>
+-->
+
+ <!-- See http://checkstyle.sf.net/config_header.html -->
+ <!-- Checks the header of a source file against a header file that
+ contains a regular expression for each line of the source header. -->
+ <!-- <property name="headerFile" value=""/> -->
+ <!-- <property name="multiLines" value=""/> -->
+<!--
+ <module name="RegexpHeader">
+ </module>
+-->
+
+
+ <!-- See http://checkstyle.sf.net/config_import.html -->
+ <!-- Checks that there are no import statements that use the * notation. -->
+ <!-- <property name="excludes" value=""/> -->
+ <module name="AvoidStarImport">
+ </module>
+
+ <!-- See http://checkstyle.sf.net/config_import.html -->
+ <!-- Checks for imports from a set of illegal packages. -->
+ <!-- <property name="illegalPkgs" value="sun"/> -->
+ <module name="IllegalImport">
+ </module>
+
+ <!-- See http://checkstyle.sf.net/config_import.html -->
+ <!-- Checks for redundant import statements. -->
+ <module name="RedundantImport">
+ </module>
+
+ <!-- See http://checkstyle.sf.net/config_import.html -->
+ <!-- Checks for unused import statements. -->
+ <module name="UnusedImports">
+ </module>
+
+ <!-- See http://checkstyle.sf.net/config_import.html -->
+ <!-- Checks the ordering/grouping of imports. -->
+ <!-- <property name="groups" value=""/> -->
+ <!-- <property name="ordered" value="true"/> -->
+ <!-- <property name="separated" value="false"/> -->
+ <!-- <property name="caseSensitive" value="true"/> -->
+ <module name="ImportOrder">
+ </module>
+
+
+ <!-- See http://checkstyle.sf.net/config_sizes.html -->
+ <!-- Restricts the number of executable statements to a specified
+ limit. -->
+ <!-- <property name="max" value="30"/> -->
+ <!-- <property name="tokens" value="CTOR_DEF, METHOD_DEF, INSTANCE_INIT, STATIC_INIT"/> -->
+ <module name="ExecutableStatementCount">
+ </module>
+
+ <!-- See http://checkstyle.sf.net/config_sizes.html -->
+ <!-- Checks for long source files. -->
+ <!-- <property name="max" value="2000"/> -->
+ <module name="FileLength">
+ </module>
+
+ <!-- See http://checkstyle.sf.net/config_sizes.html -->
+ <!-- Checks for long lines. -->
+ <!-- <property name="ignorePattern" value="^$"/> -->
+ <!-- <property name="max" value="80"/> -->
+ <module name="LineLength">
+ </module>
+
+ <!-- See http://checkstyle.sf.net/config_sizes.html -->
+ <!-- Checks for long methods and constructors. -->
+ <!-- <property name="max" value="150"/> -->
+ <!-- <property name="countEmpty" value="true"/> -->
+ <!-- <property name="tokens" value="METHOD_DEF, CTOR_DEF"/> -->
+ <module name="MethodLength">
+ </module>
+
+ <!-- See http://checkstyle.sf.net/config_sizes.html -->
+ <!-- Checks for long anonymous inner classes. -->
+ <!-- <property name="max" value="20"/> -->
+ <module name="AnonInnerLength">
+ </module>
+
+ <!-- See http://checkstyle.sf.net/config_sizes.html -->
+ <!-- Checks the number of parameters of a method or constructor. -->
+ <!-- <property name="max" value="7"/> -->
+ <!-- <property name="tokens" value="METHOD_DEF, CTOR_DEF"/> -->
+ <module name="ParameterNumber">
+ </module>
+
+
+ <!-- See http://checkstyle.sf.net/config_whitespace.html -->
+ <!-- Checks the padding of an empty for initializer. -->
+ <!-- <property name="option" value="nospace"/> -->
+ <module name="EmptyForInitializerPad">
+ </module>
+
+ <!-- See http://checkstyle.sf.net/config_whitespace.html -->
+ <!-- Checks the padding of an empty for iterator. -->
+ <!-- <property name="option" value="nospace"/> -->
+ <module name="EmptyForIteratorPad">
+ </module>
+
+ <!-- See http://checkstyle.sf.net/config_whitespace.html -->
+ <!-- Checks the padding between the identifier of a method definition,
+ constructor definition, method call, or constructor invocation; and
+ the left parenthesis of the parameter list. -->
+ <!-- <property name="allowLineBreaks" value="true"/> -->
+ <!-- <property name="tokens" value="CTOR_DEF, LITERAL_NEW,
+ METHOD_CALL, METHOD_DEF, SUPER_CTOR_CALL "/> -->
+ <module name="MethodParamPad">
+ </module>
+
+ <!-- See http://checkstyle.sf.net/config_whitespace.html -->
+ <!-- Checks that there is no whitespace after a token. -->
+ <!-- <property name="allowLineBreaks" value="true"/> -->
+ <!-- <property name="tokens" value="ARRAY_INIT, BNOT, DEC, DOT, INC,
+ LNOT, UNARY_MINUS, UNARY_PLUS"/> -->
+ <module name="NoWhitespaceAfter">
+ </module>
+
+ <!-- See http://checkstyle.sf.net/config_whitespace.html -->
+ <!-- Checks that there is no whitespace before a token. -->
+ <!-- <property name="allowLineBreaks" value="false"/> -->
+ <!-- <property name="tokens" value="SEMI, DOT, POST_DEC, POST_INC"/> -->
+ <module name="NoWhitespaceBefore">
+ </module>
+
+ <!-- See http://checkstyle.sf.net/config_whitespace.html -->
+ <!-- Checks the policy on how to wrap lines on operators. -->
+ <!-- <property name="option" value="nl"/> -->
+ <!-- <property name="tokens" value="ASSIGN, BAND, BAND_ASSIGN, BOR,
+ BOR_ASSIGN, BSR, BSR_ASSIGN, BXOR, BXOR_ASSIGN, COLON, DIV,
+ DIV_ASSIGN, EQUAL, GE, GT, LAND, LE, LITERAL_INSTANCEOF,
+ LOR, LT, MINUS, MINUS_ASSIGN, MOD, MOD_ASSIGN, NOT_EQUAL,
+ PLUS, PLUS_ASSIGN, QUESTION, SL, SL_ASSIGN, SR, SR_ASSIGN,
+ STAR, STAR_ASSIGN"/> -->
+ <module name="OperatorWrap">
+ </module>
+
+ <!-- See http://checkstyle.sf.net/config_whitespace.html -->
+ <!-- Checks the policy on the padding of parentheses. -->
+ <!-- <property name="option" value="nospace"/> -->
+ <!-- <property name="tokens" value="CTOR_CALL, LPAREN, METHOD_CALL,
+ RPAREN, SUPER_CTOR_CALL"/> -->
+ <module name="ParenPad">
+ </module>
+
+ <!-- See http://checkstyle.sf.net/config_whitespace.html -->
+ <!-- Checks the policy on the padding of parentheses for typecasts. -->
+ <!-- <property name="option" value="nospace"/> -->
+ <!-- <property name="tokens" value="TYPECAST, RPAREN"/> -->
+ <module name="TypecastParenPad">
+ </module>
+
+ <!-- See http://checkstyle.sf.net/config_whitespace.html -->
+ <!-- Checks that there are no tab characters ('\t') in the source
+ code. -->
+ <module name="TabCharacter">
+ </module>
+
+ <!-- See http://checkstyle.sf.net/config_whitespace.html -->
+ <!-- Checks that a token is followed by whitespace. -->
+ <!-- <property name="tokens" value="COMMA, SEMI, TYPECAST"/> -->
+ <module name="WhitespaceAfter">
+ </module>
+
+ <!-- See http://checkstyle.sf.net/config_whitespace.html -->
+ <!-- Checks that a token is surrounded by whitespace. -->
+ <!-- <property name="tokens" value="ASSIGN, BAND, BAND_ASSIGN, BOR,
+ BOR_ASSIGN, BSR, BSR_ASSIGN, BXOR, BXOR_ASSIGN, COLON, DIV,
+ DIV_ASSIGN, EQUAL, GE, GT, LAND, LCURLY, LE, LITERAL_ASSERT,
+ LITERAL_CATCH, LITERAL_DO, LITERAL_ELSE, LITERAL_FINALLY,
+ LITERAL_FOR, LITERAL_IF, LITERAL_RETURN,
+ LITERAL_SYNCHRONIZED, LITERAL_TRY, LITERAL_WHILE, LOR, LT,
+ MINUS, MINUS_ASSIGN, MOD, MOD_ASSIGN, NOT_EQUAL, PLUS,
+ PLUS_ASSIGN, QUESTION, RCURLY, SL, SLIST, SL_ASSIGN, SR,
+ SR_ASSIGN, STAR, STAR_ASSIGN"/> -->
+ <module name="WhitespaceAround">
+ </module>
+
+
+ <!-- See http://checkstyle.sf.net/config_modifiers.html -->
+ <!-- Checks that the order of modifiers conforms to the suggestions
+ in the Java Language specification, sections 8.1.1, 8.3.1 and 8.4.3. -->
+ <module name="ModifierOrder">
+ </module>
+
+ <!-- See http://checkstyle.sf.net/config_modifiers.html -->
+ <!-- Checks that there is no redundant modifiers. -->
+ <!-- <property name="tokens" value="METHOD_DEF, VARIABLE_DEF"/> -->
+ <module name="RedundantModifier">
+ </module>
+
+
+ <!-- See http://checkstyle.sf.net/config_blocks.html -->
+ <!-- Checks for empty blocks. -->
+ <!-- <property name="option" value="stmt"/> -->
+ <!-- <property name="tokens" value="LITERAL_CATCH, LITERAL_DO,
+ LITERAL_ELSE, LITERAL_FINALLY, LITERAL_IF, LITERAL_FOR,
+ LITERAL_TRY, LITERAL_WHILE, INSTANCE_INIT STATIC_INIT"/> -->
+ <module name="EmptyBlock">
+ </module>
+
+ <!-- See http://checkstyle.sf.net/config_blocks.html -->
+ <!-- Checks for the placement of left curly braces ('{') for code
+ blocks. -->
+ <!-- <property name="option" value="eol"/> -->
+ <!-- <property name="maxLineLength" value="80"/> -->
+ <!-- <property name="tokens" value="CLASS_DEF, CTOR_DEF,
+ INTERFACE_DEF, LITERAL_CATCH, LITERAL_DO, LITERAL_ELSE,
+ LITERAL_FINALLY, LITERAL_FOR, LITERAL_IF, LITERAL_SWITCH,
+ LITERAL_SYNCHRONIZED, LITERAL_TRY, LITERAL_WHILE,
+ METHOD_DEF"/> -->
+ <module name="LeftCurly">
+ </module>
+
+ <!-- See http://checkstyle.sf.net/config_blocks.html -->
+ <!-- Checks for braces around code blocks. -->
+ <!-- <property name="tokens" value="LITERAL_DO, LITERAL_ELSE,
+ LITERAL_IF, LITERAL_FOR, LITERAL_WHILE"/> -->
+ <module name="NeedBraces">
+ </module>
+
+ <!-- See http://checkstyle.sf.net/config_blocks.html -->
+ <!-- Checks the placement of right curly braces ('}') for else,
+ try, and catch tokens. -->
+ <!-- <property name="option" value="same"/> -->
+ <!-- <property name="tokens" value="LITERAL_CATCH, LITERAL_ELSE,
+ LITERAL_TRY"/> -->
+ <module name="RightCurly">
+ </module>
+
+ <!-- See http://checkstyle.sf.net/config_blocks.html -->
+ <!-- Finds nested blocks, i.e. blocks that are used freely in the
+ code. -->
+ <!-- <property name="allowInSwitchCase" value="false"/> -->
+ <module name="AvoidNestedBlocks">
+ </module>
+
+
+ <!-- See http://checkstyle.sf.net/config_coding.html -->
+ <!-- Checks that array initialization contains a trailing comma. -->
+ <module name="ArrayTrailingComma">
+ </module>
+
+ <!-- See http://checkstyle.sf.net/config_coding.html -->
+ <!-- Detects inline conditionals. -->
+ <module name="AvoidInlineConditionals">
+ </module>
+
+ <!-- See http://checkstyle.sf.net/config_coding.html -->
+ <!-- Checks that classes that define a covariant equals() method
+ also override method equals(java.lang.Object). -->
+ <module name="CovariantEquals">
+ </module>
+
+ <!-- See http://checkstyle.sf.net/config_coding.html -->
+ <!-- The "double-checked locking" idiom (DCL) tries to avoid the runtime
+ cost of synchronization. -->
+ <module name="DoubleCheckedLocking">
+ </module>
+
+ <!-- See http://checkstyle.sf.net/config_coding.html -->
+ <!-- Detects empty statements (standalone ;). -->
+ <module name="EmptyStatement">
+ </module>
+
+ <!-- See http://checkstyle.sf.net/config_coding.html -->
+ <!-- Checks that classes that override equals() also override
+ hashCode(). -->
+ <module name="EqualsHashCode">
+ </module>
+
+ <!-- See http://checkstyle.sf.net/config_coding.html -->
+ <!-- Checks that local variables that never have their values
+ changed are declared final. -->
+ <!-- <property name="tokens" value="PARAMETER_DEF, VARIABLE_DEF"/> -->
+ <module name="FinalLocalVariable">
+ </module>
+
+ <!-- See http://checkstyle.sf.net/config_coding.html -->
+ <!-- Checks that a local variable or a parameter does not shadow a field
+ that is defined in the same class. -->
+ <!-- <property name="tokens" value="PARAMETER_DEF, VARIABLE_DEF"/> -->
+ <!-- <property name="ignoreFormat" value=""/> -->
+ <!-- <property name="ignoreConstructorParameter" value="false"/> -->
+ <!-- <property name="ignoreSetter" value="false"/> -->
+ <module name="HiddenField">
+ </module>
+
+ <!-- See http://checkstyle.sf.net/config_coding.html -->
+ <!-- Checks for illegal instantiations where a factory method is
+ preferred. -->
+ <!-- <property name="classes" value="java.lang.Boolean"/> -->
+ <module name="IllegalInstantiation">
+ </module>
+
+ <!-- See http://checkstyle.sf.net/config_coding.html -->
+ <!-- Checks for illegal tokens. -->
+ <!-- <property name="tokens" value="LITERAL_SWITCH, POST_INC, POST_DEC"/> -->
+ <module name="IllegalToken">
+ </module>
+
+ <!-- See http://checkstyle.sf.net/config_coding.html -->
+ <!-- Checks for illegal token text. -->
+ <!-- <property name="tokens" value=""/> -->
+ <!-- <property name="format" value=""/> -->
+ <!-- <property name="ignoreCase" value="false"/> -->
+ <!-- <property name="message" value=""/> -->
+<!--
+ <module name="IllegalTokenText">
+ </module>
+-->
+
+ <!-- See http://checkstyle.sf.net/config_coding.html -->
+ <!-- Checks for assignments in subexpressions, such as in
+ String s = Integer.toString(i = 2);. -->
+ <!-- <property name="tokens" value="ASSIGN, BAND_ASSIGN, BOR_ASSIGN,
+ BSR_ASSIGN, BXOR_ASSIGN, DIV_ASSIGN, MINUS_ASSIGN,
+ MOD_ASSIGN, PLUS_ASSIGN, SL_ASSIGN, SR_ASSIGN,
+ STAR_ASSIGN"/> -->
+ <module name="InnerAssignment">
+ </module>
+
+ <!-- See http://checkstyle.sf.net/config_coding.html -->
+ <!-- Checks that there are no "magic numbers", where a magic number
+ is a numeric literal that is not defined as a constant. -->
+ <!-- <property name="tokens" value="NUM_DOUBLE, NUM_FLOAT, NUM_INT,
+ NUM_LONG"/> -->
+ <!-- <property name="ignoreNumbers" value="-1, 0, 1, 2"/> -->
+ <module name="MagicNumber">
+ </module>
+
+ <!-- See http://checkstyle.sf.net/config_coding.html -->
+ <!-- Checks that switch statement has "default" clause. -->
+ <module name="MissingSwitchDefault">
+ </module>
+
+ <!-- See http://checkstyle.sf.net/config_coding.html -->
+ <!-- Checks for redundant exceptions declared in throws clause such
+ as duplicates, unchecked exceptions or subclasses of another declared exception. -->
+ <!-- <property name="allowUnchecked" value="false"/> -->
+ <!-- <property name="allowSubclasses" value="false"/> -->
+ <module name="RedundantThrows">
+ </module>
+
+ <!-- See http://checkstyle.sf.net/config_coding.html -->
+ <!-- Checks for overly complicated boolean expressions. -->
+ <module name="SimplifyBooleanExpression">
+ </module>
+
+ <!-- See http://checkstyle.sf.net/config_coding.html -->
+ <!-- Checks for overly complicated boolean return statements. -->
+ <module name="SimplifyBooleanReturn">
+ </module>
+
+ <!-- See http://checkstyle.sf.net/config_coding.html -->
+ <!-- Checks that string literals are not used with == or !=. -->
+ <module name="StringLiteralEquality">
+ </module>
+
+ <!-- See http://checkstyle.sf.net/config_coding.html -->
+ <!-- Restricts nested if-else blocks to a specified depth (default = 1). -->
+ <!-- <property name="max" value="1"/> -->
+ <module name="NestedIfDepth">
+ </module>
+
+ <!-- See http://checkstyle.sf.net/config_coding.html -->
+ <!-- Restricts nested try-catch blocks to a specified depth (default = 1). -->
+ <!-- <property name="max" value="1"/> -->
+ <module name="NestedTryDepth">
+ </module>
+
+ <!-- See http://checkstyle.sf.net/config_coding.html -->
+ <!-- Checks that an overriding clone() method invokes super.clone(). -->
+ <module name="SuperClone">
+ </module>
+
+ <!-- See http://checkstyle.sf.net/config_coding.html -->
+ <!-- Checks that an overriding finalize() method invokes super.finalize(). -->
+ <module name="SuperFinalize">
+ </module>
+
+ <!-- See http://checkstyle.sf.net/config_coding.html -->
+ <!-- Catching java.lang.Exception, java.lang.Error or
+ java.lang.RuntimeException is almost never acceptable. -->
+ <!-- <property name="illegalClassNames" value="java.lang.Exception,
+ java.lang.Throwable, java.lang.RuntimeException"/> -->
+ <module name="IllegalCatch">
+ </module>
+
+ <!-- See http://checkstyle.sf.net/config_coding.html -->
+ <!-- Ensure a class is has a package declaration. -->
+ <module name="PackageDeclaration">
+ </module>
+
+ <!-- See http://checkstyle.sf.net/config_coding.html -->
+ <!-- Ensures that the setUp(), tearDown()methods are named correctly,
+ have no arguments, return void and are either public or protected. -->
+ <module name="JUnitTestCase">
+ </module>
+
+ <!-- See http://checkstyle.sf.net/config_coding.html -->
+ <!-- Restrict the number of return statements. Default = 2. -->
+ <!-- <property name="max" value="2"/> -->
+ <module name="ReturnCount">
+ </module>
+
+ <!-- See http://checkstyle.sf.net/config_coding.html -->
+ <!-- Checks that particular class are never used as types in variable
+ declarations, return values or parameters. -->
+ <!-- <property name="tokens" value="PARAMETER_DEF,
+ VARIABLE_DEF METHOD_DEF"/> -->
+ <!-- <property name="illegalClassNames" value="
+ java.util.GregorianCalendar, java.util.Hashtable,
+ java.util.HashSet, java.util.HashMap, java.util.ArrayList,
+ java.util.LinkedList, java.util.LinkedHashMap,
+ java.util.LinkedHashSet, java.util.TreeSet,
+ java.util.TreeMap, java.util.Vector"/> -->
+ <!-- <property name="ignoredMethodNames" value="getInitialContext,
+ getEnvironment"/> -->
+ <module name="IllegalType">
+ </module>
+
+ <!-- See http://checkstyle.sf.net/config_coding.html -->
+ <!-- Checks declaration order according to Code Conventions for
+ the Java Programming Language. -->
+ <module name="DeclarationOrder">
+ </module>
+
+ <!-- See http://checkstyle.sf.net/config_coding.html -->
+ <!-- Disallow assignment of parameters. -->
+ <module name="ParameterAssignment">
+ </module>
+
+ <!-- See http://checkstyle.sf.net/config_coding.html -->
+ <!-- Checks if any class or object member explicitly initialized to
+ default for its type value. -->
+ <module name="ExplicitInitialization">
+ </module>
+
+ <!-- See http://checkstyle.sf.net/config_coding.html -->
+ <!-- Check that the default is after all the cases in a switch statement. -->
+ <module name="DefaultComesLast">
+ </module>
+
+ <!-- See http://checkstyle.sf.net/config_coding.html -->
+ <!-- Checks that classes (except abtract one) define a ctor and don't
+ rely on the default one. -->
+ <module name="MissingCtor">
+ </module>
+
+ <!-- See http://checkstyle.sf.net/config_coding.html -->
+ <!-- Checks for fall through in switch statements Finds locations where
+ a case contains Java code - but lacks a break, return, throw or
+ continue statement. -->
+ <module name="FallThrough">
+ </module>
+
+ <!-- See http://checkstyle.sf.net/config_coding.html -->
+ <!-- Checks that each variable declaration is in its own statement and
+ on its own line. -->
+ <module name="MultipleVariableDeclarations">
+ </module>
+
+ <!-- See http://checkstyle.sf.net/config_coding.html -->
+ <!-- Checks that code doesn't rely on the "this." default. -->
+ <!-- <property name="checkFields" value="true"/> -->
+ <!-- <property name="checkMethods" value="true"/> -->
+ <module name="RequireThis">
+ </module>
+
+ <!-- See http://checkstyle.sf.net/config_coding.html -->
+ <!-- Checks for the use of unnecessary parentheses. -->
+ <module name="UnnecessaryParentheses">
+ </module>
+
+
+ <!-- See http://checkstyle.sf.net/config_design.html -->
+ <!-- Checks visibility of class members. -->
+ <!-- <property name="packageAllowed" value="false"/> -->
+ <!-- <property name="protectedAllowed" value="false"/> -->
+ <!-- <property name="publicMemberPattern" value="^serialVersionUID"/> -->
+ <module name="VisibilityModifier">
+ </module>
+
+ <!-- See http://checkstyle.sf.net/config_design.html -->
+ <!-- Checks that a class which has only private constructors is
+ declared as final. -->
+ <module name="FinalClass">
+ </module>
+
+ <!-- See http://checkstyle.sf.net/config_design.html -->
+ <!-- Implements Bloch, Effective Java, Item 17 - Use Interfaces only to define types. -->
+ <!-- <property name="allowMarkerInterfaces" value="true"/> -->
+ <module name="InterfaceIsType">
+ </module>
+
+ <!-- See http://checkstyle.sf.net/config_design.html -->
+ <!-- Make sure that utility classes (classes that contain only
+ static methods) do not have a public constructor. -->
+ <module name="HideUtilityClassConstructor">
+ </module>
+
+ <!-- See http://checkstyle.sf.net/config_design.html -->
+ <!-- Checks that classes are designed for extension. -->
+ <module name="DesignForExtension">
+ </module>
+
+ <!-- See http://checkstyle.sf.net/config_design.html -->
+ <!-- Ensures that exceptions (defined as any class name conforming
+ to some regular expression) are immutable. That is, have only final fields. -->
+ <!-- <property name="format" value="^.*Exception$|^.*Error$"/> -->
+ <module name="MutableException">
+ </module>
+
+ <!-- See http://checkstyle.sf.net/config_design.html -->
+ <!-- Restricts throws statements to a specified count (default = 1). -->
+ <!-- <property name="max" value="1"/> -->
+ <module name="ThrowsCount">
+ </module>
+
+
+ <!-- See http://checkstyle.sf.net/config_metrics.html -->
+ <!-- Restrict the number of number of &&, || and ^ in an expression. -->
+ <!-- <property name="max" value="3"/> -->
+ <module name="BooleanExpressionComplexity">
+ </module>
+
+ <!-- See http://checkstyle.sf.net/config_metrics.html -->
+ <!-- This metric measures the number of instantiations of other
+ classes within the given class. -->
+ <!-- <property name="max" value="7"/> -->
+ <module name="ClassDataAbstractionCoupling">
+ </module>
+
+ <!-- See http://checkstyle.sf.net/config_metrics.html -->
+ <!-- The number of other classes a given class relies on. -->
+ <!-- <property name="max" value="20"/> -->
+ <module name="ClassFanOutComplexity">
+ </module>
+
+ <!-- See http://checkstyle.sf.net/config_metrics.html -->
+ <!-- Checks cyclomatic complexity against a specified limit. -->
+ <!-- <property name="max" value="10"/> -->
+ <module name="CyclomaticComplexity">
+ </module>
+
+ <!-- See http://checkstyle.sf.net/config_metrics.html -->
+ <!-- The NPATH metric computes the number of possible execution paths
+ through a function. -->
+ <!-- <property name="max" value="200"/> -->
+ <module name="NPathComplexity">
+ </module>
+
+
+ <!-- See http://checkstyle.sf.net/config_misc.html -->
+ <!-- A generic check for code problems - the user can search for any pattern. -->
+ <!-- <property name="format" value="^$"/> -->
+ <!-- <property name="ignoreCase" value="false"/> -->
+ <!-- <property name="ignoreComments" value="false"/> -->
+ <!-- <property name="message" value=""/> -->
+ <module name="GenericIllegalRegexp">
+ <property name="format" value="\S\s+$"/>
+ <property name="message" value="Line has trailing spaces."/>
+ </module>
+
+ <!-- See http://checkstyle.sf.net/config_misc.html -->
+ <!-- A check for TODO: comments. Actually it is a generic regular
+ expression matcher on Java comments. To check for other patterns in
+ Java comments, set property format. -->
+ <!-- <property name="format" value="TODO:"/> -->
+ <module name="TodoComment">
+ </module>
+
+ <!-- See http://checkstyle.sf.net/config_misc.html -->
+ <!-- Checks for uncommented main() methods (debugging leftovers). -->
+ <!-- <property name="excludedClasses" value=""/> -->
+ <module name="UncommentedMain">
+ </module>
+
+ <!-- See http://checkstyle.sf.net/config_misc.html -->
+ <!-- Checks that long constants are defined with an upper ell.
+ That is 'L' and not 'l'. -->
+ <module name="UpperEll">
+ </module>
+
+ <!-- See http://checkstyle.sf.net/config_misc.html -->
+ <!-- Checks the style of array type definitions. -->
+ <!-- <property name="javaStyle" value="true"/> -->
+ <module name="ArrayTypeStyle">
+ </module>
+
+ <!-- See http://checkstyle.sf.net/config_misc.html -->
+ <!-- Check that method/constructor parameters are final. -->
+ <!-- <property name="tokens" value="METHOD_DEF, CTOR_DEF"/> -->
+ <module name="FinalParameters">
+ </module>
+
+ <!-- See http://checkstyle.sf.net/config_misc.html -->
+ <!-- Checks for restricted tokens beneath other tokens. -->
+ <!-- <property name="tokens" value=""/> -->
+ <!-- <property name="limitedTokens" value=""/> -->
+ <!-- <property name="minimumDepth" value="0"/> -->
+ <!-- <property name="maximumDepth" value="java.lang.Integer.MAX_VALUE"/> -->
+ <!-- <property name="minimumNumber" value="0"/> -->
+ <!-- <property name="maximumNumber" value="java.lang.Integer.MAX_VALUE"/> -->
+ <!-- <property name="minimumMessage" value="descendant.token.min"/> -->
+ <!-- <property name="maximumMessage" value="descendant.token.max"/> -->
+<!--
+ <module name="DescendantToken">
+ </module>
+-->
+
+ <!-- See http://checkstyle.sf.net/config_misc.html -->
+ <!-- Checks correct indentation of Java Code. -->
+ <!-- <property name="basicOffset" value="4"/> -->
+ <!-- <property name="braceAdjustment" value="0"/> -->
+ <!-- <property name="caseIndent" value="4"/> -->
+ <module name="Indentation">
+ </module>
+
+ <!-- See http://checkstyle.sf.net/config_misc.html -->
+ <!-- The check to ensure that requires that comments be the only thing
+ on a line. -->
+ <!-- <property name="format" value="^[\\s\\}\\);]*$"/> -->
+ <module name="TrailingComment">
+ </module>
+
+ </module>
+
+
+ <!-- See http://checkstyle.sf.net/config_duplicates.html -->
+ <!-- Performs a line-by-line comparison of all code lines and
+ reports duplicate code. -->
+ <!-- <property name="min" value="12"/> -->
+ <module name="StrictDuplicateCode">
+ </module>
+
+
+ <!-- See http://checkstyle.sf.net/config_misc.html#NewlineAtEndOfFile -->
+ <!-- Checks whether files end with a new line. -->
+ <!-- <property name="lineSeparator" value="system"/> -->
+ <module name="NewlineAtEndOfFile">
+ </module>
+
+ <!-- See http://checkstyle.sf.net/config_misc.html#Translation -->
+ <!-- Checks that property files contain the same keys. -->
+ <!-- <property name="fileExtensions" value="properties"/> -->
+ <module name="Translation">
+ </module>
+
+</module>
diff --git a/thirdparty/checkstyle/contrib/examples/filters/com/mycompany/filters/FilesFilter.java b/thirdparty/checkstyle/contrib/examples/filters/com/mycompany/filters/FilesFilter.java
new file mode 100755
index 000000000..da49b5c2a
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/examples/filters/com/mycompany/filters/FilesFilter.java
@@ -0,0 +1,34 @@
+package com.mycompany.filters;
+
+import org.apache.regexp.RE;
+import org.apache.regexp.RESyntaxException;
+
+import com.puppycrawl.tools.checkstyle.api.AuditEvent;
+import com.puppycrawl.tools.checkstyle.api.AutomaticBean;
+import com.puppycrawl.tools.checkstyle.api.Filter;
+import com.puppycrawl.tools.checkstyle.api.Utils;
+
+public class FilesFilter
+ extends AutomaticBean
+ implements Filter
+{
+ private RE mFileRegexp;
+
+ public FilesFilter()
+ throws RESyntaxException
+ {
+ setFiles("^$");
+ }
+
+ public boolean accept(AuditEvent aEvent)
+ {
+ final String fileName = aEvent.getFileName();
+ return ((fileName == null) || !mFileRegexp.match(fileName));
+ }
+
+ public void setFiles(String aFilesPattern)
+ throws RESyntaxException
+ {
+ mFileRegexp = Utils.getRE(aFilesPattern);
+ }
+}
diff --git a/thirdparty/checkstyle/contrib/examples/linkErrors2Source/build.xml b/thirdparty/checkstyle/contrib/examples/linkErrors2Source/build.xml
new file mode 100755
index 000000000..a99404809
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/examples/linkErrors2Source/build.xml
@@ -0,0 +1,70 @@
+<?xml version="1.0" encoding="iso-8859-1"?>
+<project name="style" default="checkstyle.style" basedir=".">
+
+ <property name="checkstyle-all.jar" value="C:/javautil/checkstyle-3.4/checkstyle-all-3.4.jar" />
+ <property name="java2html.jar" value="C:/javautil/java2html/java2html.jar" />
+ <property name="src.dir" value="T:\2004\eclipse\workspace\checkstyle\src\checkstyle\com\puppycrawl\tools\checkstyle\checks" />
+ <property name="check.config" value="T:/2004/eclipse/workspace/checkstyle/docs/sun_checks.xml" />
+ <property name="dest.dir" value="target/cs-errors"/>
+ <property name="html.dir" value="src_html"/>
+
+ <!-- -->
+ <!-- Cleanup targets -->
+ <!-- -->
+ <target name="clean" description="Cleans any directories and generated files">
+ <delete dir="target" />
+ </target>
+
+ <!-- -->
+ <!-- Create syntax-highlighted HTML files from Java source files. -->
+ <!-- Requires java2html, http://www.java2html.de/ -->
+ <!-- -->
+ <target name="java.to.html"
+ description="Creates HTML files with syntax highlighting from Java source files">
+
+ <taskdef name="java2html"
+ classname="de.java2html.anttasks.Java2HtmlTask"
+ classpath="${java2html.jar}"
+ />
+ <java2html srcdir="${src.dir}"
+ destdir="target/${html.dir}"
+ includes="**/*.java"
+ outputFormat="html"
+ tabs="4"
+ style="eclipse"
+ showLineNumbers="true"
+ addLineAnchors="true"
+ showFileName="true"
+ includeDocumentHeader="true"
+ includeDocumentFooter="true"
+ />
+ </target>
+
+ <taskdef resource="checkstyletask.properties"
+ classpath="${checkstyle-all.jar}"/>
+
+ <!-- -->
+ <!-- Run checkstyle and generate error report with links to source code -->
+ <!-- -->
+ <target name="checkstyle.style"
+ depends="java.to.html"
+ description="Runs checkstyle and generates an error report with links to source code">
+
+ <mkdir dir="target"/>
+ <checkstyle failonviolation="false" config="${check.config}">
+ <fileset dir="${src.dir}"
+ includes="**/*.java,**/*.properties"
+ excludes="**/Generated*.java,**/gui/*,,**/transmogrify/*"/>
+ <formatter type="xml" toFile="target/cs_errors.xml"/>
+ </checkstyle>
+ <mkdir dir="target/cs-errors"/>
+ <style basedir="target"
+ destdir="target/cs-errors"
+ includes="cs_errors.xml"
+ style="checkstyle-noframes.xsl">
+ <param name="src.dir" expression="${src.dir}"/>
+ <param name="html.dir" expression="../${html.dir}"/>
+ </style>
+ </target>
+
+</project> \ No newline at end of file
diff --git a/thirdparty/checkstyle/contrib/examples/linkErrors2Source/checkstyle-noframes.xsl b/thirdparty/checkstyle/contrib/examples/linkErrors2Source/checkstyle-noframes.xsl
new file mode 100755
index 000000000..3c8fb399d
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/examples/linkErrors2Source/checkstyle-noframes.xsl
@@ -0,0 +1,190 @@
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
+<xsl:output method="html" indent="yes"/>
+<xsl:decimal-format decimal-separator="." grouping-separator="," />
+
+<!-- Checkstyle XML Style Sheet by Stephane Bailliez <sbailliez@apache.org> -->
+<!-- Links errors to lines in HTML version of source code. -->
+<!-- Part of the Checkstyle distribution found at http://checkstyle.sourceforge.net -->
+<!-- Usage (generates checkstyle_report.html): -->
+<!-- <checkstyle failonviolation="false" config="${check.config}"> -->
+<!-- <fileset dir="${src.dir}" includes="**/*.java"/> -->
+<!-- <formatter type="xml" toFile="${doc.dir}/checkstyle_report.xml"/> -->
+<!-- </checkstyle> -->
+<!-- <style basedir="${doc.dir}" destdir="${doc.dir}" -->
+<!-- includes="checkstyle_report.xml" -->
+<!-- style="${doc.dir}/checkstyle-noframes.xsl"> -->
+<!-- <param name="src.dir" expression="${src.dir}"/> -->
+<!-- <param name="html.dir" expression="${html.dir}"/> -->
+<!-- </style> -->
+
+<!-- source directory name for stripping off link href attribute value -->
+<xsl:param name="src.dir"/>
+<!-- directory containing syntax-highlighted HTML files for java source files -->
+<xsl:param name="html.dir"/>
+
+<xsl:template match="checkstyle">
+ <html>
+ <head>
+ <style type="text/css">
+ .bannercell {
+ border: 0px;
+ padding: 0px;
+ }
+ body {
+ margin-left: 10;
+ margin-right: 10;
+ font:normal 80% arial,helvetica,sanserif;
+ background-color:#FFFFFF;
+ color:#000000;
+ }
+ .a td {
+ background: #efefef;
+ }
+ .b td {
+ background: #fff;
+ }
+ th, td {
+ text-align: left;
+ vertical-align: top;
+ }
+ th {
+ font-weight:bold;
+ background: #ccc;
+ color: black;
+ }
+ table, th, td {
+ font-size:100%;
+ border: none
+ }
+ table.log tr td, tr th {
+
+ }
+ h2 {
+ font-weight:bold;
+ font-size:140%;
+ margin-bottom: 5;
+ }
+ h3 {
+ font-size:100%;
+ font-weight:bold;
+ background: #525D76;
+ color: white;
+ text-decoration: none;
+ padding: 5px;
+ margin-right: 2px;
+ margin-left: 2px;
+ margin-bottom: 0;
+ }
+ </style>
+ </head>
+ <body>
+ <a name="top"></a>
+ <!-- jakarta logo -->
+ <table border="0" cellpadding="0" cellspacing="0" width="100%">
+ <tr>
+ <td class="bannercell" rowspan="2">
+ <!--a href="http://jakarta.apache.org/">
+ <img src="http://jakarta.apache.org/images/jakarta-logo.gif" alt="http://jakarta.apache.org" align="left" border="0"/>
+ </a-->
+ </td>
+ <td class="text-align:right"><h2>CheckStyle Audit</h2></td>
+ </tr>
+ <tr>
+ <td class="text-align:right">Designed for use with <a href='http://checkstyle.sourceforge.net/'>CheckStyle</a> and <a href='http://jakarta.apache.org'>Ant</a>.</td>
+ </tr>
+ </table>
+ <hr size="1"/>
+
+ <!-- Summary part -->
+ <xsl:apply-templates select="." mode="summary"/>
+ <hr size="1" width="100%" align="left"/>
+
+ <!-- Package List part -->
+ <xsl:apply-templates select="." mode="filelist"/>
+ <hr size="1" width="100%" align="left"/>
+
+ <!-- For each package create its part -->
+ <xsl:for-each select="file">
+ <xsl:sort select="@name"/>
+ <xsl:apply-templates select="."/>
+ <p/>
+ <p/>
+ </xsl:for-each>
+ <hr size="1" width="100%" align="left"/>
+
+
+ </body>
+ </html>
+</xsl:template>
+
+
+
+ <xsl:template match="checkstyle" mode="filelist">
+ <h3>Files</h3>
+ <table class="log" border="0" cellpadding="5" cellspacing="2" width="100%">
+ <tr>
+ <th>Name</th>
+ <th>Errors</th>
+ </tr>
+ <xsl:for-each select="file">
+ <xsl:sort select="@name"/>
+ <xsl:variable name="errorCount" select="count(error)"/>
+ <tr>
+ <xsl:call-template name="alternated-row"/>
+ <td><a href="#f-{@name}"><xsl:value-of select="@name"/></a></td>
+ <td><xsl:value-of select="$errorCount"/></td>
+ </tr>
+ </xsl:for-each>
+ </table>
+ </xsl:template>
+
+
+ <xsl:template match="file">
+ <a name="f-{@name}"></a>
+ <h3>File <xsl:value-of select="@name"/></h3>
+
+ <table class="log" border="0" cellpadding="5" cellspacing="2" width="100%">
+ <tr>
+ <th>Error Description</th>
+ <th>Line</th>
+ </tr>
+ <xsl:for-each select="error">
+ <tr>
+ <xsl:call-template name="alternated-row"/>
+ <td><xsl:value-of select="@message"/></td>
+ <td><a>
+ <xsl:attribute name="href"><xsl:value-of select="$html.dir"/>/<xsl:value-of select="substring-after(../@name, $src.dir)"/>.html#<xsl:value-of select="@line"/></xsl:attribute>
+ <xsl:value-of select="@line"/></a></td>
+ </tr>
+ </xsl:for-each>
+ </table>
+ <a href="#top">Back to top</a>
+ </xsl:template>
+
+
+ <xsl:template match="checkstyle" mode="summary">
+ <h3>Summary</h3>
+ <xsl:variable name="fileCount" select="count(file)"/>
+ <xsl:variable name="errorCount" select="count(file/error)"/>
+ <table class="log" border="0" cellpadding="5" cellspacing="2" width="100%">
+ <tr>
+ <th>Files</th>
+ <th>Errors</th>
+ </tr>
+ <tr>
+ <xsl:call-template name="alternated-row"/>
+ <td><xsl:value-of select="$fileCount"/></td>
+ <td><xsl:value-of select="$errorCount"/></td>
+ </tr>
+ </table>
+ </xsl:template>
+
+ <xsl:template name="alternated-row">
+ <xsl:attribute name="class">
+ <xsl:if test="position() mod 2 = 1">a</xsl:if>
+ <xsl:if test="position() mod 2 = 0">b</xsl:if>
+ </xsl:attribute>
+ </xsl:template>
+</xsl:stylesheet>
+
+
diff --git a/thirdparty/checkstyle/contrib/examples/linkErrors2Source/readme.txt b/thirdparty/checkstyle/contrib/examples/linkErrors2Source/readme.txt
new file mode 100755
index 000000000..c66e49418
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/examples/linkErrors2Source/readme.txt
@@ -0,0 +1,6 @@
+Example of an ant build file and stylesheet for generation of an HTML error
+report with links to source code, as discussed on sourceforge.net:
+checkstyle-user,
+http://sourceforge.net/mailarchive/forum.php?thread_id=4891991&forum_id=8139.
+
+Requires: java2html, http://www.java2html.de/ \ No newline at end of file
diff --git a/thirdparty/checkstyle/contrib/examples/listeners/com/mycompany/listeners/CommonsLoggingListener.java b/thirdparty/checkstyle/contrib/examples/listeners/com/mycompany/listeners/CommonsLoggingListener.java
new file mode 100755
index 000000000..6b141990e
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/examples/listeners/com/mycompany/listeners/CommonsLoggingListener.java
@@ -0,0 +1,127 @@
+package com.mycompany.listeners;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogConfigurationException;
+import org.apache.commons.logging.LogFactory;
+
+import com.puppycrawl.tools.checkstyle.Checker;
+import com.puppycrawl.tools.checkstyle.api.AuditEvent;
+import com.puppycrawl.tools.checkstyle.api.AuditListener;
+import com.puppycrawl.tools.checkstyle.api.CheckstyleException;
+import com.puppycrawl.tools.checkstyle.api.SeverityLevel;
+
+/**
+ * Jakarta Commons Logging listener.
+ * Note: With Ant, do not use the SimpleLog as your logger implementation as it
+ * causes an infinite loop since it writes to System.err, which Ant traps
+ * and reroutes to the logger/listener layer.
+ * Based on
+ * <a href="http://ant.apache.org/index.html">org.apache.tools.ant.listener.CommonsLoggingListener>org.apache.tools.ant.listener.CommonsLoggingListener</a>
+ * @author Rick Giles
+ */
+public class CommonsLoggingListener
+ implements AuditListener
+{
+ /** cushion for avoiding StringBuffer.expandCapacity */
+ private static final int BUFFER_CUSHION = 30;
+
+ /** true if the log factory has been initialized */
+ private boolean mInitialized = false;
+
+ /** Factory for creating org.apache.commons.logging.Log instances */
+ private LogFactory mLogFactory;
+
+ /**
+ * Creates a <code>CommonsLoggingListener. Initializes its log factory.
+ * @throws CheckstyleException if if the implementation class is not
+ * available or cannot be instantiated.
+ */
+ public CommonsLoggingListener() throws CheckstyleException
+ {
+ try {
+ mLogFactory = LogFactory.getFactory();
+ }
+ catch (LogConfigurationException e) {
+ throw new CheckstyleException("log configuration exception", e);
+ }
+ mInitialized = true;
+ }
+
+ /** @see com.puppycrawl.tools.checkstyle.api.AuditListener */
+ public void auditStarted(AuditEvent aEvt)
+ {
+ if (mInitialized) {
+ final Log log = mLogFactory.getInstance(Checker.class);
+ log.info("Audit started.");
+ }
+ }
+
+ /** @see com.puppycrawl.tools.checkstyle.api.AuditListener */
+ public void auditFinished(AuditEvent aEvt)
+ {
+ if (mInitialized) {
+ final Log log = mLogFactory.getInstance(Checker.class);
+ log.info("Audit finished.");
+ }
+ }
+
+ /** @see com.puppycrawl.tools.checkstyle.api.AuditListener */
+ public void fileStarted(AuditEvent aEvt)
+ {
+ if (mInitialized) {
+ final Log log = mLogFactory.getInstance(Checker.class);
+ log.info("File \"" + aEvt.getFileName() + "\" started.");
+ }
+ }
+
+ /** @see com.puppycrawl.tools.checkstyle.api.AuditListener */
+ public void fileFinished(AuditEvent aEvt)
+ {
+ if (mInitialized) {
+ final Log log = mLogFactory.getInstance(Checker.class);
+ log.info("File \"" + aEvt.getFileName() + "\" finished.");
+ }
+ }
+
+ /** @see com.puppycrawl.tools.checkstyle.api.AuditListener */
+ public void addError(AuditEvent aEvt)
+ {
+ final SeverityLevel severityLevel = aEvt.getSeverityLevel();
+ if (mInitialized && !SeverityLevel.IGNORE.equals(severityLevel)) {
+ final Log log = mLogFactory.getInstance(aEvt.getSourceName());
+
+ final String fileName = aEvt.getFileName();
+ final String message = aEvt.getMessage();
+
+ // avoid StringBuffer.expandCapacity
+ final int bufLen = message.length() + BUFFER_CUSHION;
+ final StringBuffer sb = new StringBuffer(bufLen);
+
+ sb.append("Line: ").append(aEvt.getLine());
+ if (aEvt.getColumn() > 0) {
+ sb.append(" Column: ").append(aEvt.getColumn());
+ }
+ sb.append(" Message: ").append(message);
+
+ if (aEvt.getSeverityLevel().equals(SeverityLevel.WARNING)) {
+ log.warn(sb.toString());
+ }
+ else if (aEvt.getSeverityLevel().equals(SeverityLevel.INFO)) {
+ log.info(sb.toString());
+ }
+ else {
+ log.error(sb.toString());
+ }
+ }
+ }
+
+ /** @see com.puppycrawl.tools.checkstyle.api.AuditListener */
+ public void addException(AuditEvent aEvt, Throwable aThrowable)
+ {
+ if (mInitialized) {
+ final Log log = mLogFactory.getInstance(aEvt.getSourceName());
+ log.error("Error auditing " + aEvt.getFileName(), aThrowable);
+ }
+ }
+
+}
diff --git a/thirdparty/checkstyle/contrib/examples/listeners/com/mycompany/listeners/MailLogger.java b/thirdparty/checkstyle/contrib/examples/listeners/com/mycompany/listeners/MailLogger.java
new file mode 100755
index 000000000..e96816944
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/examples/listeners/com/mycompany/listeners/MailLogger.java
@@ -0,0 +1,241 @@
+package com.mycompany.listeners;
+
+import java.io.ByteArrayOutputStream;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Enumeration;
+import java.util.Properties;
+import java.util.StringTokenizer;
+
+import javax.mail.Session;
+import javax.mail.Transport;
+import javax.mail.internet.InternetAddress;
+import javax.mail.internet.MimeMessage;
+
+import com.puppycrawl.tools.checkstyle.DefaultLogger;
+import com.puppycrawl.tools.checkstyle.api.AuditEvent;
+import com.puppycrawl.tools.checkstyle.api.AuditListener;
+import com.puppycrawl.tools.checkstyle.api.CheckstyleException;
+import com.puppycrawl.tools.checkstyle.api.SeverityLevel;
+
+/**
+ * Buffers log messages from DefaultLogger, and sends an e-mail with the
+ * results. The following Project properties are used to send the mail.
+ * <ul>
+ * <li> MailLogger.mailhost [default: localhost] - Mail server to use</li>
+ *
+ * <li> MailLogger.from [required] - Mail "from" address</li>
+ * <li> MailLlistener.failure.notify [default: true] - Send build failure
+ * e-mails?</li>
+ * <li> MailLogger.success.notify [default: true] - Send build success
+ * e-mails?</li>
+ * <li> MailLogger.failure.to [required if failure mail to be sent] - Address
+ * to send failure messages to</li>
+ * <li> MailLogger.success.to [required if success mail to be sent] - Address
+ * to send success messages to</li>
+ * <li> MailLogger.failure.subject [default: "Build Failure"] - Subject of
+ * failed build</li>
+ * <li> MailLlistener.success.subject [default: "Build Success"] - Subject of
+ * successful build</li>
+ * </ul>
+ * These properties are set using standard property setting mechanisms
+ * (command-line -D, ant &lt;property&gt;, etc).Properties can be overridden
+ * by specifying the filename of a properties file in the <i>
+ * MailLogger.properties.file property</i> . Any properties defined in that
+ * file will override properties.
+ * Based on
+ * <a href="http://ant.apache.org/index.html">org.apache.tools.ant.listener.MailLogger>org.apache.tools.ant.listener.MailLogger</a>
+ * @author Erik Hatcher
+ * <a href="mailto:ehatcher@apache.org">ehatcher@apache.org</a>
+ * @author Rick Giles
+ */
+public class MailLogger
+ implements AuditListener
+{
+ /** output stream for logger */
+ private ByteArrayOutputStream mOutputStream;
+
+ /** adapted listener */
+ private DefaultLogger mLogger;
+
+ /** count of the number of errors and exceptions */
+ private int mErrors;
+
+ /**
+ * Constructs a <code>MailLogger</code>
+ */
+ public MailLogger()
+ {
+ mOutputStream = new ByteArrayOutputStream();
+ mLogger = new DefaultLogger(mOutputStream, false);
+ mErrors = 0;
+ }
+
+ /** @see com.puppycrawl.tools.checkstyle.api.AuditListener */
+ public void auditStarted(AuditEvent aEvt)
+ {
+ mLogger.auditStarted(aEvt);
+ }
+
+ /**
+ * Sends an e-mail with the log results.
+ * @see com.puppycrawl.tools.checkstyle.api.AuditListener
+ */
+ public void auditFinished(AuditEvent aEvt)
+ {
+ mLogger.auditFinished(aEvt);
+
+ final Properties properties = System.getProperties();
+
+ // overlay specified properties file (if any), which overrides project
+ // settings
+ final Properties fileProperties = new Properties();
+ final String filename =
+ (String) properties.get("MailLogger.properties.file");
+ if (filename != null) {
+ InputStream is = null;
+ try {
+ is = new FileInputStream(filename);
+ fileProperties.load(is);
+ }
+ catch (IOException ioe) {
+ // ignore because properties file is not required
+ ;
+ }
+ finally {
+ if (is != null) {
+ try {
+ is.close();
+ }
+ catch (IOException e) {
+ ;
+ }
+ }
+ }
+ }
+
+ for (Enumeration e = fileProperties.keys(); e.hasMoreElements();) {
+ final String key = (String) e.nextElement();
+ final String value = fileProperties.getProperty(key);
+ properties.put(key, value);
+ }
+
+ final boolean success = (mErrors == 0);
+ final String prefix = success ? "success" : "failure";
+
+ try {
+ final String mailhost =
+ getValue(properties, "mailhost", "localhost");
+ final String from = getValue(properties, "from", null);
+
+ final String toList = getValue(properties, prefix + ".to", null);
+ final String subject = getValue(properties, prefix + ".subject",
+ (success)
+ ? "Checkstyle Audit Success"
+ : "Checkstyle Audit Failure");
+
+ sendMail(mailhost, from, toList, subject, mOutputStream.toString());
+ }
+ catch (Exception e) {
+ System.out.println("MailLogger failed to send e-mail!");
+ e.printStackTrace(System.err);
+ }
+ }
+
+ /** @see com.puppycrawl.tools.checkstyle.api.AuditListener */
+ public void fileStarted(AuditEvent aEvt)
+ {
+ mLogger.fileStarted(aEvt);
+ }
+
+ /** @see com.puppycrawl.tools.checkstyle.api.AuditListener */
+ public void fileFinished(AuditEvent aEvt)
+ {
+ mLogger.fileFinished(aEvt);
+ }
+
+ /** @see com.puppycrawl.tools.checkstyle.api.AuditListener */
+ public void addError(AuditEvent aEvt)
+ {
+ if (SeverityLevel.ERROR.equals(aEvt.getSeverityLevel())) {
+ mLogger.addError(aEvt);
+ mErrors++;
+ }
+ }
+
+ /** @see com.puppycrawl.tools.checkstyle.api.AuditListener */
+ public void addException(AuditEvent aEvt, Throwable aThrowable)
+ {
+ mLogger.addException(aEvt, aThrowable);
+ mErrors++;
+ }
+
+ /**
+ * Gets the value of a property.
+ *
+ * @param aProperties Properties to obtain value from.
+ * @param aName suffix of property name. "MailLogger." will be
+ * prepended internally.
+ * @param aDefaultValue value returned if not present in the properties.
+ * Set to null to make required.
+ * @return The value of the property, or default value.
+ * @throws CheckstyleException if no default value is specified and the
+ * property is not present in properties.
+ */
+ private String getValue(Properties aProperties, String aName,
+ String aDefaultValue) throws CheckstyleException
+ {
+ final String propertyName = "MailLogger." + aName;
+ String value = (String) aProperties.get(propertyName);
+
+ if (value == null) {
+ value = aDefaultValue;
+ }
+
+ if (value == null) {
+ throw new CheckstyleException(
+ "Missing required parameter: " + propertyName);
+ }
+
+ return value;
+ }
+ /**
+ * Send the mail
+ *
+ * @param aMailhost mail server
+ * @param aFrom from address
+ * @param aToList comma-separated recipient list
+ * @param aSubject mail subject
+ * @param aText mail body
+ * @throws Exception if sending message fails
+ */
+ private void sendMail(String aMailhost, String aFrom, String aToList,
+ String aSubject, String aText)
+ throws Exception
+ {
+ // Get system properties
+ final Properties props = System.getProperties();
+
+ // Setup mail server
+ props.put("mail.smtp.host", aMailhost);
+
+ // Get session
+ final Session session = Session.getDefaultInstance(props, null);
+
+ // Define message
+ final MimeMessage message = new MimeMessage(session);
+
+ message.setFrom(new InternetAddress(aFrom));
+ final StringTokenizer t = new StringTokenizer(aToList, ", ", false);
+ while (t.hasMoreTokens()) {
+ message.addRecipient(
+ MimeMessage.RecipientType.TO,
+ new InternetAddress(t.nextToken()));
+ }
+ message.setSubject(aSubject);
+ message.setText(aText);
+
+ Transport.send(message);
+ }
+}
diff --git a/thirdparty/checkstyle/contrib/examples/listeners/com/mycompany/listeners/VerboseListener.java b/thirdparty/checkstyle/contrib/examples/listeners/com/mycompany/listeners/VerboseListener.java
new file mode 100755
index 000000000..6860d1beb
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/examples/listeners/com/mycompany/listeners/VerboseListener.java
@@ -0,0 +1,111 @@
+package com.mycompany.listeners;
+
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.OutputStream;
+import java.io.PrintWriter;
+
+import com.puppycrawl.tools.checkstyle.api.AuditEvent;
+import com.puppycrawl.tools.checkstyle.api.AuditListener;
+import com.puppycrawl.tools.checkstyle.api.AutomaticBean;
+import com.puppycrawl.tools.checkstyle.api.SeverityLevel;
+
+/**
+ * An AuditListener that reports every event to an output stream.
+ * @author Rick Giles
+ */
+public class VerboseListener
+ extends AutomaticBean
+ implements AuditListener
+{
+ /** where to write messages */
+ private PrintWriter mWriter = new PrintWriter(System.out);
+
+ /** close output stream */
+ private boolean mCloseOut = false;
+
+ /** total number of errors and exceptions */
+ private int mTotalErrors;
+
+ /** number of errors and exceptions in the audit of one file */
+ private int mErrors;
+
+ /**
+ * Sets the output stream to a file.
+ * @param aFileName name of the output file.
+ * @throws FileNotFoundException if an error occurs.
+ */
+ public void setFile(String aFileName)
+ throws FileNotFoundException
+ {
+ final OutputStream out = new FileOutputStream(aFileName);
+ mWriter = new PrintWriter(out);
+ mCloseOut = true;
+ }
+
+ /** @see com.puppycrawl.tools.checkstyle.api.AuditListener */
+ public void auditStarted(AuditEvent aEvt)
+ {
+ mTotalErrors = 0;
+ mWriter.println("Audit started.");
+ }
+
+ /** @see com.puppycrawl.tools.checkstyle.api.AuditListener */
+ public void auditFinished(AuditEvent aEvt)
+ {
+ mWriter.println("Audit finished. Total errors: " + mTotalErrors);
+ mWriter.flush();
+ if (mCloseOut) {
+ mWriter.close();
+ }
+ }
+
+ /** @see com.puppycrawl.tools.checkstyle.api.AuditListener */
+ public void fileStarted(AuditEvent aEvt)
+ {
+ mErrors = 0;
+ mWriter.println(
+ "Started checking file '" + aEvt.getFileName() + "'.");
+ }
+
+ /** @see com.puppycrawl.tools.checkstyle.api.AuditListener */
+ public void fileFinished(AuditEvent aEvt)
+ {
+ mWriter.println("Finished checking file '" + aEvt.getFileName()
+ + "'. Errors: " + mErrors);
+ }
+
+ /** @see com.puppycrawl.tools.checkstyle.api.AuditListener */
+ public void addError(AuditEvent aEvt)
+ {
+ printEvent(aEvt);
+ if (SeverityLevel.ERROR.equals(aEvt.getSeverityLevel())) {
+ mErrors++;
+ mTotalErrors++;
+ }
+ }
+
+ /** @see com.puppycrawl.tools.checkstyle.api.AuditListener */
+ public void addException(AuditEvent aEvt, Throwable aThrowable)
+ {
+ printEvent(aEvt);
+ aThrowable.printStackTrace(System.out);
+ mErrors++;
+ mTotalErrors++;
+ }
+
+ /**
+ * Prints event information to standard output.
+ * @param aEvt the event to print.
+ */
+ private void printEvent(AuditEvent aEvt)
+ {
+ mWriter.println("Logging error -"
+ + " file: '" + aEvt.getFileName() + "'"
+ + " line: " + aEvt.getLine()
+ + " column: " + aEvt.getColumn()
+ + " severity: " + aEvt.getSeverityLevel()
+ + " message: " + aEvt.getMessage()
+ + " source: " + aEvt.getSourceName());
+ }
+}
diff --git a/thirdparty/checkstyle/contrib/hooks/git-pre-commit-hook.pl b/thirdparty/checkstyle/contrib/hooks/git-pre-commit-hook.pl
new file mode 100755
index 000000000..586dfd8fd
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/hooks/git-pre-commit-hook.pl
@@ -0,0 +1,72 @@
+#!/usr/bin/perl
+#
+# Pre-commit hook for running checkstyle on changed Java sources
+#
+# To use this you need:
+# 1. checkstyle's jar file somewhere
+# 2. a checkstyle XML check file somewhere
+# 3. To configure git:
+# * git config --add checkstyle.jar <location of jar>
+# * git config --add checkstyle.checkfile <location of checkfile>
+# * git config --add java.command <path to java executale> [optional
+# defaults to assuming it's in your path]
+# 4. Put this in your .git/hooks directory as pre-commit
+#
+# Now, when you commit, you will be disallowed from doing so
+# until you pass your checkstyle checks.
+
+$command = "git-diff-index --cached HEAD 2>&1 | sed 's/^:.* //' | uniq";
+open (FILES,$command . "|") || die "Cannot run '$command': $!\n";
+
+$CONFIG_CHECK_FILE = "checkstyle.checkfile";
+$CONFIG_JAR = "checkstyle.jar";
+$CONFIG_JAVA = "java.command";
+
+$check_file = `git config --get $CONFIG_CHECK_FILE`;
+$checkstyle_jar = `git config --get $CONFIG_JAR`;
+$java_command = `git config --get $CONFIG_JAVA`;
+
+if (!$check_file || !$checkstyle_jar)
+{
+ die "You must configure checkstyle in your git config:\n"
+ . "\t$CONFIG_CHECK_FILE - path to your checkstyle.xml file\n"
+ . "\t$CONFIG_JAR - path to your checkstyle jar file\n"
+ . "\t$CONFIG_JAVA - path to your java executable (optional)\n"
+ ;
+}
+
+$java_command = "java" if (!$java_command);
+
+chomp $check_file;
+chomp $checkstyle_jar;
+chomp $java_command;
+
+$command = "$java_command -jar $checkstyle_jar -c $check_file";
+
+@java_files = ();
+
+foreach (<FILES>)
+{
+ chomp;
+ next if (!(/\.java$/));
+ push @java_files,$_;
+ $command .= " ";
+ $command .= $_;
+}
+if ($#java_files >= 0)
+{
+ if (&run_and_log_system ($command))
+ {
+ print STDERR "Commit aborted.\n";
+ exit -1;
+ }
+}
+
+exit 0;
+
+sub run_and_log_system
+{
+ ($cmd) = @_;
+
+ system $cmd;
+} \ No newline at end of file
diff --git a/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/AbstractUsageCheck.java b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/AbstractUsageCheck.java
new file mode 100755
index 000000000..c22c87c07
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/AbstractUsageCheck.java
@@ -0,0 +1,200 @@
+////////////////////////////////////////////////////////////////////////////////
+// checkstyle: Checks Java source code for adherence to a set of rules.
+// Copyright (C) 2001-2005 Oliver Burn
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+////////////////////////////////////////////////////////////////////////////////
+package com.puppycrawl.tools.checkstyle.checks.usage;
+
+import com.puppycrawl.tools.checkstyle.api.Check;
+import com.puppycrawl.tools.checkstyle.api.DetailAST;
+import com.puppycrawl.tools.checkstyle.api.TokenTypes;
+import com.puppycrawl.tools.checkstyle.api.Utils;
+import com.puppycrawl.tools.checkstyle.checks.usage.transmogrify.ASTManager;
+import com.puppycrawl.tools.checkstyle.checks.usage.transmogrify.ClassManager;
+import com.puppycrawl.tools.checkstyle.checks.usage.transmogrify.Definition;
+import com.puppycrawl.tools.checkstyle.checks.usage.transmogrify.SymTabAST;
+import com.puppycrawl.tools.checkstyle.checks.usage.transmogrify.
+ SymbolTableException;
+import java.util.Iterator;
+import java.util.Set;
+import java.util.regex.Pattern;
+import java.util.regex.PatternSyntaxException;
+
+import org.apache.commons.beanutils.ConversionException;
+
+/**
+ * Performs a usage check for fields, methods, parameters, variables.
+ * @author Rick Giles
+ */
+public abstract class AbstractUsageCheck
+ extends Check
+{
+ /** the regexp to match against */
+ private Pattern mRegexp;
+ /** the format string of the regexp */
+ private String mIgnoreFormat;
+
+ /**
+ * Constructs an <code>AbstractUsageCheck</code>.
+ */
+ public AbstractUsageCheck()
+ {
+ setIgnoreFormat("^$");
+ }
+
+ /**
+ * Set the ignore format to the specified regular expression.
+ * @param aFormat a <code>String</code> value
+ * @throws ConversionException unable to parse aFormat
+ */
+ public void setIgnoreFormat(String aFormat)
+ throws ConversionException
+ {
+ try {
+ mRegexp = Utils.getPattern(aFormat);
+ mIgnoreFormat = aFormat;
+ }
+ catch (PatternSyntaxException e) {
+ throw new ConversionException("unable to parse " + aFormat, e);
+ }
+ }
+
+ /** @return the regexp to match against */
+ public Pattern getRegexp()
+ {
+ return mRegexp;
+ }
+
+ /** @return the regexp format */
+ public String getIgnoreFormat()
+ {
+ return mIgnoreFormat;
+ }
+
+ /** @see com.puppycrawl.tools.checkstyle.api.Check */
+ public void beginTree(DetailAST aRootAST)
+ {
+ // use my class loader
+ ClassManager.setClassLoader(getClassLoader());
+
+ final String fileName = getFileContents().getFilename();
+ getASTManager().addTree(fileName, aRootAST);
+ }
+
+ /** @see com.puppycrawl.tools.checkstyle.api.Check */
+ public void visitToken(DetailAST aAST)
+ {
+ if (mustCheckReferenceCount(aAST)) {
+ final DetailAST nameAST = aAST.findFirstToken(TokenTypes.IDENT);
+ Pattern regexp = getRegexp();
+ if ((regexp == null)
+ || !regexp.matcher(nameAST.getText()).find())
+ {
+ getASTManager().registerCheckNode(this, nameAST);
+ }
+ }
+ }
+
+ /** @see com.puppycrawl.tools.checkstyle.api.Check */
+ public void finishTree(DetailAST aAST)
+ {
+ if (aAST == null) {
+ // we have nothing to check
+ return;
+ }
+ try {
+ final Set nodes = getASTManager().getCheckNodes(this);
+ if (nodes != null) {
+ applyTo(nodes);
+ }
+ }
+ catch (SymbolTableException ste) {
+ logError(ste);
+ }
+ getASTManager().removeCheck(this);
+ }
+
+ /**
+ * Logs an exception.
+ * @param aException the exception to log.
+ */
+ public void logError(Exception aException)
+ {
+ log(0, "general.exception", new String[] {aException.getMessage()});
+ Utils.getExceptionLogger().debug("An exception occured.", aException);
+ }
+
+ /**
+ * Determines the reference count for a DetailAST.
+ * @param aAST the DetailAST to count.
+ * @return the number of references to aAST.
+ */
+ private int getReferenceCount(DetailAST aAST)
+ {
+ final SymTabAST ident = getASTManager().get(aAST);
+ if (ident == null) {
+ return 0;
+ }
+ final Definition definition =
+ (Definition) ident.getDefinition();
+ if (definition != null) {
+ return definition.getNumReferences();
+ }
+
+ return 0;
+ }
+
+ /**
+ * Returns the key for the Checkstyle error message.
+ * @return the key for the Checkstyle error message.
+ */
+ public abstract String getErrorKey();
+
+ /**
+ * Determines whether the reference count of an aAST is required.
+ * @param aAST the node to check.
+ * @return true if the reference count of aAST is required.
+ */
+ public abstract boolean mustCheckReferenceCount(DetailAST aAST);
+
+ /**
+ * Applies this check to a set of nodes.
+ * @param aNodes the nodes to check.
+ */
+ public void applyTo(Set aNodes)
+ {
+ final Iterator it = aNodes.iterator();
+ while (it.hasNext()) {
+ final DetailAST nameAST = (DetailAST) it.next();
+ if (getReferenceCount(nameAST) == 1) {
+ log(
+ nameAST.getLineNo(),
+ nameAST.getColumnNo(),
+ getErrorKey(),
+ nameAST.getText());
+ }
+ }
+ }
+
+ /**
+ * Gets the manager for AST nodes.
+ * @return the AST manager.
+ */
+ protected ASTManager getASTManager()
+ {
+ return ASTManager.getInstance();
+ }
+}
diff --git a/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/OneMethodPrivateFieldCheck.java b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/OneMethodPrivateFieldCheck.java
new file mode 100755
index 000000000..2ed002284
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/OneMethodPrivateFieldCheck.java
@@ -0,0 +1,139 @@
+////////////////////////////////////////////////////////////////////////////////
+// checkstyle: Checks Java source code for adherence to a set of rules.
+// Copyright (C) 2001-2005 Oliver Burn
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+////////////////////////////////////////////////////////////////////////////////
+package com.puppycrawl.tools.checkstyle.checks.usage;
+
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+import com.puppycrawl.tools.checkstyle.api.DetailAST;
+import com.puppycrawl.tools.checkstyle.api.Scope;
+import com.puppycrawl.tools.checkstyle.api.ScopeUtils;
+import com.puppycrawl.tools.checkstyle.api.TokenTypes;
+import com.puppycrawl.tools.checkstyle.checks.usage.transmogrify.Definition;
+import com.puppycrawl.tools.checkstyle.checks.usage.transmogrify.Reference;
+import com.puppycrawl.tools.checkstyle.checks.usage.transmogrify.SymTabAST;
+
+
+/**
+ * <p>Checks that a private field is used in more than one method,
+ * constructor, or initializer.
+ * </p>
+ * <p>
+ * Rationale: a private field used in only one method, constructor, or
+ * initializer should be replaced by a local variable.
+ * </p>
+ * <p>
+ * An example of how to configure the check is:
+ * </p>
+ * <pre>
+ * &lt;module name="usage.OneMethodPrivateField"/&gt;
+ * </pre>
+ *
+ * @author Rick Giles
+ */
+public class OneMethodPrivateFieldCheck
+ extends AbstractUsageCheck
+{
+ /** @see com.puppycrawl.tools.checkstyle.api.Check */
+ public int[] getDefaultTokens()
+ {
+ return new int[] {
+ TokenTypes.VARIABLE_DEF,
+ };
+ }
+
+ /** @see com.puppycrawl.tools.checkstyle.checks.usage.AbstractUsageCheck */
+ public String getErrorKey()
+ {
+ return "one.method.private.field";
+ }
+
+ /** @see com.puppycrawl.tools.checkstyle.checks.usage.AbstractUsageCheck */
+ public boolean mustCheckReferenceCount(DetailAST aAST)
+ {
+ final DetailAST mods = aAST.findFirstToken(TokenTypes.MODIFIERS);
+ return ((mods != null)
+ && (ScopeUtils.getScopeFromMods(mods) == Scope.PRIVATE));
+ }
+
+ /** @see com.puppycrawl.tools.checkstyle.checks.usage.AbstractUsageCheck */
+ public void applyTo(Set aNodes)
+ {
+ // apply the check to each private field
+ final Set methods = new HashSet();
+ final Iterator it = aNodes.iterator();
+ while (it.hasNext()) {
+ methods.clear();
+ final DetailAST nameAST = (DetailAST) it.next();
+ // find methods using the field
+ final Iterator refIt = getReferences(nameAST);
+ while (refIt.hasNext()) {
+ final Reference ref = (Reference) refIt.next();
+ final SymTabAST refNode = ref.getTreeNode();
+ final DetailAST refDetail = refNode.getDetailNode();
+ // don't need to check a self-reference
+ if (refDetail == nameAST) {
+ continue;
+ }
+ DetailAST parent = refDetail.getParent();
+ while (parent != null) {
+ final int type = parent.getType();
+ if ((type == TokenTypes.METHOD_DEF)
+ || (type == TokenTypes.CTOR_DEF)
+ || (type == TokenTypes.INSTANCE_INIT)
+ || (type == TokenTypes.STATIC_INIT))
+ {
+ methods.add(parent);
+ break;
+ }
+ // initializer for inner class?
+ else if (type == TokenTypes.CLASS_DEF) {
+ break;
+ }
+ parent = parent.getParent();
+ }
+ }
+ if (methods.size() == 1) {
+ log(
+ nameAST.getLineNo(),
+ nameAST.getColumnNo(),
+ getErrorKey(),
+ nameAST.getText());
+ }
+ }
+ }
+
+ /**
+ * Returns the references to an AST.
+ * @param aAST the AST for the references.
+ * @return an iterator for the references to aAST.
+ */
+ private Iterator getReferences(DetailAST aAST)
+ {
+ final SymTabAST ident = getASTManager().get(aAST);
+ final Definition definition =
+ (Definition) ident.getDefinition();
+ if (definition != null) {
+ return definition.getReferences();
+ }
+ final Set dummy = new HashSet();
+ return dummy.iterator();
+ }
+}
diff --git a/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/UnusedLocalVariableCheck.java b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/UnusedLocalVariableCheck.java
new file mode 100755
index 000000000..1683fd260
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/UnusedLocalVariableCheck.java
@@ -0,0 +1,59 @@
+////////////////////////////////////////////////////////////////////////////////
+// checkstyle: Checks Java source code for adherence to a set of rules.
+// Copyright (C) 2001-2005 Oliver Burn
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+////////////////////////////////////////////////////////////////////////////////
+package com.puppycrawl.tools.checkstyle.checks.usage;
+
+import com.puppycrawl.tools.checkstyle.api.DetailAST;
+import com.puppycrawl.tools.checkstyle.api.ScopeUtils;
+import com.puppycrawl.tools.checkstyle.api.TokenTypes;
+
+
+/**
+ * <p>Checks that a local variable is read.
+ * </p>
+ * <p>
+ * An example of how to configure the check is:
+ * </p>
+ * <pre>
+ * &lt;module name="usage.UnusedLocalVariable"/&gt;
+ * </pre>
+ *
+ * @author Rick Giles
+ */
+public class UnusedLocalVariableCheck extends AbstractUsageCheck
+{
+ /** @see com.puppycrawl.tools.checkstyle.api.Check */
+ public int[] getDefaultTokens()
+ {
+ return new int[] {
+ TokenTypes.VARIABLE_DEF,
+ };
+ }
+
+ /** @see com.puppycrawl.tools.checkstyle.checks.usage.AbstractUsageCheck */
+ public String getErrorKey()
+ {
+ return "unused.local";
+ }
+
+ /** @see com.puppycrawl.tools.checkstyle.checks.usage.AbstractUsageCheck */
+ public boolean mustCheckReferenceCount(DetailAST aAST)
+ {
+ return ScopeUtils.isLocalVariableDef(aAST);
+ }
+}
diff --git a/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/UnusedParameterCheck.java b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/UnusedParameterCheck.java
new file mode 100755
index 000000000..de93de14a
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/UnusedParameterCheck.java
@@ -0,0 +1,132 @@
+////////////////////////////////////////////////////////////////////////////////
+// checkstyle: Checks Java source code for adherence to a set of rules.
+// Copyright (C) 2001-2005 Oliver Burn
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+////////////////////////////////////////////////////////////////////////////////
+package com.puppycrawl.tools.checkstyle.checks.usage;
+
+import com.puppycrawl.tools.checkstyle.api.DetailAST;
+import com.puppycrawl.tools.checkstyle.api.TokenTypes;
+
+
+/**
+ * <p>Checks that a parameter is used.
+ * </p>
+ * <p>
+ * An example of how to configure the check is:
+ * </p>
+ * <pre>
+ * &lt;module name="usage.UnusedParameter"/&gt;
+ * </pre>
+ *
+ * @author Rick Giles
+ */
+public class UnusedParameterCheck extends AbstractUsageCheck
+{
+ /** controls checking of catch clause parameter */
+ private boolean mIgnoreCatch = true;
+ /** controls checking of public/protected/package methods */
+ private boolean mIgnoreNonLocal;
+
+ /** @see com.puppycrawl.tools.checkstyle.api.Check */
+ public int[] getDefaultTokens()
+ {
+ return new int[] {
+ TokenTypes.PARAMETER_DEF,
+ };
+ }
+
+ /** @see com.puppycrawl.tools.checkstyle.checks.usage.AbstractUsageCheck */
+ public String getErrorKey()
+ {
+ return "unused.parameter";
+ }
+
+ /** @see com.puppycrawl.tools.checkstyle.checks.usage.AbstractUsageCheck */
+ public boolean mustCheckReferenceCount(DetailAST aAST)
+ {
+ boolean result = false;
+ final DetailAST parent = aAST.getParent();
+ if (parent != null) {
+ if (parent.getType() == TokenTypes.PARAMETERS) {
+ final DetailAST grandparent = parent.getParent();
+ if (grandparent != null) {
+ result = hasBody(grandparent)
+ && (!mIgnoreNonLocal || isLocal(grandparent));
+ }
+ }
+ else if (parent.getType() == TokenTypes.LITERAL_CATCH) {
+ result = !mIgnoreCatch;
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Determines whether an AST is a method definition with a body, or is
+ * a constructor definition.
+ * @param aAST the AST to check.
+ * @return if AST has a body.
+ */
+ private boolean hasBody(DetailAST aAST)
+ {
+ if (aAST.getType() == TokenTypes.METHOD_DEF) {
+ return aAST.branchContains(TokenTypes.SLIST);
+ }
+ else if (aAST.getType() == TokenTypes.CTOR_DEF) {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Checks if a given method is local, i.e. either static or private.
+ * @param aAST method def for check
+ * @return true if a given method is iether static or private.
+ */
+ private boolean isLocal(DetailAST aAST)
+ {
+ if (aAST.getType() == TokenTypes.METHOD_DEF) {
+ final DetailAST modifiers =
+ aAST.findFirstToken(TokenTypes.MODIFIERS);
+ return (modifiers == null)
+ || modifiers.branchContains(TokenTypes.LITERAL_STATIC)
+ || modifiers.branchContains(TokenTypes.LITERAL_PRIVATE);
+ }
+ return true;
+ }
+
+ /**
+ * Control whether unused catch clause parameters are flagged.
+ * @param aIgnoreCatch whether unused catch clause parameters
+ * should be flagged.
+ */
+ public void setIgnoreCatch(boolean aIgnoreCatch)
+ {
+ mIgnoreCatch = aIgnoreCatch;
+ }
+
+ /**
+ * Controls whether public/protected/paskage methods shouldn't be checked.
+ * @param aIgnoreNonLocal whether we should check any other methods
+ * except static and private should be checked.
+ */
+ public void setIgnoreNonLocal(boolean aIgnoreNonLocal)
+ {
+ mIgnoreNonLocal = aIgnoreNonLocal;
+ }
+
+}
diff --git a/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/UnusedPrivateFieldCheck.java b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/UnusedPrivateFieldCheck.java
new file mode 100755
index 000000000..8e2851b43
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/UnusedPrivateFieldCheck.java
@@ -0,0 +1,63 @@
+////////////////////////////////////////////////////////////////////////////////
+// checkstyle: Checks Java source code for adherence to a set of rules.
+// Copyright (C) 2001-2005 Oliver Burn
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+////////////////////////////////////////////////////////////////////////////////
+package com.puppycrawl.tools.checkstyle.checks.usage;
+
+import com.puppycrawl.tools.checkstyle.api.DetailAST;
+import com.puppycrawl.tools.checkstyle.api.Scope;
+import com.puppycrawl.tools.checkstyle.api.ScopeUtils;
+import com.puppycrawl.tools.checkstyle.api.TokenTypes;
+
+
+/**
+ * <p>Checks that a private field is used.
+ * </p>
+ * <p>
+ * An example of how to configure the check is:
+ * </p>
+ * <pre>
+ * &lt;module name="usage.UnusedPrivateField"/&gt;
+ * </pre>
+ *
+ * @author Rick Giles
+ */
+public class UnusedPrivateFieldCheck
+ extends AbstractUsageCheck
+{
+ /** @see com.puppycrawl.tools.checkstyle.api.Check */
+ public int[] getDefaultTokens()
+ {
+ return new int[] {
+ TokenTypes.VARIABLE_DEF,
+ };
+ }
+
+ /** @see com.puppycrawl.tools.checkstyle.checks.usage.AbstractUsageCheck */
+ public String getErrorKey()
+ {
+ return "unused.field";
+ }
+
+ /** @see com.puppycrawl.tools.checkstyle.checks.usage.AbstractUsageCheck */
+ public boolean mustCheckReferenceCount(DetailAST aAST)
+ {
+ final DetailAST mods = aAST.findFirstToken(TokenTypes.MODIFIERS);
+ return ((mods != null)
+ && (ScopeUtils.getScopeFromMods(mods) == Scope.PRIVATE));
+ }
+}
diff --git a/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/UnusedPrivateMethodCheck.java b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/UnusedPrivateMethodCheck.java
new file mode 100755
index 000000000..6c2ab5f9f
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/UnusedPrivateMethodCheck.java
@@ -0,0 +1,244 @@
+////////////////////////////////////////////////////////////////////////////////
+// checkstyle: Checks Java source code for adherence to a set of rules.
+// Copyright (C) 2001-2005 Oliver Burn
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+////////////////////////////////////////////////////////////////////////////////
+package com.puppycrawl.tools.checkstyle.checks.usage;
+
+import com.puppycrawl.tools.checkstyle.api.DetailAST;
+import com.puppycrawl.tools.checkstyle.api.FullIdent;
+import com.puppycrawl.tools.checkstyle.api.Scope;
+import com.puppycrawl.tools.checkstyle.api.ScopeUtils;
+import com.puppycrawl.tools.checkstyle.api.TokenTypes;
+
+/**
+ * <p>Checks that a private method is used.
+ * </p>
+ * <p>
+ * An example of how to configure the check is:
+ * </p>
+ * <pre>
+ * &lt;module name="usage.UnusedPrivateMethod"/&gt;
+ * </pre>
+ *
+ * @author Rick Giles
+ */
+public class UnusedPrivateMethodCheck
+ extends AbstractUsageCheck
+
+{
+ /** Controls if checks skips serialization methods.*/
+ private boolean mAllowSerializationMethods;
+ /** @see com.puppycrawl.tools.checkstyle.api.Check */
+ public int[] getDefaultTokens()
+ {
+ return new int[] {
+ TokenTypes.METHOD_DEF,
+ };
+ }
+
+ /** @see com.puppycrawl.tools.checkstyle.checks.usage.AbstractUsageCheck */
+ public String getErrorKey()
+ {
+ return "unused.method";
+ }
+
+ /**
+ * Configure the check to allow (or not) serialization-related methods.
+ * @param aFlag new value for allowSerializationMethods value.
+ */
+ public void setAllowSerializationMethods(boolean aFlag)
+ {
+ mAllowSerializationMethods = aFlag;
+ }
+
+ /** @see com.puppycrawl.tools.checkstyle.checks.usage.AbstractUsageCheck */
+ public boolean mustCheckReferenceCount(DetailAST aAST)
+ {
+ final DetailAST mods = aAST.findFirstToken(TokenTypes.MODIFIERS);
+ if ((mods == null)
+ || (ScopeUtils.getScopeFromMods(mods) != Scope.PRIVATE))
+ {
+ return false;
+ }
+
+ return !mAllowSerializationMethods
+ || !(isWriteObject(aAST) || isReadObject(aAST)
+ || isWriteReplaceOrReadResolve(aAST));
+ }
+
+ /**
+ * Checks if a given method is writeObject().
+ * @param aAST method def to check
+ * @return true if this is a writeObject() definition
+ */
+ private boolean isWriteObject(DetailAST aAST)
+ {
+ // name is writeObject...
+ final DetailAST ident = aAST.findFirstToken(TokenTypes.IDENT);
+ if (!"writeObject".equals(ident.getText())) {
+ return false;
+ }
+
+ // returns void...
+ final DetailAST typeAST =
+ (DetailAST) aAST.findFirstToken(TokenTypes.TYPE).getFirstChild();
+ if (typeAST.getType() != TokenTypes.LITERAL_VOID) {
+ return false;
+ }
+
+ // should have one parameter...
+ final DetailAST params = aAST.findFirstToken(TokenTypes.PARAMETERS);
+ if (params == null || params.getChildCount() != 1) {
+ return false;
+ }
+ // and paramter's type should be java.io.ObjectOutputStream
+ final DetailAST type =
+ (DetailAST) ((DetailAST) params.getFirstChild())
+ .findFirstToken(TokenTypes.TYPE).getFirstChild();
+ final String typeName = FullIdent.createFullIdent(type).getText();
+ if (!"java.io.ObjectOutputStream".equals(typeName)
+ && !"ObjectOutputStream".equals(typeName))
+ {
+ return false;
+ }
+
+ // and, finally, it should throws java.io.IOException
+ final DetailAST throwsAST =
+ aAST.findFirstToken(TokenTypes.LITERAL_THROWS);
+ if (throwsAST == null || throwsAST.getChildCount() != 1) {
+ return false;
+ }
+ final DetailAST expt = (DetailAST) throwsAST.getFirstChild();
+ final String exceptionName = FullIdent.createFullIdent(expt).getText();
+ if (!"java.io.IOException".equals(exceptionName)
+ && !"IOException".equals(exceptionName))
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * Checks if a given method is readObject().
+ * @param aAST method def to check
+ * @return true if this is a readObject() definition
+ */
+ private boolean isReadObject(DetailAST aAST)
+ {
+ // name is readObject...
+ final DetailAST ident = aAST.findFirstToken(TokenTypes.IDENT);
+ if (!"readObject".equals(ident.getText())) {
+ return false;
+ }
+
+ // returns void...
+ final DetailAST typeAST =
+ (DetailAST) aAST.findFirstToken(TokenTypes.TYPE).getFirstChild();
+ if (typeAST.getType() != TokenTypes.LITERAL_VOID) {
+ return false;
+ }
+
+ // should have one parameter...
+ final DetailAST params = aAST.findFirstToken(TokenTypes.PARAMETERS);
+ if (params == null || params.getChildCount() != 1) {
+ return false;
+ }
+ // and paramter's type should be java.io.ObjectInputStream
+ final DetailAST type =
+ (DetailAST) ((DetailAST) params.getFirstChild())
+ .findFirstToken(TokenTypes.TYPE).getFirstChild();
+ final String typeName = FullIdent.createFullIdent(type).getText();
+ if (!"java.io.ObjectInputStream".equals(typeName)
+ && !"ObjectInputStream".equals(typeName))
+ {
+ return false;
+ }
+
+ // and, finally, it should throws java.io.IOException
+ // and java.lang.ClassNotFoundException
+ final DetailAST throwsAST =
+ aAST.findFirstToken(TokenTypes.LITERAL_THROWS);
+ if (throwsAST == null || throwsAST.getChildCount() != 3) {
+ return false;
+ }
+ final DetailAST excpt1 = (DetailAST) throwsAST.getFirstChild();
+ final String exception1 = FullIdent.createFullIdent(excpt1).getText();
+ final String exception2 =
+ FullIdent.createFullIdent(throwsAST.getLastChild()).getText();
+ if (!"java.io.IOException".equals(exception1)
+ && !"IOException".equals(exception1)
+ && !"java.io.IOException".equals(exception2)
+ && !"IOException".equals(exception2)
+ || !"java.lang.ClassNotFoundException".equals(exception1)
+ && !"ClassNotFoundException".equals(exception1)
+ && !"java.lang.ClassNotFoundException".equals(exception2)
+ && !"ClassNotFoundException".equals(exception2))
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * Checks if a given method is writeReplace() or readResolve().
+ * @param aAST method def to check
+ * @return true if this is a writeReplace() definition
+ */
+ private boolean isWriteReplaceOrReadResolve(DetailAST aAST)
+ {
+ // name is writeReplace or readResolve...
+ final DetailAST ident = aAST.findFirstToken(TokenTypes.IDENT);
+ if (!"writeReplace".equals(ident.getText())
+ && !"readResolve".equals(ident.getText()))
+ {
+ return false;
+ }
+
+ // returns Object...
+ final DetailAST typeAST =
+ (DetailAST) aAST.findFirstToken(TokenTypes.TYPE).getFirstChild();
+ if (typeAST.getType() != TokenTypes.DOT
+ && typeAST.getType() != TokenTypes.IDENT)
+ {
+ return false;
+ }
+
+ // should have no parameters...
+ final DetailAST params = aAST.findFirstToken(TokenTypes.PARAMETERS);
+ if (params != null && params.getChildCount() != 0) {
+ return false;
+ }
+
+ // and, finally, it should throws java.io.ObjectStreamException
+ final DetailAST throwsAST =
+ aAST.findFirstToken(TokenTypes.LITERAL_THROWS);
+ if (throwsAST == null || throwsAST.getChildCount() != 1) {
+ return false;
+ }
+ final DetailAST excpt = (DetailAST) throwsAST.getFirstChild();
+ final String exception = FullIdent.createFullIdent(excpt).getText();
+ if (!"java.io.ObjectStreamException".equals(exception)
+ && !"ObjectStreamException".equals(exception))
+ {
+ return false;
+ }
+
+ return true;
+ }
+}
diff --git a/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/messages.properties b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/messages.properties
new file mode 100755
index 000000000..974cbb891
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/messages.properties
@@ -0,0 +1,5 @@
+one.method.private.field=Field ''{0}'' is used in only one method.
+unused.local=Unused local variable ''{0}''.
+unused.parameter=Unused parameter ''{0}''.
+unused.field=Unused private field ''{0}''.
+unused.method=Unused private method ''{0}''.
diff --git a/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/messages_fi.properties b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/messages_fi.properties
new file mode 100755
index 000000000..4d2b13a03
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/messages_fi.properties
@@ -0,0 +1,5 @@
+one.method.private.field=Muuttujaa ''{0}'' käytetään vain yhdessä metodissa.
+unused.local=Käyttämäton paikallinen muuttuja ''{0}''.
+unused.parameter=Käyttämätön parameteri ''{0}''.
+unused.field=Käyttämätön private muuttuja ''{0}''.
+unused.method=Käyttämätön private metodi ''{0}''.
diff --git a/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/messages_fr.properties b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/messages_fr.properties
new file mode 100755
index 000000000..373635ab3
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/messages_fr.properties
@@ -0,0 +1,5 @@
+one.method.private.field=L''attribut privé ''{0}'' est utilisé dans une seule méthode.
+unused.local=Variable locale non utilisée ''{0}''.
+unused.parameter=Paramètre ''{0}'' inutilisé.
+unused.field=Attribut privé ''{0}'' inutilisé.
+unused.method=Méthode privée ''{0}'' inutilisée.
diff --git a/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/package.html b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/package.html
new file mode 100755
index 000000000..4b74c771c
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/package.html
@@ -0,0 +1,10 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head></head>
+
+<body>
+
+<p>Contains the Usage checks that are bundled with the main distribution.</p>
+
+</body>
+</html>
diff --git a/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/ASTManager.java b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/ASTManager.java
new file mode 100755
index 000000000..e664dd208
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/ASTManager.java
@@ -0,0 +1,228 @@
+////////////////////////////////////////////////////////////////////////////////
+// checkstyle: Checks Java source code for adherence to a set of rules.
+// Copyright (C) 2001-2003 Oliver Burn
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+////////////////////////////////////////////////////////////////////////////////
+package com.puppycrawl.tools.checkstyle.checks.usage.transmogrify;
+
+import java.io.File;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+import antlr.collections.AST;
+
+import com.puppycrawl.tools.checkstyle.checks.usage.AbstractUsageCheck;
+
+/**
+ * Manages AST trees and nodes. Capable of managing multiple parse trees, which
+ * is useful for inter-file checks.
+ * @author Rick Giles
+ */
+public final class ASTManager
+{
+ /** singleton */
+ private static final ASTManager INSTANCE = new ASTManager();
+
+ /**
+ * Maps DetailASTs to SymTabASTs.
+ * A HashMap is acceptable provided DetailAST method hashCode() returns
+ * distinct integers for distinct objects.
+ * If not, a structure such as IdentityHashMap must be employed.
+ */
+ private Map mMap = new HashMap();
+
+ /** root with subtrees for a set of files */
+ private SymTabAST mCompleteTree = null;
+
+ /** Map for parse trees, keyed on File name */
+ private Map mTrees = new HashMap();
+
+ /** Set of checks and their nodes to check */
+ private Map mCheckNodes = new HashMap();
+
+ /** prevent client creation */
+ private ASTManager()
+ {
+ }
+
+ /**
+ * Returns the singleon ASTManager.
+ * @return the singleon ASTManager.
+ */
+ public static ASTManager getInstance()
+ {
+ return INSTANCE;
+ }
+
+ /**
+ * Add the parse tree for a file to the set of parse trees.
+ * Postcondition: since all checks are local to one source file,
+ * all managed elements are cleared.
+ * @param aFileName the name of the file.
+ * @param aRoot the root of the AST.
+ */
+ public void addTree(String aFileName, AST aRoot)
+ {
+ clear();
+ mTrees.put(aFileName, aRoot);
+ }
+
+ /**
+ * Clears all managed elements.
+ */
+ private void clear() {
+ mCheckNodes.clear();
+ mTrees.clear();
+ mMap.clear();
+ mCompleteTree = null;
+ }
+
+ /**
+ * Builds the complete tree for all added parse trees.
+ * @throws SymbolTableException if there is an error.
+ */
+ private void buildTree()
+ throws SymbolTableException
+ {
+ mCompleteTree = SymTabASTFactory.create(0, "AST Root");
+ final Set keys = mTrees.keySet();
+ final Iterator it = keys.iterator();
+ while (it.hasNext()) {
+ final String fileName = (String) it.next();
+ final File file = new File(fileName);
+ final AST rootAST = (AST) mTrees.get(fileName);
+ addToCompleteTree(file, rootAST);
+ }
+
+ // Walk of the complete tree.
+ // TODO: This is a hack. Find a better way.
+ new TableMaker(mCompleteTree).getTable();
+ }
+
+ /**
+ * Adds a file and a DetailAST to the root SymTabAST tree. Normally, the
+ * DetailAST will be the parse tree for the file.
+ * @param aFile the file to add.
+ * @param aAST the DetailAST to add.
+ */
+ private void addToCompleteTree(File aFile, AST aAST)
+ {
+ // add aFile to the root
+ final SymTabAST fileNode =
+ SymTabASTFactory.create(0, aFile.getAbsolutePath());
+ fileNode.setFile(aFile);
+ mCompleteTree.addChild(fileNode);
+ fileNode.setParent(mCompleteTree);
+
+ // add aAST to aFile
+ final SymTabAST child = SymTabASTFactory.create(aAST);
+ child.setFile(aFile);
+ fileNode.addChild(child);
+ child.setParent(fileNode);
+ fileNode.finishDefinition(aFile, mCompleteTree);
+ }
+
+ /**
+ * Registers a node for checking.
+ * @param aCheck the check to apply.
+ * @param aNode the node to check.
+ */
+ public void registerCheckNode(AbstractUsageCheck aCheck, AST aNode)
+ {
+ Set nodeSet = (Set) mCheckNodes.get(aCheck);
+ if (nodeSet == null) {
+ nodeSet = new HashSet();
+ nodeSet.add(aNode);
+ mCheckNodes.put(aCheck, nodeSet);
+ }
+ else {
+ nodeSet.add(aNode);
+ }
+ }
+
+ /**
+ * Gets the nodes to check with a usage check.
+ * @param aCheck the usage check.
+ * @return the nodes to check with aCheck.
+ * @throws SymbolTableException if there is an error.
+ */
+ public Set getCheckNodes(AbstractUsageCheck aCheck)
+ throws SymbolTableException
+ {
+ // lazy initialization
+ if (mCompleteTree == null) {
+ buildTree();
+ }
+ Set result = (Set) mCheckNodes.get(aCheck);
+ if (result == null) {
+ result = new HashSet();
+ }
+ return result;
+ }
+
+ /**
+ * Maps a AST to its associated SymTabAST.
+ * @param aAST the AST.
+ * @param aSymTabAST the SymTabAST associated with aAST.
+ */
+ public void put(AST aAST, SymTabAST aSymTabAST)
+ {
+ mMap.put(aAST, aSymTabAST);
+ }
+
+ /**
+ * Gets the SymTabAST associated with a AST.
+ * @param aAST the AST.
+ * @return the the SymTabAST associated with aAST.
+ */
+ public SymTabAST get(AST aAST)
+ {
+ return (SymTabAST) mMap.get(aAST);
+ }
+
+ /**
+ * Clears all associations from DetailsASTs to SymTabASTs.
+ */
+ public void clearDetailsMap()
+ {
+ mMap.clear();
+ }
+
+ /**
+ * Determines whether the map from DetailsASTs to SymTabASTs is empty.
+ * @return true if the map is empty.
+ */
+ public boolean isEmptyDetailsMap()
+ {
+ return mMap.isEmpty();
+ }
+
+ /**
+ * Removes a check and its check nodes. Clears all managed elements if
+ * last check removed.
+ * @param aCheck the check to remove.
+ */
+ public void removeCheck(AbstractUsageCheck aCheck)
+ {
+ mCheckNodes.remove(aCheck);
+ if (mCheckNodes.isEmpty()) {
+ clear();
+ }
+ }
+}
diff --git a/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/ASTUtil.java b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/ASTUtil.java
new file mode 100755
index 000000000..b883edfe5
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/ASTUtil.java
@@ -0,0 +1,220 @@
+// Transmogrify License
+//
+// Copyright (c) 2001, ThoughtWorks, Inc.
+// All rights reserved.
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// - Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+// - Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// Neither the name of the ThoughtWorks, Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from this
+// software without specific prior written permission.
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+package com.puppycrawl.tools.checkstyle.checks.usage.transmogrify;
+
+import java.io.File;
+
+import com.puppycrawl.tools.checkstyle.api.TokenTypes;
+
+
+
+/**
+ * <code>ASTUtil</code> is a <code>Utility Class</code> that contains utility code
+ * for managing our SymTabAST.
+ *
+ * @see Definition
+ * @see TypedDef
+ */
+
+public class ASTUtil {
+
+ /**
+ * gets a line number for the tree; if the current SymTabAST node does not have one associated
+ * with it, traverse its children until a line number is found. Failure results in line
+ * number value of 0.
+ *
+ * @param tree the SymTabAST to process
+ *
+ * @return int the resulting line number (0 if none is found)
+ */
+ public static int getLine(SymTabAST tree) {
+ SymTabAST indexedNode = tree;
+
+ // find a node that actually has line number info
+ if (indexedNode.getLineNo() == 0) {
+ indexedNode = (SymTabAST) indexedNode.getFirstChild();
+
+ while (indexedNode != null && indexedNode.getLineNo() == 0) {
+ indexedNode = (SymTabAST) indexedNode.getNextSibling();
+ }
+
+ if (indexedNode == null) {
+ // we're screwed
+ indexedNode = tree;
+ }
+ }
+
+ return indexedNode.getLineNo();
+ }
+
+ /**
+ * gets a column number for the tree; if the current SymTabAST node does not have one associated
+ * with it, traverse its children until a column number is found. Failure results in column
+ * number value of 0.
+ *
+ * @param tree the SymTabAST to process
+ *
+ * @return int the resulting line number (0 if none is found)
+ */
+ public static int getColumn(SymTabAST tree) {
+ SymTabAST indexedNode = tree;
+
+ // find a node that actually has line number info
+ // REDTAG -- a label's ':' is a real token and has (the wrong) column info
+ // because it is the parent of the ident node that people will want
+ if (indexedNode.getColumnNo() == 0
+ || indexedNode.getType() == TokenTypes.LABELED_STAT) {
+ indexedNode = (SymTabAST) indexedNode.getFirstChild();
+
+ while (indexedNode != null && indexedNode.getColumnNo() == 0) {
+ indexedNode = (SymTabAST) indexedNode.getNextSibling();
+ }
+
+ if (indexedNode == null) {
+ // we're screwed
+ indexedNode = tree;
+ }
+ }
+
+ return indexedNode.getColumnNo();
+ }
+
+ /**
+ * Builds the dotted name String representation of the object contained within
+ * the SymTabAST.
+ *
+ * @return String
+ * @param tree the SymTabAST contaning the entire hierarcy of the object
+ */
+ public static String constructDottedName(SymTabAST tree) {
+ String result;
+
+ if (tree.getType() == TokenTypes.DOT) {
+ SymTabAST left = (SymTabAST) tree.getFirstChild();
+ SymTabAST right = (SymTabAST) left.getNextSibling();
+
+ result =
+ constructDottedName(left) + "." + constructDottedName(right);
+ }
+ else if (tree.getType() == TokenTypes.ARRAY_DECLARATOR) {
+ StringBuffer buf = new StringBuffer();
+ SymTabAST left = (SymTabAST) tree.getFirstChild();
+ SymTabAST right = (SymTabAST) left.getNextSibling();
+
+ buf.append(constructDottedName(left));
+
+ if (right != null) {
+ buf.append(".");
+ buf.append(constructDottedName(right));
+ }
+
+ buf.append(" []");
+
+ result = buf.toString();
+ }
+ else if (tree.getType() == TokenTypes.METHOD_CALL) {
+ result =
+ constructDottedName((SymTabAST) tree.getFirstChild()) + "()";
+ }
+ else {
+ result = tree.getText();
+ }
+
+ return result;
+ }
+
+ /**
+ * Returns the Package name in the hierarchy represented by the SymTabAST.
+ *
+ * @return String
+ * @param tree the SymTabAST contaning the entire hierarcy of the object
+ */
+ public static String constructPackage(SymTabAST tree) {
+ String fullName = constructDottedName(tree);
+
+ return fullName.substring(0, fullName.lastIndexOf("."));
+ }
+
+ /**
+ * Returns the top Class name in the hierarchy represented by the SymTabAST.
+ *
+ * @return String
+ * @param tree the SymTabAST contaning the entire hierarcy of the object
+ */
+ public static String constructClass(SymTabAST tree) {
+ String fullName = constructDottedName(tree);
+
+ return fullName.substring(
+ fullName.lastIndexOf(".") + 1,
+ fullName.length());
+ }
+
+ public static boolean treesBelowFilesAreEqual(
+ SymTabAST firstRoot,
+ File[] firstFiles,
+ SymTabAST secondRoot,
+ File[] secondFiles) {
+ boolean result = true;
+
+ if (firstFiles.length == secondFiles.length) {
+ for (int i = 0; i < firstFiles.length; i++) {
+ SymTabAST firstTree =
+ (SymTabAST) getFileNode(firstRoot, firstFiles[i])
+ .getFirstChild();
+ SymTabAST secondTree =
+ (SymTabAST) getFileNode(secondRoot, secondFiles[i])
+ .getFirstChild();
+
+ if (!firstTree.equalsList(secondTree)) {
+ result = false;
+ break;
+ }
+ }
+ }
+ else {
+ result = false;
+ }
+
+ return result;
+ }
+
+ public static SymTabAST getFileNode(SymTabAST root, File file)
+ {
+ SymTabAST result = null;
+
+ SymTabAST fileNode = (SymTabAST) root.getFirstChild();
+ while (fileNode != null && result == null) {
+ if (file.equals(fileNode.getFile())) {
+ result = fileNode;
+ }
+ fileNode = (SymTabAST) fileNode.getNextSibling();
+ }
+
+ return result;
+ }
+}
diff --git a/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/AnonymousInnerClass.java b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/AnonymousInnerClass.java
new file mode 100755
index 000000000..0c0ca4e1f
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/AnonymousInnerClass.java
@@ -0,0 +1,62 @@
+
+// Transmogrify License
+//
+// Copyright (c) 2001, ThoughtWorks, Inc.
+// All rights reserved.
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// - Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+// - Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// Neither the name of the ThoughtWorks, Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from this
+// software without specific prior written permission.
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+package com.puppycrawl.tools.checkstyle.checks.usage.transmogrify;
+
+
+
+
+public class AnonymousInnerClass extends ClassDef {
+
+ protected SymTabAST _objblock;
+ protected SymTabAST _classExtended;
+
+ public AnonymousInnerClass(SymTabAST objblock,
+ SymTabAST classExtended,
+ Scope parentScope) {
+ super(parentScope.getName() + "$" + parentScope.getEnclosingClass().getNextAnonymousId(),
+ parentScope,
+ objblock);
+
+ _objblock = objblock;
+ _classExtended = classExtended;
+ }
+
+ public void finishMakingDefinition() {
+ if (_classExtended != null) {
+ String extendedClassName = ASTUtil.constructDottedName(_classExtended);
+ IClass superclass = getClassDefinition(extendedClassName);
+
+ if (superclass != null) {
+ setSuperclass(superclass);
+ superclass.addSubclass(this);
+ }
+ }
+ }
+
+}
diff --git a/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/ArrayDef.java b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/ArrayDef.java
new file mode 100755
index 000000000..1e9427aff
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/ArrayDef.java
@@ -0,0 +1,154 @@
+
+// Transmogrify License
+//
+// Copyright (c) 2001, ThoughtWorks, Inc.
+// All rights reserved.
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// - Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+// - Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// Neither the name of the ThoughtWorks, Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from this
+// software without specific prior written permission.
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+package com.puppycrawl.tools.checkstyle.checks.usage.transmogrify;
+
+
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Vector;
+//import com.puppycrawl.tools.checkstyle.checks.lint.parser.JavaTokenTypes;
+
+public class ArrayDef implements IClass {
+
+ private final static IVariable LENGTH_MEMBER = new ArrayLengthMember();
+
+ private IClass _type;
+
+ public ArrayDef(IClass type){
+ _type = type;
+ }
+
+ public IClass getType(){
+ return _type;
+ }
+
+ public IClass getSuperclass() {
+ return new ArrayDef(getType().getSuperclass());
+ }
+
+ public IClass[] getInterfaces() {
+ return new IClass[0];
+ }
+
+ public IClass[] getInnerClasses() {
+ return new IClass[0];
+ }
+
+ public IClass getClassDefinition(String name) {
+ return null;
+ }
+
+ public IMethod getMethodDefinition(String name,
+ ISignature signature) {
+ return new ExternalClass(Object.class).getMethodDefinition(name,
+ signature);
+ }
+
+ public IVariable getVariableDefinition(String name) {
+ IVariable result = null;
+
+ if (name.equals("length")) {
+ result = LENGTH_MEMBER;
+ }
+
+ return result;
+ }
+
+ public void addSubclass(ClassDef subclass) {}
+
+ public void addReference(Reference reference) {}
+
+ public Iterator getReferences() {
+ return new Vector().iterator();
+ }
+
+ public int getNumReferences() {
+ return 0;
+ }
+
+ public List getSubclasses() {
+ return new ArrayList();
+ }
+
+ public void addImplementor(ClassDef implementor) {}
+
+ public List getImplementors() {
+ return new ArrayList();
+ }
+
+ public boolean isCompatibleWith(IClass type) {
+ boolean result = false;
+ if (type.equals(new ExternalClass(Object.class))) {
+ result = true;
+ }
+ else if (type instanceof ArrayDef) {
+ result = getType().isCompatibleWith(((ArrayDef)type).getType());
+ }
+
+ return result;
+ }
+
+ public boolean isSourced() {
+ return getType().isSourced();
+ }
+
+ public String getName() {
+ return getType().getName() + "[]";
+ }
+
+ public String getQualifiedName() {
+ return getType().getQualifiedName() + "[]";
+ }
+
+ public boolean isPrimitive() {
+ return false;
+ }
+
+ public boolean equals(Object obj) {
+ boolean result = false;
+
+ if (obj instanceof ArrayDef) {
+ ArrayDef compared = (ArrayDef)obj;
+ result = (getType().equals(compared.getType()));
+ }
+
+ return result;
+ }
+
+ public int hashCode() {
+ return getType().hashCode();
+ }
+
+ public String toString() {
+ return getQualifiedName() + "[]";
+ }
+
+}
diff --git a/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/ArrayLengthMember.java b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/ArrayLengthMember.java
new file mode 100755
index 000000000..f4058ee91
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/ArrayLengthMember.java
@@ -0,0 +1,48 @@
+
+// Transmogrify License
+//
+// Copyright (c) 2001, ThoughtWorks, Inc.
+// All rights reserved.
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// - Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+// - Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// Neither the name of the ThoughtWorks, Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from this
+// software without specific prior written permission.
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+package com.puppycrawl.tools.checkstyle.checks.usage.transmogrify;
+
+public class ArrayLengthMember extends ExternalVariable {
+
+ public ArrayLengthMember() {
+ super(null);
+ }
+
+ public String getName() {
+ return "length";
+ }
+
+ public String getQualifiedName() {
+ return getName();
+ }
+
+ public IClass getType() {
+ return LiteralResolver.getDefinition("int");
+ }
+}
diff --git a/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/BaseScope.java b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/BaseScope.java
new file mode 100755
index 000000000..b8356320a
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/BaseScope.java
@@ -0,0 +1,100 @@
+
+// Transmogrify License
+//
+// Copyright (c) 2001, ThoughtWorks, Inc.
+// All rights reserved.
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// - Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+// - Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// Neither the name of the ThoughtWorks, Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from this
+// software without specific prior written permission.
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+package com.puppycrawl.tools.checkstyle.checks.usage.transmogrify;
+
+/**
+ * the bottom scope of the scope stack, contains some extra information
+ * to make resolution easier.
+ */
+
+
+
+public class BaseScope extends DefaultScope {
+ private SymbolTable table;
+
+ public BaseScope( SymbolTable symbolTable ) {
+ super("~BASE~", null, null);
+ this.table = symbolTable;
+ }
+
+ public boolean isBaseScope() {
+ return true;
+ }
+
+ public void addDefinition(IPackage def) {
+ elements.put(def.getName(), def);
+ }
+
+ /**
+ * gets the package associated with a fully qualified name
+ *
+ * @param fullyQualifiedName the name of the package
+ *
+ * @return the package that was gotten
+ */
+ public IPackage getPackageDefinition(String fullyQualifiedName) {
+ return (IPackage)(table.getPackages().get(fullyQualifiedName));
+ }
+
+ public IClass getClassDefinition(String name) {
+ IClass result = null;
+
+ result = LiteralResolver.getDefinition(name);
+
+ if (result == null) {
+ int lastDot = name.lastIndexOf(".");
+ if (lastDot > 0) {
+ String packageName = name.substring(0, lastDot);
+ String className = name.substring(lastDot + 1);
+
+ IPackage pkg = getPackageDefinition(packageName);
+ if (pkg != null) {
+ result = pkg.getClass(className);
+ }
+ }
+ }
+
+ if (result == null) {
+ Class theClass = null;
+ try {
+ theClass = ClassManager.getClassLoader().loadClass(name);
+ result = new ExternalClass(theClass);
+ }
+ catch (ClassNotFoundException e) {
+ // no-op
+ }
+ catch (NoClassDefFoundError e) {
+ // no-op, checkstyle bug 842781
+ }
+ }
+
+ return result;
+ }
+}
+
diff --git a/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/BlockDef.java b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/BlockDef.java
new file mode 100755
index 000000000..a732ef166
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/BlockDef.java
@@ -0,0 +1,53 @@
+
+// Transmogrify License
+//
+// Copyright (c) 2001, ThoughtWorks, Inc.
+// All rights reserved.
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// - Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+// - Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// Neither the name of the ThoughtWorks, Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from this
+// software without specific prior written permission.
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+package com.puppycrawl.tools.checkstyle.checks.usage.transmogrify;
+
+
+
+
+/**
+ * <code>BlockDef</code> is a <code>Scope</code> which contains
+ * information about everything that defines a nameless block of java code.
+ * There are provisions for keeping the name of several anonymous
+ * blocks of java code within the same parent scope to have unique names.
+ *
+ * @see Scope
+ * @see Resolvable
+ */
+
+public class BlockDef extends DefaultScope
+{
+ private static long id = 0;
+
+ public BlockDef(Scope parentScope, SymTabAST node)
+ {
+ super("~Anonymous~" + id++, parentScope, node);
+ }
+
+}
diff --git a/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/ClassDef.java b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/ClassDef.java
new file mode 100755
index 000000000..e6dde134c
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/ClassDef.java
@@ -0,0 +1,362 @@
+
+// Transmogrify License
+//
+// Copyright (c) 2001, ThoughtWorks, Inc.
+// All rights reserved.
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// - Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+// - Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// Neither the name of the ThoughtWorks, Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from this
+// software without specific prior written permission.
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+package com.puppycrawl.tools.checkstyle.checks.usage.transmogrify;
+
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.HashSet;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+import java.util.SortedSet;
+import java.util.TreeSet;
+import java.util.Vector;
+
+
+
+/**
+ * <code>ClassDef</code> contains all the information needed to
+ * represent a java class or interface. This includes the superclass,
+ * whether it's a class or an interface, the interfaces it implements,
+ * a list of its (direct?) subclasses, and the classes that implement
+ * it if it is an interface
+ *
+ * @see Scope
+ */
+public class ClassDef extends DefaultScope implements IClass {
+ private long id = 0;
+
+ private IClass superclass = null;
+ private List interfaces = new Vector();
+
+ private List subclasses = new Vector();
+ private List implementors = new Vector();
+
+ private Set importedPackages = new HashSet();
+
+ // variable definitions will use elements from parent
+ private Set methods = new HashSet();
+
+ private Hashtable imports = new Hashtable();
+ private Vector unprocessedImports = null;
+
+ protected MethodDef _defaultConstructor;
+
+ public ClassDef(String name, Scope parentScope, SymTabAST node) {
+ super(name, parentScope, node);
+ _defaultConstructor = new DefaultConstructor(this);
+ addDefinition(_defaultConstructor);
+ }
+
+ public long getNextAnonymousId() {
+ return ++id;
+ }
+
+ public void setSuperclass(IClass newSuperclass) {
+ this.superclass = newSuperclass;
+ }
+
+ public IClass getSuperclass() {
+ return superclass;
+ }
+
+ public void addUnprocessedImports(Vector aImports) {
+ unprocessedImports = (Vector) (aImports.clone());
+ }
+
+ public Vector getUnprocessedImports() {
+ return unprocessedImports;
+ }
+
+ public void importPackage(IPackage pkg) {
+ importedPackages.add(pkg);
+ }
+
+ public void importClass(IClass imported) {
+ imports.put(imported.getName(), imported);
+ }
+
+ // begin definitions interface
+
+ public void addDefinition(MethodDef method) {
+ if (method.getName().equals(getName())) {
+ methods.remove(_defaultConstructor);
+ }
+ methods.add(method);
+ }
+
+ protected Enumeration getDefinitions() {
+ Vector allElements = new Vector();
+
+ allElements.addAll(elements.values());
+ allElements.addAll(methods);
+ allElements.addAll(labels.values());
+ allElements.addAll(classes.values());
+
+ return allElements.elements();
+ }
+
+ public IClass getClassDefinition(String name) {
+ IClass result = null;
+
+ result = (ClassDef) (classes.get(name));
+
+ if (result == null) {
+ result = (IClass) (imports.get(name));
+ }
+
+ if (result == null) {
+ Iterator it = importedPackages.iterator();
+ while (it.hasNext() && result == null) {
+ IPackage pkg = (IPackage) it.next();
+ result = pkg.getClass(name);
+ }
+ }
+
+ if (result == null) {
+ result = getParentScope().getClassDefinition(name);
+ }
+
+ //TODO: check for a class in the same package?
+ if (result == null) {
+ final String packageName = getParentScope().getQualifiedName();
+ final String fullName = packageName + "." + name;
+ Class theClass = null;
+ try {
+ theClass = ClassManager.getClassLoader().loadClass(fullName);
+ result = new ExternalClass(theClass);
+ }
+ catch (ClassNotFoundException e) {
+ // no-op
+ }
+ }
+
+ return result;
+ }
+
+ public IMethod getMethodDefinition(String name, ISignature signature) {
+ IMethod result = null;
+
+ result = getDeclaredMethod(name, signature);
+
+ if (result == null) {
+ result = getMostCompatibleMethod(name, signature);
+ }
+
+ if (result == null) {
+ if (superclass != null) {
+ result = superclass.getMethodDefinition(name, signature);
+ }
+ }
+
+ if (result == null) {
+ IClass[] myInterfaces = getInterfaces();
+ for (int index = 0;
+ index < myInterfaces.length && result == null;
+ index++) {
+ result = myInterfaces[index].getMethodDefinition(name, signature);
+ }
+ }
+
+ // not sure why this is here -- inner classes, maybe?
+ // regardless, write better
+ if (result == null) {
+ if (getParentScope() != null) {
+ result = getParentScope().getMethodDefinition(name, signature);
+ }
+ }
+
+ return result;
+ }
+
+ public IMethod getMostCompatibleMethod(String name, ISignature signature) {
+ IMethod result = null;
+
+ SortedSet compatibleMethods =
+ new TreeSet(new MethodSpecificityComparator());
+
+ Iterator it = methods.iterator();
+ while (it.hasNext()) {
+ MethodDef method = (MethodDef) it.next();
+ if (name.equals(method.getName())) {
+ if (method.hasCompatibleSignature(signature)) {
+ compatibleMethods.add(method);
+ }
+ }
+ }
+
+ if (!compatibleMethods.isEmpty()) {
+ result = (IMethod) compatibleMethods.first();
+ }
+
+ return result;
+ }
+
+ public IMethod getDeclaredMethod(String name, ISignature signature) {
+ // finds methods declared by this class with the given signature
+
+ IMethod result = null;
+
+ Iterator it = methods.iterator();
+ while (it.hasNext()) {
+ MethodDef method = (MethodDef) it.next();
+ if (name.equals(method.getName())) {
+ if (method.hasSameSignature(signature)) {
+ result = method;
+ break;
+ }
+ }
+ }
+
+ return result;
+ }
+
+ public IVariable getVariableDefinition(String name) {
+ IVariable result = null;
+
+ // in keeping with getField in java.lang.Class
+ // 1) current class
+ // 2) direct superinterfaces
+ // 3) superclass
+ // then we do the parent scope in case its an inner class
+
+ result = (VariableDef) (elements.get(name));
+
+ if (result == null) {
+ IClass[] superinterfaces = getInterfaces();
+ for (int i = 0;
+ i < superinterfaces.length && result == null;
+ i++) {
+ result = superinterfaces[i].getVariableDefinition(name);
+ }
+ }
+
+ if (result == null) {
+ if (superclass != null) {
+ result = superclass.getVariableDefinition(name);
+ }
+ }
+
+ if (result == null) {
+ if (getParentScope() != null) {
+ result = getParentScope().getVariableDefinition(name);
+ }
+ }
+
+ return result;
+ }
+
+ // end definitions interface
+
+ public void addInterface(IClass implemented) {
+ interfaces.add(implemented);
+ }
+
+ public IClass[] getInterfaces() {
+ IClass[] type = new IClass[0];
+ return (IClass[]) interfaces.toArray(type);
+ }
+
+ public ClassDef getEnclosingClass() {
+ return this;
+ }
+
+ public void addSubclass(ClassDef subclass) {
+ subclasses.add(subclass);
+ }
+
+ public List getSubclasses() {
+ return subclasses;
+ }
+
+ public void addImplementor(ClassDef implementor) {
+ implementors.add(implementor);
+ }
+
+ public List getImplementors() {
+ return implementors;
+ }
+
+ public IClass[] getInnerClasses() {
+ Iterator it = getClasses();
+ List result = new ArrayList();
+
+ while (it.hasNext()) {
+ result.add(it.next());
+ }
+
+ return (IClass[]) result.toArray(new IClass[0]);
+ }
+
+ public boolean isSuperclassOf(IClass possibleChild) {
+ // justify my existence
+ boolean result = subclasses.contains(possibleChild);
+
+ /*
+ Iterator it = subclasses.iterator();
+ while (it.hasNext() && !result) {
+ IClass child = (IClass)it.next();
+ result = child.isSuperclassOf(possibleChild);
+ }
+ */
+ return result;
+ }
+
+ public boolean isCompatibleWith(IClass type) {
+ boolean result = false;
+
+ // check myself
+ if (type.equals(this)) {
+ result = true;
+ }
+ // check my superclass
+ else if (superclass != null && superclass.isCompatibleWith(type)) {
+ result = true;
+ }
+ // check my interfaces
+ else if (!interfaces.isEmpty()) {
+ Iterator it = interfaces.iterator();
+
+ while (it.hasNext() && !result) {
+ IClass current = (IClass) it.next();
+
+ if (current.isCompatibleWith(type)) {
+ result = true;
+ }
+ }
+ }
+
+ return result;
+ }
+
+ public boolean isPrimitive() {
+ return false;
+ }
+}
diff --git a/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/ClassImportException.java b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/ClassImportException.java
new file mode 100755
index 000000000..8224331b6
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/ClassImportException.java
@@ -0,0 +1,35 @@
+
+// Transmogrify License
+//
+// Copyright (c) 2001, ThoughtWorks, Inc.
+// All rights reserved.
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// - Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+// - Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// Neither the name of the ThoughtWorks, Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from this
+// software without specific prior written permission.
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+package com.puppycrawl.tools.checkstyle.checks.usage.transmogrify;
+
+public class ClassImportException extends SymbolTableException {
+ public ClassImportException(String name) {
+ super(name);
+ }
+} \ No newline at end of file
diff --git a/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/ClassManager.java b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/ClassManager.java
new file mode 100755
index 000000000..01f59a1a3
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/ClassManager.java
@@ -0,0 +1,41 @@
+
+// Transmogrify License
+//
+// Copyright (c) 2001, ThoughtWorks, Inc.
+// All rights reserved.
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// - Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+// - Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// Neither the name of the ThoughtWorks, Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from this
+// software without specific prior written permission.
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+package com.puppycrawl.tools.checkstyle.checks.usage.transmogrify;
+
+public class ClassManager {
+ private static ClassLoader _classLoader = ClassLoader.getSystemClassLoader();
+
+ public static void setClassLoader(ClassLoader classLoader) {
+ _classLoader = classLoader;
+ }
+
+ public static ClassLoader getClassLoader() {
+ return _classLoader;
+ }
+} \ No newline at end of file
diff --git a/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/DefaultConstructor.java b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/DefaultConstructor.java
new file mode 100755
index 000000000..9884b481f
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/DefaultConstructor.java
@@ -0,0 +1,65 @@
+
+// Transmogrify License
+//
+// Copyright (c) 2001, ThoughtWorks, Inc.
+// All rights reserved.
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// - Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+// - Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// Neither the name of the ThoughtWorks, Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from this
+// software without specific prior written permission.
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+package com.puppycrawl.tools.checkstyle.checks.usage.transmogrify;
+
+import java.util.Vector;
+
+public class DefaultConstructor extends MethodDef {
+
+ protected ClassDef _classConstructed;
+
+ public DefaultConstructor(ClassDef classConstructed) {
+ super(classConstructed.getName(), classConstructed, null);
+ _classConstructed = classConstructed;
+ }
+
+ public IClass getType() {
+ return _classConstructed;
+ }
+
+ public ISignature getSignature() {
+ return new MethodSignature(new Vector());
+ }
+
+ public boolean equals(Object o) {
+ boolean result = false;
+
+ if (o instanceof DefaultConstructor) {
+ DefaultConstructor constructor = (DefaultConstructor)o;
+ result = getType().equals(constructor.getType());
+ }
+
+ return result;
+ }
+
+ public void setType() {}
+ public void addParameter() {}
+ public void addException() {}
+
+}
diff --git a/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/DefaultScope.java b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/DefaultScope.java
new file mode 100755
index 000000000..48fb7729b
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/DefaultScope.java
@@ -0,0 +1,82 @@
+
+// Transmogrify License
+//
+// Copyright (c) 2001, ThoughtWorks, Inc.
+// All rights reserved.
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// - Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+// - Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// Neither the name of the ThoughtWorks, Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from this
+// software without specific prior written permission.
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+package com.puppycrawl.tools.checkstyle.checks.usage.transmogrify;
+
+
+
+
+public class DefaultScope extends Scope {
+ public DefaultScope(String name, Scope parentScope, SymTabAST node) {
+ super(name, parentScope, node);
+ }
+
+ public void addDefinition(IPackage def) {
+ throw new UnsupportedOperationException(getClass().getName());
+ }
+
+ public IClass getClassDefinition( String name ) {
+ IClass result = (ClassDef)classes.get(name);
+
+ if ( result == null && getParentScope() != null ) {
+ result = getParentScope().getClassDefinition( name );
+ }
+
+ return result;
+ }
+
+ public IMethod getMethodDefinition(String name,
+ ISignature signature) {
+ IMethod result = null;
+ if (getParentScope() != null) {
+ result = getParentScope().getMethodDefinition(name, signature);
+ }
+
+ return result;
+ }
+
+ public IVariable getVariableDefinition( String name ) {
+ IVariable result = (VariableDef)elements.get(name);
+
+ if ( result == null && getParentScope() != null ) {
+ result = getParentScope().getVariableDefinition( name );
+ }
+
+ return result;
+ }
+
+ public LabelDef getLabelDefinition(String name) {
+ LabelDef result = (LabelDef)labels.get(name);
+
+ if (result == null && getParentScope() != null) {
+ result = getParentScope().getLabelDefinition(name);
+ }
+
+ return result;
+ }
+}
diff --git a/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/Definition.java b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/Definition.java
new file mode 100755
index 000000000..9d7e4b94b
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/Definition.java
@@ -0,0 +1,203 @@
+
+// Transmogrify License
+//
+// Copyright (c) 2001, ThoughtWorks, Inc.
+// All rights reserved.
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// - Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+// - Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// Neither the name of the ThoughtWorks, Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from this
+// software without specific prior written permission.
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+package com.puppycrawl.tools.checkstyle.checks.usage.transmogrify;
+
+import java.util.Iterator;
+import java.util.SortedSet;
+import java.util.TreeSet;
+
+
+
+
+/**
+ * <code>Definition</code> contains basic information for everything
+ * that is defined in a java source file. A definition has a list
+ * of <code>Reference</code>s, an <code>Occurrence</code>, a name, and
+ * a parent <code>Scope</code>.
+ *
+ * @see Occurrence
+ * @see Scope
+ * @see Reference
+ */
+
+public abstract class Definition implements IDefinition, Comparable {
+ private String _name = null;
+ private Scope _parentScope = null;
+ private SymTabAST _node = null;
+ private SortedSet _references;
+
+ private Occurrence _occurrence = null;
+
+ public Definition(String name, Scope parentScope, SymTabAST node) {
+ _name = name;
+ _parentScope = parentScope;
+ _node = node;
+ _references = new TreeSet();
+
+ if ( node != null ) {
+ _occurrence = new Occurrence( _node.getFile(),
+ ASTUtil.getLine( _node ),
+ ASTUtil.getColumn( _node ));
+ }
+ }
+
+ public boolean isSourced() {
+ return true;
+ }
+
+ /**
+ * returns the name of the definition
+ *
+ * @return String
+ */
+
+ public String getName() {
+ return _name;
+ }
+
+ /**
+ * returns the node in the AST that represents this definition
+ *
+ * @return the node in the AST that represents this definition
+ */
+ public SymTabAST getTreeNode() {
+ return _node;
+ }
+
+ /**
+ * Adds a <code>Reference</code> to the collection of <code>Reference</code>s
+ *
+ * @param reference the <code>Reference</code> to add
+ */
+ public void addReference( Reference reference ) {
+ _references.add( reference );
+ }
+
+ /**
+ * Returns the <code>Reference</code>s to this definition
+ *
+ * @return the <code>Reference</code>s to this definition
+ */
+ public Iterator getReferences() {
+ return _references.iterator();
+ }
+
+ public int getNumReferences() {
+ return _references.size();
+ }
+
+ /**
+ * Returns the scope in which this definition is defined
+ *
+ * @return the scope in which this definition is defined
+ */
+ public Scope getParentScope() {
+ return _parentScope;
+ }
+
+ /**
+ * returns the fully qualifed name of this defintion. The name of
+ * the parentScope and all of its parents are considered when constructing
+ * this name.
+ *
+ * @return the fully qualified name of this definition
+ */
+ public String getQualifiedName() {
+ String nameToUse = _name;
+ String result;
+
+ if (_name == null) {
+ nameToUse = "~NO NAME~";
+ }
+
+ if (getParentScope() != null &&
+ !(getParentScope() instanceof BaseScope)) {
+ result = getParentScope().getQualifiedName() + "." + nameToUse;
+ }
+ else {
+ result = nameToUse;
+ }
+ return result;
+ }
+
+ /**
+ * Returns the <code>Occurrence</code> for the location of this definition
+ *
+ * @return the <code>Occurrence</code> for the location of this definition
+ */
+ public Occurrence getOccurrence() {
+ return _occurrence;
+ }
+
+ /**
+ * Returns the <code>ClassDef</code> that this scope is contained in.
+ *
+ * @return the <code>ClassDef</code> this definition is contained in
+ */
+ public ClassDef getEnclosingClass() {
+ ClassDef result = null;
+
+ if ( getParentScope() != null ) {
+ result = getParentScope().getEnclosingClass();
+ }
+
+ return result;
+ }
+
+ public IPackage getEnclosingPackage() {
+ IPackage result = null;
+ if (getParentScope() != null) {
+ result = getParentScope().getEnclosingPackage();
+ }
+
+ return result;
+ }
+
+ /**
+ * returns a String representation of the definition. This string includes
+ * the class of the defintion and its qualified name
+ *
+ * @return String
+ */
+ public String toString() {
+ return getClass().getName() + "[" + getQualifiedName() + "]";
+ }
+
+ public int compareTo(Object o) {
+ int result = 0;
+
+ if (!(o instanceof Definition)) {
+ throw new ClassCastException(o.getClass().getName());
+ }
+ result = getQualifiedName().compareTo(((Definition)o).getQualifiedName());
+
+ return result;
+ }
+
+}
diff --git a/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/DefinitionTraverser.java b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/DefinitionTraverser.java
new file mode 100755
index 000000000..12732ebea
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/DefinitionTraverser.java
@@ -0,0 +1,139 @@
+
+// Transmogrify License
+//
+// Copyright (c) 2001, ThoughtWorks, Inc.
+// All rights reserved.
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// - Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+// - Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// Neither the name of the ThoughtWorks, Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from this
+// software without specific prior written permission.
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+package com.puppycrawl.tools.checkstyle.checks.usage.transmogrify;
+
+
+
+import java.util.Enumeration;
+import java.util.Iterator;
+
+public class DefinitionTraverser {
+
+ protected SymbolTable _symbolTable;
+
+ public DefinitionTraverser( SymbolTable symbolTable ) {
+ _symbolTable = symbolTable;
+ }
+
+ public void traverse() {
+ Enumeration packages = _symbolTable.getPackages().elements();
+ while ( packages.hasMoreElements() ) {
+ traverse( (PackageDef)(packages.nextElement()) );
+ }
+ }
+
+ private void traverse( Definition def ) {
+ if ( def instanceof PackageDef ) {
+ traverse( (PackageDef)def );
+ }
+ else if (def instanceof AnonymousInnerClass) {
+ traverse((AnonymousInnerClass)def);
+ }
+ else if ( def instanceof ClassDef ) {
+ traverse( (ClassDef)def );
+ }
+ else if (def instanceof DefaultConstructor) {
+ traverse((DefaultConstructor)def);
+ }
+ else if ( def instanceof MethodDef ) {
+ traverse( (MethodDef)def );
+ }
+ else if ( def instanceof BlockDef ) {
+ traverse( (BlockDef)def );
+ }
+ else if ( def instanceof VariableDef ) {
+ traverse( (VariableDef)def );
+ }
+ else if ( def instanceof LabelDef ) {
+ traverse( (LabelDef)def );
+ }
+ }
+
+ private void traverse(PackageDef pkg) {
+ handlePackage(pkg);
+ traversePackage(pkg);
+ }
+
+ private void traverse(AnonymousInnerClass innerClass) {
+ handleAnonymousInnerClass(innerClass);
+ traverseChildren(innerClass);
+ }
+
+ private void traverse( ClassDef classDef ) {
+ handleClass( classDef );
+ traverseChildren( classDef );
+ }
+
+ private void traverse(DefaultConstructor constructor) {
+ handleDefaultConstructor(constructor);
+ }
+
+ private void traverse( MethodDef method ) {
+ handleMethod( method );
+ traverseChildren( method );
+ }
+
+ private void traverse( BlockDef block ) {
+ handleBlock( block );
+ traverseChildren( block );
+ }
+
+ private void traverse( VariableDef variable ) {
+ handleVariable( variable );
+ }
+
+ private void traverse( LabelDef label ) {
+ handleLabel( label );
+ }
+
+ private void traversePackage(PackageDef pkg) {
+ Iterator definitions = pkg.getClasses();
+ while (definitions.hasNext()) {
+ ClassDef classDef = (ClassDef)definitions.next();
+ traverse(classDef);
+ }
+ }
+
+ private void traverseChildren(Scope scope) {
+ Enumeration definitions = scope.getDefinitions();
+ while ( definitions.hasMoreElements() ) {
+ Definition def = (Definition)(definitions.nextElement());
+ traverse(def);
+ }
+ }
+
+ protected void handlePackage( PackageDef pkg ) {}
+ protected void handleAnonymousInnerClass(AnonymousInnerClass innerClass) {}
+ protected void handleClass( ClassDef classDef ) {}
+ protected void handleDefaultConstructor(DefaultConstructor constructor) {}
+ protected void handleMethod( MethodDef method ) {}
+ protected void handleBlock( BlockDef block ) {}
+ protected void handleVariable( VariableDef variable ) {}
+ protected void handleLabel( LabelDef label ) {}
+}
diff --git a/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/DotIterator.java b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/DotIterator.java
new file mode 100755
index 000000000..470fd4a12
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/DotIterator.java
@@ -0,0 +1,108 @@
+// Transmogrify License
+//
+// Copyright (c) 2001, ThoughtWorks, Inc.
+// All rights reserved.
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// - Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+// - Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// Neither the name of the ThoughtWorks, Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from this
+// software without specific prior written permission.
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+package com.puppycrawl.tools.checkstyle.checks.usage.transmogrify;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import com.puppycrawl.tools.checkstyle.api.TokenTypes;
+
+/**
+ * An iterator for dot ('.') delimited tokens.
+ *
+ * @version 1.0
+ * @since 1.0
+ * @see Iterator
+ */
+public class DotIterator implements Iterator {
+ Iterator _nodesIter;
+ List _nodes;
+
+ public DotIterator(SymTabAST topNode)
+ {
+ _nodes = new ArrayList();
+ makeNodes(topNode);
+ _nodesIter = _nodes.iterator();
+ }
+
+ private void makeNodes(SymTabAST node)
+ {
+ if (node.getType() == TokenTypes.DOT) {
+ SymTabAST left = (SymTabAST) node.getFirstChild();
+ SymTabAST right = (SymTabAST) left.getNextSibling();
+
+ makeNodes(left);
+ makeNodes(right);
+ }
+ else {
+ _nodes.add(node);
+ }
+ }
+
+ /**
+ * Returns true if the iteration has more elements. (In other words,
+ * returns true if next would return an element rather than throwing an
+ * exception.)
+ *
+ * @return <tt>true</tt> if the iterator has more elements.
+ */
+ public boolean hasNext()
+ {
+ return _nodesIter.hasNext();
+ }
+
+ /**
+ * Returns the next portion of the dotted name.
+ *
+ * @return the next node in the dotted name.
+ */
+ public Object next()
+ {
+ return _nodesIter.next();
+ }
+
+ /**
+ * Returns the next portion of the dotted name.
+ *
+ * @return the next node in the dotted name.
+ */
+ public SymTabAST nextNode()
+ {
+ return (SymTabAST) _nodesIter.next();
+ }
+
+ /**
+ * Unsupported operation.
+ *
+ */
+ public void remove()
+ {
+ throw new UnsupportedOperationException();
+ }
+}
diff --git a/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/ExternalClass.java b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/ExternalClass.java
new file mode 100755
index 000000000..6de5176e3
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/ExternalClass.java
@@ -0,0 +1,373 @@
+
+// Transmogrify License
+//
+// Copyright (c) 2001, ThoughtWorks, Inc.
+// All rights reserved.
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// - Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+// - Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// Neither the name of the ThoughtWorks, Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from this
+// software without specific prior written permission.
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+package com.puppycrawl.tools.checkstyle.checks.usage.transmogrify;
+
+
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+import java.util.SortedSet;
+import java.util.TreeSet;
+
+//import com.puppycrawl.tools.checkstyle.checks.lint.parser.DotUtils;
+
+public class ExternalClass extends ExternalDefinition implements IClass {
+ private Class _javaClass;
+
+ private List _subclasses;
+ private List _implementors;
+
+ private Set _methods;
+
+ public ExternalClass(Class javaClass) {
+ _javaClass = javaClass;
+ _subclasses = new ArrayList();
+ _implementors = new ArrayList();
+ }
+
+ public Class getJavaClass() {
+ return _javaClass;
+ }
+
+ public String getName() {
+ return getLocalName();
+ }
+
+ private String getLocalName() {
+ String fullName = _javaClass.getName();
+ return fullName.substring(fullName.lastIndexOf(".") + 1);
+ }
+
+ public IClass getSuperclass() {
+ IClass result = null;
+ Class javaSuperclass = _javaClass.getSuperclass();
+
+ if (javaSuperclass != null) {
+ result = new ExternalClass(javaSuperclass);
+ }
+ else {
+ if (_javaClass.isInterface()) {
+ // according to Java, java.lang.Object is not the superclass of
+ // interfaces, which makes sense. However, we need Object to be
+ // the superclass of everything to make type compatibility work.
+ result = new ExternalClass(Object.class);
+ }
+ }
+
+ return result;
+ }
+
+ public IClass[] getInterfaces() {
+ Class[] javaInterfaces = _javaClass.getInterfaces();
+
+ IClass[] result = new IClass[javaInterfaces.length];
+
+ // should we cache this?
+ for (int i = 0; i < javaInterfaces.length; i++) {
+ result[i] = new ExternalClass(javaInterfaces[i]);
+ }
+
+ return result;
+ }
+
+ public IClass getClassDefinition(String name) {
+ IClass result = null;
+
+ String qualifiedName = getQualifiedName() + "$" + name;
+
+ Class[] classes = getJavaClass().getClasses();
+ for (int i = 0; i < classes.length; i++) {
+ String candidateQualifiedName = classes[i].getName();
+
+ if (qualifiedName.equals(candidateQualifiedName)) {
+ result = new ExternalClass(classes[i]);
+ break;
+ }
+ }
+
+ return result;
+ }
+
+ // REDTAG -- this should be a template method!
+ public IVariable getVariableDefinition(String name) {
+ IVariable result = null;
+ Field javaField = null;
+
+ try {
+ javaField = _javaClass.getDeclaredField(name);
+ }
+ catch (NoSuchFieldException ignoreMe) {}
+
+ if (javaField == null) {
+ Class[] interfaces = _javaClass.getInterfaces();
+ for (int i = 0; i < interfaces.length && javaField == null; i++) {
+ try {
+ javaField = interfaces[i].getDeclaredField(name);
+ }
+ catch (NoSuchFieldException ignoreMe) {}
+ }
+ }
+
+ if (javaField != null) {
+ result = new ExternalVariable(javaField);
+ }
+ else {
+ if (getSuperclass() != null) {
+ result = getSuperclass().getVariableDefinition(name);
+ }
+ }
+
+ return result;
+ }
+
+ public IMethod getMethodDefinition(String name,
+ ISignature signature) {
+ IMethod result = null;
+
+ if (name.equals(getName())) {
+ result = getConstructorDefinition(signature);
+ }
+ else {
+ Method[] methods = _javaClass.getDeclaredMethods();
+
+ for (int i = 0; i < methods.length; i++) {
+ if (name.equals(methods[i].getName())) {
+ IMethod method = new ExternalMethod(methods[i]);
+ if (method.hasSameSignature(signature)) {
+ result = method;
+ break;
+ }
+ }
+ }
+
+ if (result == null) {
+ result = getMostCompatibleMethod(name, signature);
+ }
+
+ if (result == null) {
+ if (getSuperclass() != null) {
+ result = getSuperclass().getMethodDefinition(name, signature);
+ }
+ }
+
+ if (result == null) {
+ IClass[] interfaces = getInterfaces();
+ for (int i = 0; i < interfaces.length; i++) {
+ result = interfaces[i].getMethodDefinition(name, signature);
+
+ if (result != null) {
+ break;
+ }
+
+ }
+ }
+ }
+
+ return result;
+ }
+
+ public IMethod getMostCompatibleMethod(String name, ISignature signature) {
+ IMethod result = null;
+
+ SortedSet compatibleMethods
+ = new TreeSet(new MethodSpecificityComparator());
+
+ Iterator it = getMethods().iterator();
+ while (it.hasNext()) {
+ IMethod method = (IMethod)it.next();
+ if ( name.equals( method.getName() ) ) {
+ if ( method.hasCompatibleSignature( signature ) ) {
+ compatibleMethods.add(method);
+ }
+ }
+ }
+
+ if (!compatibleMethods.isEmpty()) {
+ result = (IMethod)compatibleMethods.first();
+ }
+
+ return result;
+ }
+
+ private Collection getMethods() {
+ if (_methods == null) {
+ _methods = new HashSet();
+
+ Method[] methods = _javaClass.getDeclaredMethods();
+ for (int i = 0; i < methods.length; i++) {
+ _methods.add(new ExternalMethod(methods[i]));
+ }
+
+ }
+
+ return _methods;
+ }
+
+ public IMethod getConstructorDefinition(ISignature signature) {
+ IMethod result = null;
+
+ if (_javaClass.isInterface()) {
+ result = getInterfaceConstructor(signature);
+ }
+ else {
+ result = getClassConstructor(signature);
+ }
+
+ return result;
+ }
+
+ private IMethod getInterfaceConstructor(ISignature signature) {
+ IMethod result = null;
+
+ if (signature.getParameters().length == 0) {
+ result = new InterfaceConstructor(_javaClass);
+ }
+
+ return result;
+ }
+
+ private IMethod getClassConstructor(ISignature signature) {
+ IMethod result = null;
+
+ Constructor[] constructors = _javaClass.getConstructors();
+
+ for (int i = 0; i < constructors.length; i++) {
+ IMethod constructor = new ExternalConstructor(constructors[i]);
+ if (constructor.hasSameSignature(signature)) {
+ result = constructor;
+ break;
+ }
+ }
+
+ if (result == null) {
+ for (int i = 0; i < constructors.length; i++) {
+ IMethod constructor = new ExternalConstructor(constructors[i]);
+ if (constructor.hasCompatibleSignature(signature)) {
+ result = constructor;
+ break;
+ }
+ }
+ }
+
+ return result;
+ }
+
+ public boolean isCompatibleWith(IClass type) {
+ boolean result = false;
+
+ if (isPrimitive() && type.isPrimitive()) {
+ result = PrimitiveClasses.typesAreCompatible((ExternalClass)type,
+ this);
+ }
+ else {
+ // check myself
+ if (type.equals(this)) {
+ result = true;
+ }
+ // check my superclass
+ else if (getSuperclass() != null && getSuperclass().isCompatibleWith(type)) {
+ result = true;
+ }
+ // check my interfaces
+ else if (_javaClass.getInterfaces().length > 0) {
+ Class[] interfaces = _javaClass.getInterfaces();
+ for (int i = 0; i < interfaces.length; i++) {
+ if (new ExternalClass(interfaces[i]).isCompatibleWith(type)) {
+ result = true;
+ break;
+ }
+ }
+ }
+ }
+
+ return result;
+ }
+
+ public void addImplementor(ClassDef implementor) {
+ _implementors.add(implementor);
+ }
+
+ public List getImplementors() {
+ return _implementors;
+ }
+
+ public void addSubclass(ClassDef subclass) {
+ _subclasses.add(subclass);
+ }
+
+ public List getSubclasses() {
+ return _subclasses;
+ }
+
+ public String getQualifiedName() {
+ return _javaClass.getName();
+ }
+
+ public boolean isPrimitive() {
+ return getJavaClass().isPrimitive();
+ }
+
+ public IClass[] getInnerClasses() {
+ Class[] innerJavaClasses = getJavaClass().getDeclaredClasses();
+ IClass[] result = new IClass[innerJavaClasses.length];
+
+ for (int i = 0; i < result.length; i++) {
+ result[i] = new ExternalClass(innerJavaClasses[i]);
+ }
+
+ return result;
+ }
+
+ public String toString() {
+ return getClass() + "[" + getQualifiedName() + "]";
+ }
+
+ public boolean equals(Object o) {
+ boolean result = false;
+
+ if (o instanceof ExternalClass) {
+ ExternalClass compared = (ExternalClass)o;
+ result = (getJavaClass().equals(compared.getJavaClass()));
+ }
+
+ return result;
+ }
+
+ public int hashCode() {
+ return getJavaClass().hashCode();
+ }
+
+}
diff --git a/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/ExternalConstructor.java b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/ExternalConstructor.java
new file mode 100755
index 000000000..6691b1ab3
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/ExternalConstructor.java
@@ -0,0 +1,101 @@
+
+// Transmogrify License
+//
+// Copyright (c) 2001, ThoughtWorks, Inc.
+// All rights reserved.
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// - Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+// - Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// Neither the name of the ThoughtWorks, Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from this
+// software without specific prior written permission.
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+package com.puppycrawl.tools.checkstyle.checks.usage.transmogrify;
+
+import java.lang.reflect.Constructor;
+
+public class ExternalConstructor extends ExternalDefinition implements IMethod {
+
+ private Constructor _javaConstructor;
+ private ISignature _signature;
+
+ public ExternalConstructor(Constructor javaConstructor) {
+ _javaConstructor = javaConstructor;
+ _signature = new ExternalSignature(_javaConstructor.getParameterTypes());
+ }
+
+ public String getName() {
+ return _javaConstructor.getDeclaringClass().getName();
+ }
+
+ public IClass getType() {
+ return new ExternalClass(_javaConstructor.getDeclaringClass());
+ }
+
+ public ISignature getSignature() {
+ return _signature;
+ }
+
+ public boolean hasSameSignature(ISignature signature) {
+ return getSignature().isSame(signature);
+ }
+
+ public boolean hasCompatibleSignature(ISignature signature) {
+ return signature.isCompatibleWith(getSignature());
+ }
+
+ public String getQualifiedName() {
+ return getName() + getSignature();
+ }
+
+ public Constructor getJavaConstructor() {
+ return _javaConstructor;
+ }
+
+ public IClass[] getExceptions() {
+ Class[] javaExceptions = getJavaConstructor().getExceptionTypes();
+ IClass[] result = new IClass[javaExceptions.length];
+
+ for (int i = 0; i < result.length; i++) {
+ result[i] = new ExternalClass(javaExceptions[i]);
+ }
+
+ return result;
+ }
+
+ public String toString() {
+ return getQualifiedName();
+ }
+
+ public boolean equals(Object o) {
+ boolean result = false;
+
+ if (o instanceof ExternalConstructor) {
+ ExternalConstructor constructor = (ExternalConstructor)o;
+ result = getJavaConstructor().equals(constructor.getJavaConstructor());
+ }
+
+ return result;
+ }
+
+ public int hashCode() {
+ return getJavaConstructor().hashCode();
+ }
+
+}
diff --git a/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/ExternalDefinition.java b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/ExternalDefinition.java
new file mode 100755
index 000000000..6b53d4bc3
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/ExternalDefinition.java
@@ -0,0 +1,50 @@
+
+// Transmogrify License
+//
+// Copyright (c) 2001, ThoughtWorks, Inc.
+// All rights reserved.
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// - Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+// - Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// Neither the name of the ThoughtWorks, Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from this
+// software without specific prior written permission.
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+package com.puppycrawl.tools.checkstyle.checks.usage.transmogrify;
+
+
+
+import java.util.Iterator;
+import java.util.Vector;
+
+public abstract class ExternalDefinition implements IDefinition {
+
+ public boolean isSourced() {
+ return false;
+ }
+
+ public void addReference(Reference reference) {}
+ public Iterator getReferences() {
+ return new Vector().iterator();
+ }
+
+ public int getNumReferences() {
+ return 0;
+ }
+} \ No newline at end of file
diff --git a/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/ExternalMethod.java b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/ExternalMethod.java
new file mode 100755
index 000000000..07a19131a
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/ExternalMethod.java
@@ -0,0 +1,128 @@
+
+// Transmogrify License
+//
+// Copyright (c) 2001, ThoughtWorks, Inc.
+// All rights reserved.
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// - Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+// - Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// Neither the name of the ThoughtWorks, Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from this
+// software without specific prior written permission.
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+package com.puppycrawl.tools.checkstyle.checks.usage.transmogrify;
+
+
+
+
+import java.lang.reflect.Method;
+
+/**
+ * <code>MethodDef</code> contains all the pertinent information for
+ * a method, including return type, formal parameters, and exceptions
+ * thrown
+ *
+ * @see ClassDef
+ * @see MethodSignature
+ */
+public class ExternalMethod extends ExternalDefinition implements IMethod {
+ private Method _javaMethod;
+ private ISignature _signature;
+
+ public ExternalMethod(Method javaMethod) {
+ _javaMethod = javaMethod;
+ _signature = new ExternalSignature(_javaMethod.getParameterTypes());
+ }
+
+ public String getName() {
+ return _javaMethod.getName();
+ }
+
+ /**
+ * Returns the <code>ClassDef</code> for the return type of this method.
+ *
+ * @return the <code>ClassDef</code> for the return type of this method
+ */
+ public IClass getType() {
+ IClass result = null;
+ if (_javaMethod.getReturnType().isArray()) {
+ result = new ArrayDef(new ExternalClass(_javaMethod.getReturnType().getComponentType()));
+ }
+ else {
+ result = new ExternalClass(_javaMethod.getReturnType());
+ }
+
+ return result;
+ }
+
+ /**
+ * Returns the signature of this method.
+ *
+ * @return the signature of this method
+ */
+ public ISignature getSignature() {
+ return _signature;
+ }
+
+ public boolean hasSameSignature(ISignature signature) {
+ return _signature.isSame(signature);
+ }
+
+ public boolean hasCompatibleSignature(ISignature signature) {
+ return signature.isCompatibleWith(getSignature());
+ }
+
+ public String getQualifiedName() {
+ return getName() + getSignature();
+ }
+
+ public Method getJavaMethod() {
+ return _javaMethod;
+ }
+
+ public IClass[] getExceptions() {
+ Class[] javaExceptions = getJavaMethod().getExceptionTypes();
+ IClass[] result = new IClass[javaExceptions.length];
+
+ for (int i = 0; i < result.length; i++) {
+ result[i] = new ExternalClass(javaExceptions[i]);
+ }
+
+ return result;
+ }
+
+ public String toString() {
+ return getQualifiedName();
+ }
+
+ public boolean equals(Object o) {
+ boolean result = false;
+
+ if (o instanceof ExternalMethod) {
+ ExternalMethod compared = (ExternalMethod)o;
+ result = getJavaMethod().equals(compared.getJavaMethod());
+ }
+
+ return result;
+ }
+
+ public int hashCode() {
+ return getJavaMethod().hashCode();
+ }
+}
diff --git a/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/ExternalPackage.java b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/ExternalPackage.java
new file mode 100755
index 000000000..a0872651f
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/ExternalPackage.java
@@ -0,0 +1,95 @@
+
+// Transmogrify License
+//
+// Copyright (c) 2001, ThoughtWorks, Inc.
+// All rights reserved.
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// - Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+// - Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// Neither the name of the ThoughtWorks, Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from this
+// software without specific prior written permission.
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+package com.puppycrawl.tools.checkstyle.checks.usage.transmogrify;
+
+import java.util.HashMap;
+import java.util.Map;
+
+
+
+/**
+ * <code>PackageDef</code> contains all pertinent information about a
+ * package.
+ */
+public class ExternalPackage extends ExternalDefinition implements IPackage {
+
+ String _name;
+ IPackage _parent;
+
+ Map _packages;
+
+ public ExternalPackage(String name, IPackage parent) {
+ _name = name;
+ _parent = parent;
+
+ _packages = new HashMap();
+ }
+
+ public IClass getClass(String name) {
+ IClass result = null;
+
+ try {
+ Class theClass
+ = ClassManager.getClassLoader().loadClass(getQualifiedName()
+ + "."
+ + name);
+ result = new ExternalClass(theClass);
+ }
+ catch (ClassNotFoundException e) {
+ // look elsewhere for the class
+ }
+
+ return result;
+ }
+
+ public void addDefinition(IPackage pkg) {
+ _packages.put(pkg.getName(), pkg);
+ }
+
+ public IPackage getEnclosingPackage() {
+ return _parent;
+ }
+
+ public String getName() {
+ return _name;
+ }
+
+ public String getQualifiedName() {
+ StringBuffer result = new StringBuffer();
+
+ if (_parent != null) {
+ result.append(_parent.getQualifiedName());
+ result.append(".");
+ }
+
+ result.append(getName());
+
+ return result.toString();
+ }
+}
diff --git a/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/ExternalSignature.java b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/ExternalSignature.java
new file mode 100755
index 000000000..314826c00
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/ExternalSignature.java
@@ -0,0 +1,97 @@
+
+// Transmogrify License
+//
+// Copyright (c) 2001, ThoughtWorks, Inc.
+// All rights reserved.
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// - Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+// - Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// Neither the name of the ThoughtWorks, Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from this
+// software without specific prior written permission.
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+package com.puppycrawl.tools.checkstyle.checks.usage.transmogrify;
+
+public class ExternalSignature implements ISignature {
+
+ private IClass[] _parameters;
+
+ public ExternalSignature(Class[] parameters) {
+ _parameters = new IClass[parameters.length];
+ for (int i = 0; i < parameters.length; i++) {
+ if (parameters[i].isArray()) {
+ _parameters[i] =
+ new ArrayDef(new ExternalClass(parameters[i].getComponentType()));
+ }
+ else {
+ _parameters[i] = new ExternalClass(parameters[i]);
+ }
+ }
+ }
+
+ /**
+ * Whether this method signature is compatible with the signature of the
+ * argument. That is to say, each type for this signature are subclasses,
+ * subinterfaces, or implement the interface for each corresponding type
+ * in the argument signature.
+ *
+ * @param signature the signature of the method definition being compared
+ * @return whether the signatures are compatible
+ */
+ public boolean isCompatibleWith(ISignature signature) {
+ boolean result = true;
+
+ if (_parameters.length == signature.getParameters().length) {
+ for (int i = 0; i < _parameters.length; i++) {
+ if (!getParameters()[i].isCompatibleWith(signature.getParameters()[i])) {
+ result = false;
+ break;
+ }
+ }
+ }
+ else {
+ result = false;
+ }
+
+ return result;
+ }
+
+ public boolean isSame(ISignature signature) {
+ return java.util.Arrays.equals(_parameters, signature.getParameters());
+ }
+
+ public IClass[] getParameters() {
+ return _parameters;
+ }
+
+ public String toString() {
+ StringBuffer result = new StringBuffer();
+ result.append("(");
+ for (int i = 0; i < _parameters.length; i++) {
+ result.append(_parameters[i]);
+ if (i < _parameters.length - 1) {
+ result.append(", ");
+ }
+ }
+ result.append(")");
+
+ return result.toString();
+ }
+
+}
diff --git a/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/ExternalVariable.java b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/ExternalVariable.java
new file mode 100755
index 000000000..b252821ad
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/ExternalVariable.java
@@ -0,0 +1,76 @@
+
+// Transmogrify License
+//
+// Copyright (c) 2001, ThoughtWorks, Inc.
+// All rights reserved.
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// - Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+// - Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// Neither the name of the ThoughtWorks, Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from this
+// software without specific prior written permission.
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+package com.puppycrawl.tools.checkstyle.checks.usage.transmogrify;
+
+import java.lang.reflect.Field;
+
+
+
+/**
+ * <code>VariableDef</code> is a <code>Definition</code> that contains
+ * information about the definition of a variable.
+ *
+ * @see Definition
+ * @see TypedDef
+ */
+public class ExternalVariable extends ExternalDefinition implements IVariable {
+ Field _javaField;
+
+ public ExternalVariable(Field javaField) {
+ _javaField = javaField;
+ }
+
+ public String getName() {
+ return _javaField.getName();
+ }
+
+ public String getQualifiedName() {
+ return new ExternalClass(_javaField.getDeclaringClass()).getQualifiedName() + "." + getName();
+ }
+
+ /**
+ * Returns the <code>Type</code> of the variable.
+ *
+ * @see TypedDef
+ *
+ * @return the <code>Type</code> of the variable
+ */
+ public IClass getType() {
+ IClass result = null;
+
+ if (_javaField.getType().isArray()) {
+ result = new ArrayDef(new ExternalClass(_javaField.getType().getComponentType()));
+ }
+ else {
+ result = new ExternalClass(_javaField.getType());
+ }
+
+ return result;
+ }
+}
diff --git a/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/IClass.java b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/IClass.java
new file mode 100755
index 000000000..2d742f520
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/IClass.java
@@ -0,0 +1,142 @@
+
+// Transmogrify License
+//
+// Copyright (c) 2001, ThoughtWorks, Inc.
+// All rights reserved.
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// - Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+// - Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// Neither the name of the ThoughtWorks, Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from this
+// software without specific prior written permission.
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+package com.puppycrawl.tools.checkstyle.checks.usage.transmogrify;
+
+
+
+import java.util.List;
+
+/**
+ * interface implemented by classes/interfaces definition, for source or
+ * non-sourced classes and interfaces
+ * The implementor of this class have all information about its inner classes,
+ * methods, variables, subclasses, etc.
+ * @see net.sourceforge.transmogrify.symtab.ClassDef
+ * @see net.sourceforge.transmogrify.symtab.ExternalClass
+ */
+public interface IClass extends IDefinition {
+
+ /**
+ * gets superclass definition of this class
+ * @return superclass of this class definition
+ */
+ public IClass getSuperclass();
+
+ /**
+ * gets interfaces definition implemented by this class definition
+ * @return interfaces implemented
+ */
+ public IClass[] getInterfaces();
+
+ /**
+ * gets subclasses definition of this class definition
+ * @return list of subclasses definition
+ */
+ public List getSubclasses();
+
+ /**
+ * gets class definition referenced by this class, including its inner classes,
+ * imported classes, packages, and its parent scope referenced class definitions
+ * @param name name of the class definition to be searched
+ * @return class definition that matches the input name
+ */
+ public IClass getClassDefinition(String name);
+
+ /**
+ * gets the method associated with the given name and signature
+ *
+ * @param name the name of the method
+ * @param signature the signature (formal parameter types) of the method
+ *
+ * @return <code>MethodDef</code>
+ *
+ * @see MethodSignature
+ */
+ public IMethod getMethodDefinition(String name,
+ ISignature signature);
+
+ /**
+ * gets the <code>VariableDef</code> associated with the given name
+ *
+ * @param name the name of the variable
+ *
+ * @return <code>VariableDef</code>
+ */
+ public IVariable getVariableDefinition(String name);
+
+ // end definitions interface
+
+ /**
+ * adds <code>ClassDef</code> to the collection of (direct?) subclasses of
+ * this class
+ *
+ * @param subclass the class to add
+ * @return <code>void</code>
+ */
+ public void addSubclass(ClassDef subclass);
+
+ /**
+ * adds <code>ClassDef</code> to the collection of implemented interfaces
+ * of this class
+ *
+ * @param implementor the interface to add
+ * @return <code>void</code>
+ */
+ public void addImplementor(ClassDef implementor);
+
+ /**
+ * gets the list of <code>ClassDefs</code> that implmement this interface
+ *
+ * @return Vector the list of implementors
+ */
+ public List getImplementors();
+
+ /**
+ * verifies if the input type is equal to this class or its superclass or
+ * its interfaces
+ * @param type class to be compared with
+ * @return <code>true</code> if the input type is equals
+ * <code>false</code> otherwise
+ */
+ public boolean isCompatibleWith(IClass type);
+
+ /**
+ * verifies if this class is of primitive Java type
+ * @return <code>true</code> if the class is a primitive type
+ * <code>false</code> otherwise
+ */
+ public boolean isPrimitive();
+
+ /**
+ * gets inner classes definition associated with this class
+ * @return array of inner classes
+ */
+ public IClass[] getInnerClasses();
+
+}
diff --git a/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/IDefinition.java b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/IDefinition.java
new file mode 100755
index 000000000..77bb0a3e0
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/IDefinition.java
@@ -0,0 +1,84 @@
+
+// Transmogrify License
+//
+// Copyright (c) 2001, ThoughtWorks, Inc.
+// All rights reserved.
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// - Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+// - Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// Neither the name of the ThoughtWorks, Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from this
+// software without specific prior written permission.
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+package com.puppycrawl.tools.checkstyle.checks.usage.transmogrify;
+
+
+
+import java.util.Iterator;
+
+/**
+ * implemented by all definitions of the <code>SymTabAST</code> tree, including
+ * source/non-sourced node
+ * @see net.sourceforge.transmogrify.symtab.Definition
+ * @see net.sourceforge.transmogrify.symtab.ExternalDefinition
+ */
+public interface IDefinition {
+
+ /**
+ * verifies if this definition node is source/non-sourced(with no source-code)
+ * @return <code>true</code> if the node is parsed from a source code
+ * <code>false</code> otherwise
+ */
+ public boolean isSourced();
+
+ /**
+ * gets the name that identified this particular definition/node
+ * @return name for this definition
+ */
+ public String getName();
+
+ /**
+ * gets the fully qualified name of the definition, ie. dotted name for classes,
+ * or method name with its signature for methods, etc
+ * @return qualified name for this node
+ */
+ public String getQualifiedName();
+
+ /**
+ * adds any reference that this definition have to its collection of
+ * <code>_references</code>
+ * @param reference reference to be added which has <code>SymTabAST</code> node
+ * @return <code>void</code>
+ * @see net.sourceforge.transmogrify.symtab.antlr.SymTabAST
+ */
+ public void addReference(Reference reference);
+
+ /**
+ * gets the collection of references refer to by this definition
+ * @return iterator of the references
+ */
+ public Iterator getReferences();
+
+ /**
+ * gets the number of references refer to by this definition
+ * @return number of references
+ */
+ public int getNumReferences();
+
+} \ No newline at end of file
diff --git a/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/IMethod.java b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/IMethod.java
new file mode 100755
index 000000000..50a81344a
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/IMethod.java
@@ -0,0 +1,67 @@
+
+// Transmogrify License
+//
+// Copyright (c) 2001, ThoughtWorks, Inc.
+// All rights reserved.
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// - Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+// - Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// Neither the name of the ThoughtWorks, Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from this
+// software without specific prior written permission.
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+package com.puppycrawl.tools.checkstyle.checks.usage.transmogrify;
+
+
+
+/**
+ * <code>MethodDef</code> contains all the pertinent information for
+ * a method, including return type, formal parameters, and exceptions
+ * thrown
+ *
+ * @see ClassDef
+ * @see MethodSignature
+ * @see net.sourceforge.transmogrify.symtab.ExternalMethod
+ * @see net.sourceforge.transmogrify.symtab.MethodDef
+ */
+public interface IMethod extends Typed {
+
+ /**
+ * Returns the signature of this method.
+ *
+ * @return the signature of this method
+ */
+ public ISignature getSignature();
+
+ /**
+ * verifies if the input signature is the same with signatures of this method
+ * @return <code>true</code> if the two set signatures are equal
+ * <code>false</code> otherwise
+ */
+ public boolean hasSameSignature(ISignature signature);
+
+ /**
+ * verifies if the input signature type is compatible with this method signature
+ * @return <code>true</code> if the two set of signatures are compatible
+ * <code>false</code> otherwise
+ */
+ public boolean hasCompatibleSignature(ISignature signature);
+
+ public IClass[] getExceptions();
+} \ No newline at end of file
diff --git a/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/IPackage.java b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/IPackage.java
new file mode 100755
index 000000000..12c7faf91
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/IPackage.java
@@ -0,0 +1,63 @@
+
+// Transmogrify License
+//
+// Copyright (c) 2001, ThoughtWorks, Inc.
+// All rights reserved.
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// - Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+// - Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// Neither the name of the ThoughtWorks, Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from this
+// software without specific prior written permission.
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+package com.puppycrawl.tools.checkstyle.checks.usage.transmogrify;
+
+
+
+
+
+
+/**
+ * <code>PackageDef</code> contains all pertinent information about a
+ * package.
+ * @see net.sourceforge.transmogrify.symtab.ExternalPackage
+ * @see net.sourceforge.transmogrify.symtab.PackageDef
+ */
+public interface IPackage extends IDefinition {
+
+ /**
+ * return class definition associated with this package
+ * @param name of the class to be returned
+ * @return the class definition
+ */
+ public IClass getClass(String name);
+
+ /**
+ * gets the Package definition of itself
+ * @return Package definition
+ */
+ public IPackage getEnclosingPackage();
+
+ /**
+ * adds a package definition to its parent's list of package definitions
+ * @param def package definition
+ * @return <code>void</code>
+ */
+ public void addDefinition(IPackage def);
+} \ No newline at end of file
diff --git a/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/ISignature.java b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/ISignature.java
new file mode 100755
index 000000000..e6c99be75
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/ISignature.java
@@ -0,0 +1,58 @@
+
+// Transmogrify License
+//
+// Copyright (c) 2001, ThoughtWorks, Inc.
+// All rights reserved.
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// - Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+// - Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// Neither the name of the ThoughtWorks, Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from this
+// software without specific prior written permission.
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+package com.puppycrawl.tools.checkstyle.checks.usage.transmogrify;
+
+/**
+ * implemented by signatures of methods
+ * @see net.sourceforge.transmogrify.symtab.MethodSignature
+ * @see net.sourceforge.transmogrify.symtab.ExternalSignature
+ */
+public interface ISignature {
+
+ public IClass[] getParameters();
+
+ /**
+ * Whether this method signature is compatible with the signature of the
+ * argument. That is to say, each type for this signature are subclasses,
+ * subinterfaces, or implement the interface for each corresponding type
+ * in the argument signature.
+ *
+ * @param signature the signature of the method definition being compared
+ * @return whether the signatures are compatible
+ */
+ public boolean isCompatibleWith(ISignature signature);
+
+ /**
+ * if both signature has the same set of parameters
+ * @param signature signature to be compared
+ * @return <code>true</code> if the two set of parameters are equal
+ * <code>false</code> otherwise
+ */
+ public boolean isSame(ISignature signature);
+}
diff --git a/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/IVariable.java b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/IVariable.java
new file mode 100755
index 000000000..be6fb296b
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/IVariable.java
@@ -0,0 +1,39 @@
+
+// Transmogrify License
+//
+// Copyright (c) 2001, ThoughtWorks, Inc.
+// All rights reserved.
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// - Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+// - Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// Neither the name of the ThoughtWorks, Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from this
+// software without specific prior written permission.
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+package com.puppycrawl.tools.checkstyle.checks.usage.transmogrify;
+
+
+
+/**
+ * contains information about type of a variable or its <code>Field</code>,
+ * in case of non-source variable
+ * @see net.sourceforge.transmogrify.symtab.VariableDef
+ * @see net.sourceforge.transmogrify.symtab.ExternalVariable
+ */
+public interface IVariable extends Typed {} \ No newline at end of file
diff --git a/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/InterfaceConstructor.java b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/InterfaceConstructor.java
new file mode 100755
index 000000000..8db79a303
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/InterfaceConstructor.java
@@ -0,0 +1,90 @@
+
+// Transmogrify License
+//
+// Copyright (c) 2001, ThoughtWorks, Inc.
+// All rights reserved.
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// - Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+// - Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// Neither the name of the ThoughtWorks, Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from this
+// software without specific prior written permission.
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+package com.puppycrawl.tools.checkstyle.checks.usage.transmogrify;
+
+import java.lang.reflect.Constructor;
+import java.util.Vector;
+
+public class InterfaceConstructor extends ExternalDefinition implements IMethod {
+
+ protected Class _classConstructed;
+
+ public InterfaceConstructor(Class classConstructed) {
+ _classConstructed = classConstructed;
+ }
+
+ public String getName() {
+ return _classConstructed.getName();
+ }
+
+ public IClass getType() {
+ return new ExternalClass(_classConstructed);
+ }
+
+ public ISignature getSignature() {
+ return new MethodSignature(new Vector());
+ }
+
+ public boolean hasSameSignature(ISignature signature) {
+ return getSignature().isSame(signature);
+ }
+
+ public boolean hasCompatibleSignature(ISignature signature) {
+ return signature.isCompatibleWith(getSignature());
+ }
+
+ public Constructor getJavaConstructor() {
+ return null;
+ }
+
+ public IClass[] getExceptions() {
+ return new IClass[0];
+ }
+
+
+ public String getQualifiedName() {
+ return getName() + getSignature();
+ }
+
+ public boolean equals(Object o) {
+ boolean result = false;
+
+ if (o instanceof InterfaceConstructor) {
+ InterfaceConstructor constructor = (InterfaceConstructor)o;
+ result = getType().equals(constructor.getType());
+ }
+
+ return result;
+ }
+
+ public int hashCode() {
+ return getType().hashCode();
+ }
+
+}
diff --git a/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/LabelDef.java b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/LabelDef.java
new file mode 100755
index 000000000..3c8dce9c3
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/LabelDef.java
@@ -0,0 +1,48 @@
+
+// Transmogrify License
+//
+// Copyright (c) 2001, ThoughtWorks, Inc.
+// All rights reserved.
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// - Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+// - Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// Neither the name of the ThoughtWorks, Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from this
+// software without specific prior written permission.
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+package com.puppycrawl.tools.checkstyle.checks.usage.transmogrify;
+
+
+
+
+
+/**
+ * <code>LabelDef</code> is a <code>Definition</code> that contains information
+ * about the definition of a Label.
+ *
+ * @see Definition
+ */
+
+public class LabelDef extends Definition {
+
+ public LabelDef( String name, Scope parentScope, SymTabAST node ) {
+ super( name, parentScope, node );
+ }
+
+}
diff --git a/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/LiteralResolver.java b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/LiteralResolver.java
new file mode 100755
index 000000000..370a9942b
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/LiteralResolver.java
@@ -0,0 +1,157 @@
+
+// Transmogrify License
+//
+// Copyright (c) 2001, ThoughtWorks, Inc.
+// All rights reserved.
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// - Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+// - Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// Neither the name of the ThoughtWorks, Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from this
+// software without specific prior written permission.
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+package com.puppycrawl.tools.checkstyle.checks.usage.transmogrify;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import com.puppycrawl.tools.checkstyle.api.TokenTypes;
+
+/**
+ * Resolves primitive identifiers (int, double) to their corresponding
+ * <code>ClassDef</code>. This class uses the Singleton pattern.
+ *
+ * @author <a href="mailto:smileyy@thoughtworks.com">andrew</a>
+ * @version 1.0
+ * @since 1.0
+ */
+
+public class LiteralResolver {
+
+ private static Map intMap;
+ private static Map nameMap;
+ private static Map classMap;
+
+ static {
+ nameMap = new HashMap();
+
+ nameMap.put("boolean", new ExternalClass(Boolean.TYPE));
+ nameMap.put("byte", new ExternalClass(Byte.TYPE));
+ nameMap.put("char", new ExternalClass(Character.TYPE));
+ nameMap.put("short", new ExternalClass(Short.TYPE));
+ nameMap.put("int", new ExternalClass(Integer.TYPE));
+ nameMap.put("float", new ExternalClass(Float.TYPE));
+ nameMap.put("long", new ExternalClass(Long.TYPE));
+ nameMap.put("double", new ExternalClass(Double.TYPE));
+
+ intMap = new HashMap();
+
+ intMap.put(
+ new Integer(TokenTypes.LITERAL_BOOLEAN),
+ new ExternalClass(Boolean.TYPE));
+ intMap.put(
+ new Integer(TokenTypes.LITERAL_BYTE),
+ new ExternalClass(Byte.TYPE));
+ intMap.put(
+ new Integer(TokenTypes.LITERAL_CHAR),
+ new ExternalClass(Character.TYPE));
+ intMap.put(
+ new Integer(TokenTypes.LITERAL_SHORT),
+ new ExternalClass(Short.TYPE));
+ intMap.put(
+ new Integer(TokenTypes.LITERAL_INT),
+ new ExternalClass(Integer.TYPE));
+ intMap.put(
+ new Integer(TokenTypes.LITERAL_FLOAT),
+ new ExternalClass(Float.TYPE));
+ intMap.put(
+ new Integer(TokenTypes.LITERAL_LONG),
+ new ExternalClass(Long.TYPE));
+ intMap.put(
+ new Integer(TokenTypes.LITERAL_DOUBLE),
+ new ExternalClass(Double.TYPE));
+ intMap.put(
+ new Integer(TokenTypes.STRING_LITERAL),
+ new ExternalClass("".getClass()));
+
+ classMap = new HashMap();
+ classMap.put(
+ new ExternalClass(Boolean.TYPE),
+ SymTabASTFactory.create(TokenTypes.LITERAL_BOOLEAN, "boolean"));
+ classMap.put(
+ new ExternalClass(Byte.TYPE),
+ SymTabASTFactory.create(TokenTypes.LITERAL_BYTE, "byte"));
+ classMap.put(
+ new ExternalClass(Character.TYPE),
+ SymTabASTFactory.create(TokenTypes.LITERAL_CHAR, "char"));
+ classMap.put(
+ new ExternalClass(Short.TYPE),
+ SymTabASTFactory.create(TokenTypes.LITERAL_SHORT, "short"));
+ classMap.put(
+ new ExternalClass(Integer.TYPE),
+ SymTabASTFactory.create(TokenTypes.LITERAL_INT, "int"));
+ classMap.put(
+ new ExternalClass(Float.TYPE),
+ SymTabASTFactory.create(TokenTypes.LITERAL_FLOAT, "float"));
+ classMap.put(
+ new ExternalClass(Long.TYPE),
+ SymTabASTFactory.create(TokenTypes.LITERAL_LONG, "long"));
+ classMap.put(
+ new ExternalClass(Double.TYPE),
+ SymTabASTFactory.create(TokenTypes.LITERAL_DOUBLE, "double"));
+
+ }
+
+ /**
+ * Returns a <code>LiteralResolver</code>
+ *
+ * @return a <code>LiteralResolver</code>
+ */
+
+ public static LiteralResolver getResolver() {
+ return new LiteralResolver();
+ }
+
+ /**
+ * Returns the <code>ClassDef</code> for a primitive type reference.
+ *
+ * <p>
+ * We could probably do without passing in the context, if we could figure
+ * out a way to access the base scope.
+ * </p>
+ *
+ * @param literalType the JavaTokenType for the literal type
+ * @param context the scope in which the search performed
+ * @return returns the <code>ClassDef</code>corresponding to the primitive
+ * type
+ */
+
+ public static IClass getDefinition(int literalType) {
+ Integer key = new Integer(literalType);
+ return (IClass) intMap.get(key);
+ }
+
+ public static IClass getDefinition(String name) {
+ return (IClass) nameMap.get(name);
+ }
+
+ public static SymTabAST getASTNode(IClass primitive) {
+ return (SymTabAST) classMap.get(primitive);
+ }
+}
diff --git a/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/MethodDef.java b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/MethodDef.java
new file mode 100755
index 000000000..6a87a4527
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/MethodDef.java
@@ -0,0 +1,157 @@
+
+// Transmogrify License
+//
+// Copyright (c) 2001, ThoughtWorks, Inc.
+// All rights reserved.
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// - Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+// - Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// Neither the name of the ThoughtWorks, Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from this
+// software without specific prior written permission.
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+package com.puppycrawl.tools.checkstyle.checks.usage.transmogrify;
+
+
+
+import java.util.List;
+import java.util.Vector;
+
+
+/**
+ * <code>MethodDef</code> contains all the pertinent information for
+ * a method, including return type, formal parameters, and exceptions
+ * thrown
+ *
+ * @see ClassDef
+ * @see MethodSignature
+ */
+public class MethodDef extends DefaultScope implements IMethod {
+
+ private IClass returnType;
+ private List exceptions;
+
+ private List parameters;
+
+ public MethodDef(String name, Scope parentScope, SymTabAST node) {
+ super(name, parentScope, node);
+ parameters = new Vector();
+ }
+
+ /**
+ * Returns the <code>ClassDef</code> for the return type of this method.
+ *
+ * @return the <code>ClassDef</code> for the return type of this method
+ */
+ public IClass getType() {
+ return returnType;
+ }
+
+ /**
+ * Sets the return type of this method.
+ *
+ * @param type the <code>ClassDef</code> for the return type
+ */
+ public void setType(IClass type) {
+ returnType = type;
+ }
+
+ /**
+ * Adds a parameter to the collection of formal parameters
+ *
+ * @param parameter the <code>VariableDef</code> to add
+ */
+ public void addParameter(VariableDef parameter) {
+ parameters.add( parameter );
+ addDefinition(parameter);
+ }
+
+ /**
+ * Whether this method has the same signature as the given signature.
+ *
+ * @param signature the <code>MethodSignature</code> to compare
+ *
+ * @return whether the signatures are equal
+ */
+ public boolean hasSameSignature(ISignature signature) {
+ return getSignature().equals(signature);
+ }
+
+ /**
+ * Whether this method has a signature compatible with the given signature.
+ *
+ * @param signature the signature being compared
+ * @return whether the signatures are compatible
+ */
+ public boolean hasCompatibleSignature(ISignature signature) {
+ return signature.isCompatibleWith(getSignature());
+ }
+
+ /**
+ * Returns the signature of this method.
+ *
+ * @return the signature of this method
+ */
+ public ISignature getSignature() {
+ Vector argTypes = new Vector();
+
+ for (int i = 0; i < parameters.size(); i++) {
+ argTypes.add(getParameterAt(i).getType());
+ }
+
+ return new MethodSignature(argTypes);
+ }
+
+ /**
+ * Gets the <i>i</i>th parameter of this method
+ *
+ * @param i the index of the parameter
+ *
+ * @return the <code>VariableDef</code> of the <i>i</i>th parameter
+ */
+ private VariableDef getParameterAt( int i ) {
+ return (VariableDef)(parameters.get( i ));
+ }
+
+ /**
+ * Adds an exception that this method throws.
+ *
+ * @param exception the exception to add
+ */
+ public void addException(IClass exception) {
+ if (exceptions == null) {
+ exceptions = new Vector();
+ }
+
+ exceptions.add(exception);
+ }
+
+ /**
+ * Returns the exceptions this method throws
+ *
+ * @return the exceptions this method throws
+ */
+ public IClass[] getExceptions() {
+ return (IClass[])exceptions.toArray(new IClass[0]);
+ }
+
+ public String getQualifiedName() {
+ return super.getQualifiedName() + getSignature();
+ }
+} \ No newline at end of file
diff --git a/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/MethodSignature.java b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/MethodSignature.java
new file mode 100755
index 000000000..a31a26fd4
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/MethodSignature.java
@@ -0,0 +1,138 @@
+
+// Transmogrify License
+//
+// Copyright (c) 2001, ThoughtWorks, Inc.
+// All rights reserved.
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// - Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+// - Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// Neither the name of the ThoughtWorks, Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from this
+// software without specific prior written permission.
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+package com.puppycrawl.tools.checkstyle.checks.usage.transmogrify;
+
+import java.util.Vector;
+
+
+
+/**
+ * <code>MethodSignature</code> is used to resolve various methods
+ * in the same scope of the same name based on formal parameter lists
+ *
+ * @see MethodDef
+ */
+
+public class MethodSignature implements ISignature{
+
+ private IClass[] _argTypes = null;
+
+ public MethodSignature(IClass[] argTypes) {
+ _argTypes = argTypes;
+ }
+
+ public MethodSignature(Vector argTypes) {
+ _argTypes = new IClass[argTypes.size()];
+ argTypes.toArray(_argTypes);
+ }
+
+ /**
+ * returns an array of the types of the arguments in the signature
+ *
+ * @return ClassDef[]
+ */
+ public IClass[] getParameters() {
+ return _argTypes;
+ }
+
+ /**
+ * Whether this method signature is compatible with the signature of the
+ * argument. That is to say, each type for this signature are subclasses,
+ * subinterfaces, or implement the interface for each corresponding type
+ * in the argument signature.
+ *
+ * @param signature the signature of the method definition being compared
+ * @return whether the signatures are compatible
+ */
+ public boolean isCompatibleWith(ISignature signature) {
+ boolean result = true;
+
+ IClass[] comparedArgTypes = signature.getParameters();
+ if (_argTypes.length != comparedArgTypes.length) {
+ result = false;
+ }
+ else {
+ for (int i = 0; i < _argTypes.length; i++) {
+ // TODO: Checkstyle modification. Why can _argTypes[i] be null?
+ // if (!_argTypes[i].isCompatibleWith(comparedArgTypes[i])) {
+ if ((_argTypes[i] != null)
+ && !_argTypes[i].isCompatibleWith(comparedArgTypes[i]))
+ {
+ result = false;
+ break;
+ }
+ }
+ }
+
+ return result;
+ }
+
+ public boolean isSame(ISignature signature) {
+ return equals(signature);
+ }
+
+ /**
+ * compares two objects for equality. If the compared object is a
+ * <code>MethodSignature</code> and the argTypes match, they are the
+ * same
+ *
+ * @return boolean
+ */
+ public boolean equals(Object o) {
+ boolean result = false;
+
+ if (o instanceof MethodSignature) {
+ MethodSignature signature = (MethodSignature)o;
+ result = java.util.Arrays.equals(getParameters(), signature.getParameters());
+ }
+
+ return result;
+ }
+
+ /**
+ * returns a String representation of this object. Includes information
+ * about the types of the arguments in the signature
+ *
+ * @return String
+ */
+ public String toString() {
+ StringBuffer result = new StringBuffer( "(" );
+
+ for ( int i = 0; i < _argTypes.length; i++ ) {
+ result.append( _argTypes[i] != null ? _argTypes[i].getName() : "[null]" );
+ if ( i < (_argTypes.length - 1) ) {
+ result.append( ", " );
+ }
+ }
+ result.append( ")" );
+
+ return result.toString();
+ }
+
+}
diff --git a/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/MethodSpecificityComparator.java b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/MethodSpecificityComparator.java
new file mode 100755
index 000000000..f75743f8e
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/MethodSpecificityComparator.java
@@ -0,0 +1,59 @@
+
+// Transmogrify License
+//
+// Copyright (c) 2001, ThoughtWorks, Inc.
+// All rights reserved.
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// - Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+// - Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// Neither the name of the ThoughtWorks, Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from this
+// software without specific prior written permission.
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+package com.puppycrawl.tools.checkstyle.checks.usage.transmogrify;
+
+import java.util.Comparator;
+
+public class MethodSpecificityComparator implements Comparator {
+
+ public int compare(Object o1, Object o2) {
+ int result = 0;
+
+ IMethod method1 = (IMethod)o1;
+ IMethod method2 = (IMethod)o2;
+
+ if (method1.equals(method2)) {
+ result = 0;
+ }
+ else {
+ ISignature sig1 = method1.getSignature();
+ ISignature sig2 = method2.getSignature();
+
+ if (sig1.isCompatibleWith(sig2)) {
+ result = -1;
+ }
+ else {
+ result = 1;
+ }
+ }
+
+ return result;
+ }
+
+}
diff --git a/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/NullClass.java b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/NullClass.java
new file mode 100755
index 000000000..23fc72c6d
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/NullClass.java
@@ -0,0 +1,107 @@
+
+// Transmogrify License
+//
+// Copyright (c) 2001, ThoughtWorks, Inc.
+// All rights reserved.
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// - Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+// - Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// Neither the name of the ThoughtWorks, Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from this
+// software without specific prior written permission.
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+package com.puppycrawl.tools.checkstyle.checks.usage.transmogrify;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+public class NullClass implements IClass {
+
+ public Iterator getReferences() {
+ return new ArrayList().iterator();
+ }
+
+ public int getNumReferences() {
+ return 0;
+ }
+
+ public void addReference(Reference ref) {}
+
+ public String getName() {
+ return "null";
+ }
+
+ public String getQualifiedName() {
+ return getName();
+ }
+
+ public boolean isSourced() {
+ return false;
+ }
+
+ public IClass getSuperclass() {
+ return null;
+ }
+
+ public IClass[] getInterfaces() {
+ return new IClass[0];
+ }
+
+ public IClass[] getInnerClasses() {
+ return new IClass[0];
+ }
+
+ public List getSubclasses() {
+ return new ArrayList();
+ }
+
+ public IClass getClassDefinition(String name) {
+ return null;
+ }
+
+ public IMethod getMethodDefinition(String name,
+ ISignature signature) {
+ return null;
+ }
+
+ public IVariable getVariableDefinition(String name) {
+ return null;
+ }
+
+ public void addSubclass(ClassDef subclass) {}
+ public void addImplementor(ClassDef implementor) {}
+
+ public List getImplementors() {
+ return new ArrayList();
+ }
+
+ public boolean isCompatibleWith(IClass type) {
+ return true;
+ }
+
+ public boolean isPrimitive() {
+ return false;
+ }
+
+}
+
+
+
+
diff --git a/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/Occurrence.java b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/Occurrence.java
new file mode 100755
index 000000000..fb1373e1d
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/Occurrence.java
@@ -0,0 +1,131 @@
+
+// Transmogrify License
+//
+// Copyright (c) 2001, ThoughtWorks, Inc.
+// All rights reserved.
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// - Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+// - Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// Neither the name of the ThoughtWorks, Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from this
+// software without specific prior written permission.
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+package com.puppycrawl.tools.checkstyle.checks.usage.transmogrify;
+
+import java.io.File;
+
+
+
+
+/**
+ * <code>Occurrence</code> contains file and line number information.
+ * It is used to denote the location of various <code>Definintion</code>s
+ * and <code>Reference</code>s
+ *
+ * @see Reference
+ * @see Definition
+ */
+
+public class Occurrence implements Comparable {
+ private File _file;
+ private int _line;
+ private int _column;
+
+ public Occurrence(File file, int line, int column) {
+ _file = file;
+ _line = line;
+ _column = column;
+ }
+
+ public Occurrence(SymTabAST node) {
+ _file = node.getFile();
+ _line = node.getLineNo();
+ _column = node.getColumnNo();
+ }
+
+ /**
+ * returns the File of this <code>Occurrence</code>
+ *
+ * @return File
+ */
+ public File getFile() {
+ return _file;
+ }
+
+ /**
+ * returns the line number of this <code>Occurrence</code>
+ *
+ * @return the line number of this <code>Occurrence</code>
+ */
+ public int getLine() {
+ return _line;
+ }
+
+ /**
+ * returns the column that this token starts at
+ *
+ * @return the column that this token starts at
+ */
+ public int getColumn() {
+ return _column;
+ }
+
+ public int compareTo(Object o) {
+ if (!(o instanceof Occurrence)) {
+ throw new ClassCastException(getClass().getName());
+ }
+
+ Occurrence other = (Occurrence)o;
+
+ int result = 0;
+
+ result = getFile().compareTo(other.getFile());
+
+ if (result == 0) {
+ result = getLine() - other.getLine();
+ }
+ if (result == 0) {
+ result = getColumn() - other.getColumn();
+ }
+
+ return result;
+ }
+
+ public boolean equals(Object o) {
+ boolean result = false;
+
+ if (o instanceof Occurrence) {
+ Occurrence occ = (Occurrence)o;
+ result = (getFile().equals(occ.getFile())
+ && getLine() == occ.getLine()
+ && getColumn() == occ.getColumn());
+ }
+
+ return result;
+ }
+
+ public int hashCode() {
+ return getFile().hashCode();
+ }
+
+ public String toString() {
+ return "[" + getFile() + ":" + getLine() + "," + getColumn() + "]";
+ }
+
+}
diff --git a/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/PackageDef.java b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/PackageDef.java
new file mode 100755
index 000000000..1ec967a17
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/PackageDef.java
@@ -0,0 +1,66 @@
+
+// Transmogrify License
+//
+// Copyright (c) 2001, ThoughtWorks, Inc.
+// All rights reserved.
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// - Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+// - Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// Neither the name of the ThoughtWorks, Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from this
+// software without specific prior written permission.
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+package com.puppycrawl.tools.checkstyle.checks.usage.transmogrify;
+
+
+
+
+/**
+ * <code>PackageDef</code> contains all pertinent information about a
+ * package.
+ */
+public class PackageDef extends DefaultScope implements IPackage {
+
+ public PackageDef(String name, Scope parentScope, SymTabAST node) {
+ super(name, parentScope, node);
+ }
+
+ public LabelDef getLabelDefinition(String name) {
+ throw new UnsupportedOperationException(getClass().getName());
+ }
+
+ public IClass getClass(String name) {
+ return (IClass)classes.get(name);
+ }
+
+ public IPackage getEnclosingPackage() {
+ return this;
+ }
+
+ public IVariable getVariableDefinition(String name) {
+ return null;
+ }
+
+ public void addDefinition(IPackage def) {
+ if (elements.get(def.getName()) == null) {
+ elements.put(def.getName(), def);
+ }
+ }
+
+}
diff --git a/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/PrimitiveClasses.java b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/PrimitiveClasses.java
new file mode 100755
index 000000000..4a7860bde
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/PrimitiveClasses.java
@@ -0,0 +1,107 @@
+
+// Transmogrify License
+//
+// Copyright (c) 2001, ThoughtWorks, Inc.
+// All rights reserved.
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// - Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+// - Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// Neither the name of the ThoughtWorks, Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from this
+// software without specific prior written permission.
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+package com.puppycrawl.tools.checkstyle.checks.usage.transmogrify;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class PrimitiveClasses {
+
+ public static final ExternalClass BOOLEAN = new ExternalClass(Boolean.TYPE);
+ public static final ExternalClass CHAR = new ExternalClass(Character.TYPE);
+ public static final ExternalClass BYTE = new ExternalClass(Byte.TYPE);
+ public static final ExternalClass SHORT = new ExternalClass(Short.TYPE);
+ public static final ExternalClass INT = new ExternalClass(Integer.TYPE);
+ public static final ExternalClass LONG = new ExternalClass(Long.TYPE);
+ public static final ExternalClass FLOAT = new ExternalClass(Float.TYPE);
+ public static final ExternalClass DOUBLE = new ExternalClass(Double.TYPE);
+
+ private static List order;
+
+ static {
+ order = new ArrayList();
+ order.add(DOUBLE);
+ order.add(FLOAT);
+ order.add(LONG);
+ order.add(INT);
+ order.add(SHORT);
+ order.add(BYTE);
+ }
+
+ public static boolean typesAreCompatible(ExternalClass hole,
+ ExternalClass peg) {
+ boolean result = false;
+
+ if (hole.equals(BOOLEAN)) {
+ result = peg.equals(BOOLEAN);
+ }
+ else if (hole.equals(CHAR)) {
+ result = peg.equals(CHAR);
+ }
+ else if (peg.equals(CHAR)) {
+ result = (hole.equals(CHAR) ||
+ order.indexOf(hole) <= order.indexOf(INT));
+ }
+ else {
+ result = (order.indexOf(hole) <= order.indexOf(peg));
+ }
+
+ return result;
+ }
+
+ public static IClass unaryPromote(IClass type) {
+ IClass result = type;
+
+ if (type.equals(BYTE) || type.equals(SHORT) || type.equals(CHAR)) {
+ result = INT;
+ }
+
+ return result;
+ }
+
+ public static IClass binaryPromote(IClass a, IClass b) {
+ IClass result = null;
+
+ if (a.equals(DOUBLE) || b.equals(DOUBLE)) {
+ result = DOUBLE;
+ }
+ else if (a.equals(FLOAT) || b.equals(FLOAT)) {
+ result = FLOAT;
+ }
+ else if (a.equals(LONG) || b.equals(LONG)) {
+ result = LONG;
+ }
+ else {
+ result = INT;
+ }
+
+ return result;
+ }
+
+}
diff --git a/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/QueryEngine.java b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/QueryEngine.java
new file mode 100755
index 000000000..e10c3e8f8
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/QueryEngine.java
@@ -0,0 +1,185 @@
+
+// Transmogrify License
+//
+// Copyright (c) 2001, ThoughtWorks, Inc.
+// All rights reserved.
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// - Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+// - Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// Neither the name of the ThoughtWorks, Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from this
+// software without specific prior written permission.
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+package com.puppycrawl.tools.checkstyle.checks.usage.transmogrify;
+
+import java.io.File;
+import java.util.Iterator;
+
+import com.puppycrawl.tools.checkstyle.api.TokenTypes;
+
+
+
+/**
+ * a wrapper around a <code>SymbolTable</code> that makes Definition and
+ * reference lookup easier
+ */
+public class QueryEngine {
+ private SymbolTable symbolTable;
+ private ScopeIndex index;
+
+ public QueryEngine(SymbolTable aSymbolTable) {
+ this.symbolTable = aSymbolTable;
+ setIndex();
+ }
+
+ /**
+ * sets the scope index that this <code>QueryEngine</code> uses
+ */
+ private void setIndex() {
+ index = symbolTable.getScopeIndex();
+ }
+
+ /**
+ * gets a symbol from the associated symbol table
+ *
+ * @param name the name of the symbol to get
+ * @param location the location of that symbol
+ *
+ * @return Object the (possibly null) result of the lookup
+ */
+ public Reference getSymbol(String name, Occurrence location) {
+ Scope enclosingScope = index.lookup(location);
+ Reference result = enclosingScope.getSymbol(name, location);
+
+ // REDTAG -- for cases like a label on the same line as the
+ // block it names, e.g. 'bar: for(int i = 0; ...'
+ if (result == null) {
+ result = enclosingScope.getParentScope().getSymbol(name, location);
+ }
+
+ return result;
+ }
+
+ /**
+ * gets the definition of the given symbol
+ *
+ * @param name the name of the symbol to consider
+ * @param location the <code>Occurrence</code> that represents the
+ * location of the symbol
+ *
+ * @return Definition the (possibly null) result of the lookup
+ */
+ public IDefinition getDefinition(String name, Occurrence location) {
+ Reference symbol = getSymbol(name, location);
+
+ //if (symbol != null) {
+ // System.out.println(" found " + name);
+ //}
+ //else {
+ // System.out.println(" !could not find " + name);
+ //}
+
+ return resolveDefinition(symbol);
+ }
+
+ public IDefinition getDefinition(Occurrence location) {
+ IDefinition result = null;
+
+ SymTabAST node = getWordNodeAtOccurrence(location);
+ if ( node != null ) {
+ result = node.getDefinition();
+ }
+
+ return result;
+ }
+
+ private IDefinition resolveDefinition(Reference reference) {
+ IDefinition result = null;
+
+ if ( reference != null ) {
+ result = reference.getDefinition();
+ }
+
+ return result;
+ }
+
+ /**
+ * gets a collection of references determined by a symbol and location
+ *
+ * @param name the name of the symbol to consider
+ * @param location the <code>Occurrence</code> that represents its location
+ *
+ * @return
+ */
+ public Iterator getReferences(String name, Occurrence location) {
+ Reference symbol = getSymbol(name, location);
+ return resolveReferences(symbol);
+ }
+
+ public Iterator getReferences(Occurrence location) {
+ Iterator result = null;
+
+ SymTabAST node = getWordNodeAtOccurrence(location);
+ if ( node != null && node.getDefinition() != null ) {
+ result = node.getDefinition().getReferences();
+ }
+
+ return result;
+ }
+
+ private Iterator resolveReferences(Reference reference) {
+ return reference.getDefinition().getReferences();
+ }
+
+ public SymTabAST getFileNode(File file) {
+ return ASTUtil.getFileNode(symbolTable.getTree(), file);
+ }
+
+ private SymTabAST getWordNodeAtOccurrence(Occurrence location) {
+ SymTabAST result = null;
+
+ SymTabAST fileNode = getFileNode(location.getFile());
+ if ( fileNode != null ) {
+ SymTabAST node = fileNode.getEnclosingNode(location.getLine(),
+ location.getColumn());
+
+ if ( (node != null) && (node.getType() == TokenTypes.IDENT) ) {
+ result = node;
+ }
+ }
+
+ return result;
+ }
+
+ public String getWordAtOccurrence(Occurrence location ) {
+ String result = null;
+
+ SymTabAST node = getWordNodeAtOccurrence(location);
+ if ( node != null ) {
+ result = node.getText();
+ }
+
+ return result;
+ }
+
+}
+
+
+
+
diff --git a/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/Reference.java b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/Reference.java
new file mode 100755
index 000000000..a6b7d8207
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/Reference.java
@@ -0,0 +1,141 @@
+
+// Transmogrify License
+//
+// Copyright (c) 2001, ThoughtWorks, Inc.
+// All rights reserved.
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// - Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+// - Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// Neither the name of the ThoughtWorks, Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from this
+// software without specific prior written permission.
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+package com.puppycrawl.tools.checkstyle.checks.usage.transmogrify;
+
+import java.io.File;
+
+
+
+
+/**
+ * represents a place where a definition is used. There are two flavors
+ * of references -- resolved (those that have a definition associated with
+ * them) and unresolved (those that don't have a definition associated).
+ * The goal of the resolution step is to get all of the references in the
+ * symbol table to fall into the resolved category.
+ */
+
+public class Reference implements Comparable {
+
+ private SymTabAST _node;
+ private Occurrence _occurrence;
+
+ public Reference( SymTabAST node ) {
+ _node = node;
+ _occurrence = new Occurrence( _node.getFile(), ASTUtil.getLine(_node), ASTUtil.getColumn(_node) );
+ }
+
+ /**
+ * gets the definition associated with this reference
+ *
+ * @return Definition the (possibly null) definition associated with
+ * this reference
+ */
+ public IDefinition getDefinition() {
+ return _node.getDefinition();
+ }
+
+ /**
+ * return the node that was passed in during ctor
+ */
+ public SymTabAST getTreeNode() {
+ return _node;
+ }
+
+ /**
+ * gets the occurrence of this reference
+ *
+ * @return Occurrence
+ */
+ public Occurrence getOccurrence() {
+ return _occurrence;
+ }
+
+ /**
+ * gets the line where the node resides
+ */
+ public int getLine() {
+ return getOccurrence().getLine();
+ }
+
+ /**
+ * gets the column for where the node resides
+ */
+ public int getColumn() {
+ return getOccurrence().getColumn();
+ }
+
+ /**
+ * gets the enclosing file for the node
+ */
+ public File getFile() {
+ return getOccurrence().getFile();
+ }
+
+ /**
+ * gets the name of the reference
+ *
+ * @return String the name of the definition associated with this reference
+ * if this reference is resolved, else null
+ */
+ public String getName() {
+ return _node.getName();
+ }
+
+ /**
+ * returns a string representation of the reference.
+ *
+ * @return String
+ */
+ public String toString() {
+ return getOccurrence().toString();
+ }
+
+ /**
+ * returns whether the <code>Reference</code>s are equal
+ *
+ * @return whether the <code>Reference</code>s are equal
+ */
+ // REDTAG -- not finished
+ public boolean equals(Object obj){
+ boolean result = false;
+ if (obj instanceof Reference) {
+ result = getOccurrence().equals(((Reference)obj).getOccurrence());
+ }
+ return result;
+ }
+
+ public int compareTo(Object o) {
+ if (!(o instanceof Reference)) {
+ throw new ClassCastException(getClass().getName());
+ }
+
+ return getOccurrence().compareTo(((Reference)o).getOccurrence());
+ }
+}
diff --git a/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/ReferenceCounter.java b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/ReferenceCounter.java
new file mode 100755
index 000000000..adb8b220b
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/ReferenceCounter.java
@@ -0,0 +1,88 @@
+
+// Transmogrify License
+//
+// Copyright (c) 2001, ThoughtWorks, Inc.
+// All rights reserved.
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// - Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+// - Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// Neither the name of the ThoughtWorks, Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from this
+// software without specific prior written permission.
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+package com.puppycrawl.tools.checkstyle.checks.usage.transmogrify;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.ListIterator;
+
+import com.puppycrawl.tools.checkstyle.api.TokenTypes;
+
+/**
+ * This class is for counting the reference
+ */
+public class ReferenceCounter extends ReferenceTool {
+ private List _references = new ArrayList();
+ private List _resolvedReferences = new ArrayList();
+ private List _unresolvedReferences = new ArrayList();
+
+ public ReferenceCounter(SymbolTable table) {
+ super(table.getTree());
+ countReferences();
+ }
+
+ /**
+ * Return the number of references
+ */
+ public int numberOfReferences() {
+ return _references.size();
+ }
+
+ /**
+ * Return the number of resolved references
+ */
+ public int numberOfResolvedReferences() {
+ return _resolvedReferences.size();
+ }
+
+ public int numberOfUnresolvedReferences() {
+ return _unresolvedReferences.size();
+ }
+
+ public ListIterator getUnresolvedReferences() {
+ return _unresolvedReferences.listIterator();
+ }
+
+ private void countReferences() {
+ handleNode( _tree );
+ }
+
+ protected void handleNode( SymTabAST node ) {
+ if (node.getType() == TokenTypes.IDENT && node.isMeaningful()) {
+ _references.add( node );
+ if (node.getDefinition() != null && !(node.getDefinition() instanceof UnknownClass)) {
+ _resolvedReferences.add( node );
+ }
+ else {
+ _unresolvedReferences.add( node );
+ }
+ }
+ walkChildren( node );
+ }
+}
diff --git a/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/ReferenceThreshold.java b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/ReferenceThreshold.java
new file mode 100755
index 000000000..a46caeacd
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/ReferenceThreshold.java
@@ -0,0 +1,78 @@
+
+// Transmogrify License
+//
+// Copyright (c) 2001, ThoughtWorks, Inc.
+// All rights reserved.
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// - Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+// - Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// Neither the name of the ThoughtWorks, Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from this
+// software without specific prior written permission.
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+package com.puppycrawl.tools.checkstyle.checks.usage.transmogrify;
+
+
+import java.util.Set;
+import java.util.TreeSet;
+
+
+
+public class ReferenceThreshold extends ReferenceTool {
+ private Set _underreferencedDefinitions;
+ private int _threshold;
+
+ public ReferenceThreshold(SymbolTable table, int threshold) {
+ super(table.getTree());
+ _threshold = threshold;
+ _underreferencedDefinitions = new TreeSet();
+ go();
+ }
+
+ private void go() {
+ collectUnderreferencedDefinitions();
+ }
+
+ private void collectUnderreferencedDefinitions() {
+ handleNode(_tree);
+ }
+
+ protected void handleNode(SymTabAST node) {
+ if (node.isMeaningful()) {
+ IDefinition def = node.getDefinition();
+ if (def != null &&
+ def.getNumReferences() <= _threshold &&
+ def instanceof Definition) {
+ // this is inheritently hackish
+ // basically we want to ignore
+ // all test cases and main() methods
+ if (def.getQualifiedName().indexOf("test") < 0 &&
+ def.getQualifiedName().indexOf("main") < 0) {
+ _underreferencedDefinitions.add(def);
+ }
+ }
+ }
+
+ walkChildren(node);
+ }
+
+ public Set getUnderreferencedDefinitions() {
+ return _underreferencedDefinitions;
+ }
+}
diff --git a/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/ReferenceTool.java b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/ReferenceTool.java
new file mode 100755
index 000000000..677935926
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/ReferenceTool.java
@@ -0,0 +1,55 @@
+
+// Transmogrify License
+//
+// Copyright (c) 2001, ThoughtWorks, Inc.
+// All rights reserved.
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// - Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+// - Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// Neither the name of the ThoughtWorks, Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from this
+// software without specific prior written permission.
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+package com.puppycrawl.tools.checkstyle.checks.usage.transmogrify;
+
+
+public abstract class ReferenceTool {
+ protected SymTabAST _tree = null;
+
+ public ReferenceTool(SymTabAST tree) {
+ _tree = tree;
+ }
+
+ protected void walkChildren( SymTabAST node ) {
+ if ( node.getFirstChild() != null ) {
+ walkSelfAndSiblings( (SymTabAST)node.getFirstChild() );
+ }
+ }
+
+ private void walkSelfAndSiblings( SymTabAST node ) {
+ handleNode( node );
+ SymTabAST sibling = (SymTabAST)node.getNextSibling();
+ while ( sibling != null ) {
+ handleNode( sibling );
+ sibling = (SymTabAST)sibling.getNextSibling();
+ }
+ }
+
+ protected abstract void handleNode(SymTabAST node);
+} \ No newline at end of file
diff --git a/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/Resolver.java b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/Resolver.java
new file mode 100755
index 000000000..8df1ae6c2
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/Resolver.java
@@ -0,0 +1,1893 @@
+
+// Transmogrify License
+//
+// Copyright (c) 2001, ThoughtWorks, Inc.
+// All rights reserved.
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// - Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+// - Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// Neither the name of the ThoughtWorks, Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from this
+// software without specific prior written permission.
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+package com.puppycrawl.tools.checkstyle.checks.usage.transmogrify;
+
+
+
+import java.util.Vector;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogConfigurationException;
+import org.apache.commons.logging.LogFactory;
+
+import com.puppycrawl.tools.checkstyle.api.TokenTypes;
+
+/**
+ * The resolver is responsible for traversing all the various
+ * definitions in a symbol table and resolving references in them.
+ *
+ * @see SymbolTable
+ */
+
+public class Resolver extends DefinitionTraverser {
+
+ /** true if the log factory has been initialized */
+ private boolean mInitialized = false;
+
+ /** Factory for creating org.apache.commons.logging.Log instances */
+ private LogFactory mLogFactory;
+
+ /**
+ * constructor with <code>SymbolTable</code> to be resolved
+ */
+ public Resolver(SymbolTable symbolTable) {
+ super(symbolTable);
+
+ try {
+ mLogFactory = LogFactory.getFactory();
+ }
+ catch (LogConfigurationException e) {
+ System.out.println("log configuration exception" + e);
+ }
+ mInitialized = true;
+
+ }
+
+ /**
+ * resolves the symbol table
+ * @return <code>void</code>
+ * @see #traverse()
+ */
+ public void resolve() {
+ traverse();
+ }
+
+ protected void handleSList(SymTabAST node, Scope scope) {
+ SymTabASTIterator iterator = node.getChildren();
+ while (iterator.hasNext()) {
+ SymTabAST current = iterator.nextChild();
+ resolveExpression(current, scope, null, true);
+ }
+ }
+
+ protected void handleAnonymousInnerClass(AnonymousInnerClass innerClass) {
+ SymTabAST objblock = innerClass.getTreeNode();
+ SymTabAST expression = (SymTabAST) objblock.getFirstChild();
+ while (expression != null) {
+ resolveExpression(expression, innerClass, null, true);
+ expression = (SymTabAST) expression.getNextSibling();
+ }
+ }
+
+ /**
+ * processes a <code>ClassDef</code> and resolves references in it
+ *
+ * @param classDef the <code>ClassDef</code> to process
+ */
+ protected void handleClass(ClassDef classDef) {
+ SymTabAST node = classDef.getTreeNode();
+
+ if (node != null) {
+ SymTabAST nameNode = node.findFirstToken(TokenTypes.IDENT);
+ nameNode.setDefinition(classDef, classDef, true);
+
+ SymTabAST extendsClause =
+ node.findFirstToken(TokenTypes.EXTENDS_CLAUSE);
+
+ if(extendsClause != null) {
+ SymTabAST extendedClassNode =
+ (SymTabAST) extendsClause.getFirstChild();
+
+ while (extendedClassNode != null) {
+ IClass superClass =
+ resolveClass(extendedClassNode, classDef, null, true);
+ extendedClassNode.setDefinition(superClass, classDef, true);
+ extendedClassNode =
+ (SymTabAST) extendedClassNode.getNextSibling();
+ }
+ }
+
+ SymTabAST implementsNode =
+ node.findFirstToken(TokenTypes.IMPLEMENTS_CLAUSE);
+
+ if (implementsNode != null) {
+ SymTabAST interfaceNode =
+ (SymTabAST) (implementsNode.getFirstChild());
+ while (interfaceNode != null) {
+ resolveClass(interfaceNode, classDef, null, true);
+ interfaceNode =
+ (SymTabAST) (interfaceNode.getNextSibling());
+ }
+ }
+ }
+ }
+
+ /**
+ * processes a <code>MethodDef</code> and resolves references in it
+ *
+ * @param method the <code>MethodDef</code> to process
+ */
+ protected void handleMethod(MethodDef method) {
+ SymTabAST node = method.getTreeNode();
+
+ SymTabAST nameNode = node.findFirstToken(TokenTypes.IDENT);
+ nameNode.setDefinition(method, method, true);
+
+ // references to classes in return type
+ SymTabAST returnTypeNode = node.findFirstToken(TokenTypes.TYPE);
+
+ if (returnTypeNode != null) {
+ // this is not a constructor
+ resolveExpression(returnTypeNode, method, null, true);
+ }
+
+ SymTabAST throwsNode =
+ node.findFirstToken(TokenTypes.LITERAL_THROWS);
+ if (throwsNode != null) {
+ SymTabAST exception = (SymTabAST) throwsNode.getFirstChild();
+ while (exception != null) {
+ // handle Checkstyle grammar
+ if (exception.getType() != TokenTypes.COMMA) {
+ resolveClass(exception, method, null, true);
+ }
+ exception = (SymTabAST) exception.getNextSibling();
+ }
+ }
+
+ // references to classes in parameters
+
+ // the body -- this would be better its own function
+ SymTabAST slist = node.findFirstToken(TokenTypes.SLIST);
+
+ if (slist != null) {
+ handleSList(slist, method);
+ }
+ }
+
+ /**
+ * processes a <code>BlockDef</code> and resolves references in it
+ *
+ * @param block the <code>BlockDef</code> to process
+ */
+ protected void handleBlock(BlockDef block) {
+ SymTabAST node = block.getTreeNode();
+
+ switch (node.getType()) {
+
+ case TokenTypes.LITERAL_FOR :
+ handleFor(block);
+ break;
+
+ case TokenTypes.LITERAL_IF :
+ handleIf(block);
+ break;
+
+ case TokenTypes.LITERAL_WHILE :
+ handleWhileAndSynchronized(block);
+ break;
+
+ case TokenTypes.LITERAL_DO :
+ handleDoWhile(block);
+ break;
+
+ case TokenTypes.LITERAL_TRY :
+ case TokenTypes.LITERAL_FINALLY :
+ SymTabAST slist = node.findFirstToken(TokenTypes.SLIST);
+
+ handleSList(slist, block);
+ break;
+
+ case TokenTypes.LITERAL_CATCH :
+ handleCatch(block);
+ break;
+
+ case TokenTypes.LITERAL_SWITCH :
+ handleSwitch(block);
+ break;
+
+ case TokenTypes.SLIST :
+ handleSList(node, block);
+ break;
+
+ case TokenTypes.EXPR :
+ resolveExpression(node, block, null, true);
+ break;
+
+ case TokenTypes.INSTANCE_INIT :
+ case TokenTypes.STATIC_INIT :
+ handleSList((SymTabAST) node.getFirstChild(), block);
+ break;
+
+ case TokenTypes.LITERAL_SYNCHRONIZED :
+ handleWhileAndSynchronized(block);
+ break;
+
+ case TokenTypes.LITERAL_ASSERT :
+ handleAssert(block);
+ break;
+
+ default :
+ if (mInitialized) {
+ final Log log = mLogFactory.getInstance(this.getClass());
+ log.error(
+ "Unhandled block "
+ + block
+ + " of type "
+ + node.getType());
+ }
+ }
+ }
+
+ /**
+ * @param block
+ */
+ private void handleAssert(BlockDef block) {
+ SymTabAST node = block.getTreeNode();
+
+ SymTabAST conditional =
+ (node.findFirstToken(TokenTypes.EXPR));
+ resolveExpression(conditional, block, null, true);
+
+ SymTabAST message = (SymTabAST) conditional.getNextSibling();
+ while ((message != null) && (message.getType() != TokenTypes.EXPR)) {
+ message = (SymTabAST) message.getNextSibling();
+ }
+ if (message != null) {
+ resolveExpression(message, block, null, true);
+ }
+ }
+
+ /**
+ * processes a switch statement and resolves references in it
+ *
+ * @param block the <code>BlockDef</code> to process
+ */
+ private void handleSwitch(BlockDef block) {
+ SymTabAST node = block.getTreeNode();
+
+ SymTabAST expr = node.findFirstToken(TokenTypes.EXPR);
+ resolveExpression(expr, block, null, true);
+
+ SymTabAST caseGroup = (SymTabAST) (expr.getNextSibling());
+ while (caseGroup != null
+ && (caseGroup.getType() != TokenTypes.CASE_GROUP)) {
+ caseGroup = (SymTabAST) caseGroup.getNextSibling();
+ }
+ if (caseGroup != null) {
+ while (caseGroup.getType() == TokenTypes.CASE_GROUP) {
+ SymTabAST caseNode =
+ caseGroup.findFirstToken(TokenTypes.LITERAL_CASE);
+ while (caseNode != null
+ && caseNode.getType() == TokenTypes.LITERAL_CASE) {
+ resolveExpression(
+ (SymTabAST) caseNode.getFirstChild(),
+ block,
+ null,
+ true);
+ caseNode = (SymTabAST) caseNode.getNextSibling();
+ }
+
+ SymTabAST caseSlist =
+ caseGroup.findFirstToken(TokenTypes.SLIST);
+ handleSList(caseSlist, block);
+
+ caseGroup = (SymTabAST) (caseGroup.getNextSibling());
+ }
+ }
+ }
+
+ /**
+ * processes a catch block and resolves references in it
+ *
+ * @param block the <code>BlockDef</code> to process
+ */
+ private void handleCatch(BlockDef block) {
+ SymTabAST node = block.getTreeNode();
+
+ SymTabAST slist = node.findFirstToken(TokenTypes.SLIST);
+ handleSList(slist, block);
+ }
+
+ /**
+ * processes a for loop and resolves references in it
+ *
+ * @param block the <code>BlockDef</code> to process
+ */
+ private void handleFor(BlockDef block) {
+ SymTabAST node = block.getTreeNode();
+
+ SymTabAST body;
+ SymTabAST forEach = node.findFirstToken(TokenTypes.FOR_EACH_CLAUSE);
+ if (forEach == null) {
+ SymTabAST init = node.findFirstToken(TokenTypes.FOR_INIT);
+ // only need to handle the elist case. if the init node is a variable
+ // definition, the variable def will be handled later on in the resolution
+ if (init.getFirstChild() != null) {
+ if (init.getFirstChild().getType() == TokenTypes.ELIST) {
+ resolveExpression(
+ (SymTabAST) (init.getFirstChild()),
+ block,
+ null,
+ true);
+ }
+ }
+
+ SymTabAST cond = node.findFirstToken(TokenTypes.FOR_CONDITION);
+ if (cond.getFirstChild() != null) {
+ resolveExpression(
+ (SymTabAST) (cond.getFirstChild()),
+ block,
+ null,
+ true);
+ }
+
+ SymTabAST iterator = node.findFirstToken(TokenTypes.FOR_ITERATOR);
+ if (iterator.getFirstChild() != null) {
+ resolveExpression(
+ (SymTabAST) (iterator.getFirstChild()),
+ block,
+ null,
+ true);
+ }
+ body = (SymTabAST) (iterator.getNextSibling());
+ }
+ else {
+ resolveExpression(
+ (forEach.findFirstToken(TokenTypes.EXPR)),
+ block,
+ null,
+ true);
+ body = (SymTabAST) (forEach.getNextSibling());
+ }
+ //could be an SLIST, EXPR or an EMPTY_STAT
+ if (body.getType() == TokenTypes.RPAREN) {
+ body = (SymTabAST) body.getNextSibling();
+ }
+ if (body.getType() == TokenTypes.SLIST) {
+ handleSList(body, block);
+ }
+ else {
+ resolveExpression(body, block, null, true);
+ }
+
+ }
+
+ /**
+ * processes an if statement and resolves references in it
+ *
+ * @param block the <code>BlockDef</code> to process
+ */
+ private void handleIf(BlockDef block) {
+ SymTabAST node = block.getTreeNode();
+
+ SymTabAST conditional =
+ (node.findFirstToken(TokenTypes.EXPR));
+ resolveExpression(conditional, block, null, true);
+
+ SymTabAST body = (SymTabAST) conditional.getNextSibling();
+ // Handle Checkstyle grammar
+ if (body.getType() == TokenTypes.RPAREN) {
+ body = (SymTabAST) body.getNextSibling();
+ }
+ if (body != null) {
+ if (body.getType() == TokenTypes.SLIST) {
+ handleSList(body, block);
+ }
+ else {
+ resolveExpression(body, block, null, true);
+ }
+
+ SymTabAST elseBody = (SymTabAST) body.getNextSibling();
+ //handle Checkstyle grammar
+ while ((elseBody != null)
+ && (elseBody.getType() != TokenTypes.LITERAL_ELSE)) {
+ elseBody = (SymTabAST) elseBody.getNextSibling();
+ }
+ /*
+ if (elseBody != null && elseBody.getType() == TokenTypes.SLIST) {
+ handleSList(elseBody, block);
+ }else{
+ resolveExpression(elseBody, block, null, true);
+ }
+ */
+ if (elseBody != null) {
+ elseBody = (SymTabAST) elseBody.getFirstChild();
+ }
+ if (elseBody != null) {
+ resolveExpression(elseBody, block.getParentScope(), null, true);
+ }
+ }
+ }
+
+ /**
+ * processes a while loop and resolves references in it
+ *
+ * @param block the <code>BlockDef</code> to process
+ */
+ private void handleWhileAndSynchronized(BlockDef block) {
+ SymTabAST node = block.getTreeNode();
+
+ SymTabAST condition =
+ (node.findFirstToken(TokenTypes.EXPR));
+ SymTabAST slist = (SymTabAST) (condition.getNextSibling());
+ // handle Checkstyle grammar
+ if (slist.getType() == TokenTypes.RPAREN) {
+ slist = (SymTabAST) slist.getNextSibling();
+ }
+
+ resolveExpression(condition, block, null, true);
+ handleSList(slist, block);
+ }
+
+ private void handleDoWhile(BlockDef block) {
+ SymTabAST node = block.getTreeNode();
+
+ SymTabAST slist = (SymTabAST) node.getFirstChild();
+ SymTabAST condition =
+ node.findFirstToken(TokenTypes.EXPR);
+
+ handleSList(slist, block);
+ resolveExpression(condition, block, null, true);
+ }
+
+ /**
+ * processes a variable definition and resolves references in it
+ *
+ * @param variable the <code>VariableDef</code> to process
+ */
+ protected void handleVariable(VariableDef variable) {
+ SymTabAST node = variable.getTreeNode();
+ Scope location = variable.getParentScope();
+
+ SymTabAST nameNode = node.findFirstToken(TokenTypes.IDENT);
+ nameNode.setDefinition(variable, location, true);
+
+ SymTabAST typeNode = node.findFirstToken(TokenTypes.TYPE);
+ resolveType(typeNode, location, null, true);
+
+ SymTabAST assignmentNode = node.findFirstToken(TokenTypes.ASSIGN);
+ if (assignmentNode != null) {
+ resolveExpression(
+ (SymTabAST) (assignmentNode.getFirstChild()),
+ variable.getParentScope(),
+ null,
+ true);
+ }
+ }
+
+ /**
+ * processes a label and resolves references in it
+ *
+ * @param label the <code>LabelDef</code> to process
+ */
+ protected void handleLabel(LabelDef label) {
+ SymTabAST node = label.getTreeNode();
+ ((SymTabAST) node.getFirstChild()).setDefinition(
+ label,
+ label.getParentScope(),
+ true);
+ }
+
+ /**
+ * Resolves Java expressions, returning the type to which the expression
+ * evalutes. If this is the reference creation phase, any references found during resolution are created and
+ * resolved.
+ *
+ * @param expression the <code>SymTabAST</code> representing the expression
+ * @param location the <code>Scope</code> in which the expression occours.
+ * @param context the <code>Scope</code> in which the search for the
+ * definition will start
+ * @param referencePhase whether or not this is the reference phase of
+ * table construction
+ *
+ * @return the <code>ClassDef</code> representing the type to which the
+ * expression evalutes.
+ */
+ public IClass resolveExpression(
+ SymTabAST expression,
+ Scope location,
+ IClass context,
+ boolean referencePhase) {
+ IClass result = null;
+
+ try {
+
+ switch (expression.getType()) {
+
+ case TokenTypes.TYPECAST :
+ result =
+ resolveTypecast(
+ expression,
+ location,
+ context,
+ referencePhase);
+ break;
+ case TokenTypes.EXPR :
+ case TokenTypes.LITERAL_RETURN :
+ if (expression.getFirstChild() != null) {
+ result =
+ resolveExpression(
+ (SymTabAST) expression.getFirstChild(),
+ location,
+ context,
+ referencePhase);
+ }
+ else {
+ // YOU WRITE BAD CODE!
+ }
+ break;
+
+ case TokenTypes.ELIST :
+
+ SymTabAST child = (SymTabAST) (expression.getFirstChild());
+ while (child != null) {
+ if (child.getType() != TokenTypes.COMMA) {
+ resolveExpression(
+ child,
+ location,
+ context,
+ referencePhase);
+ }
+ child = (SymTabAST) (child.getNextSibling());
+ }
+ break;
+
+ case TokenTypes.IDENT :
+ result =
+ resolveIdent(
+ expression,
+ location,
+ context,
+ referencePhase);
+ break;
+
+ case TokenTypes.TYPE :
+ result =
+ resolveType(
+ expression,
+ location,
+ context,
+ referencePhase);
+ break;
+
+ case TokenTypes.METHOD_CALL :
+ //case TokenTypes.SUPER_CTOR_CALL :
+ result =
+ resolveMethod(
+ expression,
+ location,
+ context,
+ referencePhase);
+ break;
+
+ case TokenTypes.LITERAL_THIS :
+ result = resolveLiteralThis(expression, location, context);
+ break;
+
+ case TokenTypes.LITERAL_SUPER :
+ result = resolveLiteralSuper(expression, location, context);
+ break;
+
+ case TokenTypes.DOT :
+ result =
+ resolveDottedName(
+ expression,
+ location,
+ context,
+ referencePhase);
+ break;
+
+ case TokenTypes.LITERAL_NEW :
+ case TokenTypes.CTOR_CALL :
+ case TokenTypes.SUPER_CTOR_CALL :
+ result =
+ resolveNew(
+ expression,
+ location,
+ context,
+ referencePhase);
+ break;
+
+ case TokenTypes.LITERAL_BOOLEAN :
+ case TokenTypes.LITERAL_DOUBLE :
+ case TokenTypes.LITERAL_FLOAT :
+ case TokenTypes.LITERAL_LONG :
+ case TokenTypes.LITERAL_INT :
+ case TokenTypes.LITERAL_SHORT :
+ case TokenTypes.LITERAL_BYTE :
+ case TokenTypes.LITERAL_CHAR :
+ result =
+ resolvePrimitiveType(
+ expression,
+ location,
+ context,
+ referencePhase);
+ break;
+
+ case TokenTypes.NUM_INT :
+ case TokenTypes.NUM_LONG :
+ result = resolveNumInt(expression, location, context);
+ break;
+
+ case TokenTypes.NUM_FLOAT :
+ case TokenTypes.NUM_DOUBLE :
+ result = resolveNumFloat(expression, location, context);
+ break;
+
+ case TokenTypes.STRING_LITERAL :
+ result =
+ resolveStringLiteral(expression, location, context);
+ break;
+
+ case TokenTypes.CHAR_LITERAL :
+ result = resolveCharLiteral(expression, location, context);
+ break;
+
+ case TokenTypes.ASSIGN :
+ case TokenTypes.PLUS_ASSIGN :
+ case TokenTypes.MINUS_ASSIGN :
+ case TokenTypes.STAR_ASSIGN :
+ case TokenTypes.DIV_ASSIGN :
+ case TokenTypes.MOD_ASSIGN :
+ case TokenTypes.SR_ASSIGN :
+ case TokenTypes.BSR_ASSIGN :
+ case TokenTypes.SL_ASSIGN :
+ case TokenTypes.BAND_ASSIGN :
+ case TokenTypes.BXOR_ASSIGN :
+ case TokenTypes.BOR_ASSIGN :
+ resolveAssignment(
+ expression,
+ location,
+ context,
+ referencePhase);
+ break;
+
+ case TokenTypes.LOR :
+ case TokenTypes.LAND :
+ case TokenTypes.NOT_EQUAL :
+ case TokenTypes.EQUAL :
+ case TokenTypes.LT :
+ case TokenTypes.GT :
+ case TokenTypes.LE :
+ case TokenTypes.GE :
+ result =
+ resolveBooleanExpression(
+ expression,
+ location,
+ context,
+ referencePhase);
+ break;
+
+ case TokenTypes.LITERAL_INSTANCEOF :
+ result =
+ resolveInstanceOf(
+ expression,
+ location,
+ context,
+ referencePhase);
+ break;
+
+ case TokenTypes.LITERAL_TRUE :
+ case TokenTypes.LITERAL_FALSE :
+ result =
+ resolveBooleanLiteral(expression, location, context);
+ break;
+
+ case TokenTypes.LNOT :
+ result =
+ resolveBooleanUnary(
+ expression,
+ location,
+ context,
+ referencePhase);
+ break;
+
+ case TokenTypes.INC :
+ case TokenTypes.POST_INC :
+ case TokenTypes.DEC :
+ case TokenTypes.POST_DEC :
+ case TokenTypes.UNARY_PLUS :
+ case TokenTypes.UNARY_MINUS :
+ result =
+ resolveUnaryExpression(
+ expression,
+ location,
+ context,
+ referencePhase);
+ break;
+
+ case TokenTypes.PLUS :
+ case TokenTypes.MINUS :
+ case TokenTypes.DIV :
+ case TokenTypes.STAR :
+ case TokenTypes.BAND :
+ case TokenTypes.BOR :
+ case TokenTypes.BXOR :
+ case TokenTypes.MOD :
+ result =
+ resolveArithmeticExpression(
+ expression,
+ location,
+ context,
+ referencePhase);
+ break;
+
+ case TokenTypes.LITERAL_BREAK :
+ case TokenTypes.LITERAL_CONTINUE :
+ resolveGoto(expression, location, context, referencePhase);
+ break;
+
+ case TokenTypes.LPAREN :
+ result = resolveExpression(
+ //TODO: child || sibling?
+ (SymTabAST) (expression.getNextSibling()),
+ //(SymTabAST) (expression.getFirstChild()),
+ location, context, referencePhase);
+ break;
+
+ case TokenTypes.INDEX_OP :
+ result =
+ resolveArrayAccess(
+ expression,
+ location,
+ context,
+ referencePhase);
+ break;
+
+ case TokenTypes.LITERAL_NULL :
+ result = new NullClass();
+ break;
+
+ case TokenTypes.QUESTION :
+ result =
+ resolveQuestion(
+ expression,
+ location,
+ context,
+ referencePhase);
+ break;
+
+ case TokenTypes.LITERAL_CLASS :
+ result = resolveLiteralClass();
+ break;
+
+ case TokenTypes.ARRAY_INIT :
+ resolveArrayInitializer(
+ expression,
+ location,
+ context,
+ referencePhase);
+ break;
+
+ case TokenTypes.LITERAL_THROW :
+ resolveThrowExpression(
+ expression,
+ location,
+ context,
+ referencePhase);
+ break;
+
+ case TokenTypes.SL :
+ case TokenTypes.SR :
+ case TokenTypes.BSR :
+ result =
+ resolveShiftOperator(
+ expression,
+ location,
+ context,
+ referencePhase);
+ break;
+
+ case TokenTypes.BNOT :
+ resolveBitwiseNot(
+ expression,
+ location,
+ context,
+ referencePhase);
+ break;
+
+ case TokenTypes.LITERAL_ASSERT :
+// resolveAssert(
+// expression,
+// location,
+// context,
+// referencePhase);
+ break;
+
+ case TokenTypes.RPAREN :
+ case TokenTypes.EMPTY_STAT :
+ // case TokenTypes.ML_COMMENT:
+ // case TokenTypes.SL_COMMENT:
+ case TokenTypes.VARIABLE_DEF :
+ case TokenTypes.METHOD_DEF :
+ case TokenTypes.CLASS_DEF :
+ case TokenTypes.LITERAL_FOR :
+ case TokenTypes.LITERAL_WHILE :
+ case TokenTypes.LITERAL_IF :
+ case TokenTypes.LITERAL_VOID :
+ // case TokenTypes.LITERAL_INTERFACE:
+ case TokenTypes.LITERAL_DO :
+ case TokenTypes.LITERAL_SWITCH :
+ case TokenTypes.LITERAL_STATIC :
+ case TokenTypes.LITERAL_TRANSIENT :
+ case TokenTypes.LITERAL_NATIVE :
+ // case TokenTypes.LITERAL_threadsafe:
+ case TokenTypes.LITERAL_SYNCHRONIZED :
+ case TokenTypes.LITERAL_VOLATILE :
+ case TokenTypes.LITERAL_TRY :
+ case TokenTypes.LITERAL_CATCH :
+ case TokenTypes.LITERAL_FINALLY :
+ case TokenTypes.LABELED_STAT :
+ case TokenTypes.LCURLY :
+ case TokenTypes.RCURLY :
+ case TokenTypes.SLIST :
+ case TokenTypes.SEMI :
+ case TokenTypes.COMMA :
+ case TokenTypes.ARRAY_DECLARATOR :
+ break;
+
+ default :
+ //TODO: throw exception
+ if (mInitialized) {
+ final Log log =
+ mLogFactory.getInstance(this.getClass());
+ log.error(
+ "Unhandled expression type: "
+ + expression.getType());
+ }
+ break;
+ }
+ }
+ catch (Exception e) {
+
+ result = new UnknownClass(expression.getText(), expression);
+// TODO: This really should be logged
+// if (mInitialized) {
+// final Log log = mLogFactory.getInstance(this.getClass());
+// log.error("Error resolving near " + expression);
+// }
+ }
+
+ return result;
+ }
+
+ private IClass resolveTypecast(
+ SymTabAST node,
+ Scope location,
+ IClass context,
+ boolean referencePhase) {
+ SymTabAST typeNode = (SymTabAST) node.getFirstChild();
+ SymTabAST exprNode = (SymTabAST) typeNode.getNextSibling();
+ //handle Checkstyle grammar
+ if (exprNode.getType() == TokenTypes.RPAREN) {
+ exprNode = (SymTabAST) exprNode.getNextSibling();
+ }
+
+ IClass type = null;
+
+ final SymTabAST child = (SymTabAST) typeNode.getFirstChild();
+ // TODO: Checkstyle change.
+ // Do not create references from typecast.
+ // Original transmogrify code is equivalent to
+ // final boolean createReference = referencePhase;
+ // which creates non-existant references for variables.
+ final boolean createReference = false;
+ if (child.getType()
+ == TokenTypes.ARRAY_DECLARATOR) {
+ type =
+ new ArrayDef(
+ resolveType(
+ (SymTabAST) typeNode.getFirstChild(),
+ location,
+ context,
+ createReference));
+ }
+ else {
+ type = resolveType(typeNode, location, context, createReference);
+ }
+
+ resolveExpression(exprNode, location, context, referencePhase);
+ //TODO: Checkstyle change. Can this be ignored?
+ if (type != null) {
+ ((SymTabAST) typeNode.getFirstChild()).setDefinition(
+ type,
+ location,
+ referencePhase);
+ }
+
+ return type;
+ }
+
+ private IClass resolveArrayAccess(
+ SymTabAST node,
+ Scope location,
+ IClass context,
+ boolean referencePhase) {
+
+ SymTabAST arrayNode = (SymTabAST) (node.getFirstChild());
+ SymTabAST exprNode = (SymTabAST) (arrayNode.getNextSibling());
+
+ //resolve index expressions
+ while (arrayNode.getType() == TokenTypes.INDEX_OP) {
+ resolveExpression(exprNode, location, context, referencePhase);
+ arrayNode = (SymTabAST) (arrayNode.getFirstChild());
+ exprNode = (SymTabAST) (arrayNode.getNextSibling());
+ }
+
+ ArrayDef array =
+ (ArrayDef) resolveExpression(arrayNode,
+ location,
+ context,
+ referencePhase);
+
+ resolveExpression(exprNode, location, context, referencePhase);
+
+ return array.getType();
+ }
+
+ private IClass resolveLiteralClass() {
+ return new ExternalClass(Class.class);
+ }
+
+ /**
+ * Resolves any dotted reference, returning the <code>Scope</code>
+ * identified by the reference.
+ *
+ * @param tree the root node of the dotted reference
+ * @param location the <code>Scope</code> in which the expression occours.
+ * @param context the <code>Scope</code> in which the search for the
+ * definition will start
+ * @return the <code>Scope</code> indentified by the reference
+ */
+ private IClass resolveDottedName(
+ SymTabAST tree,
+ Scope location,
+ IClass context,
+ boolean referencePhase) {
+ IClass result = null;
+
+ IClass localContext = context;
+ String name = null;
+
+ DotIterator it = new DotIterator(tree);
+ while (it.hasNext()) {
+ SymTabAST node = it.nextNode();
+ if (node.getType() != TokenTypes.COMMA) {
+ localContext =
+ resolveExpression(
+ node,
+ location,
+ localContext,
+ referencePhase);
+ if (localContext == null) {
+ node.setMeaningfulness(false);
+ name = node.getText();
+ while (localContext == null && it.hasNext()) {
+ SymTabAST next = it.nextNode();
+ name = name + "." + next.getText();
+ localContext = location.getClassDefinition(name);
+ if (localContext != null && referencePhase) {
+ next.setDefinition(
+ localContext,
+ location,
+ referencePhase);
+ }
+ else {
+ next.setMeaningfulness(false);
+ }
+ }
+ }
+ }
+ }
+
+ if (localContext != null) {
+ result = localContext;
+ }
+ else {
+ result = new UnknownClass(name, tree);
+ }
+
+ return result;
+ }
+
+ /**
+ * Resolves a method call.
+ *
+ * @param methodNode the <code>SymTabAST</code> for the METHOD_CALL node
+ * @param location the <code>Scope</code> where the expression occurs
+ * @param context the <code>Scope</code> in which the expression occurs
+ * (where the search for a defintion begins)
+ * @param referencePhase whether or not this is the reference phase of
+ * table construction
+ *
+ * @return the <code>ClassDef</code> for the type returned by the method
+ */
+ private IClass resolveMethod(
+ SymTabAST methodNode,
+ Scope location,
+ IClass context,
+ boolean referencePhase) {
+ IClass result = new UnknownClass(methodNode.getText(), methodNode);
+ IClass newContext = null;
+
+ if (context == null) {
+ newContext = location.getEnclosingClass();
+ }
+ else {
+ newContext = context;
+ }
+
+ String name = null;
+ boolean createReference = true;
+
+ SymTabAST nameNode = (SymTabAST) (methodNode.getFirstChild());
+ SymTabAST parametersNode = (SymTabAST) (nameNode.getNextSibling());
+
+ ISignature signature =
+ resolveParameters(
+ parametersNode,
+ location,
+ context,
+ referencePhase);
+
+ if (nameNode.getType() == TokenTypes.IDENT) {
+ name = nameNode.getText();
+ }
+ else if (
+ nameNode.getType() == TokenTypes.LITERAL_SUPER
+ || (nameNode.getType() == TokenTypes.SUPER_CTOR_CALL)) {
+ IClass superclass = location.getEnclosingClass().getSuperclass();
+ newContext = superclass;
+ name = superclass.getName();
+ createReference = false;
+ }
+ else if (nameNode.getType() == TokenTypes.LITERAL_THIS) {
+ newContext = location.getEnclosingClass();
+ name = newContext.getName();
+ createReference = false;
+ }
+ else {
+ // REDTAG -- doing dotted name resolution on its own
+ SymTabAST contextNode = (SymTabAST) (nameNode.getFirstChild());
+ //TODO: handle Checkstyle grammar
+ nameNode = (SymTabAST) contextNode.getNextSibling();
+ //skip to IDENT
+ while (nameNode.getType() != TokenTypes.IDENT) {
+ nameNode = (SymTabAST) nameNode.getNextSibling();
+ }
+
+ name = nameNode.getText();
+ newContext =
+ resolveExpression(
+ contextNode,
+ location,
+ context,
+ referencePhase);
+ }
+
+ if (newContext != null) {
+ IMethod method = newContext.getMethodDefinition(name, signature);
+
+ if (method != null) {
+ if (createReference && referencePhase) {
+ nameNode.setDefinition(method, location, referencePhase);
+ }
+ result = method.getType();
+ }
+ }
+
+ if (result == null) {
+ result = new UnknownClass(methodNode.getText(), methodNode);
+ }
+
+ return result;
+ }
+
+ /**
+ * resolves a literal "this"
+ *
+ * @param expression the <code>SymTabAST</code> of the expression
+ * @param location the <code>Scope</code> where the expression occurs
+ * @param context the <code>Scope</code> in which the expression occurs
+ * (where the search for a defintion begins)
+ *
+ * @return the resulting scope of the expression (the type to which it evaluates)
+ */
+ private IClass resolveLiteralThis(
+ SymTabAST thisNode,
+ Scope location,
+ IClass context) {
+ return location.getEnclosingClass();
+ }
+
+ /**
+ * resolves a literal "super"
+ *
+ * @param expression the <code>SymTabAST</code> of the expression
+ * @param location the <code>Scope</code> where the expression occurs
+ * @param context the <code>Scope</code> in which the expression occurs
+ * (where the search for a defintion begins)
+ *
+ * @return the resulting scope of the expression (the type to which it evaluates)
+ */
+ private IClass resolveLiteralSuper(
+ SymTabAST superNode,
+ Scope location,
+ IClass context) {
+ return location.getEnclosingClass().getSuperclass();
+ }
+
+ private boolean newIsConstructor(SymTabAST newNode) {
+ boolean result = false;
+
+ SymTabAST typeNode =
+ (SymTabAST) (newNode.getFirstChild().getNextSibling());
+ //handle Checkstyle grammar
+ if (typeNode.getType() == TokenTypes.LPAREN) {
+ typeNode = (SymTabAST) typeNode.getNextSibling();
+ }
+ if (typeNode.getType() == TokenTypes.ELIST) {
+ result = true;
+ }
+ return result;
+
+ }
+
+ /**
+ * resolves and expression of type TokenTypes.TYPE
+ *
+ * @param expression the <code>SymTabAST</code> of the expression
+ * @param location the <code>Scope</code> where the expression occurs
+ * @param context the <code>Scope</code> in which the expression occurs
+ * (where the search for a defintion begins)
+ * @param referencePhase whether or not this is the reference phase of
+ * table construction
+ * @return the resulting scope of the expression (the type to which it evaluates)
+ * @see #resolveDottedName(SymTabAST, Scope, IClass, boolean)
+ * @see #resolveClassIdent(SymTabAST, Scope, IClass, boolean)
+ */
+ public IClass resolveType(
+ SymTabAST expr,
+ Scope location,
+ IClass context,
+ boolean referencePhase) {
+ IClass result = null;
+ SymTabAST nameNode = (SymTabAST) expr.getFirstChild();
+
+ // TODO: Checkstyle change.
+ // Do not create references from typecast.
+ // Original transmogrify code is equivalent to
+ // final boolean createReference = referencePhase;
+ // which creates non-existant references for variables.
+ final boolean createReference = false;
+ if (nameNode.getType() == TokenTypes.DOT) {
+ result =
+ resolveDottedName(nameNode, location, context, createReference);
+ }
+ else {
+ result =
+ resolveClassIdent(nameNode, location, context, createReference);
+ }
+
+ return result;
+ }
+
+ /**
+ * resolves Class type expression
+ * @param expr node to be resolved
+ * @param location scope of the <code>expr</code>
+ * @param context context of the <code>expr</code> if exists
+ * @param referencePhase <code>true</code> if this method is used to during
+ * finding reference phase
+ * <code>false</code> otherwise
+ * @return <code>IClass</code> representing the type to which the
+ * expression evalutes.
+ * @see #resolveDottedName(SymTabAST, Scope, IClass, boolean)
+ */
+ public IClass resolveClass(
+ SymTabAST expr,
+ Scope location,
+ IClass context,
+ boolean referencePhase) {
+
+ IClass result =
+ resolveDottedName(expr, location, context, referencePhase);
+ if (result != null && referencePhase) {
+ expr.setDefinition(result, location, referencePhase);
+ }
+
+ return result;
+ }
+
+ /**
+ * resolves expression with <code>JavaTokenTypes<code> other than <code>DOT</code>
+ * @param expr expression to be resolved
+ * @param location scope of the expression
+ * @param context context of the expression if any
+ * @param referencePhase <code>true</code> if this method is used to during
+ * finding reference phase
+ * <code>false</code> otherwise
+ * @return <code>IClass</code> representing the type to which the
+ * expression evalutes.
+ */
+ public IClass resolveClassIdent(
+ SymTabAST expr,
+ Scope location,
+ IClass context,
+ boolean referencePhase) {
+
+ IClass result = location.getClassDefinition(expr.getText());
+ if (result != null) {
+ expr.setDefinition(result, location, referencePhase);
+ }
+
+ return result;
+ }
+
+ private IClass resolveNew(
+ SymTabAST newNode,
+ Scope location,
+ IClass context,
+ boolean referencePhase) {
+
+ IClass result;
+
+ if (newIsConstructor(newNode)) {
+ result =
+ resolveConstructor(newNode, location, context, referencePhase);
+ }
+ else {
+ result =
+ resolveNewArray(newNode, location, context, referencePhase);
+ }
+
+ return result;
+ }
+
+ private IClass resolveNewArray(
+ SymTabAST newNode,
+ Scope location,
+ IClass context,
+ boolean referencePhase) {
+ IClass arrayType;
+
+ SymTabAST typeNode = (SymTabAST) (newNode.getFirstChild());
+ SymTabAST declaratorNode = (SymTabAST) (typeNode.getNextSibling());
+ SymTabAST initializerNode =
+ (SymTabAST) (declaratorNode.getNextSibling());
+
+ arrayType = resolveClass(typeNode, location, context, referencePhase);
+
+ if (declaratorNode.getFirstChild() != null) {
+ resolveExpression(
+ ((SymTabAST) declaratorNode.getFirstChild()),
+ location,
+ context,
+ referencePhase);
+ }
+
+ if (initializerNode != null) {
+ resolveArrayInitializer(
+ initializerNode,
+ location,
+ context,
+ referencePhase);
+ }
+
+ return new ArrayDef(arrayType);
+ }
+
+ private IClass resolveQuestion(
+ SymTabAST question,
+ Scope location,
+ IClass context,
+ boolean referencePhase) {
+ SymTabAST test = (SymTabAST) question.getFirstChild();
+ while (test.getType() == TokenTypes.LPAREN) {
+ test = (SymTabAST) test.getNextSibling();
+ }
+ SymTabAST leftBranch = (SymTabAST) test.getNextSibling();
+ while (leftBranch.getType() == TokenTypes.RPAREN) {
+ leftBranch = (SymTabAST) leftBranch.getNextSibling();
+ }
+ SymTabAST rightBranch = (SymTabAST) leftBranch.getNextSibling();
+ while (rightBranch.getType() != TokenTypes.COLON) {
+ rightBranch = (SymTabAST) rightBranch.getNextSibling();
+ }
+ rightBranch = (SymTabAST) rightBranch.getNextSibling();
+
+ resolveExpression(test, location, context, referencePhase);
+ IClass leftClass =
+ resolveExpression(leftBranch, location, context, referencePhase);
+ IClass rightClass =
+ resolveExpression(rightBranch, location, context, referencePhase);
+
+ return moreGeneral(leftClass, rightClass);
+ }
+
+ private IClass moreGeneral(IClass a, IClass b) {
+ return (a.isCompatibleWith(b)) ? b : a;
+ }
+
+ /**
+ * Resolves a constructor call.
+ *
+ * @param tree the root node of the constructor call
+ * @return the <code>ClassDef</code> for the class instantiated by the
+ * constructor
+ */
+ private IClass resolveConstructor(
+ SymTabAST constructor,
+ Scope location,
+ IClass context,
+ boolean referencePhase) {
+
+ IClass classConstructed = null;
+
+ SymTabAST nameNode = (SymTabAST) (constructor.getFirstChild());
+ //SymTabAST parametersNode = (SymTabAST) (nameNode.getNextSibling());
+ SymTabAST parametersNode =
+ constructor.findFirstToken(TokenTypes.ELIST);
+ SymTabAST nameIdent = null;
+ if (nameNode.getType() == TokenTypes.IDENT) {
+ nameIdent = nameNode;
+ }
+ else {
+ nameIdent = (SymTabAST) nameNode.getFirstChild().getNextSibling();
+ }
+
+ classConstructed = resolveClass(nameNode, location, context, false);
+ if (classConstructed != null) {
+ MethodSignature signature =
+ resolveParameters(
+ parametersNode,
+ location,
+ context,
+ referencePhase);
+
+ IMethod constructorDef =
+ classConstructed.getMethodDefinition(
+ nameIdent.getText(),
+ signature);
+
+ if (constructorDef != null && referencePhase) {
+ nameIdent.setDefinition(
+ constructorDef,
+ location,
+ referencePhase);
+ }
+ }
+
+ return classConstructed;
+ }
+
+ /**
+ * Resolves the types found in a method call. Any references found
+ * in the process are created. Returns a <code>MethodSignature</code> for
+ * the types of the parameters.
+ *
+ * @param elist The <code>SymTabAST</code> for the list of parameters
+ * @return the signature of the parameters
+ */
+ private MethodSignature resolveParameters(
+ SymTabAST elist,
+ Scope location,
+ IClass context,
+ boolean referencePhase) {
+ Vector parameters = new Vector();
+
+ SymTabAST expr = (SymTabAST) (elist.getFirstChild());
+ while (expr != null) {
+ if (expr.getType() != TokenTypes.COMMA) {
+ IClass parameter =
+ resolveExpression((SymTabAST) (expr
+ .getFirstChild()),
+ location,
+ context,
+ referencePhase);
+ parameters.add(parameter);
+ }
+
+ expr = (SymTabAST) (expr.getNextSibling());
+ }
+
+ return new MethodSignature(parameters);
+ }
+
+ /**
+ * Resolves an IDENT node of an AST, creating the appropriate reference and
+ * returning the scope of the identifer.
+ *
+ * @param ident the IDENT node
+ * @param location the <code>Scope</code> in which the IDENT is found
+ * @return the <code>Scope</code> the identifier identifies
+ */
+ private IClass resolveIdent(
+ SymTabAST ident,
+ Scope location,
+ IClass context,
+ boolean referencePhase) {
+
+ IClass result = null;
+ IDefinition def = null;
+ String name = ident.getText();
+
+ // look for var
+ if (context != null) {
+ def = context.getVariableDefinition(name);
+ }
+ else {
+ def = location.getVariableDefinition(name);
+ }
+
+ if (def != null) {
+ result = ((IVariable) def).getType();
+ }
+ else {
+ // look for class
+ if (context != null) {
+ result = context.getClassDefinition(name);
+ }
+ else {
+ result = location.getClassDefinition(name);
+ }
+ def = result;
+ }
+
+ if (def != null) {
+ ident.setDefinition(def, location, referencePhase);
+ }
+
+ return result;
+ }
+
+ /**
+ * Resolves a (binary) boolean expression. The left and right sides of the
+ * expression
+ * are resolved in the process.
+ *
+ * @param expression the <code>SymTabAST</code> representing the boolean
+ * expression.
+ * @return the <code>Scope</code> for the boolean primitive type.
+ */
+ private IClass resolveBooleanExpression(
+ SymTabAST expression,
+ Scope location,
+ IClass context,
+ boolean referencePhase) {
+ IClass result = null;
+
+ SymTabAST leftChild = findLeftChild(expression);
+ resolveExpression(leftChild, location, context, referencePhase);
+ SymTabAST rightChild = findRightSibling(leftChild);
+
+ resolveExpression(rightChild, location, context, referencePhase);
+
+ result = LiteralResolver.getDefinition(TokenTypes.LITERAL_BOOLEAN);
+
+ return result;
+ }
+
+ /**
+ * resolves references in an assignment expression
+ *
+ * @param expression the <code>SymTabAST</code> of the expression
+ * @param location the <code>Scope</code> where the expression occurs
+ * @param context the <code>Scope</code> in which the expression occurs
+ * (where the search for a defintion begins)
+ *
+ * @return the resulting scope of the expression (the type to which it evaluates)
+ */
+ private IClass resolveAssignment(
+ SymTabAST expression,
+ Scope location,
+ IClass context,
+ boolean referencePhase) {
+ IClass result = null;
+
+ SymTabAST leftNode = (SymTabAST) (expression.getFirstChild());
+ SymTabAST rightNode = (SymTabAST) (leftNode.getNextSibling());
+
+ result = resolveExpression(leftNode, location, context, referencePhase);
+ resolveExpression(rightNode, location, context, referencePhase);
+
+ return result;
+ }
+
+ /**
+ * Resolves a unary expression. Returns the type of the expression,
+ * creating any references found along the way. Unary expressions are
+ * increment (x++), decrement (x--), unary plus (+x), and unary minus (-x)
+ *
+ * @param expression the <code>SymTabAST</code> of the unary expression.
+ * @return the <code>Scope</code> for the type to which the expression
+ * evalutes.
+ */
+ private IClass resolveUnaryExpression(
+ SymTabAST expression,
+ Scope location,
+ IClass context,
+ boolean referencePhase) {
+ SymTabAST operatee = (SymTabAST) (expression.getFirstChild());
+ return resolveExpression(operatee, location, context, referencePhase);
+ }
+
+ /**
+ * Resolves an arithmetic expression. Returns the <code>Scope</code> for
+ * the type to which the expression resolves. Any references found during
+ * resolution are created and resolved.
+ *
+ * @param expression the <code>SymTabAST</code> representing the arithmetic
+ * expression.
+ *
+ * @return the <code>Scope</code> for the type to which the expression
+ * evaluates.
+ */
+ private IClass resolveArithmeticExpression(
+ SymTabAST expression,
+ Scope location,
+ IClass context,
+ boolean referencePhase) {
+ IClass result = null;
+
+ SymTabAST leftChild = findLeftChild(expression);
+
+ IClass leftType =
+ (resolveExpression(leftChild,
+ location,
+ context,
+ referencePhase));
+
+ SymTabAST rightChild = findRightSibling(leftChild);
+
+ IClass rightType =
+ (resolveExpression(rightChild,
+ location,
+ context,
+ referencePhase));
+
+ result = binaryResultType(leftType, rightType);
+
+ return result;
+ }
+
+ /**
+ * Finds the left child of a binary operator, skipping parentheses.
+ * @param aExpression the node for the binary operator.
+ * @return the node for the left child.
+ */
+ private SymTabAST findLeftChild(SymTabAST aExpression) {
+ SymTabAST leftChild = (SymTabAST) (aExpression.getFirstChild());
+ // handle Checkstyle grammar
+ while (leftChild.getType() == TokenTypes.LPAREN) {
+ leftChild = (SymTabAST) leftChild.getNextSibling();
+ }
+ return leftChild;
+ }
+
+ /**
+ * Finds the right sibling of the left child of a binary operator,
+ * skipping parentheses.
+ * @param aLeftChild the left child of a binary operator.
+ * @return the node of the right sibling.
+ */
+ private SymTabAST findRightSibling(SymTabAST aLeftChild) {
+ SymTabAST rightChild = (SymTabAST) (aLeftChild.getNextSibling());
+ // handle Checkstyle grammar
+ while ((rightChild != null)
+ && (rightChild.getType() == TokenTypes.RPAREN))
+ {
+ rightChild = (SymTabAST) rightChild.getNextSibling();
+ }
+ return rightChild;
+ }
+
+ /**
+ * Returns the <code>ClassDef</code> for the type to which arithmetic
+ * expressions evaluate.
+ *
+ * @param a the <code>ClassDef</code> of the first operand.
+ * @param b the <code>ClassDef</code> of the second operand.
+ *
+ * @return the <code>ClassDef</code> to which the expression evaluates.
+ */
+ private IClass binaryResultType(IClass a, IClass b) {
+
+ IClass result = null;
+
+ // These may or may not be in line with the rules set forth in the java
+ // language specification. Not being in line would be a BadThing(r).
+
+ IClass string = new ExternalClass(java.lang.String.class);
+
+ if (a.equals(string) || b.equals(string)) {
+ result = string;
+ }
+ else if (a.equals(PrimitiveClasses.BOOLEAN)) {
+ result = PrimitiveClasses.BOOLEAN;
+ }
+ else {
+ result =
+ PrimitiveClasses.binaryPromote(
+ a,
+ b);
+ }
+
+ return result;
+ }
+
+ /**
+ * resolves references in an instanceof expression
+ *
+ * @param expression the <code>SymTabAST</code> of the expression
+ * @param location the <code>Scope</code> where the expression occurs
+ * @param context the <code>Scope</code> in which the expression occurs
+ * (where the search for a defintion begins)
+ *
+ * @return the resulting scope of the expression (the type to which it evaluates)
+ */
+ private IClass resolveInstanceOf(
+ SymTabAST expression,
+ Scope location,
+ IClass context,
+ boolean referencePhase) {
+ SymTabAST leftNode = (SymTabAST) (expression.getFirstChild());
+ SymTabAST rightNode = (SymTabAST) (leftNode.getNextSibling());
+
+ resolveExpression(leftNode, location, context, referencePhase);
+
+ SymTabAST classNameNode = (SymTabAST) (rightNode.getFirstChild());
+ resolveClass(classNameNode, location, context, referencePhase);
+
+ return LiteralResolver.getDefinition(TokenTypes.LITERAL_BOOLEAN);
+ }
+
+ /**
+ * resolves references in a a break statement
+ *
+ * @param expression the <code>SymTabAST</code> for the expression
+ * @param location the <code>Scope</code> where the expression occurs
+ * @param context the <code>Scope</code> in which the expression occurs
+ * (where the search for a defintion begins)
+ *
+ * @return the <code>Scope</code> for the int primitive type
+ */
+ private IClass resolveGoto(
+ SymTabAST expression,
+ Scope location,
+ IClass context,
+ boolean referencePhase) {
+ SymTabAST label = (SymTabAST) (expression.getFirstChild());
+ // handle Checkstyle grammar
+ if (label != null && (label.getType() != TokenTypes.SEMI)) {
+ LabelDef def = location.getLabelDefinition(label.getText());
+ if (def != null) {
+ label.setDefinition(def, location, referencePhase);
+ }
+ }
+
+ return null;
+ }
+
+ private IClass resolvePrimitiveType(
+ SymTabAST primitive,
+ Scope location,
+ IClass context,
+ boolean referencePhase) {
+ IClass result =
+ LiteralResolver.getDefinition(primitive.getType());
+
+ primitive.setDefinition(result, location, referencePhase);
+ return result;
+ }
+
+ /**
+ * Returns the <code>ClassDef</code> of the int primitive type. This may
+ * need to be amended, based on the Java Language spec, to return a long
+ * if the literal is larger than an int can hold.
+ *
+ * @param expression the <code>SymTabAST</code> for the integer literal
+ * @param location the <code>Scope</code> where the expression occurs
+ * @param context the <code>Scope</code> in which the expression occurs
+ * (where the search for a defintion begins)
+ *
+ * @return the <code>Scope</code> for the int primitive type
+ */
+ private IClass resolveNumInt(
+ SymTabAST expression,
+ Scope location,
+ IClass context) {
+ return PrimitiveClasses.INT;
+ }
+
+ /**
+ * Returns the <code>ClassDef</code> type of the float primitive type.
+ * This may need to be amended, based on the Java Language spec, to return
+ * a double if the literal is larger than a float can hold.
+ *
+ * @param expression the <code>SymTabAST</code> for the floating point
+ literal
+ * @param location the <code>Scope</code> where the expression occurs
+ * @param context the <code>Scope</code> in which the expression occurs
+ * (where the search for a defintion begins)
+ *
+ * @return the <code>Scope</code> for the float primitive type
+ */
+ private IClass resolveNumFloat(
+ SymTabAST expression,
+ Scope location,
+ IClass context) {
+ return PrimitiveClasses.DOUBLE;
+ }
+
+ /**
+ * Returns the <code>ClassDef</code> type of a string literal
+ *
+ * @param expression the <code>SymTabAST</code> for a string literal
+ * @param location the <code>Scope</code> where the expression occurs
+ * @param context the <code>Scope</code> in which the expression occurs
+ * (where the search for a defintion begins)
+ *
+ * @return the <code>Scope</code> type of a string literal
+ */
+ private IClass resolveStringLiteral(
+ SymTabAST expression,
+ Scope location,
+ IClass context) {
+ return LiteralResolver.getDefinition(
+ TokenTypes.STRING_LITERAL);
+ }
+
+ /**
+ * Returns the <code>ClassDef</code> type of a character literal
+ *
+ * @param expression the <code>SymTabAST</code> for a string literal
+ * @param location the <code>Scope</code> where the expression occurs
+ * @param context the <code>Scope</code> in which the expression occurs
+ * (where the search for a defintion begins)
+ *
+ * @return the <code>Scope</code> type of a character literal
+ */
+ private IClass resolveCharLiteral(
+ SymTabAST expression,
+ Scope location,
+ IClass context) {
+ return LiteralResolver.getDefinition(
+ TokenTypes.LITERAL_CHAR);
+ }
+
+ /**
+ * Describe <code>resolveBooleanLiteral</code> method here.
+ *
+ * @param expression the <code>SymTabAST</code> of the expression
+ * @param location the <code>Scope</code> where the expression occurs
+ * @param context the <code>Scope</code> in which the expression occurs
+ * (where the search for a defintion begins)
+ *
+ * @return the <code>Scope</code> for the boolean primitive.
+ */
+ private IClass resolveBooleanLiteral(
+ SymTabAST expression,
+ Scope location,
+ IClass context) {
+ return LiteralResolver.getDefinition(TokenTypes.LITERAL_BOOLEAN);
+ }
+
+ private IClass resolveBooleanUnary(
+ SymTabAST expression,
+ Scope location,
+ IClass context,
+ boolean referencePhase) {
+ SymTabAST child = (SymTabAST) expression.getFirstChild();
+ resolveExpression(child, location, context, referencePhase);
+
+ return LiteralResolver.getDefinition(TokenTypes.LITERAL_BOOLEAN);
+ }
+
+ /**
+ * Resolves a constructor call.
+ *
+ * @param tree the root node of the constructor call
+ * @return the <code>ClassDef</code> for the class instantiated by the
+ * constructor
+ */
+ private void resolveArrayInitializer(
+ SymTabAST initializerNode,
+ Scope location,
+ IClass context,
+ boolean referencePhase) {
+ SymTabAST child = (SymTabAST) (initializerNode.getFirstChild());
+ while (child != null) {
+ if (child.getType() != TokenTypes.COMMA) {
+ resolveExpression(child, location, context, referencePhase);
+ }
+ child = (SymTabAST) (child.getNextSibling());
+ }
+ }
+
+ /**
+ * Resolves a constructor call.
+ *
+ * @param tree the root node of the constructor call
+ * @return the <code>ClassDef</code> for the class instantiated by the
+ * constructor
+ */
+ private void resolveThrowExpression(
+ SymTabAST throwNode,
+ Scope location,
+ IClass context,
+ boolean referencePhase) {
+
+ SymTabAST nameNode = (SymTabAST) (throwNode.getFirstChild());
+ resolveExpression(nameNode, location, context, referencePhase);
+ }
+
+ private IClass resolveShiftOperator(
+ SymTabAST expression,
+ Scope location,
+ IClass context,
+ boolean referencePhase) {
+ IClass result = null;
+
+ SymTabAST leftChild = findLeftChild(expression);
+ SymTabAST rightChild = findRightSibling(leftChild);
+
+ result =
+ resolveExpression(leftChild, location, context, referencePhase);
+ resolveExpression(rightChild, location, context, referencePhase);
+
+ result = PrimitiveClasses.unaryPromote(result);
+
+ return result;
+ }
+
+ private IClass resolveBitwiseNot(
+ SymTabAST expression,
+ Scope location,
+ IClass context,
+ boolean referencePhase) {
+ IClass result = null;
+ SymTabAST child = (SymTabAST) expression.getFirstChild();
+ result = resolveExpression(child, location, context, referencePhase);
+
+ result = PrimitiveClasses.unaryPromote(result);
+
+ return result;
+ }
+}
diff --git a/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/Scope.java b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/Scope.java
new file mode 100755
index 000000000..c03c0bf8d
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/Scope.java
@@ -0,0 +1,124 @@
+
+// Transmogrify License
+//
+// Copyright (c) 2001, ThoughtWorks, Inc.
+// All rights reserved.
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// - Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+// - Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// Neither the name of the ThoughtWorks, Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from this
+// software without specific prior written permission.
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+package com.puppycrawl.tools.checkstyle.checks.usage.transmogrify;
+
+
+
+import java.util.Enumeration;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.SortedSet;
+import java.util.TreeSet;
+import java.util.Vector;
+
+
+/**
+ * Represents a scope of Java code.
+ *
+ * @author andrew mccormick, dave wood
+ * @version 1.0
+ * @since 1.0
+ * @see Definition
+ * @see Resolvable
+ */
+public abstract class Scope extends Definition {
+
+ // rename to references?
+ protected SortedSet referencesInScope = new TreeSet();
+
+ protected Hashtable elements = new Hashtable();
+ protected Hashtable labels = new Hashtable();
+ protected Hashtable classes = new Hashtable();
+
+ public Scope( String name, Scope parentScope, SymTabAST node ) {
+ super( name, parentScope, node );
+ }
+
+ public void addDefinition(VariableDef def) {
+ elements.put(def.getName(), def);
+ }
+
+ public void addDefinition(BlockDef def) {
+ elements.put(def.getName(), def);
+ }
+
+ public void addDefinition(ClassDef def) {
+ classes.put(def.getName(), def);
+ }
+
+ public void addDefinition(LabelDef def) {
+ labels.put(def.getName(), def);
+ }
+
+ public abstract void addDefinition(IPackage def);
+
+ protected Enumeration getDefinitions() {
+ Vector allElements = new Vector();
+
+ allElements.addAll(elements.values());
+ allElements.addAll(labels.values());
+ allElements.addAll(classes.values());
+
+ return allElements.elements();
+ }
+
+ protected Iterator getClasses() {
+ return classes.values().iterator();
+ }
+
+ public abstract IMethod getMethodDefinition(String name, ISignature signature);
+ public abstract IVariable getVariableDefinition(String name);
+ public abstract LabelDef getLabelDefinition(String name);
+ public abstract IClass getClassDefinition(String name);
+
+ public Iterator getReferencesIn() {
+ return referencesInScope.iterator();
+ }
+
+ public Reference getSymbol(String name, Occurrence location) {
+ Reference result = null;
+
+ for (Iterator it = getReferencesIn(); it.hasNext(); ) {
+ Reference reference = (Reference)it.next();
+// if (name.equals(reference.getName())) {
+ if (reference.getLine() == location.getLine() &&
+ reference.getColumn() == location.getColumn()) {
+ result = reference;
+ break;
+ }
+// }
+ }
+ return result;
+ }
+
+ public void addReferenceInScope( Reference reference ) {
+ referencesInScope.add( reference );
+ }
+
+}
diff --git a/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/ScopeIndex.java b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/ScopeIndex.java
new file mode 100755
index 000000000..7ae3048a1
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/ScopeIndex.java
@@ -0,0 +1,140 @@
+
+// Transmogrify License
+//
+// Copyright (c) 2001, ThoughtWorks, Inc.
+// All rights reserved.
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// - Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+// - Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// Neither the name of the ThoughtWorks, Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from this
+// software without specific prior written permission.
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+package com.puppycrawl.tools.checkstyle.checks.usage.transmogrify;
+
+import java.util.Hashtable;
+import java.util.Vector;
+
+
+
+
+/**
+ * <code>ScopeIndex</code> provides methods for finding <code>Scope</code>s
+ * related to a known <code>Occurrence</code>
+ */
+public class ScopeIndex {
+
+ //This is a Hashtable full of Vectors. The keys to this hashtable are filenames.
+ //Each vector contains all of the scope objects from the specific file.
+ private Hashtable indexOfFiles = new Hashtable();
+
+ public Hashtable getIndex() {
+ return indexOfFiles;
+ }
+
+ /**
+ * returns the most specific <code>Scope</code> to which the specified
+ * <code>Occurence</code> belongs.
+ *
+ * @param occ the <code>Occurrence</code> whose <code>Scope</code> we're interested in.
+ * @return Scope
+ */
+ public Scope lookup(Occurrence occ) {
+ String key = occ.getFile().getAbsolutePath();
+ Vector scopeList = getFileVector(key);
+
+ Scope result = findScope(scopeList, occ);
+
+ return result;
+ }
+
+ /**
+ * returns the most specific <code>Scope</code> to which the specified
+ * <code>Occurence</code> belongs from the specified <code>Vector</code>
+ * of <code>Scope</code>s.
+ *
+ * @param occ the <code>Occurrence</code> whose <code>Scope</code> we're interested in.
+ * @param scopeList the <code>Vector</code> of <code>Scope</code>s to chose from.
+ * @return Scope
+ */
+ public Scope findScope(Vector scopeList, Occurrence occ) {
+ int i = 0;
+
+ Scope bestSoFar = (Scope) scopeList.elementAt(i);
+
+ while (!bestSoFar
+ .getTreeNode()
+ .getSpan()
+ .contains(occ.getLine(), occ.getColumn())) {
+ i++;
+ bestSoFar = (Scope) scopeList.elementAt(i);
+ }
+
+ for (; i < scopeList.size(); i++) {
+ Scope currentScope = (Scope) scopeList.elementAt(i);
+
+ if (currentScope
+ .getTreeNode()
+ .getSpan()
+ .contains(occ.getLine(), occ.getColumn())) {
+ if (bestSoFar
+ .getTreeNode()
+ .getSpan()
+ .contains(currentScope.getTreeNode().getSpan())) {
+ bestSoFar = currentScope;
+ }
+ }
+ }
+
+ return bestSoFar;
+ }
+
+ /**
+ * adds a <code>Scope</code> to the <code>ScopeIndex</code> for searching.
+ *
+ * @param scope the <code>Scope</code> to add.
+ */
+ public void addScope(Scope scope) {
+
+ final SymTabAST SymTabAST = scope.getTreeNode();
+ SymTabAST.getFile();
+ Vector fileVector =
+ getFileVector(scope.getTreeNode().getFile().getAbsolutePath());
+
+ fileVector.addElement(scope);
+ }
+
+ /**
+ * returns the <code>Vector</code> containing the <code>Scope</code>s related
+ * to the specified filename.
+ *
+ * @param fileName the fileName to find scopes for.
+ * @return Vector
+ */
+ private Vector getFileVector(String fileName) {
+ Vector result = (Vector) indexOfFiles.get(fileName);
+
+ if (result == null) {
+ result = new Vector();
+ indexOfFiles.put(fileName, result);
+ }
+
+ return result;
+ }
+} \ No newline at end of file
diff --git a/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/Span.java b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/Span.java
new file mode 100755
index 000000000..bbbc61db8
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/Span.java
@@ -0,0 +1,153 @@
+//Transmogrify License
+//
+//Copyright (c) 2001, ThoughtWorks, Inc.
+//All rights reserved.
+//Redistribution and use in source and binary forms, with or without
+//modification, are permitted provided that the following conditions
+//are met:
+//- Redistributions of source code must retain the above copyright notice,
+//this list of conditions and the following disclaimer.
+//- Redistributions in binary form must reproduce the above copyright
+//notice, this list of conditions and the following disclaimer in the
+//documentation and/or other materials provided with the distribution.
+//Neither the name of the ThoughtWorks, Inc. nor the names of its
+//contributors may be used to endorse or promote products derived from this
+//software without specific prior written permission.
+//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+//TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+//PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+//CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+//EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+//PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+//OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+//WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+//OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+//ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+package com.puppycrawl.tools.checkstyle.checks.usage.transmogrify;
+
+public class Span {
+
+ private int _startLine;
+ private int _startColumn;
+ private int _endLine;
+ private int _endColumn;
+
+ public Span() {}
+
+ public Span(int startLine, int startColumn, int endLine, int endColumn) {
+ setStart(startLine, startColumn);
+ setEnd(endLine, endColumn);
+ }
+
+ public Span( Span span ) {
+ this( span.getStartLine(), span.getStartColumn(),
+ span.getEndLine(), span.getEndColumn() );
+ }
+
+ public void setStart(int startLine, int startColumn) {
+ _startLine = startLine;
+ _startColumn = startColumn;
+ }
+
+ public void setEnd(int endLine, int endColumn) {
+ _endLine = endLine;
+ _endColumn = endColumn;
+ }
+
+ public int getStartLine() {
+ return _startLine;
+ }
+
+ public int getStartColumn() {
+ return _startColumn;
+ }
+
+ public int getEndLine() {
+ return _endLine;
+ }
+
+ public int getEndColumn() {
+ return _endColumn;
+ }
+
+ public boolean contains( Span span ) {
+ return ( contains(span.getStartLine(), span.getStartColumn())
+ && contains( span.getEndLine(), span.getEndColumn()) );
+ }
+
+ public boolean contains(int line, int column) {
+ boolean afterStart = false;
+ boolean beforeEnd = false;
+
+ if ( getStartLine() < line ) {
+ afterStart = true;
+ }
+ else if ( getStartLine() == line && getStartColumn() <= column ) {
+ afterStart = true;
+ }
+
+ if ( getEndLine() > line ) {
+ beforeEnd = true;
+ }
+ else if ( getEndLine() == line && getEndColumn() >= column ) {
+ beforeEnd = true;
+ }
+
+ return ( afterStart && beforeEnd );
+ }
+
+ protected boolean startsBefore( Span span ) {
+ boolean result = false;
+ if ( getStartLine() < span.getStartLine() ) {
+ result = true;
+ }
+ else if ( getStartLine() == span.getStartLine()
+ && getStartColumn() <= span.getStartColumn() ) {
+ result = true;
+ }
+
+ return result;
+ }
+
+ protected boolean endsAfter( Span span ) {
+ boolean result = false;
+ if ( getEndLine() > span.getEndLine() ) {
+ result = true;
+ }
+ else if ( getEndLine() == span.getEndLine()
+ && getEndColumn() >= span.getEndColumn() ) {
+ result = true;
+ }
+
+ return result;
+ }
+
+ public void compose( Span span ) {
+ if ( span.startsBefore( this ) ) {
+ setStart( span.getStartLine(), span.getStartColumn() );
+ }
+ if ( span.endsAfter( this ) ) {
+ setEnd( span.getEndLine(), span.getEndColumn() );
+ }
+ }
+
+ public boolean equals(Object o) {
+ boolean result = false;
+ if ( o instanceof Span ) {
+ Span span = (Span)o;
+ result = ( span.getStartLine() == getStartLine()
+ && span.getStartColumn() == getStartColumn()
+ && span.getEndLine() == getEndLine()
+ && span.getEndColumn() == getEndColumn() );
+ }
+ return result;
+ }
+
+ public String toString() {
+ return "[" + getStartLine() + "," + getStartColumn()
+ + ":" + getEndLine() + "," + getEndColumn() + "]";
+ }
+
+}
diff --git a/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/SymTabAST.java b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/SymTabAST.java
new file mode 100755
index 000000000..0fd8fd3ff
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/SymTabAST.java
@@ -0,0 +1,554 @@
+
+// Transmogrify License
+//
+// Copyright (c) 2001, ThoughtWorks, Inc.
+// All rights reserved.
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// - Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+// - Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// Neither the name of the ThoughtWorks, Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from this
+// software without specific prior written permission.
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+package com.puppycrawl.tools.checkstyle.checks.usage.transmogrify;
+
+import java.io.File;
+
+import antlr.collections.AST;
+
+import com.puppycrawl.tools.checkstyle.api.DetailAST;
+import com.puppycrawl.tools.checkstyle.api.TokenTypes;
+
+
+
+/**
+ * an extension of <code>antlr.CommonAST</code> that includes
+ * extra information about the AST's location. This information
+ * is the file and line number where the AST was created.
+ *
+ * To use this AST node in your tree structure, assuming your
+ * antlr.TreeParser is called parser, use
+ *
+ * parser.setASTNOdeCLass(SymTabAST.class.getName());
+ *
+ * make sure you also call setTokenObjectClass for the lexer as well
+ *
+ *
+ * @see SymTabToken
+ */
+//TODO: Should be an adapter of DetailAST
+
+public class SymTabAST
+ extends antlr.CommonASTWithHiddenTokens
+{
+ private Scope _scope;
+ private IDefinition _definition = null;
+ private boolean _isMeaningful = true;
+
+ private File _file;
+ private int _line;
+ private int _column;
+
+// parent is not used by Checkstyle
+// private SymTabAST parent;
+
+ private Span _span;
+
+ /** original syntax tree node */
+ private DetailAST detailNode;
+
+// /**
+// * gets parent of this node
+// * @return <code>SymTabAST</code>
+// */
+// public SymTabAST getParent() {
+// return parent;
+// }
+
+// /**
+// * gets previous sibling of this node
+// * @return <code>SymTabAST</code>
+// */
+// public SymTabAST getPreviousSibling() {
+// return prevSibling;
+// }
+
+ /**
+ * sets parent of this node
+ * @param parent
+ * @return <code>void</code>
+ */
+ public void setParent(SymTabAST parent) {
+//parent is not used by Checkstyle
+// this.parent = parent;
+ }
+
+ /**
+ * gets the scope of this node
+ * @return <code>Scope</code>
+ */
+ public Scope getScope() {
+ return _scope;
+ }
+
+ /**
+ * sets the scope of this node
+ * @param scope
+ * @return <code>void</code>
+ */
+ public void setScope(Scope scope) {
+ _scope = scope;
+ }
+
+ /**
+ * sets <code>Definition</code> for this node
+ * @param definition
+ * @param scope
+ * @return <code>void</code>
+ * @see #setDefinition(IDefinition, Scope, boolean)
+ */
+ public void setDefinition(IDefinition definition, Scope scope) {
+ setDefinition(definition, scope, true);
+ }
+
+ /**
+ * sets <code>Definition</code> for this node and adds <code>Reference</code>
+ * to the <code>_definition</code> and <code>scope</code>
+ * @param definition
+ * @param scope
+ * @param createReference
+ * @return <code>void</code>
+ * @see net.sourceforge.transmogrify.symtab.Reference
+ */
+ public void setDefinition(
+ IDefinition definition,
+ Scope scope,
+ boolean createReference) {
+ _definition = definition;
+ Reference reference = new Reference(this);
+ if (scope != null) {
+ scope.addReferenceInScope(reference);
+ }
+
+ if (definition.isSourced() && createReference) {
+ _definition.addReference(reference);
+ }
+ }
+
+ /**
+ * gets <code>_definitin</code>
+ * @return <code>IDefinition</code>
+ */
+ public IDefinition getDefinition() {
+ return _definition;
+ }
+
+ /**
+ * tests if this node is meaningful or should be ignored
+ * @return <code>boolean</code>
+ */
+ public boolean isMeaningful() {
+ return _isMeaningful;
+ }
+
+ /**
+ * sets <code>_isMeaningful</code> member
+ * @param isMeaningful
+ * @return <code>void</code>
+ */
+ public void setMeaningfulness(boolean isMeaningful) {
+ _isMeaningful = isMeaningful;
+ }
+
+ /**
+ * sets meaningfulness for this node and its children
+ * @return <code>void</code>
+ * @see #setMeaningfulness(boolean)
+ */
+ public void ignoreChildren() {
+ if (getType() == TokenTypes.IDENT) {
+ setMeaningfulness(false);
+ }
+ SymTabAST child = (SymTabAST) getFirstChild();
+ while (child != null) {
+ child.ignoreChildren();
+ child = (SymTabAST) child.getNextSibling();
+ }
+ }
+
+ /**
+ * sets file where this node belong to
+ * @param file
+ * @return <code>void</code>
+ */
+ public void setFile(File file) {
+ _file = file;
+ }
+
+ /**
+ * finishes process for adding node to its parent
+ * @param file file where this node belongs to
+ * @param parent parent of this node
+ * @param previousSibling previous sibling of this node
+ * @return <code>Span</code> the span of this node
+ * @see #setFile(File)
+ * @see #setParent(SymTabAST)
+ * @see #setPreviousSibling(SymTabAST)
+ * @see #finishChildren(File)
+ * @see #setSpan(Span)
+ */
+ public Span finishDefinition(
+ File file,
+ SymTabAST parent) {
+ setFile(file);
+ setParent(parent);
+
+ Span result = finishChildren(file);
+
+ if (getLineNo() != 0) {
+ result.compose(
+ new Span(
+ getLineNo(),
+ getColumnNo(),
+ getLineNo(),
+ getColumnNo()
+ + ((getText() == null) ? 0 : getText().length() - 1)));
+ }
+
+ setSpan(result);
+ return result;
+ }
+
+ /**
+ * finishes children of this node definition process
+ * @param file file where this node belongs to
+ * @return <code>Span</code>
+ * @see #finishDefinition(File, SymTabAST, SymTabAST)
+ */
+ public Span finishChildren(File file) {
+ Span result = null;
+ SymTabAST current = (SymTabAST) getFirstChild();
+
+ if (current == null) {
+ result = getSpan();
+ }
+ else {
+ while (current != null) {
+ Span childSpan =
+ current.finishDefinition(file, this);
+
+ if (childSpan != null) {
+ if (result == null) {
+ result = new Span(childSpan);
+ }
+ else {
+ result.compose(childSpan);
+ }
+ }
+
+ current = (SymTabAST) current.getNextSibling();
+ }
+ }
+
+ return result;
+ }
+
+ /**
+ * gets file where this node belongs to
+ * @return <code>File</code>
+ */
+ public File getFile() {
+ return _file;
+ }
+
+ /**
+ * sets the line where this node reside
+ * @return <code>void</code>
+ */
+ public void setLine(int line) {
+ _line = line;
+ }
+
+ /**
+ * gets the line where this node reside
+ * @return <code>int</code>
+ */
+ public int getLineNo() {
+ return _line;
+ }
+
+ /**
+ * sets the column where this node reside
+ * @param column
+ */
+ public void setColumn(int column) {
+ _column = column;
+ }
+
+ /**
+ * gets the column where this node reside
+ * @return <code>int</code>
+ */
+ public int getColumnNo() {
+ return _column;
+ }
+
+ /**
+ * gets the definition name of this node
+ * @return <code>String</code>
+ * @see net.sourceforge.transmogrify.symtab.IDefinition
+ */
+ public String getName() {
+ String result = null;
+ if (_definition != null) {
+ result = _definition.getName();
+ }
+
+ return result;
+ }
+
+ /**
+ * prints the line, column and file for this node for debugging purpose
+ * @return <code>String</code>
+ */
+ public String toString() {
+ //StringBuffer resultBuffer = new StringBuffer(super.toString());
+ StringBuffer resultBuffer = new StringBuffer(prefixString(true));
+ resultBuffer.append("[" + getLineNo() + "," + getColumnNo() + "]");
+ //if ( getSpan() != null ) {
+ // resultBuffer.append( " spans " + getSpan() );
+ //}
+ resultBuffer.append(" in " + getFile());
+ //resultBuffer.append(" type: " + getType());
+ return resultBuffer.toString();
+ }
+
+ public String prefixString(boolean verboseStringConversion) {
+ StringBuffer b = new StringBuffer();
+
+ try {
+ final String name = TokenTypes.getTokenName(getType());
+ // if verbose and type name not same as text (keyword probably)
+ if (verboseStringConversion && !getText().equalsIgnoreCase(name)) {
+ b.append('[');
+ b.append(getText());
+ b.append(",<");
+ b.append(name);
+ b.append(">]");
+ return b.toString();
+ }
+ }
+ catch (Exception ex) {
+ ;
+ }
+ return getText();
+ }
+
+ /**
+ * gets <code>Span</code> of this node
+ * @return <code>Span</code>
+ */
+ public Span getSpan() {
+ if ((_span == null)) {
+ int endColumn = getColumnNo() + 1;
+ final String text = getText();
+ if (text != null) {
+ endColumn += text.length() - 1;
+ }
+ _span = new Span(getLineNo(), getColumnNo() + 1, getLineNo(), endColumn);
+ }
+ return _span;
+ }
+
+ /**
+ * sets <code>Span</code> for this node
+ * @param span
+ * @return <code>void</code>
+ */
+ public void setSpan(Span span) {
+ _span = span;
+ }
+
+// not used by Checkstyle
+// /**
+// * tests if this node is inside the span
+// * @param line
+// * @param column
+// * @return <code>boolean</code> <code>true</code> if this node is within the span
+// * <code>false</code> otherwise
+// */
+// public boolean contains(int line, int column) {
+// return getSpan().contains(line, column);
+// }
+
+ /**
+ * gets enclosing node for this node based on line and column
+ * @param line
+ * @param column
+ * @return <code>SymTabAST</code>
+ * @see #getSpan()
+ */
+ public SymTabAST getEnclosingNode(int line, int column) {
+ SymTabAST result = null;
+
+ if ((getSpan() != null) && (getSpan().contains(line, column))) {
+ SymTabAST child = (SymTabAST) getFirstChild();
+ while (child != null && result == null) {
+ result = child.getEnclosingNode(line, column);
+ child = (SymTabAST) child.getNextSibling();
+ }
+
+ // if none of the children contain it, I'm the best node
+ if (result == null) {
+ result = this;
+ }
+
+ }
+ return result;
+ }
+
+ public AST getFirstChild()
+ {
+ if (super.getFirstChild() == null) {
+ DetailAST childDetailAST = null;
+ final DetailAST detailAST = getDetailNode();
+ if (detailAST != null) {
+ childDetailAST = (DetailAST) detailAST.getFirstChild();
+ if (childDetailAST != null) {
+ final SymTabAST child =
+ SymTabASTFactory.create(childDetailAST);
+ setFirstChild(child);
+ child.setParent(this);
+ child.setFile(getFile());
+ }
+ }
+ }
+ return super.getFirstChild();
+ }
+
+ public AST getNextSibling()
+ {
+ if (super.getNextSibling() == null) {
+ DetailAST siblingDetailAST = null;
+ final DetailAST detailAST = getDetailNode();
+ if (detailAST != null) {
+ siblingDetailAST = (DetailAST) detailAST.getNextSibling();
+ if (siblingDetailAST != null) {
+ final SymTabAST sibling =
+ SymTabASTFactory.create(siblingDetailAST);
+ setNextSibling(sibling);
+// sibling.setParent(this.getParent());
+ sibling.setFile(getFile());
+ }
+ }
+ }
+ return super.getNextSibling();
+ }
+
+
+ /**
+ * initialized this node with input node
+ * @param aAST the node to initialize from. Must be a
+ * <code>DetailAST</code> object.
+ */
+ public void initialize(AST aAST)
+ {
+ if (aAST != null) {
+ super.initialize(aAST);
+ final DetailAST detailAST = (DetailAST) aAST;
+ setDetailNode(detailAST);
+ _column = detailAST.getColumnNo() + 1;
+ _line = detailAST.getLineNo();
+ }
+ }
+
+ /**
+ * Gets first occurence of the child node with a certain type
+ * @param type
+ * @return <code>SymTabAST</code>
+ * @see #getType()
+ */
+ public SymTabAST findFirstToken(int type) {
+ SymTabAST result = null;
+
+ AST sibling = getFirstChild();
+ while (sibling != null) {
+ if (sibling.getType() == type) {
+ result = (SymTabAST) sibling;
+ break;
+ }
+ sibling = sibling.getNextSibling();
+ }
+
+ return result;
+ }
+
+// not used by Checkstyle
+// /**
+// * adds a node to the last position of this node children
+// * @param child
+// * @return <code>void</code>
+// */
+// public void addChild(SymTabAST child)
+// {
+// SymTabAST lastChild = (SymTabAST) getFirstChild();
+// if (lastChild == null) {
+// setFirstChild(child);
+// child.setParent(this);
+// child.setNextSibling(null);
+// }
+// else {
+// while (lastChild.getNextSibling() != null) {
+// lastChild = (SymTabAST) lastChild.getNextSibling();
+// }
+// lastChild.setNextSibling(child);
+// child.setNextSibling(null);
+// child.setParent(this);
+// }
+// }
+
+ /**
+ * Gets Iterator for this node
+ * @return <code>SymTabASTIterator</code>
+ */
+ public SymTabASTIterator getChildren()
+ {
+ return new SymTabASTIterator(this);
+ }
+
+ /**
+ * Returns the DetailAST associated with this node.
+ * @return the DetailAST associated with this node.
+ */
+ public DetailAST getDetailNode()
+ {
+ return detailNode;
+ }
+
+ /**
+ * Sets the DetailAST associated with this node.
+ * @param aDetailAST the DetailAST associated with this node.
+ */
+ public void setDetailNode(DetailAST aDetailAST)
+ {
+ detailNode = aDetailAST;
+ ASTManager.getInstance().put(aDetailAST, this);
+ }
+
+} \ No newline at end of file
diff --git a/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/SymTabASTFactory.java b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/SymTabASTFactory.java
new file mode 100755
index 000000000..e18365d97
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/SymTabASTFactory.java
@@ -0,0 +1,76 @@
+
+// Transmogrify License
+//
+// Copyright (c) 2001, ThoughtWorks, Inc.
+// All rights reserved.
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// - Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+// - Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// Neither the name of the ThoughtWorks, Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from this
+// software without specific prior written permission.
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+package com.puppycrawl.tools.checkstyle.checks.usage.transmogrify;
+
+import antlr.ASTFactory;
+import antlr.collections.AST;
+
+/**
+ * Factory for <code>SymTabAST</code> objects.
+ * @author Rick Giles
+ */
+public class SymTabASTFactory
+{
+ /** singleton factory */
+ private static ASTFactory factory;
+
+ static
+ {
+ factory = new ASTFactory();
+ factory.setASTNodeClass(SymTabAST.class.getName());
+ }
+
+ /**
+ * Creates a <code>SymTabAST</code> with a given type and text.
+ * @param aType the type for the new <code>SymTabAST</code>.
+ * @param aText the text for the new <code>SymTabAST</code>.
+ * @return the new <code>SymTabAST</code>.
+ */
+ public static SymTabAST create(int aType, String aText)
+ {
+ return (SymTabAST) factory.create(aType, aText);
+ }
+
+ /**
+ * Creates an <code>SymTabAST</code> from a given <code>AST</code>.
+ * @param aAST the <code>AST</code> for the new <code>SymTabAST</code>.
+ * @return the new <code>SymTabAST</code>.
+ */
+ public static SymTabAST create(AST aAST)
+ {
+ return (SymTabAST) factory.create(aAST);
+ }
+
+ ///CLOVER:OFF
+ /** prevent instantiation */
+ private SymTabASTFactory()
+ {
+ }
+ ///CLOVER:ON
+}
diff --git a/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/SymTabASTIterator.java b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/SymTabASTIterator.java
new file mode 100755
index 000000000..199dc5fd5
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/SymTabASTIterator.java
@@ -0,0 +1,95 @@
+
+// Transmogrify License
+//
+// Copyright (c) 2001, ThoughtWorks, Inc.
+// All rights reserved.
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// - Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+// - Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// Neither the name of the ThoughtWorks, Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from this
+// software without specific prior written permission.
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+package com.puppycrawl.tools.checkstyle.checks.usage.transmogrify;
+
+import java.util.Iterator;
+import java.util.NoSuchElementException;
+
+/**
+ * An iterator for the children of a tree node.
+ *
+ * @version 1.0
+ * @since 1.0
+ * @see Iterator
+ */
+public class SymTabASTIterator implements Iterator {
+ private SymTabAST _current;
+
+ /**
+ * Creates a new <tt>SymTabASTIterator</tt>.
+ *
+ * @param parent the node whose children will be iterated over.
+ */
+ public SymTabASTIterator(SymTabAST parent) {
+ _current = (SymTabAST)parent.getFirstChild();
+ }
+
+ /**
+ * Whether the node has another child. (In other words, returns
+ * <tt>true</tt> if <tt>next</tt> would return an element rather than
+ * throwing an exception.)
+ *
+ * @return the next child node.
+ */
+ public boolean hasNext() {
+ return (_current != null);
+ }
+
+ /**
+ * The next child node.
+ *
+ * @return the next child node.
+ */
+ public Object next() {
+ if (!hasNext()) {
+ throw new NoSuchElementException();
+ }
+
+ Object result = _current;
+ _current = (SymTabAST)_current.getNextSibling();
+
+ return result;
+ }
+
+ /**
+ * The next child node.
+ *
+ * @return the next child node.
+ */
+ public SymTabAST nextChild() {
+ return (SymTabAST)next();
+ }
+
+ /**
+ * Unsupported operation
+ */
+ public void remove() {
+ throw new UnsupportedOperationException();
+ }
+}
diff --git a/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/SymbolTable.java b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/SymbolTable.java
new file mode 100755
index 000000000..d37ca0190
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/SymbolTable.java
@@ -0,0 +1,274 @@
+
+// Transmogrify License
+//
+// Copyright (c) 2001, ThoughtWorks, Inc.
+// All rights reserved.
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// - Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+// - Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// Neither the name of the ThoughtWorks, Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from this
+// software without specific prior written permission.
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+package com.puppycrawl.tools.checkstyle.checks.usage.transmogrify;
+
+import java.io.File;
+import java.util.Hashtable;
+import java.util.Stack;
+
+
+
+
+/**
+ * this class contains all of the definitions, references, and scopes
+ * created by the system.
+ *
+ * Other stuff this class does:
+ * <ul>
+ * <li> holds the "base" scope containing primitive definitions
+ * <li> holds the java.lang package
+ * <li> holds the definition of java.lang.Object, which is the base class
+ * of all class hierarchies
+ * <li> kicks off the resolve step
+ * <li> does some of the work of constructing object definitions
+ * </ul>
+ */
+
+public class SymbolTable {
+
+ private Hashtable packages = new Hashtable();
+ private Stack scopes = new Stack();
+ private ScopeIndex index = new ScopeIndex();
+
+ private File currentFile;
+ private BaseScope baseScope;
+
+ private SymTabAST root;
+
+// private boolean outOfDate;
+
+ /**
+ * constructor takes <code>SymTabAST</code>
+ * @param aRoot root of the <code>SymTabAST</code> tree
+ */
+ public SymbolTable(SymTabAST aRoot) {
+ scopes = new Stack();
+ this.root = aRoot;
+
+ baseScope = new BaseScope( this );
+ pushScope(baseScope);
+ }
+
+ /**
+ * gets the root node
+ * @return <code>SymTabAST</code>
+ */
+ public SymTabAST getTree() {
+ return root;
+ }
+
+// /**
+// * sets the <code>outOfDate</code> data member to <code>true</code>
+// * @return <code>void</code>
+// */
+// public void expire() {
+// outOfDate = true;
+// }
+//
+// /**
+// * sets <code>outOfDate</code> member to <code>false</code>
+// * @param lastUpdated
+// * @return <code>void</code>
+// */
+// public void update(long lastUpdated) {
+// outOfDate = false;
+// }
+
+ /**
+ * returns the "base" scope
+ *
+ * @return Scope the base scope
+ */
+ // REDTAG -- this should eventually be replaced by a call
+ // to the lookup method that traverses scopes
+ public BaseScope getBaseScope() {
+ return baseScope;
+ }
+
+ /**
+ * returns the current scope. Scopes are nested in a stack (FIFO queue)
+ * and pushed/popped based on the structure of the AST
+ * @return <code>Scope</code>
+ */
+ public Scope getCurrentScope() {
+ return (Scope)scopes.peek();
+ }
+
+ /**
+ * pushes a new scope onto the stack
+ *
+ * @param scope the <code>Scope</code> to push
+ * @return <code>void</code>
+ */
+ public void pushScope(Scope scope) {
+ scopes.push(scope);
+ }
+
+ /**
+ * pops a scope from the stack.
+ *
+ * @return <code>Scope</code>
+ *
+ */
+ public Scope popScope() {
+ Scope scope = (Scope)(scopes.pop());
+ return scope;
+ }
+
+ /**
+ * gets all packages stored in this symbol table
+ * @return <code>Hashtable</code>
+ */
+ public Hashtable getPackages() {
+ // REDTAG -- think about making this available as something simpler,
+ // perhaps an enumeration
+ return packages;
+ }
+
+ /**
+ * gets package by its name
+ * @param name
+ * @return <code>PackageDef</code>
+ */
+ public PackageDef getPackage( String name ) {
+ return (PackageDef)(packages.get( name ));
+ }
+
+ /**
+ * adds <code>PackageDef</code> to its parent scope and stores the
+ * <code>PackageDef</code> in <code>packages</code>
+ * @param pkg
+ * @param parent
+ * @return <code>void</code>
+ */
+ public void definePackage( PackageDef pkg, Scope parent ) {
+ parent.addDefinition(pkg);
+ packages.put(pkg.getQualifiedName(), pkg);
+ }
+
+ /**
+ * defines a class in the symbol table.
+ *
+ * @param def the class to define
+ * @return <code>void</code>
+ * @see #indexScope(Scope)
+ * @see #getCurrentScope()
+ */
+ public void defineClass(ClassDef def) {
+ indexScope(def);
+ getCurrentScope().addDefinition(def);
+ }
+
+ /**
+ * defines a method in the symbol table
+ *
+ * @param method the method to be defined
+ * @return <code>void</code>
+ * @see #indexScope(Scope)
+ * @see #getCurrentScope()
+ */
+ public void defineMethod(MethodDef method) {
+ indexScope(method);
+ ((ClassDef)getCurrentScope()).addDefinition(method);
+ }
+
+ /**
+ * defines a variable in the symbol table
+ *
+ * @param v the variable to define
+ * @return <code>void</code>
+ * @see #getCurrentScope()
+ */
+ public void defineVariable(VariableDef v) {
+ getCurrentScope().addDefinition(v);
+ }
+
+ /**
+ * defines a block within the symbol table
+ *
+ * @param blockDef the block to define
+ * @return <code>void</code>
+ * @see #indexScope(Scope)
+ * @see #getCurrentScope()
+ */
+ public void defineBlock(BlockDef blockDef) {
+ indexScope(blockDef);
+ getCurrentScope().addDefinition(blockDef);
+ }
+
+ /**
+ * defines a label within the symbol table
+ *
+ * @param labelDef the label to define
+ * @return <code>void</code>
+ * @see #getCurrentScope()
+ */
+ // REDTAG -- label does not define a new scope
+ public void defineLabel(LabelDef labelDef) {
+ getCurrentScope().addDefinition(labelDef);
+ }
+
+ /**
+ * places a scope in the symbol table's index
+ *
+ * @param scope the scope to index
+ * @return <code>void</code>
+ */
+ public void indexScope(Scope scope) {
+ index.addScope(scope);
+ }
+
+ /**
+ * gets the symbol table's scope index
+ *
+ * @return ScopeIndex
+ */
+ public ScopeIndex getScopeIndex() {
+ return index;
+ }
+
+ /**
+ * sets the current file that the symbol table is processing
+ *
+ * @param file the <code>File</code> to use
+ * @return <code>void</code>
+ */
+ public void setCurrentFile(File file) {
+ currentFile = file;
+ }
+
+ /**
+ * gets the file that the symbol table is currently processing
+ *
+ * @return <code>File</code>
+ */
+ public File getCurrentFile() {
+ return currentFile;
+ }
+}
diff --git a/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/SymbolTableException.java b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/SymbolTableException.java
new file mode 100755
index 000000000..fbe1522dc
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/SymbolTableException.java
@@ -0,0 +1,35 @@
+
+// Transmogrify License
+//
+// Copyright (c) 2001, ThoughtWorks, Inc.
+// All rights reserved.
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// - Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+// - Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// Neither the name of the ThoughtWorks, Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from this
+// software without specific prior written permission.
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+package com.puppycrawl.tools.checkstyle.checks.usage.transmogrify;
+
+public class SymbolTableException extends Exception {
+ public SymbolTableException(String message) {
+ super(message);
+ }
+} \ No newline at end of file
diff --git a/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/TableMaker.java b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/TableMaker.java
new file mode 100755
index 000000000..5b079e262
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/TableMaker.java
@@ -0,0 +1,1460 @@
+
+// Transmogrify License
+//
+// Copyright (c) 2001, ThoughtWorks, Inc.
+// All rights reserved.
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// - Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+// - Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// Neither the name of the ThoughtWorks, Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from this
+// software without specific prior written permission.
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+package com.puppycrawl.tools.checkstyle.checks.usage.transmogrify;
+
+import java.io.File;
+import java.util.Enumeration;
+import java.util.Vector;
+
+import com.puppycrawl.tools.checkstyle.api.TokenTypes;
+
+
+
+
+/**
+ * this is the class that does the work of the "walking" step --
+ * going through the SymTabAST and constructing the definitions and
+ * references. The SymTabAST is constructed in a DOMish fashion, i.e.
+ * each node knows about its first child and its next sibling. The
+ * DFS search is carried out by two functions -- walkTree, which
+ * deals with a single SymTabAST node, and walkSibilngs, which deals with
+ * all the siblings of an SymTabAST node.
+ */
+
+public class TableMaker {
+ private SymbolTable symbolTable;
+ private SymTabAST _tree;
+ private File currentFile;
+ private Vector imports = new Vector();
+
+ /**
+ * Constructor for the TableMaker class
+ *
+ * @param tree is the<code>SymTabAST</code> from which to
+ * build the <code>TableMaker</code>. It is the tree which wil be walked
+ * in order to build definitions and references.
+ */
+ public TableMaker(SymTabAST tree)
+ {
+ _tree = tree;
+ }
+
+ /**
+ * returns the <code> SymTabAST </code> which is the
+ * SymTabAST generated from the parsed Java Source files.
+ *
+ * @return <code>SymTabAST</code>
+ */
+ public SymTabAST getTree() {
+ return _tree;
+ }
+
+ /**
+ * returns the <code>SymbolTable</code> that has been constructed by
+ * this <code>TableMaker</code>
+ *
+ * @return <code>SymbolTable</code>
+ * @throws <code>SymbolTableException</code>
+ */
+ public SymbolTable getTable() throws SymbolTableException {
+ if (symbolTable == null) {
+ symbolTable = new SymbolTable( _tree );
+
+ createDefinitions();
+
+ resolveReferences();
+ }
+
+ return symbolTable;
+ }
+
+ /**
+ * walks the tree and finishes creating definitions.
+ *
+ * @return <code>void</code>
+ * @throws <code>SymbolTableException</code>
+ * @see #walkTree()
+ * @see #finishCreatingDefinitions()
+ */
+ private void createDefinitions() throws SymbolTableException {
+ walkTree();
+ finishCreatingDefinitions();
+ }
+
+ /**
+ * finishes up creating definitions process
+ * starts at the base of the Table
+ *
+ * @return <code>void</code>
+ * @throws <code>SymbolTableException</code>
+ * @see net.sourceforge.transmogrify.symtab.SymbolTable
+ * @see #finishCreatingDefinition(Definition)
+ */
+ private void finishCreatingDefinitions() throws SymbolTableException {
+ finishCreatingDefinition(symbolTable.getBaseScope());
+ }
+
+ /**
+ * begins at the base of the Table and starts finishing definition creation.
+ *
+ * @param def <code>Definition</code> needs to be completed
+ * @return <code>void</code>
+ * @throws <code>SymbolTableException</code>
+ * @see ClassFinisher
+ * @see VariableFinisher
+ * @see MethodFinisher
+ * @see CatchFinisher
+ */
+ private void finishCreatingDefinition(Definition def) throws SymbolTableException {
+
+ if (def instanceof AnonymousInnerClass) {
+ AnonymousInnerClass innerClass = (AnonymousInnerClass)def;
+ innerClass.finishMakingDefinition();
+ }
+ else if (def instanceof ClassDef) {
+ new ClassFinisher(def).finish();
+ }
+ else if ( def instanceof VariableDef ) {
+ new VariableFinisher( def ).finish();
+ }
+ else if (def instanceof DefaultConstructor) {}
+ else if ( def instanceof MethodDef ) {
+ new MethodFinisher( def ).finish();
+ }
+ else if (def instanceof BlockDef) {
+ SymTabAST firstChild = (SymTabAST)def.getTreeNode().getFirstChild();
+ //handle Checkstyle grammar
+ if (firstChild.getType() == TokenTypes.LPAREN) {
+ firstChild = (SymTabAST) firstChild.getNextSibling();
+ }
+ if (firstChild.getType() == TokenTypes.PARAMETER_DEF) {
+ // this is a catch block
+ new CatchFinisher((BlockDef)def).finish();
+ }
+ }
+
+ if ( def instanceof Scope ) {
+ finishCreatingChildren((Scope)def);
+ }
+ }
+
+
+ /**
+ * iterates through all the definitions in the <code> Scope </code>
+ * finishes creating each <code>Scope</code>.
+ *
+ * @param scope <code> Scope </code> where defininitions will be finished.
+ * @return <code>void</code>
+ * @throws <code>SymbolTableException</code>
+ * @see net.sourceforge.transmogrify.symtab.Scope
+ * @see #finishCreatingDefinition(Definition)
+ */
+ private void finishCreatingChildren( Scope scope ) throws SymbolTableException {
+ Enumeration definitions = scope.getDefinitions();
+ while ( definitions.hasMoreElements() ) {
+ Definition child = (Definition)(definitions.nextElement());
+ finishCreatingDefinition(child);
+ }
+ }
+
+ /**
+ * resolves <code>SymbolTable</code> using <code>Resolver</code>
+ *
+ * @return <code>void</code>
+ * @see net.sourceforge.transmogrify.symtab.Resolver
+ * @see net.sourceforge.transmogrify.symtab.SymbolTable
+ */
+ private void resolveReferences() {
+ new Resolver( symbolTable ).resolve();
+ }
+
+ /**
+ * starts walking the <code> SymTabAST </code>
+ *
+ * @return <code>void</code>
+ * @see #walkSiblings(SymTabAST,boolean)
+ * @see net.sourceforge.transmogrify.symtab.antlr.SymTabAST
+ */
+ public void walkTree() {
+ walkSiblings((SymTabAST)_tree.getFirstChild(), false);
+ }
+
+ /**
+ * processes a single SymTabAST node based on its type and passes of its
+ * children for further processing where appropriate.
+ *
+ * @param tree the <code>SymTabAST</code> node to process
+ * @param makeAnonymousScopes sets to <code>false</code> after walking Class,
+ * Methods and Try otherwise sets to <code>true</code>
+ * @return <code>void</code>
+ * @see #walkSiblings(SymTabAST, boolean)
+ * @see #processAnonymousInnerClass(SymTabAST, SymTabAST)
+ * @see #processBlock(SymTabAST, boolean)
+ * @see #processClass(SymTabAST)
+ * @see #processConstructorDef(SymTabAST)
+ * @see #processElse(SymTabAST)
+ * @see #processFile(SymTabAST)
+ * @see #processFinally(SymTabAST)
+ * @see #processFor(SymTabAST)
+ * @see #processImplicitPackage(SymTabAST)
+ * @see #processImport(SymTabAST)
+ * @see #processLabel(SymTabAST)
+ * @see #processMethodDef(SymTabAST)
+ * @see #processPackage(SymTabAST)
+ * @see #processTry(SymTabAST)
+ * @see net.sourceforge.transmogrify.symtab.antlr.SymTabAST
+ * @see net.sourceforge.transmogrify.symtab.antlr.JavaTokenTypes
+ */
+ public void walkTree(SymTabAST tree, boolean makeAnonymousScopes) {
+
+ if (tree != null) {
+
+ tree.setScope( symbolTable.getCurrentScope() );
+
+ switch(tree.getType()) {
+ case 0:
+ processFile(tree);
+ if ( tree.getFirstChild().getType() != TokenTypes.PACKAGE_DEF ) {
+ processImplicitPackage( tree.getFile() );
+ }
+
+ walkSiblings((SymTabAST)tree.getFirstChild(), false);
+
+ // pop package scope
+ symbolTable.popScope();
+ clearImports();
+ break;
+
+ case TokenTypes.LITERAL_NEW:
+ SymTabAST symtabTree = tree;
+ //walk parameters, in case of anonymous inner class
+ walkTree(symtabTree.findFirstToken(TokenTypes.ELIST),
+ makeAnonymousScopes);
+ SymTabAST objblock
+ = symtabTree.findFirstToken(TokenTypes.OBJBLOCK);
+ if (objblock != null) {
+ SymTabAST classExtended
+ = symtabTree.findFirstToken(TokenTypes.IDENT);
+
+ processAnonymousInnerClass(objblock, classExtended);
+ }
+ break;
+
+ case TokenTypes.SLIST:
+ if (makeAnonymousScopes) {
+ processBlock(tree, true);
+ }
+ else {
+ walkSiblings((SymTabAST)tree.getFirstChild(), true);
+ }
+ break;
+
+ case TokenTypes.CTOR_DEF:
+ processConstructorDef(tree);
+ break;
+
+ case TokenTypes.METHOD_DEF:
+ processMethodDef(tree);
+ break;
+
+ case TokenTypes.LITERAL_FINALLY:
+ processFinally(tree);
+ break;
+
+ case TokenTypes.LITERAL_TRY:
+ processTry(tree);
+ break;
+
+ case TokenTypes.VARIABLE_DEF:
+ processVariableDef(tree);
+ break;
+
+ case TokenTypes.PACKAGE_DEF:
+ processPackage(tree);
+ break;
+
+ case TokenTypes.LABELED_STAT:
+ processLabel(tree);
+ break;
+
+ case TokenTypes.IMPORT:
+ processImport(tree);
+ break;
+
+ case TokenTypes.CLASS_DEF:
+ case TokenTypes.INTERFACE_DEF:
+ processClass(tree);
+ break;
+
+ case TokenTypes.LITERAL_FOR:
+ processFor(tree);
+ break;
+
+ case TokenTypes.LITERAL_IF:
+ processIf(tree);
+ break;
+
+ case TokenTypes.LITERAL_ASSERT:
+ processAssert(tree);
+ break;
+
+ case TokenTypes.LITERAL_CATCH:
+ case TokenTypes.LITERAL_WHILE:
+ case TokenTypes.LITERAL_SWITCH:
+ case TokenTypes.LITERAL_DO:
+ case TokenTypes.LITERAL_SYNCHRONIZED:
+ case TokenTypes.STATIC_INIT:
+ case TokenTypes.INSTANCE_INIT:
+ processBlock(tree, false);
+ break;
+
+ default:
+ walkSiblings((SymTabAST)tree.getFirstChild(), false);
+ }
+ }
+ }
+
+ /**
+ * @param tree
+ */
+public void processAssert(SymTabAST tree) {
+ BlockDef block = makeBlock(tree);
+
+ SymTabAST expr = tree.findFirstToken(TokenTypes.EXPR);
+ SymTabAST message = (SymTabAST)expr.getNextSibling();
+ while ((message != null) && (message.getType() != TokenTypes.EXPR)) {
+ message = (SymTabAST) message.getNextSibling();
+ }
+
+
+ symbolTable.pushScope( block );
+ walkTree(expr, false);
+ if (message != null) {
+ walkTree(message, false);
+ }
+ symbolTable.popScope();
+}
+
+/**
+ * processes the given <code>SymTabAST</code> and each of its siblings
+ *
+ * @param tree <code>SymTabAST</code> node to process
+ * @param makeAnonymousScopes
+ *
+ * @return <code>void</code>
+ * @see #walkTree(SymTabAST, boolean)
+ * @see net.sourceforge.transmogrify.symtab.antlr.SymTabAST
+ */
+ public void walkSiblings(SymTabAST tree, boolean makeAnonymousScopes) {
+ while(tree != null) {
+ walkTree(tree, makeAnonymousScopes);
+ tree = (SymTabAST)tree.getNextSibling();
+ }
+ }
+
+ /**
+ * processes the given <code>SymTabAST</code> as a package defintion
+ *
+ * @param tree the <code>SymTabAST</code> to process
+ * @return <code>void</code>
+ * @see net.sourceforge.transmogrify.symtab.antlr.SymTabAST
+ * @see net.sourceforge.transmogrify.symtab.PackageDef
+ * @see net.sourceforge.transmogrify.symtab.SymbolTable
+ */
+ public void processPackage(SymTabAST tree) {
+ SymTabAST firstChild = (SymTabAST)tree.getFirstChild();
+
+ String name = ASTUtil.constructDottedName(firstChild);
+ firstChild.ignoreChildren();
+
+ PackageDef pkg = symbolTable.getPackage(name);
+
+ if (pkg == null) {
+ pkg = createPackage( (SymTabAST)(tree.getFirstChild()) );
+ }
+
+ symbolTable.pushScope(pkg);
+ }
+
+ /**
+ * processes a java class that use default no package
+ *
+ * @param file <code>File</code> object of the java class
+ * @return <code>void</code>
+ * @see net.sourceforge.transmogrify.symtab.PackageDef
+ * @see net.sourceforge.transmogrify.symtab.SymbolTable
+ */
+ public void processImplicitPackage( File file ) {
+ String name = file.getParent();
+ if (name == null) {
+ name = "";
+ }
+ PackageDef pkg = symbolTable.getPackage( name );
+
+ if ( pkg == null ) {
+ pkg = new PackageDef( name, symbolTable.getBaseScope(), null );
+ symbolTable.definePackage( pkg, symbolTable.getBaseScope() );
+ }
+
+ symbolTable.pushScope( pkg );
+ }
+
+ /**
+ * gets the package represented by the tree. The method
+ * analyzes the tree, constructs an appropriate package name
+ * and fetches it from the internal package list. If the package does not
+ * exist it is created.
+ *
+ * @param tree <code>SymTabAST</code> to consider
+ *
+ * @return <code>PackageDef</code> the resulting package definition
+ * @see #getPackage(Scope, SymTabAST)
+ */
+ private PackageDef createPackage( SymTabAST tree ) {
+ PackageDef result = null;
+
+ if (tree.getType() == TokenTypes.DOT) {
+ // find the package result of left child
+ SymTabAST leftChild = (SymTabAST)tree.getFirstChild();
+ SymTabAST rightChild = (SymTabAST)leftChild.getNextSibling();
+
+ PackageDef context = createPackage(leftChild);
+ result = getPackage( context, rightChild );
+ }
+ else {
+ result = getPackage(symbolTable.getBaseScope(), tree);
+ }
+
+ return result;
+ }
+
+ /**
+ * gets the package determined by the tree and parent package def.
+ * The method analyzes the tree and parent scope and retrieves the
+ * appropriate package definition from the internal package list.
+ * If the package does not exist it is created.
+ *
+ * @param tree <code>SymTabAST</code> to consider
+ * @param parent the parent package definition
+ *
+ * @return PackageDef the resulting package definition
+ * @see net.sourceforge.transmogrify.symtab.PackageDef
+ * @see net.sourceforge.transmogrify.symtab.SymbolTable
+ * @see net.sourceforge.transmogrify.symtab.antlr.SymTabAST
+ */
+ private PackageDef getPackage(Scope parent, SymTabAST tree ) {
+ String name = tree.getText();
+ PackageDef result = null;
+ if (!(parent instanceof BaseScope)) {
+ result = symbolTable.getPackage(parent.getQualifiedName() + "." + name);
+ }
+ else {
+ result = symbolTable.getPackage(name);
+ }
+
+ if (result == null) {
+ result = new PackageDef(tree.getText(), parent, tree);
+ symbolTable.definePackage(result, parent);
+ }
+
+ return result;
+ }
+
+ /**
+ * process the given <code>SymTabAST</code> as a file definition
+ *
+ * @param tree the <code>SymTabAST</code> to process
+ * @return <code>void</code>
+ * @see #setCurrentFile(String)
+ */
+ public void processFile(SymTabAST tree) {
+ setCurrentFile(tree.getText());
+ }
+
+ /**
+ * adds the given <code>SymTabAST</code> to <code>imports</code> member
+ *
+ * @param tree the <code>SymTabAST</code> to process
+ * @return <code>void</code>
+ */
+ public void processImport(SymTabAST tree) {
+ imports.add( tree );
+ }
+
+ /**
+ * clears the <code>imports</code> member
+ * @return <code>void</code>
+ */
+ private void clearImports() {
+ imports.clear();
+ }
+
+ /**
+ * process the given SymTabAST as a label definition
+ *
+ * @param tree the SymTabAST to process
+ * @return <code>void</code>
+ * @see com.trwx.symtab.antlr.SymTabAST
+ * @see net.sourceforge.transmogrify.symtab.LabelDef
+ * @see #walkTree(SymTabAST, boolean)
+ */
+ public void processLabel(SymTabAST tree) {
+ String name = tree.findFirstToken(TokenTypes.IDENT).getText();
+ LabelDef label = new LabelDef( name, symbolTable.getCurrentScope(),
+ tree );
+ symbolTable.defineLabel( label );
+
+ walkTree((SymTabAST)tree.getFirstChild().getNextSibling(), false);
+ }
+
+ /**
+ * process the given <code>SymTabAST</code> as a class definition
+ *
+ * @param tree the <code>SymTabAST</code> to process
+ * @return <code>void</code>
+ * @see #makeClass(String, SymTabAST)
+ * @see #walkSiblings(SymTabAST, boolean)
+ * @see net.sourceforge.transmogrify.symtab.antlr.SymTabAST
+ */
+ public void processClass(SymTabAST tree) {
+ String name = tree.findFirstToken(TokenTypes.IDENT).getText();
+
+ makeClass(name, tree);
+ final SymTabAST objblock =
+ tree.findFirstToken(TokenTypes.OBJBLOCK);
+ SymTabAST start = (SymTabAST)objblock.getFirstChild();
+ if (start != null) {
+ //skip LPAREN
+ if (start.getType() == TokenTypes.LPAREN) {
+ start = (SymTabAST)start.getNextSibling();
+ }
+ walkSiblings(start, false);
+ }
+
+ symbolTable.popScope();
+ }
+
+ /**
+ * creates <code>ClassDef</code> for the current class node and add it to the
+ * symbol table
+ * @param name name of the class
+ * @param tree current node to be processed
+ * @return <code>void</code>
+ * @see net.sourceforge.transmogrify.symtab.ClassDef
+ * @see net.sourceforge.transmogrify.symtab.SymbolTable
+ */
+ public void makeClass(String name, SymTabAST tree) {
+ ClassDef def = new ClassDef(name, symbolTable.getCurrentScope(), tree);
+ def.addUnprocessedImports(imports);
+ symbolTable.defineClass(def);
+ symbolTable.pushScope(def);
+ }
+
+ /**
+ * processes anonymous inner class encountered in the tree
+ * @param objblock the anonymous block
+ * @param classExtended
+ * @return <code>void</code>
+ * @see net.sourceforge.transmogrify.symtab.AnonymousInnerClass
+ * @see net.sourceforge.transmogrify.symtab.SymbolTable
+ */
+ public void processAnonymousInnerClass(SymTabAST objblock,
+ SymTabAST classExtended) {
+ ClassDef def = new AnonymousInnerClass(objblock,
+ classExtended,
+ symbolTable.getCurrentScope());
+ symbolTable.defineClass(def);
+ symbolTable.pushScope(def);
+ walkSiblings((SymTabAST)objblock.getFirstChild(), false);
+ symbolTable.popScope();
+ }
+
+ /**
+ * process the given SymTabAST as a variable definition
+ *
+ * @param tree the SymTabAST to process
+ * @return <code>void</code>
+ * @see net.sourceforge.transmogrify.symtab.VariableDef
+ * @see net.sourceforge.transmogrify.symtab.SymbolTable
+ * @see net.sourceforge.transmogrify.symtab.antlr.SymTabAST
+ * @see #makeVariableDef(SymTabAST, Scope)
+ * @see #walkTree(SymTabAST, boolean)
+ */
+ private void processVariableDef(SymTabAST tree) {
+ VariableDef def = makeVariableDef( tree, symbolTable.getCurrentScope() );
+ symbolTable.defineVariable(def);
+ SymTabAST assignmentNode
+ = tree.findFirstToken(TokenTypes.ASSIGN);
+ if (assignmentNode != null) {
+ walkTree((SymTabAST)assignmentNode.getFirstChild(), false);
+ }
+ }
+
+ /**
+ * creates <code>VariableDef</code> based on the current tree node and scope
+ * @param tree the current tree node
+ * @param scope the current scope
+ * @return <code>VariableDef</code>
+ * @see net.sourceforge.transmogrify.symtab.VariableDef
+ */
+ public VariableDef makeVariableDef(SymTabAST tree, Scope scope) {
+ String name = tree.findFirstToken(TokenTypes.IDENT).getText();
+ VariableDef result = new VariableDef(name, scope, tree);
+
+ return result;
+ }
+
+ /**
+ * process the given SymTabAST as a try block
+ *
+ * @param tree the SymTabAST to process
+ * @return <code>void</code>
+ * @see #makeBlock(SymTabAST)
+ * @see net.sourceforge.transmogrify.symtab.antlr.SymTabAST
+ * @see #walkTree(SymTabAST, boolean)
+ * @see #walkSiblings(SymTabAST, boolean)
+ */
+ public void processTry(SymTabAST tree){
+ BlockDef block = makeBlock(tree);
+
+ SymTabAST slist = tree.findFirstToken(TokenTypes.SLIST);
+ SymTabAST everythingElse = (SymTabAST)slist.getNextSibling();
+
+ symbolTable.pushScope( block );
+ walkTree( slist, false );
+ symbolTable.popScope();
+
+ walkSiblings( everythingElse, false );
+ }
+
+ /**
+ * process the given SymTabAST as a finally block
+ *
+ * @param tree the SymTabAST to process
+ * @return <code>void</code>
+ * @see #makeBlock(SymTabAST)
+ * @see #walkTree(SymTabAST, boolean)
+ */
+ public void processFinally(SymTabAST tree){
+ BlockDef block = makeBlock(tree);
+
+ SymTabAST slist = tree.findFirstToken(TokenTypes.SLIST);
+ SymTabAST tryBlock = tree.findFirstToken(TokenTypes.LITERAL_TRY);
+
+ symbolTable.pushScope( block );
+ walkTree( slist, false );
+ symbolTable.popScope();
+
+ walkTree( tryBlock, false );
+ }
+
+
+ /**
+ * process the given SymTabAST as a method definition
+ *
+ * @param tree the SymTabAST to process
+ * @return <code>void</code>
+ * @see net.sourceforge.transmogrify.symtab.MethodDef
+ * @see net.sourceforge.transmogrify.symtab.SymbolTable
+ * @see #walkTree(SymTabAST, boolean)
+ */
+ public void processMethodDef(SymTabAST tree) {
+ String name = tree.findFirstToken(TokenTypes.IDENT).getText();
+ MethodDef method = new MethodDef(name, symbolTable.getCurrentScope(),
+ tree);
+ symbolTable.defineMethod( method );
+
+ symbolTable.pushScope( method );
+ walkTree(tree.findFirstToken(TokenTypes.SLIST), false);
+ symbolTable.popScope();
+ }
+
+ /**
+ * process the given SymTabAST as a constructor definition
+ *
+ * @param tree the SymTabAST to process
+ * @return <code>void</code>
+ * @see net.sourceforge.transmogrify.symtab.MethodDef
+ * @see net.sourceforge.transmogrify.symtab.SymbolTable
+ * @see #walkTree(SymTabAST, boolean)
+ */
+ public void processConstructorDef(SymTabAST tree) {
+ processMethodDef(tree);
+ }
+
+ /**
+ * process the given SymTabAST as a for block
+ *
+ * @param tree the SymTabAST to process
+ * @return <code>void</code>
+ * @see #makeBlock(SymTabAST)
+ * @see #walkTree(SymTabAST, boolean)
+ */
+ public void processFor(SymTabAST tree) {
+ BlockDef block = makeBlock(tree);
+
+ symbolTable.pushScope( block );
+ SymTabAST body;
+ SymTabAST forEach = tree.findFirstToken(TokenTypes.FOR_EACH_CLAUSE);
+ if (forEach != null) {
+ walkTree(forEach, false);
+ body = (SymTabAST)forEach.getNextSibling();
+ }
+ else {
+ walkTree(tree.findFirstToken(TokenTypes.FOR_INIT), false);
+ walkTree(tree.findFirstToken(TokenTypes.FOR_CONDITION), false);
+
+ SymTabAST forIter = tree.findFirstToken(TokenTypes.FOR_ITERATOR);
+ walkTree(forIter, false);
+ body = (SymTabAST)forIter.getNextSibling();
+ }
+
+ //handle Checkstyle grammar
+ if (body.getType() == TokenTypes.RPAREN) {
+ body = (SymTabAST) body.getNextSibling();
+ }
+ walkTree(body, false);
+ symbolTable.popScope();
+ }
+
+ /**
+ * process the given SymTabAST as an if block
+ *
+ * @param tree the SymTabAST to process
+ * @return <code>void</code>
+ * @see #makeBlock(SymTabAST)
+ * @see #walkTree(SymTabAST, boolean)
+ * @see #processElse(SymTabAST)
+ */
+ public void processIf(SymTabAST tree) {
+ BlockDef block = makeBlock(tree);
+
+ SymTabAST expr = tree.findFirstToken(TokenTypes.EXPR);
+ SymTabAST ifBranch = (SymTabAST)expr.getNextSibling();
+ // handle Checkstyle grammar
+ if (ifBranch.getType() == TokenTypes.RPAREN) {
+ ifBranch = (SymTabAST) ifBranch.getNextSibling();
+ }
+ SymTabAST elseBranch = (SymTabAST)ifBranch.getNextSibling();
+ // handle Checkstyle grammar
+ if ((elseBranch != null) && (elseBranch.getType() == TokenTypes.SEMI)) {
+ elseBranch = (SymTabAST) elseBranch.getNextSibling();
+ }
+ if ((elseBranch != null) && (elseBranch.getType() == TokenTypes.LITERAL_ELSE)) {
+ elseBranch = (SymTabAST) elseBranch.getFirstChild();
+ }
+
+ symbolTable.pushScope( block );
+ walkTree(expr, false);
+ walkTree(ifBranch, false);
+ symbolTable.popScope();
+
+ processElse(elseBranch);
+ }
+
+ /**
+ * process the given SymTabAST as an else block
+ *
+ * @param tree the SymTabAST to process
+ * @return <code>void</code>
+ * @see #processIf(SymTabAST)
+ * @see #makeElseBlock(SymTabAST)
+ */
+ public void processElse(SymTabAST tree) {
+ if (tree != null) {
+ if (tree.getType() == TokenTypes.LITERAL_IF) {
+ processIf(tree);
+ }
+ else {
+ makeElseBlock(tree);
+ }
+ }
+ }
+
+ /**
+ * defines an anonymous block to enclose the scope of an else block
+ *
+ * @param tree the SymTabAST to process
+ * @return <code>void</code>
+ * @see #makeBlock(SymTabAST)
+ * @see #walkTree(SymTabAST, boolean)
+ */
+ public void makeElseBlock(SymTabAST tree) {
+ if (tree.getType() == TokenTypes.SLIST) {
+ BlockDef block = makeBlock(tree);
+ symbolTable.pushScope( block );
+ walkTree(tree, false);
+ symbolTable.popScope();
+ }
+ else {
+ walkTree(tree, false);
+ }
+ }
+
+ /**
+ * processes the current tree node as BlockDef
+ * @param tree current tree node
+ * @param makeAnonymousScopes
+ * @return <code>void</code>
+ */
+ public void processBlock(SymTabAST tree, boolean makeAnonymousScopes) {
+ BlockDef block = makeBlock(tree);
+ symbolTable.pushScope(block);
+ //handle Checkstyle grammar
+ SymTabAST child = (SymTabAST)tree.getFirstChild();
+ if ((child != null) && (child.getType() == TokenTypes.LPAREN)) {
+ child = (SymTabAST) child.getNextSibling();
+ }
+ walkSiblings(child, makeAnonymousScopes);
+ symbolTable.popScope();
+ }
+
+ /**
+ * set the current file to the named file
+ *
+ * @param fileName the name of the file
+ * @return <code>void</code>
+ */
+ public void setCurrentFile(String fileName) {
+ currentFile = new File(fileName);
+ symbolTable.setCurrentFile(currentFile);
+ }
+
+
+ /**
+ * creates a new <code> BlockDef </code> in the SymbolTable
+ *
+ * @param tree is a <code> SymTabAST </code> whose root begins the new block
+ * @return <code> BlockDef </code>
+ * @see net.sourceforge.transmogrify.symtab.BlockDef
+ * @see net.sourceforge.transmogrify.symtab.SymbolTable
+ */
+ private BlockDef makeBlock( SymTabAST tree ) {
+ BlockDef block = new BlockDef( symbolTable.getCurrentScope(), tree );
+ symbolTable.defineBlock( block );
+ return block;
+ }
+
+ /**
+ * returns the <code>SymTabAST</code> that contains the parameter classDef's
+ * extends nodes
+ *
+ * @param classDef is a <code> ClassDef </code> whose extends nodes we want
+ * @return <code> SymTabAST </code>
+ */
+ public static SymTabAST getExtendsNode(ClassDef classDef) {
+ SymTabAST result = null;
+ SymTabAST extendsClause = null;
+
+ SymTabAST classDefTreeNode = classDef.getTreeNode();
+ extendsClause =
+ classDefTreeNode.findFirstToken(TokenTypes.EXTENDS_CLAUSE);
+
+ if (extendsClause != null) {
+ result = (SymTabAST)(extendsClause.getFirstChild());
+ }
+
+ return result;
+ }
+
+ /**
+ * Superclass for different kind of XXXFinisher subclass
+ * @see CatchFinisher
+ * @see ClassFinisher
+ * @see DefinitionFinisher
+ * @see MethodFinisher
+ * @see VariableFinisher
+ */
+ class DefinitionFinisher {
+
+ protected SymTabAST _node = null;
+
+ /**
+ * Constructor. It finishes the definition passed to it
+ *
+ */
+ public DefinitionFinisher( Definition def ) {
+ _node = def.getTreeNode();
+ }
+
+ public void finish() throws SymbolTableException {}
+
+ /**
+ * gets the classDef that represents the type of the given definition
+ *
+ *
+ * @param def the definition whose type to find
+ * @param typeNode the TokenTypes.TYPE node associated with the def
+ *
+ * @return the resulting class definition
+ */
+ protected IClass getType( Definition def, SymTabAST typeNode ) {
+ IClass result = null;
+
+ SymTabAST typeClassNode = null;
+ boolean isArray = false;
+
+ if ( typeNode.getFirstChild().getType()
+ == TokenTypes.ARRAY_DECLARATOR ) {
+ isArray = true;
+ typeClassNode = (SymTabAST)typeNode.getFirstChild().getFirstChild();
+ }
+ else {
+ typeClassNode = (SymTabAST)typeNode.getFirstChild();
+ }
+
+ Scope lookupScope = null;
+
+ if (def instanceof Scope) {
+ lookupScope = (Scope)def;
+ }
+ else {
+ lookupScope = def.getParentScope();
+ }
+
+ Resolver resolver = new Resolver(symbolTable);
+ IClass typeClass = resolver.resolveClass(typeClassNode, lookupScope, null, false);
+
+ if ( isArray ) {
+ result = new ArrayDef( typeClass );
+ }
+ else {
+ result = typeClass;
+ }
+
+ return result;
+ }
+
+ }
+
+ class ClassFinisher extends DefinitionFinisher {
+
+ private ClassDef _def = null;
+
+ /**
+ * Constructor. Creates a ClassFinisher from a <code> Definition </code>
+ *
+ * @param def is a <code> Definition </code>
+ */
+ public ClassFinisher( Definition def ) {
+ super( def );
+ _def = (ClassDef)def;
+ }
+
+ /**
+ * Completes all tasks required for finishing a ClassDef
+ * Including adding imports, setting super classes and adding
+ * interfaces.
+ * @return <code>void</code>
+ * @throws <code>SymbolTableException</code>
+ * @see #addImports()
+ * @see #setSuperclass()
+ * @see #addInterfaces()
+ */
+ public void finish() throws SymbolTableException {
+ if ( _node != null ) {
+ addImports();
+ setSuperclass();
+ addInterfaces();
+ }
+ }
+
+ /**
+ * Adds all packages and classes that are imported by this class
+ * to the class for later reference
+ */
+ private void addImports() throws ClassImportException {
+ IPackage java = new ExternalPackage("java", null);
+ IPackage lang = new ExternalPackage("lang", java);
+ java.addDefinition(lang);
+ _def.importPackage(lang);
+
+ Vector unprocessedImports = _def.getUnprocessedImports();
+ for ( int i = 0; i < unprocessedImports.size(); i++ ) {
+ SymTabAST importNode = (SymTabAST)unprocessedImports.get(i);
+ SymTabAST imported = (SymTabAST)importNode.getFirstChild();
+ SymTabAST lastPart = (SymTabAST)imported.getFirstChild().getNextSibling();
+
+ DotIterator it = new DotIterator(imported);
+ SymTabAST current = null;
+ String className = null;
+ IClass importedClass = null;
+
+ // attempt at each token to find the class
+ // first in source
+ // then on classpath
+ //
+ // if there are more tokens left
+ // continue until you hit the last token
+ // if it's a star
+ // import all inner classes
+ // else
+ // import the explicitly named inner class
+ // else import the class
+ //
+ // if no classes were found, import the package
+
+ while(it.hasNext()) {
+ current = it.nextNode();
+ if (className == null) {
+ className = current.getText();
+ }
+ else {
+ if (!current.getText().equals("*")) {
+ className += "." + current.getText();
+ }
+ else {
+ break;
+ }
+ }
+ importedClass = findOrLoadClass(className, importedClass);
+
+ if (importedClass != null) {
+ break;
+ }
+ }
+
+ if (it.hasNext()) {
+ boolean isImported = false;
+ while(it.hasNext()) {
+ current = it.nextNode();
+ if (current.getText().equals("*")) {
+ importInnerClasses(importedClass);
+ isImported = true;
+ }
+ else {
+ className += "$" + current.getText();
+ importedClass = findOrLoadClass(className, importedClass);
+ }
+ }
+ if (!isImported) {
+ _def.importClass(importedClass);
+ }
+ }
+ else {
+ if (importedClass != null) {
+ _def.importClass(importedClass);
+ }
+ else {
+ if (current != null && current.getText().equals("*")) {
+ IPackage pkg = symbolTable.getPackage(className);
+ if (pkg == null) {
+ pkg = getPackage(className);
+ }
+ _def.importPackage(pkg);
+ }
+ else {
+ //TODO: can we safely ignore this?
+ //throw new ClassImportException(className);
+ ;
+ }
+ }
+ }
+
+ // now set definitions where appropriate
+ imported.ignoreChildren();
+ if ((lastPart.getType() == TokenTypes.IDENT)
+ //TODO: guard added for class not loaded
+ //This is OK for single file processing, but not
+ //multiple files.
+ && (importedClass != null)
+ )
+ {
+ lastPart.setDefinition(importedClass, null, true);
+ lastPart.setMeaningfulness(true);
+ }
+ }
+ }
+
+ /**
+ * creates <code>ExternalPackage</code>
+ * @param packageName name of the package
+ * @return <code>ExternalPackage</code>
+ * @see net.sourceforge.transmogrify.symtab.ExternalPackage
+ */
+ private ExternalPackage getPackage(String packageName) {
+ return new ExternalPackage(packageName, null);
+ }
+
+ /**
+ * stores the inner classes in the approriate ClassDef
+ * @param outerClass
+ * @return <code>void</code>
+ */
+ private void importInnerClasses(IClass outerClass) {
+ IClass[] innerClasses = outerClass.getInnerClasses();
+
+ for (int i = 0; i < innerClasses.length; i++) {
+ _def.importClass(innerClasses[i]);
+ }
+ }
+
+ /**
+ * creates <code>ExternalClass</code> based on a java class
+ * @param className class to be loaded
+ * @return <code>IClass</code>
+ * @see net.sourceforge.transmogrify.symtab.ExternalClass
+ */
+ private IClass loadClass(String className) {
+ IClass result = null;
+
+ try {
+ Class javaClass
+ = ClassManager.getClassLoader().loadClass(className);
+
+ result = new ExternalClass(javaClass);
+ }
+ catch (ClassNotFoundException ignoreMe) {}
+
+ return result;
+ }
+
+ /**
+ * find a class from <code>BaseCode</code> or its parent
+ * @param className name of the class to be load or found
+ * @param parentClass its parent class
+ * @return <code>IClass</code>
+ * @see net.sourceforge.transmogrify.symtab.SymbolTable
+ * @see net.sourceforge.transmogrify.symtab.IClass
+ * @see #loadClass(String)
+ */
+ private IClass findOrLoadClass(String className, IClass parentClass) {
+ IClass result = null;
+
+ if (parentClass == null) {
+ result = symbolTable.getBaseScope().getClassDefinition(className);
+ }
+ else {
+ int index = className.lastIndexOf("$");
+ if (index < 0) {
+ index = className.lastIndexOf(".");
+ }
+
+ result = parentClass.getClassDefinition(className.substring(index + 1));
+ }
+
+ if (result == null) {
+ result = loadClass(className);
+ }
+
+ return result;
+ }
+
+ /**
+ *
+ * If the class has a super class a reference to this super class
+ * is added to this class.
+ * @return <code>void</code>
+ * @see net.sourceforge.transmogrify.symtab.ClassDef
+ */
+ private void setSuperclass() {
+ if (_def.getTreeNode().getType() == TokenTypes.CLASS_DEF) {
+ SymTabAST extendsNode = getExtendsNode(_def);
+ if ( extendsNode != null ) {
+ String superclassName = ASTUtil.constructDottedName(extendsNode);
+ IClass superclass = _def.getClassDefinition(superclassName);
+ if ( superclass != null ) {
+ _def.setSuperclass( superclass );
+ superclass.addSubclass( _def );
+ }
+ }
+ else {
+ _def.setSuperclass(new ExternalClass(Object.class));
+ }
+ }
+ else {
+ _def.setSuperclass(new ExternalClass(Object.class));
+ }
+ }
+
+ /**
+ *
+ * If the class implements an interface a reference to this interface
+ * is added to this class.
+ * @return <code>void</code>
+ * @see net.sourceforge.transmogrify.symtab.ClassDef
+ */
+ private void addInterfaces() {
+ SymTabAST implementsClause = null;
+
+ if (_def.getTreeNode().getType() == TokenTypes.CLASS_DEF) {
+ implementsClause
+ = _node.findFirstToken(TokenTypes.IMPLEMENTS_CLAUSE);
+ }
+ else {
+ implementsClause
+ = _node.findFirstToken(TokenTypes.EXTENDS_CLAUSE);
+ }
+
+ if ( implementsClause != null ) {
+ SymTabAST interfaceNode = (SymTabAST)implementsClause.getFirstChild();
+ while ( interfaceNode != null ) {
+ IClass implemented =
+ _def.getClassDefinition(interfaceNode.getText());
+ if ( implemented != null ) {
+ _def.addInterface( implemented );
+ implemented.addImplementor( _def );
+ }
+ interfaceNode = (SymTabAST)(interfaceNode.getNextSibling());
+ }
+ }
+ }
+ }
+
+ /**
+ *
+ * Completes a Variable by setting all required references
+ *
+ */
+ class VariableFinisher extends DefinitionFinisher {
+ VariableDef _def = null;
+
+
+ /**
+ *
+ * Constructor. Creates a VariableFinishes from the <code>Definition</code>
+ * @param def VariableDef to be finished
+ * @see net.sourceforge.transmogrify.symtab.VariableDef
+ */
+ public VariableFinisher( Definition def ) {
+ super( def );
+ _def = (VariableDef)def;
+ }
+
+
+ /**
+ *
+ * Finishes the variable by setting the Type
+ * @return <code>void</code>
+ * @see #getType(Definition, SymTabAST)
+ * @see net.sourceforge.transmogrify.symtab.VariableDef
+ */
+ public void finish() {
+
+ SymTabAST typeNode = _node.findFirstToken(TokenTypes.TYPE);
+
+ SymTabAST typeTextNode = (SymTabAST)(typeNode.getFirstChild());
+ if ( typeTextNode.getType() == TokenTypes.ARRAY_DECLARATOR ) {
+ typeTextNode = (SymTabAST)(typeTextNode.getFirstChild());
+ }
+ typeTextNode.setLine(ASTUtil.getLine( _def.getTreeNode() ));
+
+ IClass varType = getType(_def, typeNode);
+ _def.setType( varType );
+
+ }
+ }
+
+ /**
+ *
+ * Completes a Variable by setting all required references
+ *
+ */
+ class MethodFinisher extends DefinitionFinisher {
+ MethodDef _def = null;
+
+
+ /**
+ *
+ * Creates a MethodFinisher from a <code> Definition <code>
+ * @param def MethodDef to be finished
+ * @see net.sourceforge.transmogrify.symtab.MethodDef
+ */
+ public MethodFinisher( Definition def ) {
+ super( def );
+ _def = (MethodDef)def;
+ }
+
+ /**
+ *
+ * Completes a method by setting all references to return types,
+ * signatures and exceptions.
+ * @return <code>void</code>
+ * @see #setReturnType()
+ * @see #setSignature()
+ * @see #setExceptionsThrown()
+ */
+ public void finish() {
+ setReturnType();
+ setSignature();
+ setExceptionsThrown();
+ }
+
+ /**
+ *
+ * setReturnType adds a reference to the methods return type
+ * to the method definition
+ * @return <code>void</code>
+ * @see net.sourceforge.transmogrify.symtab.MethodDef
+ * @see #getType(Definition, SymTabAST)
+ * @see #getTypeNode()
+ */
+ private void setReturnType() {
+ IClass type = null;
+
+ if ( isConstructor() ) {
+ type = _def.getEnclosingClass();
+ }
+ else {
+ type = getType(_def, getTypeNode());
+ }
+
+ _def.setType(type);
+ }
+
+ /**
+ *
+ * setSignature adds a reference to the methods paramaters
+ * to the method definition
+ * @return <code>void</code>
+ * @see #makeVariableDef(SymTabAST, Definition)
+ * @see VariableFinisher
+ * @see net.sourceforge.transmogrify.symtab.MethodDef
+ */
+ private void setSignature() {
+ SymTabAST parametersNode
+ = _node.findFirstToken(TokenTypes.PARAMETERS);
+
+ SymTabAST parameterNode = (SymTabAST)(parametersNode.getFirstChild());
+ while ( parameterNode != null ) {
+ if (parameterNode.getType() == TokenTypes.PARAMETER_DEF) {
+ VariableDef parameter = makeVariableDef( parameterNode, _def );
+ new VariableFinisher( parameter ).finish();
+ _def.addParameter( parameter );
+ }
+ parameterNode = (SymTabAST)(parameterNode.getNextSibling());
+ }
+
+ }
+
+ /**
+ *
+ * setExceptionsThrown adds a reference to the methods Exceptions
+ * to the method definition
+ * @return <code>void</code>
+ * @see net.sourceforge.transmogrify.symtab.SymbolTable
+ * @see net.sourceforge.transmogrify.symtab.PackageDef
+ * @see net.sourceforge.transmogrify.symtab.MethodDef
+ */
+ private void setExceptionsThrown() {
+ IClass exception = null;
+ SymTabAST throwsNode
+ = _node.findFirstToken(TokenTypes.LITERAL_THROWS);
+
+ if ( throwsNode != null ) {
+ SymTabAST exceptionNode = (SymTabAST)(throwsNode.getFirstChild());
+ while (exceptionNode != null ) {
+ if (exceptionNode.getType() == TokenTypes.DOT) {
+ PackageDef pkg = symbolTable.getPackage(ASTUtil.constructPackage(exceptionNode));
+ if ( pkg != null ) {
+ exception = pkg.getClassDefinition(ASTUtil.constructClass(exceptionNode));
+ }
+ }
+ else {
+ exception = _def.getClassDefinition(exceptionNode.getText());
+ }
+ _def.addException(exception);
+ exceptionNode = (SymTabAST)(exceptionNode.getNextSibling());
+ }
+ }
+
+ }
+
+ /**
+ *
+ * isConstructor sets the flag in the method definition to indicate
+ * whether it is a constructor or not
+ * @return <code>boolean</code> <code>true</code> if a node has no return type
+ * <code>false</code> if a node has a return type
+ * @see #getTypeNode()
+ */
+ private boolean isConstructor() {
+ boolean result = false;
+
+ if ( getTypeNode() == null ) {
+ result = true;
+ }
+
+ return result;
+ }
+
+ /**
+ *
+ * getTypeNode returnss the <code> SymTabAST</code> node that is the
+ * return type of this method
+ *
+ * @return <code>SymTabAST</code>
+ */
+ private SymTabAST getTypeNode() {
+ return _node.findFirstToken(TokenTypes.TYPE);
+ }
+ }
+
+ class CatchFinisher extends DefinitionFinisher {
+ BlockDef _def = null;
+
+ /**
+ * constructor that takes a <code>BlockDef</code>
+ * @param def <code>BlockDef</code> for the catch block
+ */
+ public CatchFinisher(BlockDef def) {
+ super(def);
+ _def = def;
+ }
+
+ /**
+ * finishes definition creation
+ * @return <code>void</code>
+ * @see #createExceptionVariable()
+ */
+ public void finish() {
+ createExceptionVariable();
+ }
+
+ /**
+ * creates <code>VariableDef<code> and finishes creation definition for
+ * arguments in the catch clause
+ * @return <code>void</code>
+ * @see net.sourceforge.transmogrify.symtab.VariableDef
+ * @see #makeVariableDef(SymTabAST, Definition)
+ * @see VariableFinisher
+ */
+ private void createExceptionVariable() {
+ SymTabAST exceptionNode
+ = _def.getTreeNode().findFirstToken(TokenTypes.PARAMETER_DEF);
+
+ VariableDef exception = makeVariableDef(exceptionNode, _def);
+ new VariableFinisher(exception).finish();
+ _def.addDefinition(exception);
+ }
+ }
+
+}
+
+
diff --git a/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/Typed.java b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/Typed.java
new file mode 100755
index 000000000..b053c0077
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/Typed.java
@@ -0,0 +1,45 @@
+
+// Transmogrify License
+//
+// Copyright (c) 2001, ThoughtWorks, Inc.
+// All rights reserved.
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// - Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+// - Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// Neither the name of the ThoughtWorks, Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from this
+// software without specific prior written permission.
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+package com.puppycrawl.tools.checkstyle.checks.usage.transmogrify;
+
+
+
+/**
+ * classes that implement this interface have a notion
+ * of "type" like int, String, GerblinkenLight, etc.
+ */
+
+public interface Typed extends IDefinition {
+
+ /**
+ * gets the type of this definition
+ */
+ public IClass getType();
+
+}
diff --git a/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/UnknownClass.java b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/UnknownClass.java
new file mode 100755
index 000000000..ea4ade99c
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/UnknownClass.java
@@ -0,0 +1,174 @@
+
+// Transmogrify License
+//
+// Copyright (c) 2001, ThoughtWorks, Inc.
+// All rights reserved.
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// - Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+// - Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// Neither the name of the ThoughtWorks, Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from this
+// software without specific prior written permission.
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+package com.puppycrawl.tools.checkstyle.checks.usage.transmogrify;
+
+
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.Vector;
+
+
+
+public class UnknownClass implements IClass {
+
+ String _name;
+ SymTabAST _node;
+
+ public UnknownClass(String name, SymTabAST node) {
+ _name = name;
+ _node = node;
+ //System.out.println("Creating unknown class [" + name + " : " + node + "]");
+ }
+
+ /**
+ * returns the <code>ClassDef</code> that for the superclass
+ *
+ * @return the <code>ClassDef</code> for the superclass
+ */
+ public IClass getSuperclass() {
+ return null;
+ }
+
+ public IClass[] getInterfaces() {
+ return new IClass[0];
+ }
+
+ /**
+ * returns a collection of the direct subclasses of this class
+ *
+ * @return a collection of the direct subclasses of this class
+ */
+ public List getSubclasses() {
+ return new Vector();
+ }
+
+ public IClass getClassDefinition(String name) {
+ return null;
+ }
+
+ /**
+ * gets the method associated with the given name and signature
+ *
+ * @param name the name of the method
+ * @param signature the signature (formal parameter types) of the method
+ *
+ * @return MethodDef
+ *
+ * @see MethodSignature
+ */
+ public IMethod getMethodDefinition(String name,
+ ISignature signature) {
+ return null;
+ }
+
+ /**
+ * gets the <code>VariableDef</code> associated with the given name
+ *
+ * @param name the name of the variable
+ *
+ * @return VariableDef
+ */
+ public IVariable getVariableDefinition(String name) {
+ return null;
+ }
+
+ // end definitions interface
+
+ /**
+ * adds <code>ClassDef</code> to the collection of (direct?) subclasses of
+ * this class
+ *
+ * @param subclass the class to add
+ */
+ public void addSubclass(ClassDef subclass) {}
+
+ /**
+ * adds <code>ClassDef</code> to the collection of implemented interfaces
+ * of this class
+ *
+ * @param implementor the interface to add
+ */
+ public void addImplementor(ClassDef implementor) {}
+
+ /**
+ * gets the list of <code>ClassDefs</code> that implmement this interface
+ *
+ * @return Vector the list of implementors
+ */
+ public List getImplementors() {
+ return new Vector();
+ }
+
+ public boolean isCompatibleWith(IClass type) {
+ return false;
+ }
+
+ public void addReference(Reference reference) {}
+ public Iterator getReferences() {
+ return new Vector().iterator();
+ }
+
+ public int getNumReferences() {
+ return 0;
+ }
+
+ public boolean isPrimitive() {
+ return false;
+ }
+
+ public boolean isSourced() {
+ return false;
+ }
+
+ public IClass[] getInnerClasses() {
+ return new IClass[0];
+ }
+
+ public String getName() {
+ return _name;
+ }
+
+ public String getQualifiedName() {
+ return _name;
+ }
+
+ public boolean equals(Object o) {
+ //TODO: handle Checkstyle condition for two unknown classes
+ if (o instanceof UnknownClass) {
+ final UnknownClass other = (UnknownClass) o;
+ return other.getName().equals(getName());
+ }
+ return false;
+ }
+
+ public String toString() {
+ return UnknownClass.class + "[" + getName() + "]";
+ }
+}
diff --git a/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/VariableDef.java b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/VariableDef.java
new file mode 100755
index 000000000..cf6041e83
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/usage/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/transmogrify/VariableDef.java
@@ -0,0 +1,132 @@
+
+// Transmogrify License
+//
+// Copyright (c) 2001, ThoughtWorks, Inc.
+// All rights reserved.
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// - Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+// - Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// Neither the name of the ThoughtWorks, Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from this
+// software without specific prior written permission.
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+package com.puppycrawl.tools.checkstyle.checks.usage.transmogrify;
+
+import com.puppycrawl.tools.checkstyle.api.TokenTypes;
+
+
+
+/**
+ * <code>VariableDef</code> is a <code>Definition</code> that contains
+ * information about the definition of a variable.
+ *
+ * @see Definition
+ * @see TypedDef
+ */
+public class VariableDef extends Definition implements IVariable {
+
+ public static final int PRIVATE_VISIBILITY = 0;
+ public static final int PROTECTED_VISIBILITY = 1;
+ public static final int PUBLIC_VISIBILITY = 2;
+ public static final int DEFAULT_VISIBILITY = 3;
+
+ private IClass _type = null;
+
+ public VariableDef(String name, Scope parentScope, SymTabAST node) {
+ super(name, parentScope, node);
+ }
+
+ /**
+ * Returns the <code>Type</code> of the variable.
+ *
+ * @see TypedDef
+ *
+ * @return the <code>Type</code> of the variable
+ */
+ public IClass getType() {
+ return _type;
+ }
+
+ /**
+ * Sets the type of the variable.
+ *
+ * @see TypedDef
+ *
+ * @param def the <code>Type</code> object that represents the type of the
+ * variable.
+ */
+ public void setType(IClass type) {
+ _type = type;
+ }
+
+ public int getVisibility() {
+ int result = DEFAULT_VISIBILITY;
+
+ SymTabAST visibilityNode = getVisibilityNode();
+ if (visibilityNode != null) {
+ if (visibilityNode.getType() == TokenTypes.LITERAL_PRIVATE) {
+ result = PRIVATE_VISIBILITY;
+ }
+ else if (
+ visibilityNode.getType() == TokenTypes.LITERAL_PROTECTED) {
+ result = PROTECTED_VISIBILITY;
+ }
+ else if (visibilityNode.getType() == TokenTypes.LITERAL_PUBLIC) {
+ result = PUBLIC_VISIBILITY;
+ }
+ }
+
+ return result;
+ }
+
+ private SymTabAST getVisibilityNode() {
+ SymTabAST result = null;
+
+ SymTabAST modifiersNode =
+ getTreeNode().findFirstToken(TokenTypes.MODIFIERS);
+ SymTabAST modifier = (SymTabAST) modifiersNode.getFirstChild();
+ while (modifier != null) {
+ if (isVisibilityNode(modifier)) {
+ result = modifier;
+ break;
+ }
+ modifier = (SymTabAST) modifier.getNextSibling();
+ }
+
+ return result;
+ }
+
+ private boolean isVisibilityNode(SymTabAST node) {
+ return (
+ node.getType() == TokenTypes.LITERAL_PUBLIC
+ || node.getType() == TokenTypes.LITERAL_PROTECTED
+ || node.getType() == TokenTypes.LITERAL_PRIVATE);
+ }
+
+ public boolean isAssignedAtDeclaration() {
+ boolean result = false;
+
+ if (getTreeNode().findFirstToken(TokenTypes.ASSIGN) != null) {
+ result = true;
+ }
+
+ return result;
+ }
+
+}
diff --git a/thirdparty/checkstyle/contrib/usage/src/testinputs/com/puppycrawl/tools/checkstyle/usage/InputEmptyFile.java b/thirdparty/checkstyle/contrib/usage/src/testinputs/com/puppycrawl/tools/checkstyle/usage/InputEmptyFile.java
new file mode 100755
index 000000000..a1e71b047
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/usage/src/testinputs/com/puppycrawl/tools/checkstyle/usage/InputEmptyFile.java
@@ -0,0 +1,2 @@
+// this is an empty file
+// it's a test for 1165855
diff --git a/thirdparty/checkstyle/contrib/usage/src/testinputs/com/puppycrawl/tools/checkstyle/usage/InputInnerUsedMethod.java b/thirdparty/checkstyle/contrib/usage/src/testinputs/com/puppycrawl/tools/checkstyle/usage/InputInnerUsedMethod.java
new file mode 100755
index 000000000..d87036317
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/usage/src/testinputs/com/puppycrawl/tools/checkstyle/usage/InputInnerUsedMethod.java
@@ -0,0 +1,23 @@
+package com.puppycrawl.tools.checkstyle.usage;
+
+import java.awt.event.ActionEvent;
+import javax.swing.AbstractAction;
+import javax.swing.JButton;
+
+public final class InputInnerUsedMethod
+{
+ public static void show()
+ {
+ JButton b = new JButton(new AbstractAction()
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ doSomething();
+ }
+ });
+ }
+
+ private static void doSomething()
+ {
+ }
+}
diff --git a/thirdparty/checkstyle/contrib/usage/src/testinputs/com/puppycrawl/tools/checkstyle/usage/InputOneMethodPrivateField.java b/thirdparty/checkstyle/contrib/usage/src/testinputs/com/puppycrawl/tools/checkstyle/usage/InputOneMethodPrivateField.java
new file mode 100755
index 000000000..e967fbdac
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/usage/src/testinputs/com/puppycrawl/tools/checkstyle/usage/InputOneMethodPrivateField.java
@@ -0,0 +1,114 @@
+package com.puppycrawl.tools.checkstyle.usage;
+
+/** Test input for one method private field check */
+public class InputOneMethodPrivateField
+{
+ private static int SFIELD0;
+ private static int SFIELD1;
+ private static int SFIELD2;
+ private static int SFIELD3;
+
+ private int mField0;
+ private int mField1;
+ private int mField2;
+ private int mField3;
+ private int mField4;
+ private int mIgnore;
+
+ public InputOneMethodPrivateField()
+ {
+ SFIELD0 = 0;
+ mField0 = 0;
+ mField3 = 0;
+ }
+
+ private void method()
+ {
+ SFIELD1 = 0;
+ mField1 = 0;
+ mField3++;
+ mField4 = 0;
+ }
+
+ {
+ SFIELD2 = 0;
+ mField2 = 0;
+ mField4 = 1;
+ }
+
+ static
+ {
+ SFIELD3 = 0;
+ }
+}
+
+class Outer2
+{
+ private int mField0;
+ private int mField1;
+ private int mField2;
+ private int mField3;
+
+ private class Inner
+ {
+ public Inner()
+ {
+ int i = mField0;
+ }
+
+ public void method()
+ {
+ mField1 = 0;
+ mField3++;
+ }
+
+ {
+ mField2 = 0;
+ }
+ }
+
+ private void method()
+ {
+ mField3 = 0;
+ }
+}
+
+class Outer3
+{
+ private int mField0;
+ private int mField1;
+
+ private void method()
+ {
+ final class Inner
+ {
+ public int mInner = mField0;
+ }
+ }
+
+ /** tests NPE with dotted class name (bug 842781) */
+ public void dotted()
+ {
+ java.lang.Thread th
+ = new java.lang.Thread() {
+ public void run() {
+ ;
+ }
+ };
+ th.start();
+ }
+}
+
+/** Tests NPE with foreach statements (bug 1109222) */
+class Outer4
+{
+ private int[] mField;
+
+ private void method()
+ {
+ for (int someInt : mField)
+ {
+ someInt = someInt ^ 2;
+ }
+ }
+} \ No newline at end of file
diff --git a/thirdparty/checkstyle/contrib/usage/src/testinputs/com/puppycrawl/tools/checkstyle/usage/InputUnusedField.java b/thirdparty/checkstyle/contrib/usage/src/testinputs/com/puppycrawl/tools/checkstyle/usage/InputUnusedField.java
new file mode 100755
index 000000000..b0aaa450a
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/usage/src/testinputs/com/puppycrawl/tools/checkstyle/usage/InputUnusedField.java
@@ -0,0 +1,97 @@
+package com.puppycrawl.tools.checkstyle.usage;
+
+import java.awt.Rectangle;
+
+/** Test input for unused field check */
+public class InputUnusedField
+{
+ private int mReadPrimitive;
+ private int mPrimitive;
+ private int mUnreadPrimitive;
+ private String mReadString;
+ private String mReadString2;
+ private Rectangle mRectangle;
+ private int[] mArray;
+ private int[] mArray2;
+ private int[] mUnreadArray;
+ private int mThisPrimitive;
+
+ private int mInitializer = 0;
+ private int mUnused2 = mInitializer;
+
+ private static final int SUNUSED = 0;
+ private static int USED;
+
+ static
+ {
+ USED = 0;
+ }
+
+ public InputUnusedField()
+ {
+ int i = mReadPrimitive;
+ }
+
+ private void method()
+ {
+ int i = mReadString.length();
+ "".equals(mReadString2);
+ int j = mRectangle.x;
+ i = mArray[0];
+ mArray2[0] = 0;
+ this.mThisPrimitive = 1;
+ }
+
+ private void shadow()
+ {
+ int mUnreadPrimitive = 0;
+ mUnreadPrimitive++;
+
+ int[] mUnreadArray = {0};
+ int i = mUnreadArray[0];
+ }
+
+ {
+ mPrimitive = 0;
+ }
+}
+
+class Outer
+{
+ private int mUsed1;
+ private int mUsed2;
+ private int mUsed3;
+ private int mUnused;
+
+ private class Inner
+ {
+ public Inner()
+ {
+ int i = mUsed1;
+ }
+
+ public void method()
+ {
+ mUsed2 = 0;
+ }
+
+ {
+ mUsed3 = 0;
+ }
+ }
+}
+
+class ParenthesizedExpression
+{
+ private int mUsed1 = 1;
+ private int mUsed2 = 1;
+ private boolean mUsed3 = true;
+
+ public void testParentheses()
+ {
+ int x = 0;
+ int a = (x++) / mUsed1;
+ int b = (a - 1) << mUsed2;
+ boolean c = (a == b) || mUsed3;
+ }
+}
diff --git a/thirdparty/checkstyle/contrib/usage/src/testinputs/com/puppycrawl/tools/checkstyle/usage/InputUnusedLocal.java b/thirdparty/checkstyle/contrib/usage/src/testinputs/com/puppycrawl/tools/checkstyle/usage/InputUnusedLocal.java
new file mode 100755
index 000000000..24218afe9
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/usage/src/testinputs/com/puppycrawl/tools/checkstyle/usage/InputUnusedLocal.java
@@ -0,0 +1,60 @@
+package com.puppycrawl.tools.checkstyle.usage;
+
+import java.awt.Rectangle;
+
+/** Test input for unused local variable check */
+public class InputUnusedLocal
+{
+ private int mUnreadPrimitive = 0;
+
+ public InputUnusedLocal()
+ {
+ int readPrimitive = 0;
+ int mUnreadPrimitive = 0;
+ int i = readPrimitive;
+ i++;
+
+ this.mUnreadPrimitive++;
+ }
+
+ private void method()
+ {
+ String readObject = "";
+ Rectangle rectangle = null;
+ Object unreadObject;
+ int i = readObject.length();
+
+ int j = rectangle.x;
+
+ i += j;
+ }
+
+ private void methodArrays()
+ {
+ int[] array = {};
+ int[] array2 = {};
+ int[] unreadArray;
+ int i = array[0];
+ array2[0] = 0;
+ i++;
+ }
+
+ /** tests that neither type nor typecast are considered to be a reference */
+ public void method2()
+ {
+ int java;
+ java.io.File file = (java.io.File) null;
+ if (file != null) {
+ }
+ }
+
+ /** tests array index references */
+ public void testArrayIndex()
+ {
+ int [][][] a = new int[1][1][1];
+ int i = 0;
+ int j = 0;
+ int k = 0;
+ a[i][j][k]++;
+ }
+}
diff --git a/thirdparty/checkstyle/contrib/usage/src/testinputs/com/puppycrawl/tools/checkstyle/usage/InputUnusedMethod.java b/thirdparty/checkstyle/contrib/usage/src/testinputs/com/puppycrawl/tools/checkstyle/usage/InputUnusedMethod.java
new file mode 100755
index 000000000..34ef4459a
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/usage/src/testinputs/com/puppycrawl/tools/checkstyle/usage/InputUnusedMethod.java
@@ -0,0 +1,155 @@
+package com.puppycrawl.tools.checkstyle.usage;
+
+/** Test input for unread method check */
+public class InputUnusedMethod
+{
+
+ private void methodUnused0()
+ {
+ }
+
+ private void methodUsed0()
+ {
+ }
+
+ private void methodUsed1(int aParam)
+ {
+ }
+
+ private void methodUsed1(double aParam)
+ {
+ }
+
+ private void methodUsed1(String aParam)
+ {
+ }
+
+ public static void main(String[] args)
+ {
+ InputUnusedMethod method = new InputUnusedMethod();
+ method.methodUsed0();
+ method.methodUsed1(0 + 4);
+ method.methodUsed1(Math.sqrt(2.0));
+ method.methodUsed1("" + "a");
+ }
+}
+
+interface InterfaceMethod
+{
+ public void method(int aParam);
+}
+
+abstract class AbstractClassMethod
+{
+ public abstract void method(int aParam);
+}
+
+/** Test for bug 880954: false positive when parentheses around second term
+ * of ternary operator.
+ */
+class Ternary
+{
+ private int m()
+ {
+ return 1;
+ }
+
+ public void m1()
+ {
+ int i = 0;
+ int j = (i == 0) ? (i) : m();
+ }
+}
+
+class SerializableTest implements java.io.Serializable
+{
+ private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException
+ {
+ // it's ok to have this method in serializable class
+ }
+
+ private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException
+ {
+ // it's ok to have this method in serializable class
+ }
+
+ private Object writeReplace() throws java.io.ObjectStreamException
+ {
+ // it's ok to have this method in serializable class
+ return new SerializableTest();
+ }
+
+ private Object readResolve() throws java.io.ObjectStreamException
+ {
+ // it's ok to have this method in serializable class
+ return new SerializableTest();
+ }
+}
+
+class BadSerializableTest1 implements java.io.Serializable
+{
+ private void writeObject(Object out) throws java.io.IOException
+ {
+ }
+
+ private void writeObject(java.io.ObjectOutputStream out, int i) throws java.io.IOException
+ {
+ }
+
+ private void writeObject(java.io.ObjectOutputStream out)
+ {
+ }
+
+ private void readObject(java.io.ObjectInputStream in) throws java.io.IOException
+ {
+ }
+
+ private void readObject(Object in) throws java.io.IOException, ClassNotFoundException
+ {
+ }
+
+ private int writeReplace() throws java.io.ObjectStreamException
+ {
+ return 1;
+ }
+
+ private Object writeReplace(int i) throws java.io.ObjectStreamException
+ {
+ return new SerializableTest();
+ }
+
+ private int readResolve() throws java.io.ObjectStreamException
+ {
+ return 1;
+ }
+
+ private Object readResolve(int i) throws java.io.ObjectStreamException
+ {
+ return new SerializableTest();
+ }
+}
+
+class BadSerializableTest2 implements java.io.Serializable
+{
+ private int writeObject(java.io.ObjectOutputStream out) throws java.io.IOException
+ {
+ return 1;
+ }
+
+ private void readObject(java.io.ObjectInputStream in) throws ClassNotFoundException
+ {
+ }
+
+ private Object readResolve()
+ {
+ return new SerializableTest();
+ }
+}
+
+class BadSerializableTest3 implements java.io.Serializable
+{
+ private int readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException
+ {
+ return 1;
+ }
+}
diff --git a/thirdparty/checkstyle/contrib/usage/src/testinputs/com/puppycrawl/tools/checkstyle/usage/InputUnusedParameter.java b/thirdparty/checkstyle/contrib/usage/src/testinputs/com/puppycrawl/tools/checkstyle/usage/InputUnusedParameter.java
new file mode 100755
index 000000000..3ac5e0e61
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/usage/src/testinputs/com/puppycrawl/tools/checkstyle/usage/InputUnusedParameter.java
@@ -0,0 +1,50 @@
+package com.puppycrawl.tools.checkstyle.usage;
+
+import java.awt.Rectangle;
+
+/** Test input for unread parameter check */
+public class InputUnusedParameter
+{
+ public InputUnusedParameter(int aReadPrimitive, int aUnreadPrimitive)
+ {
+ int i = aReadPrimitive;
+ }
+
+ public void method(
+ String aReadObject,
+ Rectangle aRectangle,
+ Object aUnreadObject)
+ {
+ int i = aReadObject.length();
+
+ int j = aRectangle.x;
+
+ try {
+ i++;
+ }
+ catch (Exception unreadException) {
+ }
+ }
+
+ private void methodArrays(int[] aArray, int[] aArray2, int[] aUnreadArray)
+ {
+ int i = aArray[0];
+ aArray2[0] = 0;
+ }
+
+ private int member = 1;
+ private void methodSameLocalVariable(int member)
+ {
+ int x = member; // refers to the param, not the member
+ }
+}
+
+interface Interface
+{
+ public void method(int aParam);
+}
+
+abstract class AbstractClass
+{
+ public abstract void method(int aParam);
+}
diff --git a/thirdparty/checkstyle/contrib/usage/src/tests/com/puppycrawl/tools/checkstyle/checks/usage/AllTests.java b/thirdparty/checkstyle/contrib/usage/src/tests/com/puppycrawl/tools/checkstyle/checks/usage/AllTests.java
new file mode 100755
index 000000000..569b8053a
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/usage/src/tests/com/puppycrawl/tools/checkstyle/checks/usage/AllTests.java
@@ -0,0 +1,23 @@
+package com.puppycrawl.tools.checkstyle.checks.usage;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+public class AllTests {
+
+ public static void main(String[] args) {
+ junit.textui.TestRunner.run(AllTests.suite());
+ }
+
+ public static Test suite() {
+ TestSuite suite =
+ new TestSuite("Test for com.puppycrawl.tools.checkstyle.checks.usage");
+ suite.addTest(new TestSuite(OneMethodPrivateFieldCheckTest.class));
+ suite.addTest(new TestSuite(UnusedLocalVariableCheckTest.class));
+ suite.addTest(new TestSuite(UnusedParameterCheckTest.class));
+ suite.addTest(new TestSuite(UnusedPrivateFieldCheckTest.class));
+ suite.addTest(new TestSuite(UnusedPrivateMethodCheckTest.class));
+
+ return suite;
+ }
+}
diff --git a/thirdparty/checkstyle/contrib/usage/src/tests/com/puppycrawl/tools/checkstyle/checks/usage/OneMethodPrivateFieldCheckTest.java b/thirdparty/checkstyle/contrib/usage/src/tests/com/puppycrawl/tools/checkstyle/checks/usage/OneMethodPrivateFieldCheckTest.java
new file mode 100755
index 000000000..ea25988c6
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/usage/src/tests/com/puppycrawl/tools/checkstyle/checks/usage/OneMethodPrivateFieldCheckTest.java
@@ -0,0 +1,46 @@
+package com.puppycrawl.tools.checkstyle.checks.usage;
+
+import com.puppycrawl.tools.checkstyle.BaseCheckTestCase;
+import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
+
+public class OneMethodPrivateFieldCheckTest
+ extends BaseCheckTestCase
+{
+ public void testDefault() throws Exception
+ {
+ final DefaultConfiguration checkConfig =
+ createCheckConfig(OneMethodPrivateFieldCheck.class);
+ final String[] expected = {
+ "6:24: Field 'SFIELD0' is used in only one method.",
+ "7:24: Field 'SFIELD1' is used in only one method.",
+ "8:24: Field 'SFIELD2' is used in only one method.",
+ "9:24: Field 'SFIELD3' is used in only one method.",
+ "11:17: Field 'mField0' is used in only one method.",
+ "12:17: Field 'mField1' is used in only one method.",
+ "13:17: Field 'mField2' is used in only one method.",
+ "47:17: Field 'mField0' is used in only one method.",
+ "48:17: Field 'mField1' is used in only one method.",
+ "49:17: Field 'mField2' is used in only one method.",
+ "105:19: Field 'mField' is used in only one method.",
+ };
+ verify(checkConfig, getPath("usage/InputOneMethodPrivateField.java"), expected);
+ }
+
+ public void testIgnoreFormat() throws Exception
+ {
+ final DefaultConfiguration checkConfig =
+ createCheckConfig(OneMethodPrivateFieldCheck.class);
+ checkConfig.addAttribute("ignoreFormat", "2$");
+ final String[] expected = {
+ "6:24: Field 'SFIELD0' is used in only one method.",
+ "7:24: Field 'SFIELD1' is used in only one method.",
+ "9:24: Field 'SFIELD3' is used in only one method.",
+ "11:17: Field 'mField0' is used in only one method.",
+ "12:17: Field 'mField1' is used in only one method.",
+ "47:17: Field 'mField0' is used in only one method.",
+ "48:17: Field 'mField1' is used in only one method.",
+ "105:19: Field 'mField' is used in only one method.",
+ };
+ verify(checkConfig, getPath("usage/InputOneMethodPrivateField.java"), expected);
+ }
+}
diff --git a/thirdparty/checkstyle/contrib/usage/src/tests/com/puppycrawl/tools/checkstyle/checks/usage/UnusedLocalVariableCheckTest.java b/thirdparty/checkstyle/contrib/usage/src/tests/com/puppycrawl/tools/checkstyle/checks/usage/UnusedLocalVariableCheckTest.java
new file mode 100755
index 000000000..fb559d62e
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/usage/src/tests/com/puppycrawl/tools/checkstyle/checks/usage/UnusedLocalVariableCheckTest.java
@@ -0,0 +1,34 @@
+package com.puppycrawl.tools.checkstyle.checks.usage;
+
+import com.puppycrawl.tools.checkstyle.BaseCheckTestCase;
+import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
+
+public class UnusedLocalVariableCheckTest
+ extends BaseCheckTestCase
+{
+ public void testDefault() throws Exception
+ {
+ final DefaultConfiguration checkConfig =
+ createCheckConfig(UnusedLocalVariableCheck.class);
+ final String[] expected = {
+ "13:13: Unused local variable 'mUnreadPrimitive'.",
+ "24:16: Unused local variable 'unreadObject'.",
+ "36:15: Unused local variable 'unreadArray'.",
+ "45:13: Unused local variable 'java'.",
+ };
+ verify(checkConfig, getPath("usage/InputUnusedLocal.java"), expected);
+ }
+
+ public void testIgnoreFormat() throws Exception
+ {
+ final DefaultConfiguration checkConfig =
+ createCheckConfig(UnusedLocalVariableCheck.class);
+ checkConfig.addAttribute("ignoreFormat", "Array$");
+ final String[] expected = {
+ "13:13: Unused local variable 'mUnreadPrimitive'.",
+ "24:16: Unused local variable 'unreadObject'.",
+ "45:13: Unused local variable 'java'.",
+ };
+ verify(checkConfig, getPath("usage/InputUnusedLocal.java"), expected);
+ }
+}
diff --git a/thirdparty/checkstyle/contrib/usage/src/tests/com/puppycrawl/tools/checkstyle/checks/usage/UnusedParameterCheckTest.java b/thirdparty/checkstyle/contrib/usage/src/tests/com/puppycrawl/tools/checkstyle/checks/usage/UnusedParameterCheckTest.java
new file mode 100755
index 000000000..64cf386a6
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/usage/src/tests/com/puppycrawl/tools/checkstyle/checks/usage/UnusedParameterCheckTest.java
@@ -0,0 +1,58 @@
+package com.puppycrawl.tools.checkstyle.checks.usage;
+
+import com.puppycrawl.tools.checkstyle.BaseCheckTestCase;
+import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
+
+public class UnusedParameterCheckTest
+ extends BaseCheckTestCase
+{
+ public void testDefault() throws Exception
+ {
+ final DefaultConfiguration checkConfig =
+ createCheckConfig(UnusedParameterCheck.class);
+ final String[] expected = {
+ "8:57: Unused parameter 'aUnreadPrimitive'.",
+ "16:16: Unused parameter 'aUnreadObject'.",
+ "29:66: Unused parameter 'aUnreadArray'.",
+ };
+ verify(checkConfig, getPath("usage/InputUnusedParameter.java"), expected);
+ }
+
+ public void testException() throws Exception
+ {
+ final DefaultConfiguration checkConfig =
+ createCheckConfig(UnusedParameterCheck.class);
+ checkConfig.addAttribute("ignoreCatch", Boolean.FALSE.toString());
+ final String[] expected = {
+ "8:57: Unused parameter 'aUnreadPrimitive'.",
+ "16:16: Unused parameter 'aUnreadObject'.",
+ "25:26: Unused parameter 'unreadException'.",
+ "29:66: Unused parameter 'aUnreadArray'.",
+ };
+ verify(checkConfig, getPath("usage/InputUnusedParameter.java"), expected);
+ }
+
+ public void testIgnoreFormat() throws Exception
+ {
+ final DefaultConfiguration checkConfig =
+ createCheckConfig(UnusedParameterCheck.class);
+ checkConfig.addAttribute("ignoreFormat", "Array$");
+ final String[] expected = {
+ "8:57: Unused parameter 'aUnreadPrimitive'.",
+ "16:16: Unused parameter 'aUnreadObject'.",
+ };
+ verify(checkConfig, getPath("usage/InputUnusedParameter.java"), expected);
+ }
+
+ public void testIgnoreNonLocal() throws Exception
+ {
+ final DefaultConfiguration checkConfig =
+ createCheckConfig(UnusedParameterCheck.class);
+ checkConfig.addAttribute("ignoreNonLocal", "true");
+ final String[] expected = {
+ "8:57: Unused parameter 'aUnreadPrimitive'.",
+ "29:66: Unused parameter 'aUnreadArray'.",
+ };
+ verify(checkConfig, getPath("usage/InputUnusedParameter.java"), expected);
+ }
+}
diff --git a/thirdparty/checkstyle/contrib/usage/src/tests/com/puppycrawl/tools/checkstyle/checks/usage/UnusedPrivateFieldCheckTest.java b/thirdparty/checkstyle/contrib/usage/src/tests/com/puppycrawl/tools/checkstyle/checks/usage/UnusedPrivateFieldCheckTest.java
new file mode 100755
index 000000000..4fab109ac
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/usage/src/tests/com/puppycrawl/tools/checkstyle/checks/usage/UnusedPrivateFieldCheckTest.java
@@ -0,0 +1,36 @@
+package com.puppycrawl.tools.checkstyle.checks.usage;
+
+import com.puppycrawl.tools.checkstyle.BaseCheckTestCase;
+import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
+
+public class UnusedPrivateFieldCheckTest
+ extends BaseCheckTestCase
+{
+ public void testDefault() throws Exception
+ {
+ final DefaultConfiguration checkConfig =
+ createCheckConfig(UnusedPrivateFieldCheck.class);
+ final String[] expected = {
+ "10:17: Unused private field 'mUnreadPrimitive'.",
+ "16:19: Unused private field 'mUnreadArray'.",
+ "20:17: Unused private field 'mUnused2'.",
+ "22:30: Unused private field 'SUNUSED'.",
+ "64:17: Unused private field 'mUnused'.",
+ };
+ verify(checkConfig, getPath("usage/InputUnusedField.java"), expected);
+ }
+
+ public void testIgnoreFormat() throws Exception
+ {
+ final DefaultConfiguration checkConfig =
+ createCheckConfig(UnusedPrivateFieldCheck.class);
+ checkConfig.addAttribute("ignoreFormat", "Array$");
+ final String[] expected = {
+ "10:17: Unused private field 'mUnreadPrimitive'.",
+ "20:17: Unused private field 'mUnused2'.",
+ "22:30: Unused private field 'SUNUSED'.",
+ "64:17: Unused private field 'mUnused'.",
+ };
+ verify(checkConfig, getPath("usage/InputUnusedField.java"), expected);
+ }
+}
diff --git a/thirdparty/checkstyle/contrib/usage/src/tests/com/puppycrawl/tools/checkstyle/checks/usage/UnusedPrivateMethodCheckTest.java b/thirdparty/checkstyle/contrib/usage/src/tests/com/puppycrawl/tools/checkstyle/checks/usage/UnusedPrivateMethodCheckTest.java
new file mode 100755
index 000000000..3cb732c1a
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/usage/src/tests/com/puppycrawl/tools/checkstyle/checks/usage/UnusedPrivateMethodCheckTest.java
@@ -0,0 +1,78 @@
+package com.puppycrawl.tools.checkstyle.checks.usage;
+
+import com.puppycrawl.tools.checkstyle.BaseCheckTestCase;
+import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
+
+public class UnusedPrivateMethodCheckTest
+ extends BaseCheckTestCase
+{
+ public void testDefault() throws Exception
+ {
+ final DefaultConfiguration checkConfig =
+ createCheckConfig(UnusedPrivateMethodCheck.class);
+ final String[] expected = {
+ "7:18: Unused private method 'methodUnused0'.",
+ "66:18: Unused private method 'writeObject'.",
+ "71:18: Unused private method 'readObject'.",
+ "76:20: Unused private method 'writeReplace'.",
+ "82:20: Unused private method 'readResolve'.",
+ "91:18: Unused private method 'writeObject'.",
+ "95:18: Unused private method 'writeObject'.",
+ "99:18: Unused private method 'writeObject'.",
+ "103:18: Unused private method 'readObject'.",
+ "107:18: Unused private method 'readObject'.",
+ "111:17: Unused private method 'writeReplace'.",
+ "116:20: Unused private method 'writeReplace'.",
+ "121:17: Unused private method 'readResolve'.",
+ "126:20: Unused private method 'readResolve'.",
+ "134:17: Unused private method 'writeObject'.",
+ "139:18: Unused private method 'readObject'.",
+ "143:20: Unused private method 'readResolve'.",
+ "151:17: Unused private method 'readObject'.",
+ };
+ verify(checkConfig, getPath("usage/InputUnusedMethod.java"), expected);
+ }
+
+ public void testAllowSerializationMethods() throws Exception
+ {
+ final DefaultConfiguration checkConfig =
+ createCheckConfig(UnusedPrivateMethodCheck.class);
+ checkConfig.addAttribute("allowSerializationMethods", "true");
+
+ final String[] expected = {
+ "7:18: Unused private method 'methodUnused0'.",
+ "91:18: Unused private method 'writeObject'.",
+ "95:18: Unused private method 'writeObject'.",
+ "99:18: Unused private method 'writeObject'.",
+ "103:18: Unused private method 'readObject'.",
+ "107:18: Unused private method 'readObject'.",
+ "111:17: Unused private method 'writeReplace'.",
+ "116:20: Unused private method 'writeReplace'.",
+ "121:17: Unused private method 'readResolve'.",
+ "126:20: Unused private method 'readResolve'.",
+ "134:17: Unused private method 'writeObject'.",
+ "139:18: Unused private method 'readObject'.",
+ "143:20: Unused private method 'readResolve'.",
+ "151:17: Unused private method 'readObject'.",
+ };
+ verify(checkConfig, getPath("usage/InputUnusedMethod.java"), expected);
+ }
+
+ public void testInner() throws Exception
+ {
+ final DefaultConfiguration checkConfig =
+ createCheckConfig(UnusedPrivateMethodCheck.class);
+ final String[] expected = {
+ };
+ verify(checkConfig, getPath("usage/InputInnerUsedMethod.java"), expected);
+ }
+
+ public void testEmptyFile() throws Exception
+ {
+ final DefaultConfiguration checkConfig =
+ createCheckConfig(UnusedPrivateMethodCheck.class);
+ final String[] expected = {
+ };
+ verify(checkConfig, getPath("usage/InputEmptyFile.java"), expected);
+ }
+}
diff --git a/thirdparty/checkstyle/contrib/usage/src/xdocs/config_usage.xml b/thirdparty/checkstyle/contrib/usage/src/xdocs/config_usage.xml
new file mode 100755
index 000000000..506054dbf
--- /dev/null
+++ b/thirdparty/checkstyle/contrib/usage/src/xdocs/config_usage.xml
@@ -0,0 +1,359 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+
+<document>
+
+ <properties>
+ <title>Usage Checks</title>
+ <author email="checkstyle-devel@lists.sourceforge.net">Checkstyle Development Team</author>
+ </properties>
+
+ <body>
+ <section name="OneMethodPrivateField">
+ <subsection name="Description">
+ <p>
+ Checks that a private field is used in more than one method,
+ constructor, or initializer.
+ </p>
+
+ <p>
+ Rationale: a private field used in only one method,
+ constructor, or initializer should be replaced by a local
+ variable.
+ </p>
+ </subsection>
+
+ <subsection name="Properties">
+ <table>
+ <tr>
+ <th>name</th>
+ <th>description</th>
+ <th>type</th>
+ <th>default value</th>
+ </tr>
+ <tr>
+ <td>ignoreFormat</td>
+ <td>pattern for field names that should be ignored</td>
+ <td>
+ <a href="property_types.html#regexp">regular expression</a>
+ </td>
+ <td><span class="default">^$</span> (empty)</td>
+ </tr>
+ </table>
+ </subsection>
+
+ <subsection name="Examples">
+ <p>
+ To configure the check:
+ </p>
+ <source>
+&lt;module name=&quot;usage.OneMethodPrivateField&quot;/&gt;
+ </source>
+
+ <p>
+ To configure the check to ignore fields whose name ends in
+ <span class="code">Temp</span>:
+ </p>
+ <source>
+&lt;module name=&quot;usage.OneMethodPrivateField&quot;&gt;
+ &lt;property name=&quot;ignoreFormat&quot; value=&quot;Temp$&quot;/&gt;
+&lt;/module&gt;
+ </source>
+ </subsection>
+
+ <subsection name="Package">
+ <p>
+ com.puppycrawl.tools.checkstyle.checks.usage
+ </p>
+ </subsection>
+
+ <subsection name="Parent Module">
+ <p>
+ <a href="config.html#treewalker">TreeWalker</a>
+ </p>
+ </subsection>
+ </section>
+
+ <section name="UnusedLocalVariable">
+ <subsection name="Description">
+ <p>
+ Checks that a local variable is used after its declaration.
+ </p>
+ </subsection>
+
+ <subsection name="Properties">
+ <table>
+ <tr>
+ <th>name</th>
+ <th>description</th>
+ <th>type</th>
+ <th>default value</th>
+ </tr>
+ <tr>
+ <td>ignoreFormat</td>
+ <td>pattern for variable names that should be ignored</td>
+ <td>
+ <a href="property_types.html#regexp">regular expression</a>
+ </td>
+ <td><span class="default">^$</span> (empty)</td>
+ </tr>
+ </table>
+ </subsection>
+
+ <subsection name="Examples">
+ <p>
+ To configure the check:
+ </p>
+ <source>
+&lt;module name=&quot;usage.UnusedLocalVariable&quot;/&gt;
+ </source>
+
+ <p>
+ To configure the check to ignore variables whose name ends
+ in <span class="code">Temp</span>:
+ </p>
+ <source>
+&lt;module name=&quot;usage.UnusedLocalVariable&quot;&gt;
+ &lt;property name=&quot;ignoreFormat&quot; value=&quot;Temp$&quot;/&gt;
+&lt;/module&gt;
+ </source>
+ </subsection>
+
+ <subsection name="Package">
+ <p>
+ com.puppycrawl.tools.checkstyle.checks.usage
+ </p>
+ </subsection>
+
+ <subsection name="Parent Module">
+ <p>
+ <a href="config.html#treewalker">TreeWalker</a>
+ </p>
+ </subsection>
+ </section>
+
+ <section name="UnusedParameter">
+ <subsection name="Description">
+ <p>
+ Checks that a parameter is used.
+ </p>
+ </subsection>
+
+ <subsection name="Properties">
+ <table>
+ <tr>
+ <th>name</th>
+ <th>description</th>
+ <th>type</th>
+ <th>default value</th>
+ </tr>
+ <tr>
+ <td>ignoreFormat</td>
+ <td>pattern for parameter names that should be ignored</td>
+ <td>
+ <a href="property_types.html#regexp">regular expression</a>
+ </td>
+ <td><span class="default">^$</span> (empty)</td>
+ </tr>
+ <tr>
+ <td>ignoreCatch</td>
+ <td>
+ controls whether <span class="code">catch</span>
+ parameters should be ignored
+ </td>
+ <td><a href="property_types.html#boolean">boolean</a></td>
+ <td><span class="default">true</span></td>
+ </tr>
+ <tr>
+ <td>ignoreNonLocal</td>
+ <td>
+ controls whether parameters of non local (<span
+ class="code">public, protected or package</span>)
+ methods should be ignored
+ </td>
+ <td><a href="property_types.html#boolean">boolean</a></td>
+ <td><span class="default">false</span></td>
+ </tr>
+ </table>
+ </subsection>
+
+ <subsection name="Examples">
+ <p>
+ To configure the check:
+ </p>
+ <source>
+&lt;module name=&quot;usage.UnusedParameter&quot;/&gt;
+ </source>
+
+ <p>
+ To configure the check to ignore parameters whose name ends
+ in <span class="code">Temp</span>:
+ </p>
+ <source>
+&lt;module name=&quot;usage.UnusedParameter&quot;&gt;
+ &lt;property name=&quot;ignoreFormat&quot; value=&quot;Temp$&quot;/&gt;
+&lt;/module&gt;
+ </source>
+
+ <p>
+ To configure the check to report unused <span
+ class="code">catch</span> parameters:
+ </p>
+ <source>
+&lt;module name=&quot;usage.UnusedParameter&quot;&gt;
+ &lt;property name=&quot;ignoreCatch&quot; value=&quot;false&quot;/&gt;
+&lt;/module&gt;
+ </source>
+ </subsection>
+
+ <subsection name="Package">
+ <p>
+ com.puppycrawl.tools.checkstyle.checks.usage
+ </p>
+ </subsection>
+
+ <subsection name="Parent Module">
+ <p>
+ <a href="config.html#treewalker">TreeWalker</a>
+ </p>
+ </subsection>
+ </section>
+
+ <section name="UnusedPrivateField">
+ <subsection name="Description">
+ <p>
+ Checks that a private field is used.
+ </p>
+ </subsection>
+
+ <subsection name="Properties">
+ <table>
+ <tr>
+ <th>name</th>
+ <th>description</th>
+ <th>type</th>
+ <th>default value</th>
+ </tr>
+ <tr>
+ <td>ignoreFormat</td>
+ <td>pattern for field names that should be ignored</td>
+ <td>
+ <a href="property_types.html#regexp">regular expression</a>
+ </td>
+ <td><span class="default">^$</span> (empty)</td>
+ </tr>
+ </table>
+ </subsection>
+
+ <subsection name="Examples">
+ <p>
+ To configure the check:
+ </p>
+ <source>
+&lt;module name=&quot;usage.UnusedPrivateField&quot;/&gt;
+ </source>
+
+ <p>
+ To configure the check to ignore fields whose name ends in
+ <span class="code">Temp</span>:
+ </p>
+ <source>
+&lt;module name=&quot;usage.UnusedPrivateField&quot;&gt;
+ &lt;property name=&quot;ignoreFormat&quot; value=&quot;Temp$&quot;/&gt;
+&lt;/module&gt;
+ </source>
+ </subsection>
+
+ <subsection name="Package">
+ <p>
+ com.puppycrawl.tools.checkstyle.checks.usage
+ </p>
+ </subsection>
+
+ <subsection name="Parent Module">
+ <p>
+ <a href="config.html#treewalker">TreeWalker</a>
+ </p>
+ </subsection>
+ </section>
+
+ <section name="UnusedPrivateMethod">
+ <subsection name="Description">
+ <p>
+ Checks that a private method is used.
+ </p>
+ </subsection>
+
+ <subsection name="Properties">
+ <table>
+ <tr>
+ <th>name</th>
+ <th>description</th>
+ <th>type</th>
+ <th>default value</th>
+ </tr>
+ <tr>
+ <td>ignoreFormat</td>
+ <td>pattern for method names that should be ignored</td>
+ <td>
+ <a href="property_types.html#regexp">regular expression</a>
+ </td>
+ <td><span class="default">^$</span> (empty)</td>
+ </tr>
+ <tr>
+ <td>allowSerializationMethods</td>
+ <td>whether the check should allow serialization-related methods
+ (<span class="code">readObject()</span>, <span
+ class="code">writeObject()</span>, <span
+ class="code">readResolve()</span> and <span
+ class="code">writeReplace()</span></td>
+ <td>
+ <a href="property_types.html#boolean">boolean</a>
+ </td>
+ <td><span class="default">false</span></td>
+ </tr>
+ </table>
+ </subsection>
+
+ <subsection name="Examples">
+ <p>
+ To configure the check:
+ </p>
+ <source>
+&lt;module name=&quot;usage.UnusedPrivateMethod&quot;/&gt;
+ </source>
+
+ <p>
+ To configure the check to ignore methods whose name ends in
+ <span class="code">Temp</span>:
+ </p>
+ <source>
+&lt;module name=&quot;usage.UnusedPrivateMethod&quot;&gt;
+ &lt;property name=&quot;ignoreFormat&quot; value=&quot;Temp$&quot;/&gt;
+&lt;/module&gt;
+ </source>
+ </subsection>
+
+ <subsection name="Notes">
+ <ul>
+ <li>
+ The classpath may need to be configured to locate
+ parameter type information. The classpath configuration is
+ dependent on the mechanism used to invoke Checkstyle.
+ </li>
+ </ul>
+ </subsection>
+
+ <subsection name="Package">
+ <p>
+ com.puppycrawl.tools.checkstyle.checks.usage
+ </p>
+ </subsection>
+
+ <subsection name="Parent Module">
+ <p>
+ <a href="config.html#treewalker">TreeWalker</a>
+ </p>
+ </subsection>
+ </section>
+ </body>
+</document>