Search in sources :

Example 31 with Annotation

use of org.eclipse.jdt.core.dom.Annotation in project Main by SpartanRefactoring.

the class ZZZ___Fixture_ModelClass method a30.

@Test
@method
public void a30() {
    for (final Annotation a : annotations()) {
        final SingleMemberAnnotation ¢ = az.singleMemberAnnotation(a);
        if (¢ == null)
            continue;
        final List<SimpleName> ns = annotees.of(¢);
        assert ns != null;
        final SimpleName n = the.firstOf(ns);
        assert n != null;
        if (!"raisin".equals(n + ""))
            continue;
        final List<? extends ASTNode> s = scope.of(n);
        assert s != null : //
        fault.dump() + "\n\t scope = " + //
        s + "\n\t ¢ = " + //
        ¢ + "\n\t n = " + //
        n + "\n\t ns = " + //
        ns + fault.done();
    }
}
Also used : Annotation(org.eclipse.jdt.core.dom.Annotation)

Example 32 with Annotation

use of org.eclipse.jdt.core.dom.Annotation in project Main by SpartanRefactoring.

the class ZZZ___Fixture_ModelClass method a28.

@Test
@method
public void a28() {
    for (final Annotation a : annotations()) {
        final SingleMemberAnnotation ¢ = az.singleMemberAnnotation(a);
        if (¢ == null)
            continue;
        final List<SimpleName> ns = annotees.of(¢);
        assert ns != null;
        final SimpleName n = the.firstOf(ns);
        assert n != null;
        final List<? extends ASTNode> s = scope.of(n);
        assert s != null : //
        fault.dump() + "\n\t scope = " + //
        s + "\n\t ¢ = " + //
        ¢ + "\n\t n = " + //
        n + "\n\t ns = " + //
        ns + fault.done();
    }
}
Also used : Annotation(org.eclipse.jdt.core.dom.Annotation)

Example 33 with Annotation

use of org.eclipse.jdt.core.dom.Annotation in project Main by SpartanRefactoring.

the class ZZZ___Fixture_ModelClass method a37.

@Test
@method
public void a37() {
    for (final Annotation a : annotations()) {
        final SingleMemberAnnotation x = az.singleMemberAnnotation(a);
        if (x != null && (x.getTypeName() + "").equals(ScopeSize.class.getSimpleName() + "")) {
            final SimpleName n = the.firstOf(annotees.of(x));
            if (!DummyInterface.class.getSimpleName().equals(n + ""))
                continue;
            azzert.that(x + ": " + n + "/" + definition.kind(n), scope.of(n).size(), is(value(x)));
        }
    }
}
Also used : Annotation(org.eclipse.jdt.core.dom.Annotation)

Example 34 with Annotation

use of org.eclipse.jdt.core.dom.Annotation in project eclipse-pmd by acanda.

the class SuppressWarningsQuickFix method createReplacementSuppressWarningsAnnotation.

private Annotation createReplacementSuppressWarningsAnnotation(final Annotation existingAnnotation, final AST ast) {
    final Annotation replacement;
    if (existingAnnotation == null || existingAnnotation.isMarkerAnnotation()) {
        final SingleMemberAnnotation annotation = createAnnotation(ast, SingleMemberAnnotation.class);
        annotation.setValue(createPMDLiteralValue(ast));
        replacement = annotation;
    } else if (existingAnnotation.isSingleMemberAnnotation()) {
        final SingleMemberAnnotation existingSingleMemberAnnotation = (SingleMemberAnnotation) existingAnnotation;
        final SingleMemberAnnotation annotation = createAnnotation(ast, SingleMemberAnnotation.class);
        annotation.setValue(createArrayInitializer(existingSingleMemberAnnotation.getValue()));
        replacement = annotation;
    } else if (existingAnnotation.isNormalAnnotation()) {
        final NormalAnnotation existingNormalAnnotation = (NormalAnnotation) existingAnnotation;
        final NormalAnnotation annotation = createAnnotation(ast, NormalAnnotation.class);
        createAnnotationValues(existingNormalAnnotation, annotation);
        replacement = annotation;
    } else {
        replacement = existingAnnotation;
    }
    return replacement;
}
Also used : SingleMemberAnnotation(org.eclipse.jdt.core.dom.SingleMemberAnnotation) NormalAnnotation(org.eclipse.jdt.core.dom.NormalAnnotation) Annotation(org.eclipse.jdt.core.dom.Annotation) NormalAnnotation(org.eclipse.jdt.core.dom.NormalAnnotation) SingleMemberAnnotation(org.eclipse.jdt.core.dom.SingleMemberAnnotation)

Aggregations

Annotation (org.eclipse.jdt.core.dom.Annotation)34 ASTNode (org.eclipse.jdt.core.dom.ASTNode)10 IExtendedModifier (org.eclipse.jdt.core.dom.IExtendedModifier)9 ITypeBinding (org.eclipse.jdt.core.dom.ITypeBinding)7 MethodDeclaration (org.eclipse.jdt.core.dom.MethodDeclaration)5 Name (org.eclipse.jdt.core.dom.Name)5 SingleMemberAnnotation (org.eclipse.jdt.core.dom.SingleMemberAnnotation)5 ICompilationUnit (org.eclipse.jdt.core.ICompilationUnit)4 ArrayType (org.eclipse.jdt.core.dom.ArrayType)4 NormalAnnotation (org.eclipse.jdt.core.dom.NormalAnnotation)4 ArrayList (java.util.ArrayList)3 AST (org.eclipse.jdt.core.dom.AST)3 CompilationUnit (org.eclipse.jdt.core.dom.CompilationUnit)3 IMethodBinding (org.eclipse.jdt.core.dom.IMethodBinding)3 ParameterizedType (org.eclipse.jdt.core.dom.ParameterizedType)3 PrimitiveType (org.eclipse.jdt.core.dom.PrimitiveType)3 Type (org.eclipse.jdt.core.dom.Type)3 HashSet (java.util.HashSet)2 List (java.util.List)2 AbstractTypeDeclaration (org.eclipse.jdt.core.dom.AbstractTypeDeclaration)2