Search in sources :

Example 91 with AnnotationBuilder

use of org.checkerframework.javacutil.AnnotationBuilder in project checker-framework by typetools.

the class AnnotationBuilderTest method testAnnoAsArgNegative.

@Test(expected = BugInCF.class)
public void testAnnoAsArgNegative() {
    AnnotationMirror anno = AnnotationBuilder.fromClass(env.getElementUtils(), Anno.class);
    AnnotationBuilder builder = new AnnotationBuilder(env, ContainingAnno.class);
    builder.setValue("value", anno);
}
Also used : AnnotationMirror(javax.lang.model.element.AnnotationMirror) AnnotationBuilder(org.checkerframework.javacutil.AnnotationBuilder) Test(org.junit.Test)

Example 92 with AnnotationBuilder

use of org.checkerframework.javacutil.AnnotationBuilder in project checker-framework by typetools.

the class AnnotationBuilderTest method testToString3.

@Test
public void testToString3() {
    AnnotationBuilder builder = new AnnotationBuilder(env, Anno.class);
    builder.setValue("can", new Object[] { 1 });
    Assert.assertEquals("@org.checkerframework.framework.test.junit.AnnotationBuilderTest.Anno(can={1})", builder.build().toString());
}
Also used : AnnotationBuilder(org.checkerframework.javacutil.AnnotationBuilder) Test(org.junit.Test)

Example 93 with AnnotationBuilder

use of org.checkerframework.javacutil.AnnotationBuilder in project checker-framework by typetools.

the class AnnotationBuilderTest method testToString5.

@Test
public void testToString5() {
    AnnotationBuilder builder = new AnnotationBuilder(env, Anno.class);
    builder.setValue("can", new Object[] { 1 });
    builder.setValue("value", "m");
    Assert.assertEquals("@org.checkerframework.framework.test.junit.AnnotationBuilderTest.Anno" + "(can={1}, value=\"m\")", builder.build().toString());
}
Also used : AnnotationBuilder(org.checkerframework.javacutil.AnnotationBuilder) Test(org.junit.Test)

Example 94 with AnnotationBuilder

use of org.checkerframework.javacutil.AnnotationBuilder in project checker-framework by typetools.

the class AnnotationBuilderTest method testClassNegative.

@Test(expected = BugInCF.class)
public void testClassNegative() {
    AnnotationBuilder builder = new AnnotationBuilder(env, ClassElt.class);
    builder.setValue("value", 2);
}
Also used : AnnotationBuilder(org.checkerframework.javacutil.AnnotationBuilder) Test(org.junit.Test)

Example 95 with AnnotationBuilder

use of org.checkerframework.javacutil.AnnotationBuilder in project checker-framework by typetools.

the class AnnotationBuilderTest method addingValuesAfterBuilding.

@Test(expected = BugInCF.class)
public void addingValuesAfterBuilding() {
    AnnotationBuilder builder = new AnnotationBuilder(env, AnnoWithStringArg.class);
    builder.setValue("value", "m");
    // AnnotationMirror anno =
    builder.build();
    builder.setValue("value", "n");
}
Also used : AnnotationBuilder(org.checkerframework.javacutil.AnnotationBuilder) Test(org.junit.Test)

Aggregations

AnnotationBuilder (org.checkerframework.javacutil.AnnotationBuilder)117 Test (org.junit.Test)60 AnnotationMirror (javax.lang.model.element.AnnotationMirror)21 Nullable (org.checkerframework.checker.nullness.qual.Nullable)6 ArrayList (java.util.ArrayList)5 Elements (javax.lang.model.util.Elements)4 QualifierHierarchy (org.checkerframework.framework.type.QualifierHierarchy)4 List (java.util.List)3 TypeElement (javax.lang.model.element.TypeElement)3 NodeList (com.github.javaparser.ast.NodeList)2 Expression (com.github.javaparser.ast.expr.Expression)2 MarkerAnnotationExpr (com.github.javaparser.ast.expr.MarkerAnnotationExpr)2 MemberValuePair (com.github.javaparser.ast.expr.MemberValuePair)2 NormalAnnotationExpr (com.github.javaparser.ast.expr.NormalAnnotationExpr)2 SingleMemberAnnotationExpr (com.github.javaparser.ast.expr.SingleMemberAnnotationExpr)2 TreeSet (java.util.TreeSet)2 TypeMirror (javax.lang.model.type.TypeMirror)2 FormatterTreeUtil (org.checkerframework.checker.formatter.FormatterTreeUtil)2 ConversionCategory (org.checkerframework.checker.formatter.qual.ConversionCategory)2 InvalidFormat (org.checkerframework.checker.formatter.qual.InvalidFormat)2