references #81

This commit is contained in:
Andreas Dangel
2016-01-15 10:18:53 +01:00
parent e8e950ad20
commit 69dbbdfe2d
3 changed files with 46 additions and 1 deletions

View File

@ -9,6 +9,7 @@ import java.util.List;
import java.util.ListIterator;
import net.sourceforge.pmd.lang.java.ast.ASTAllocationExpression;
import net.sourceforge.pmd.lang.java.ast.ASTAnnotationTypeDeclaration;
import net.sourceforge.pmd.lang.java.ast.ASTArguments;
import net.sourceforge.pmd.lang.java.ast.ASTArrayDimsAndInits;
import net.sourceforge.pmd.lang.java.ast.ASTClassOrInterfaceDeclaration;
@ -224,6 +225,39 @@ public class AccessorClassGenerationRule extends AbstractJavaRule {
return o;
}
@Override
public Object visit(ASTAnnotationTypeDeclaration node, Object data) {
if (!(node.jjtGetParent().jjtGetParent() instanceof ASTCompilationUnit)) {
// not a toplevel annotation type
String interfaceName = node.getImage();
int formerID = getClassID();
setClassID(classDataList.size());
ClassData newClassData = new ClassData(interfaceName);
// store the names of any outer classes of this class in the
// classQualifyingName List
ClassData formerClassData = classDataList.get(formerID);
newClassData.addClassQualifyingName(formerClassData.getClassName());
classDataList.add(getClassID(), newClassData);
Object o = super.visit(node, data);
setClassID(formerID);
return o;
}
// top-level annotation type
String interfaceName = node.getImage();
classDataList.clear();
setClassID(0);
classDataList.add(getClassID(), new ClassData(interfaceName));
Object o = super.visit(node, data);
if (o != null) {
processRule(o);
} else {
processRule(data);
}
setClassID(-1);
return o;
}
/**
* Store all target constructors
*/

View File

@ -120,4 +120,12 @@ public class Foo1 {
}
]]></code>
</test-code> -->
<test-code>
<description>#1452 ArrayIndexOutOfBoundsException with Annotations for AccessorClassGenerationRule</description>
<expected-problems>0</expected-problems>
<code><![CDATA[
public @interface Something { public interface SomthingElse{}; }
]]></code>
</test-code>
</test-data>

View File

@ -16,12 +16,15 @@
**Pull Requests:**
* [#27](https://github.com/adangel/pmd/pull/27): Added support for Raw String Literals (C++11).
* [#29)(https://github.com/adangel/pmd/pull/29): Added support for files with UTF-8 BOM to JSP tokenizer.
* [#29](https://github.com/adangel/pmd/pull/29): Added support for files with UTF-8 BOM to JSP tokenizer.
* [#79](https://github.com/pmd/pmd/pull/79): do not flag public static void main(String[]) as UseVarargs; ignore @Override for UseVarargs
* [#80](https://github.com/pmd/pmd/pull/80): Update mvn-plugin.md
* [#83](https://github.com/pmd/pmd/pull/83): Adds new Code Climate-compliant JSON renderer
**Bugfixes:**
* java-design/AccessorClassGeneration:
* [#1452](https://sourceforge.net/p/pmd/bugs/1452/): ArrayIndexOutOfBoundsException with Annotations for AccessorClassGenerationRule
**API Changes:**