use of org.checkerframework.javacutil.AnnotationBuilder in project checker-framework by typetools.
the class AnnotationBuilderTest method listArrayObjectWrongType.
@Test(expected = SourceChecker.CheckerError.class)
public void listArrayObjectWrongType() {
AnnotationBuilder builder = new AnnotationBuilder(env, B.class);
builder.setValue("strings", new Object[] { "m", "n", 1 });
assertEquals(1, builder.build().getElementValues().size());
}
use of org.checkerframework.javacutil.AnnotationBuilder in project checker-framework by typetools.
the class DependentTypesHelper method standardizeDependentTypeAnnotation.
/**
* Standardizes a dependent type annotation.
*/
private AnnotationMirror standardizeDependentTypeAnnotation(FlowExpressionContext context, TreePath localScope, AnnotationMirror anno, boolean useLocalScope) {
AnnotationBuilder builder = new AnnotationBuilder(factory.getProcessingEnv(), AnnotationUtils.annotationName(anno));
for (String value : getListOfExpressionElements(anno)) {
List<String> expressionStrings = AnnotationUtils.getElementValueArray(anno, value, String.class, true);
List<String> standardizedStrings = new ArrayList<>();
for (String expression : expressionStrings) {
standardizedStrings.add(standardizeString(expression, context, localScope, useLocalScope));
}
builder.setValue(value, standardizedStrings);
}
return builder.build();
}
use of org.checkerframework.javacutil.AnnotationBuilder in project checker-framework by typetools.
the class ClassValAnnotatedTypeFactory method createClassVal.
private AnnotationMirror createClassVal(List<String> values) {
AnnotationBuilder builder = new AnnotationBuilder(processingEnv, ClassVal.class.getCanonicalName());
builder.setValue("value", values);
return builder.build();
}
use of org.checkerframework.javacutil.AnnotationBuilder in project checker-framework by typetools.
the class ClassValAnnotatedTypeFactory method createClassBound.
private AnnotationMirror createClassBound(List<String> values) {
AnnotationBuilder builder = new AnnotationBuilder(processingEnv, ClassBound.class.getCanonicalName());
builder.setValue("value", values);
return builder.build();
}
use of org.checkerframework.javacutil.AnnotationBuilder in project checker-framework by typetools.
the class MethodSignature method createMethodVal.
private AnnotationMirror createMethodVal(Set<MethodSignature> sigs) {
List<String> classNames = new ArrayList<>();
List<String> methodNames = new ArrayList<>();
List<Integer> params = new ArrayList<>();
for (MethodSignature sig : sigs) {
classNames.add(sig.className);
methodNames.add(sig.methodName);
params.add(sig.params);
}
AnnotationBuilder builder = new AnnotationBuilder(processingEnv, MethodVal.class.getCanonicalName());
builder.setValue("className", classNames);
builder.setValue("methodName", methodNames);
builder.setValue("params", params);
return builder.build();
}
Aggregations