This commit is contained in:
Clément Fournier committed 2022-11-29 02:22:33 +01:00
1 parent 0ce831fc5c
commit 71cf4ad808
9 files changed
+28 -42

No files matched your search

@@ -120,9 +120,18 @@ public interface SymbolicValue {
@Nullable SymbolicValue getAttribute(String attrName);
/**
* Return the simple names of all attributes that are explicitly set.
* Note that if the annotation is reflected from a class file,
* we can't know which annotations used their default value so it
* returns a set of all attribute names.
*/
Set<String> getAttributeNames();
/** Return the binary name of the annotation type. */
String getBinaryName();
/** Return the simple name of the annotation type. */
String getSimpleName();
@Override
@@ -24,7 +24,11 @@ import net.sourceforge.pmd.lang.java.types.JWildcardType;
/**
* @author Clément Fournier
*/
class TypeAnnotationHelper {
final class TypeAnnotationHelper {
private TypeAnnotationHelper() {
// utility class
}
/** Accumulate type annotations to be applied on a single type. */
@@ -200,7 +200,7 @@ class ClassMethodSigImpl implements JMethodSig, InternalMethodTypeItf {
@Override
public String toString() {
return "UOE";//TypePrettyPrint.prettyPrint(this);
return TypePrettyPrint.prettyPrint(this);
}
@@ -80,8 +80,8 @@ public final class JArrayType implements JTypeMirror {
@Override
public JArrayType getErasure() {
JTypeMirror erasedComp = component.getErasure();
return erasedComp == component ? this
: new JArrayType(ts, erasedComp, symbol, typeAnnots); // NOPMD CompareObjectsWithEquals
return erasedComp == component ? this // NOPMD CompareObjectsWithEquals
: new JArrayType(ts, erasedComp, symbol, typeAnnots);
}
@@ -231,7 +231,7 @@ public class TypeAnnotReflectionTest {
assertHasTypeAnnots(wild0.getBound(), bAnnot);
JWildcardType wild1 = (JWildcardType) t.getTypeArgs().get(1);
assertHasTypeAnnots(wild1,emptyList());
assertHasTypeAnnots(wild1, emptyList());
assertTrue(wild1.isLowerBound());
assertHasTypeAnnots(wild1.getBound(), aAndBAnnot);
}
@@ -244,7 +244,7 @@ public class TypeAnnotReflectionTest {
assertHasTypeAnnots(wild0.getBound(), bAnnot);
JClassType arg1 = (JClassType) t.getTypeArgs().get(1);
assertHasTypeAnnots(arg1,aAnnot);
assertHasTypeAnnots(arg1, aAnnot);
assertHasTypeAnnots(arg1.getTypeArgs().get(0), aAndBAnnot);
}
}
@@ -15,6 +15,7 @@ import net.sourceforge.pmd.lang.java.symbols.internal.asm.TypeAnnotReflectionTes
*
* @author Clément Fournier
*/
@SuppressWarnings("all")
public class ClassWithTypeAnnotationsInside {
@@ -50,13 +51,13 @@ public class ClassWithTypeAnnotationsInside {
@A OuterG<@A @B ? extends @B String, @A List<@A @B Object>> complicatedField;
@Target( { ElementType.TYPE_USE, ElementType.TYPE, ElementType.TYPE_PARAMETER })
@Target({ ElementType.TYPE_USE, ElementType.TYPE, ElementType.TYPE_PARAMETER })
public @interface A {
int value() default 1;
}
@Target( { ElementType.TYPE_USE, ElementType.TYPE, ElementType.TYPE_PARAMETER })
@Target({ ElementType.TYPE_USE, ElementType.TYPE, ElementType.TYPE_PARAMETER })
public @interface B { }
@@ -23,21 +23,25 @@ public abstract class ClassWithTypeAnnotationsOnMethods {
abstract @A @B String abOnReturn(@A String i);
abstract void aOnThrows() throws @A RuntimeException;
abstract void aOnThrows() throws @A Exception;
// tparams
abstract <@A @B T, E extends T> void abOnTypeParm();
abstract <@A @B T, E extends T> T abOnTypeParm2(T t);
// tparam bounds
abstract <@A T, E extends @B T> E bOnTypeParmBound(T t);
abstract <@A T, E extends @B Cloneable & @A Serializable> E bOnTypeParmBoundIntersection(T t);
static class CtorOwner {
CtorOwner(@A @B int i) { }
@A CtorOwner() { }
CtorOwner(String i) throws @A RuntimeException {}
CtorOwner(String i) throws @A Exception {}
}
}
@@ -1,15 +0,0 @@
/*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.symbols.testdata;
import java.lang.annotation.ElementType;
import java.lang.annotation.Target;
/**
*
*/
@Target({ ElementType.TYPE_USE })
public @interface SecondTypeUseAnnot {
}
@@ -1,17 +0,0 @@
/*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.symbols.testdata;
import java.lang.annotation.ElementType;
import java.lang.annotation.Target;
/**
*
*/
@Target({ ElementType.TYPE_USE })
public @interface TypeUseAnnot {
int value() default 1;
}