public static AnnotationValue getAnnotationValue(AnnotationMirror mirror, String name) { return getAnnotationValue(mirror, name, true); }
private void verifyExpectedMessages(ProcessorContext context, Log log, List<Message> msgs) { TypeElement expectError = context.getTruffleTypes().getExpectError(); if (expectError != null) { Element element = getMessageElement(); if (element != null) { AnnotationMirror mirror = ElementUtils.findAnnotationMirror(element.getAnnotationMirrors(), expectError.asType()); if (mirror != null) { List<String> values = ElementUtils.getAnnotationValueList(String.class, mirror, "value"); if (values == null) { values = Collections.emptyList(); } if (values.size() != msgs.size()) { log.message(Kind.ERROR, element, mirror, ElementUtils.getAnnotationValue(mirror, "value"), String.format("Error count expected %s but was %s.", values.size(), msgs.size())); } } } } }
@Override public AnnotationValue getMessageAnnotationValue() { return ElementUtils.getAnnotationValue(getMessageAnnotation(), "assumptions"); }
@Override public MethodSpec createSpecification(ExecutableElement method, AnnotationMirror mirror) { String shortCircuitValue = ElementUtils.getAnnotationValue(String.class, mirror, "value"); return createDefaultMethodSpec(method, mirror, true, shortCircuitValue); }
public static <T> T getAnnotationValue(Class<T> expectedType, AnnotationMirror mirror, String name) { return resolveAnnotationValue(expectedType, getAnnotationValue(mirror, name)); }
@Override public AnnotationValue getMessageAnnotationValue() { return ElementUtils.getAnnotationValue(getMessageAnnotation(), "assumptions"); }
@Override public AnnotationValue getMessageAnnotationValue() { return ElementUtils.getAnnotationValue(getMessageAnnotation(), "value"); }
@Override public AnnotationValue getMessageAnnotationValue() { return ElementUtils.getAnnotationValue(getMessageAnnotation(), "guards"); }
@Override public AnnotationValue getMessageAnnotationValue() { return ElementUtils.getAnnotationValue(getMessageAnnotation(), "value"); }
public static <T> List<T> getAnnotationValueList(Class<T> expectedListType, AnnotationMirror mirror, String name) { List<?> values = getAnnotationValue(List.class, mirror, name); List<T> result = new ArrayList<>(); if (values != null) { for (Object value : values) { T annotationValue = resolveAnnotationValue(expectedListType, (AnnotationValue) value); if (annotationValue != null) { result.add(annotationValue); } } } return result; }
@Override public AnnotationValue getMessageAnnotationValue() { return ElementUtils.getAnnotationValue(getMessageAnnotation(), "guards"); }
@SuppressWarnings("unchecked") public static <T> List<T> getAnnotationValueList(Class<T> expectedListType, AnnotationMirror mirror, String name) { List<? extends AnnotationValue> values = getAnnotationValue(List.class, mirror, name); List<T> result = new ArrayList<>(); if (values != null) { for (AnnotationValue value : values) { T annotationValue = resolveAnnotationValue(expectedListType, value); if (annotationValue != null) { result.add(annotationValue); } } } return result; }
public static <T> T getAnnotationValue(Class<T> expectedType, AnnotationMirror mirror, String name) { return resolveAnnotationValue(expectedType, getAnnotationValue(mirror, name)); }
protected final TypeMirror resolveCastOrCheck(TemplateMethod method) { Class<?> annotationType = getAnnotationType(); TypeMirror targetTypeMirror = ElementUtils.getAnnotationValue(TypeMirror.class, method.getMessageAnnotation(), "value"); if (!method.getMethod().getModifiers().contains(Modifier.PUBLIC) || !method.getMethod().getModifiers().contains(Modifier.STATIC)) { method.addError("@%s annotated method %s must be public and static.", annotationType.getSimpleName(), method.getMethodName()); } return targetTypeMirror; }
protected final TypeMirror resolveCastOrCheck(TemplateMethod method) { Class<?> annotationType = getAnnotationType(); TypeMirror targetTypeMirror = ElementUtils.getAnnotationValue(TypeMirror.class, method.getMessageAnnotation(), "value"); if (!method.getMethod().getModifiers().contains(Modifier.PUBLIC) || !method.getMethod().getModifiers().contains(Modifier.STATIC)) { method.addError("@%s annotated method %s must be public and static.", annotationType.getSimpleName(), method.getMethodName()); } return targetTypeMirror; }
@Override public ShortCircuitData create(TemplateMethod method, boolean invalid) { String shortCircuitValue = ElementUtils.getAnnotationValue(String.class, method.getMarkerAnnotation(), "value"); if (!shortCircuitValues.contains(shortCircuitValue)) { method.addError("Invalid short circuit value %s.", shortCircuitValue); } return new ShortCircuitData(method, shortCircuitValue); }
private TypeMirror inheritType(AnnotationMirror annotation, String valueName, TypeMirror parentType) { TypeMirror inhertNodeType = context.getTruffleTypes().getNode(); TypeMirror value = ElementUtils.getAnnotationValue(TypeMirror.class, annotation, valueName); if (ElementUtils.typeEquals(inhertNodeType, value)) { return parentType; } else { return value; } }
private TypeMirror inheritType(AnnotationMirror annotation, String valueName, TypeMirror parentType) { TypeMirror inhertNodeType = context.getTruffleTypes().getNode(); TypeMirror value = ElementUtils.getAnnotationValue(TypeMirror.class, annotation, valueName); if (ElementUtils.typeEquals(inhertNodeType, value)) { return parentType; } else { return value; } }
@Override public MethodSpec createSpecification(ExecutableElement method, AnnotationMirror mirror) { TypeMirror targetTypeMirror = ElementUtils.getAnnotationValue(TypeMirror.class, mirror, "value"); ParameterSpec returnTypeSpec = new ParameterSpec("returnType", targetTypeMirror); returnTypeSpec.setAllowSubclasses(false); MethodSpec spec = new MethodSpec(returnTypeSpec); spec.addRequired(new ParameterSpec("value", getContext().getType(Object.class))); return spec; }
@Override public MethodSpec createSpecification(ExecutableElement method, AnnotationMirror mirror) { TypeMirror targetTypeMirror = ElementUtils.getAnnotationValue(TypeMirror.class, mirror, "value"); ParameterSpec returnTypeSpec = new ParameterSpec("returnType", targetTypeMirror); returnTypeSpec.setAllowSubclasses(false); MethodSpec spec = new MethodSpec(returnTypeSpec); spec.addRequired(new ParameterSpec("value", getContext().getType(Object.class))); return spec; }