Refactor Type Resolution from pmd.typeresolution into pmd.lang.java.typeresolution, as TR is currently Java only.
git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@6141 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
1 parent
e2a1216285
commit
ca6eda7e61
25 files changed
+37
-32
No files matched your search
@@ -33,8 +33,10 @@ TODO - Release blockers - Must implement before this release can be finished
|
||||
o Rework these packages to exist with the net.sourceforge.pmd.lang.* hierarchy:
|
||||
net.sourceforge.pmd.dfa
|
||||
net.sourceforge.pmd.symboltables
|
||||
net.sourceforge.pmd.typeresolution
|
||||
net.sourceforge.pmd.properties
|
||||
o Remove the type resolution specific rules. Merge these back into the
|
||||
standard rules. In general, a Rule should use TR when it can, and fall
|
||||
back on non-TR approach otherwise. No need for separate Rules for TR/non-TR.
|
||||
o Need a JUnit test to check for "dead" Rules, that is those not used by any RuleSet.
|
||||
o Rule JUnit tests should verify the Test class follows expected naming
|
||||
conventions just like the Rules need to.
|
||||
@@ -157,6 +159,9 @@ The following is relatively complete list of the major changes (this may not be
|
||||
Renamed - net.sourceforge.pmd.dfa.IDataFlowNode to net.sourceforge.pmd.dfa.DataFlowNode
|
||||
Renamed - net.sourceforge.pmd.dfa.DataFlowNode to net.sourceforge.pmd.dfa.AbstractDataFlowNode
|
||||
Added - net.sourceforge.pmd.ast.JavaDataFlowNode
|
||||
|
||||
API Change - Generalize Type Resolution treatment
|
||||
Renamed - net.sourceforge.pmd.typeresolution.* to net.sourceforge.pmd.lang.java.typeresolution.*
|
||||
|
||||
API Change - Generalize AST treatment
|
||||
Added - net.sourceforge.pmd.lang.ast.Node (interface extracted from old Node/SimpleNode)
|
||||
@@ -176,7 +181,7 @@ The following is relatively complete list of the major changes (this may not be
|
||||
|
||||
New features:
|
||||
|
||||
New Language 'xml' added, for writting XPathRules against XML documents
|
||||
New Language 'xml' added, for writing XPathRules against XML documents
|
||||
|
||||
Other changes:
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ import net.sourceforge.pmd.lang.java.ast.ASTTypeDeclaration;
|
||||
import net.sourceforge.pmd.lang.java.ast.ASTVariableDeclarator;
|
||||
import net.sourceforge.pmd.lang.java.ast.ASTVariableDeclaratorId;
|
||||
import net.sourceforge.pmd.lang.java.ast.TypeNode;
|
||||
import net.sourceforge.pmd.typeresolution.ClassTypeResolver;
|
||||
import net.sourceforge.pmd.lang.java.typeresolution.ClassTypeResolver;
|
||||
|
||||
import org.jaxen.JaxenException;
|
||||
import org.junit.Before;
|
||||
|
||||
@@ -2,7 +2,7 @@ package test.net.sourceforge.pmd.typeresolution;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import net.sourceforge.pmd.typeresolution.PMDASMClassLoader;
|
||||
import net.sourceforge.pmd.lang.java.typeresolution.PMDASMClassLoader;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -7,14 +7,14 @@
|
||||
xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd">
|
||||
|
||||
<description>
|
||||
These are rules which resolve java Class files for comparisson, as opposed to a String
|
||||
These are rules which resolve java Class files for comparison, as opposed to a String
|
||||
</description>
|
||||
|
||||
|
||||
<rule name="LooseCoupling"
|
||||
since="3.9"
|
||||
message="Avoid using implementation types like ''{0}''; use the interface instead"
|
||||
class="net.sourceforge.pmd.typeresolution.rules.LooseCoupling"
|
||||
class="net.sourceforge.pmd.lang.java.typeresolution.rules.LooseCoupling"
|
||||
typeResolution="true"
|
||||
externalInfoUrl="http://pmd.sourceforge.net/rules/typeresolution.html#LooseCoupling">
|
||||
<description>
|
||||
@@ -40,7 +40,7 @@ public class Bar {
|
||||
<rule name="CloneMethodMustImplementCloneable"
|
||||
since="3.9"
|
||||
message="clone() method should be implemented only if implementing Cloneable interface"
|
||||
class="net.sourceforge.pmd.typeresolution.rules.CloneMethodMustImplementCloneable"
|
||||
class="net.sourceforge.pmd.lang.java.typeresolution.rules.CloneMethodMustImplementCloneable"
|
||||
typeResolution="true"
|
||||
externalInfoUrl="http://pmd.sourceforge.net/rules/typeresolution.html#CloneMethodMustImplementCloneable">
|
||||
<description>
|
||||
@@ -64,7 +64,7 @@ public class MyClass {
|
||||
<rule name="UnusedImports"
|
||||
since="4.0"
|
||||
message="Avoid unused imports such as ''{0}''"
|
||||
class="net.sourceforge.pmd.typeresolution.rules.imports.UnusedImports"
|
||||
class="net.sourceforge.pmd.lang.java.typeresolution.rules.imports.UnusedImports"
|
||||
typeResolution="true"
|
||||
externalInfoUrl="http://pmd.sourceforge.net/rules/typeresolution.html#UnusedImports">
|
||||
<description>
|
||||
@@ -83,7 +83,7 @@ public class Foo {}
|
||||
<rule name="SignatureDeclareThrowsException"
|
||||
since="4.0"
|
||||
message="A method/constructor shouldn't explicitly throw java.lang.Exception"
|
||||
class="net.sourceforge.pmd.typeresolution.rules.SignatureDeclareThrowsException"
|
||||
class="net.sourceforge.pmd.lang.java.typeresolution.rules.SignatureDeclareThrowsException"
|
||||
externalInfoUrl="http://pmd.sourceforge.net/rules/typeresolution.html#SignatureDeclareThrowsException"
|
||||
typeResolution="true">
|
||||
<description>
|
||||
@@ -91,7 +91,7 @@ It is unclear which exceptions that can be thrown from the methods.
|
||||
It might be difficult to document and understand the vague interfaces.
|
||||
Use either a class derived from RuntimeException or a checked exception.
|
||||
|
||||
Junit classes are excluded.
|
||||
JUnit classes are excluded.
|
||||
</description>
|
||||
<priority>3</priority>
|
||||
<properties>
|
||||
|
||||
@@ -12,10 +12,10 @@ import net.sourceforge.pmd.lang.java.ast.ASTCompilationUnit;
|
||||
import net.sourceforge.pmd.lang.java.ast.DumpFacade;
|
||||
import net.sourceforge.pmd.lang.java.ast.JavaNode;
|
||||
import net.sourceforge.pmd.lang.java.rule.JavaRuleViolationFactory;
|
||||
import net.sourceforge.pmd.lang.java.typeresolution.TypeResolutionFacade;
|
||||
import net.sourceforge.pmd.lang.java.xpath.TypeOfFunction;
|
||||
import net.sourceforge.pmd.lang.rule.RuleViolationFactory;
|
||||
import net.sourceforge.pmd.symboltable.SymbolFacade;
|
||||
import net.sourceforge.pmd.typeresolution.TypeResolutionFacade;
|
||||
|
||||
/**
|
||||
* Implementation of LanguageVersionHandler for the Java AST. It uses anonymous classes
|
||||
|
||||
@@ -4,7 +4,7 @@ package net.sourceforge.pmd.lang.java.ast;
|
||||
|
||||
import java.util.List;
|
||||
import net.sourceforge.pmd.lang.ast.RootNode;
|
||||
import net.sourceforge.pmd.typeresolution.ClassTypeResolver;
|
||||
import net.sourceforge.pmd.lang.java.typeresolution.ClassTypeResolver;
|
||||
|
||||
// FUTURE Change this class to extend from SimpleJavaNode, as TypeNode is not appropriate (unless I'm wrong)
|
||||
public class ASTCompilationUnit extends AbstractJavaTypeNode implements RootNode {
|
||||
|
||||
@@ -10,9 +10,9 @@ import net.sourceforge.pmd.lang.java.ast.ASTArrayDimsAndInits;
|
||||
import net.sourceforge.pmd.lang.java.ast.ASTClassOrInterfaceType;
|
||||
import net.sourceforge.pmd.lang.java.ast.ASTLiteral;
|
||||
import net.sourceforge.pmd.lang.java.rule.AbstractJavaRule;
|
||||
import net.sourceforge.pmd.lang.java.typeresolution.TypeHelper;
|
||||
import net.sourceforge.pmd.lang.LanguageVersion;
|
||||
import net.sourceforge.pmd.lang.ast.Node;
|
||||
import net.sourceforge.pmd.typeresolution.TypeHelper;
|
||||
|
||||
public class BigIntegerInstantiationRule extends AbstractJavaRule {
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ import net.sourceforge.pmd.lang.java.ast.ASTPrimaryExpression;
|
||||
import net.sourceforge.pmd.lang.java.ast.ASTPrimaryPrefix;
|
||||
import net.sourceforge.pmd.lang.java.ast.ASTPrimarySuffix;
|
||||
import net.sourceforge.pmd.lang.java.rule.AbstractJavaRule;
|
||||
import net.sourceforge.pmd.typeresolution.TypeHelper;
|
||||
import net.sourceforge.pmd.lang.java.typeresolution.TypeHelper;
|
||||
|
||||
/**
|
||||
* Avoid instantiating Boolean objects; you can reference Boolean.TRUE,
|
||||
|
||||
@@ -13,7 +13,7 @@ import net.sourceforge.pmd.lang.java.ast.ASTName;
|
||||
import net.sourceforge.pmd.lang.java.ast.ASTResultType;
|
||||
import net.sourceforge.pmd.lang.java.ast.ASTTypeParameters;
|
||||
import net.sourceforge.pmd.lang.java.rule.AbstractJavaRule;
|
||||
import net.sourceforge.pmd.typeresolution.TypeHelper;
|
||||
import net.sourceforge.pmd.lang.java.typeresolution.TypeHelper;
|
||||
|
||||
@SuppressWarnings("PMD.AvoidCatchingThrowable")
|
||||
// Don't think we can otherwise here...
|
||||
|
||||
+1
-1
@@ -7,9 +7,9 @@ import net.sourceforge.pmd.lang.java.ast.ASTPrimaryExpression;
|
||||
import net.sourceforge.pmd.lang.java.ast.ASTStatementExpression;
|
||||
import net.sourceforge.pmd.lang.java.ast.ASTVariableDeclaratorId;
|
||||
import net.sourceforge.pmd.lang.java.rule.AbstractJavaRule;
|
||||
import net.sourceforge.pmd.lang.java.typeresolution.TypeHelper;
|
||||
import net.sourceforge.pmd.lang.ast.Node;
|
||||
import net.sourceforge.pmd.symboltable.NameOccurrence;
|
||||
import net.sourceforge.pmd.typeresolution.TypeHelper;
|
||||
|
||||
public class UseStringBufferForStringAppendsRule extends AbstractJavaRule {
|
||||
|
||||
|
||||
+1
-1
@@ -26,10 +26,10 @@ import net.sourceforge.pmd.lang.java.ast.ASTVariableDeclaratorId;
|
||||
import net.sourceforge.pmd.lang.java.ast.ASTWhileStatement;
|
||||
import net.sourceforge.pmd.lang.java.ast.TypeNode;
|
||||
import net.sourceforge.pmd.lang.java.rule.AbstractJavaRule;
|
||||
import net.sourceforge.pmd.lang.java.typeresolution.TypeHelper;
|
||||
import net.sourceforge.pmd.properties.IntegerProperty;
|
||||
import net.sourceforge.pmd.symboltable.NameOccurrence;
|
||||
import net.sourceforge.pmd.symboltable.VariableNameDeclaration;
|
||||
import net.sourceforge.pmd.typeresolution.TypeHelper;
|
||||
|
||||
/**
|
||||
* This rule finds concurrent calls to StringBuffer.append where String literals
|
||||
|
||||
+1
-1
@@ -16,8 +16,8 @@ import net.sourceforge.pmd.lang.java.ast.ASTLiteral;
|
||||
import net.sourceforge.pmd.lang.java.ast.ASTName;
|
||||
import net.sourceforge.pmd.lang.java.ast.ASTStatementExpression;
|
||||
import net.sourceforge.pmd.lang.java.rule.AbstractJavaRule;
|
||||
import net.sourceforge.pmd.lang.java.typeresolution.TypeHelper;
|
||||
import net.sourceforge.pmd.symboltable.VariableNameDeclaration;
|
||||
import net.sourceforge.pmd.typeresolution.TypeHelper;
|
||||
|
||||
/*
|
||||
* How this rule works:
|
||||
|
||||
+1
-1
@@ -24,9 +24,9 @@ import net.sourceforge.pmd.lang.java.ast.ASTSwitchLabel;
|
||||
import net.sourceforge.pmd.lang.java.ast.ASTSwitchStatement;
|
||||
import net.sourceforge.pmd.lang.java.ast.ASTVariableDeclaratorId;
|
||||
import net.sourceforge.pmd.lang.java.rule.AbstractJavaRule;
|
||||
import net.sourceforge.pmd.lang.java.typeresolution.TypeHelper;
|
||||
import net.sourceforge.pmd.lang.ast.Node;
|
||||
import net.sourceforge.pmd.symboltable.NameOccurrence;
|
||||
import net.sourceforge.pmd.typeresolution.TypeHelper;
|
||||
|
||||
/**
|
||||
* This rule finds StringBuffers which may have been pre-sized incorrectly
|
||||
|
||||
@@ -9,9 +9,9 @@ import net.sourceforge.pmd.lang.java.ast.ASTClassOrInterfaceType;
|
||||
import net.sourceforge.pmd.lang.java.ast.ASTExpression;
|
||||
import net.sourceforge.pmd.lang.java.ast.ASTName;
|
||||
import net.sourceforge.pmd.lang.java.rule.AbstractJavaRule;
|
||||
import net.sourceforge.pmd.lang.java.typeresolution.TypeHelper;
|
||||
import net.sourceforge.pmd.symboltable.NameDeclaration;
|
||||
import net.sourceforge.pmd.symboltable.VariableNameDeclaration;
|
||||
import net.sourceforge.pmd.typeresolution.TypeHelper;
|
||||
|
||||
public class StringInstantiationRule extends AbstractJavaRule {
|
||||
|
||||
|
||||
@@ -6,8 +6,8 @@ package net.sourceforge.pmd.lang.java.rule.strings;
|
||||
import net.sourceforge.pmd.lang.java.ast.ASTName;
|
||||
import net.sourceforge.pmd.lang.java.ast.ASTVariableDeclaratorId;
|
||||
import net.sourceforge.pmd.lang.java.rule.AbstractJavaRule;
|
||||
import net.sourceforge.pmd.lang.java.typeresolution.TypeHelper;
|
||||
import net.sourceforge.pmd.symboltable.NameOccurrence;
|
||||
import net.sourceforge.pmd.typeresolution.TypeHelper;
|
||||
|
||||
public class StringToStringRule extends AbstractJavaRule {
|
||||
|
||||
|
||||
@@ -8,10 +8,10 @@ import net.sourceforge.pmd.lang.java.ast.ASTCompilationUnit;
|
||||
import net.sourceforge.pmd.lang.java.ast.ASTLiteral;
|
||||
import net.sourceforge.pmd.lang.java.ast.ASTName;
|
||||
import net.sourceforge.pmd.lang.java.rule.AbstractJavaRule;
|
||||
import net.sourceforge.pmd.lang.java.typeresolution.TypeHelper;
|
||||
import net.sourceforge.pmd.lang.ast.Node;
|
||||
import net.sourceforge.pmd.symboltable.NameDeclaration;
|
||||
import net.sourceforge.pmd.symboltable.VariableNameDeclaration;
|
||||
import net.sourceforge.pmd.typeresolution.TypeHelper;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
package net.sourceforge.pmd.typeresolution;
|
||||
package net.sourceforge.pmd.lang.java.typeresolution;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
+2
-2
@@ -1,9 +1,9 @@
|
||||
/**
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
package net.sourceforge.pmd.typeresolution;
|
||||
package net.sourceforge.pmd.lang.java.typeresolution;
|
||||
|
||||
import net.sourceforge.pmd.typeresolution.visitors.PMDASMVisitor;
|
||||
import net.sourceforge.pmd.lang.java.typeresolution.visitors.PMDASMVisitor;
|
||||
|
||||
import org.objectweb.asm.ClassReader;
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package net.sourceforge.pmd.typeresolution;
|
||||
package net.sourceforge.pmd.lang.java.typeresolution;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
package net.sourceforge.pmd.typeresolution;
|
||||
package net.sourceforge.pmd.lang.java.typeresolution;
|
||||
|
||||
import net.sourceforge.pmd.lang.java.ast.ASTCompilationUnit;
|
||||
import net.sourceforge.pmd.lang.java.ast.JavaParserVisitorAdapter;
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
package net.sourceforge.pmd.typeresolution.rules;
|
||||
package net.sourceforge.pmd.lang.java.typeresolution.rules;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
package net.sourceforge.pmd.typeresolution.rules;
|
||||
package net.sourceforge.pmd.lang.java.typeresolution.rules;
|
||||
|
||||
import net.sourceforge.pmd.lang.ast.Node;
|
||||
import net.sourceforge.pmd.lang.java.ast.ASTClassOrInterfaceType;
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
package net.sourceforge.pmd.typeresolution.rules;
|
||||
package net.sourceforge.pmd.lang.java.typeresolution.rules;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
package net.sourceforge.pmd.typeresolution.rules.imports;
|
||||
package net.sourceforge.pmd.lang.java.typeresolution.rules.imports;
|
||||
|
||||
import net.sourceforge.pmd.lang.ast.Node;
|
||||
import net.sourceforge.pmd.lang.java.ast.ASTImportDeclaration;
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
package net.sourceforge.pmd.typeresolution.visitors;
|
||||
package net.sourceforge.pmd.lang.java.typeresolution.visitors;
|
||||
|
||||
import org.objectweb.asm.AnnotationVisitor;
|
||||
import org.objectweb.asm.Attribute;
|
||||
Reference in new issue
Block a user