use of org.checkerframework.checker.signature.qual.CanonicalName in project checker-framework by typetools.
the class AnnotationUtils method getElementValueClassName.
/**
* Get the Name of the class that is referenced by element {@code element}.
*
* <p>This is a convenience method for the most common use-case. It is like {@code
* getElementValue(anno, element, ClassType.class).getQualifiedName()}, but this method ensures
* consistent use of the qualified name.
*
* <p>This method is intended only for use by the framework. A checker implementation should use
* {@code anno.getElementValues().get(someElement).getValue().asElement().getQualifiedName();}.
*
* @param anno the annotation to disassemble
* @param element the element to access; it must be present in the annotation
* @return the name of the class that is referenced by element with the given name; may be an
* empty name, for a local or anonymous class
*/
@CanonicalName
public static Name getElementValueClassName(AnnotationMirror anno, ExecutableElement element) {
Type.ClassType ct = getElementValue(anno, element, Type.ClassType.class);
if (ct == null) {
throw new BugInCF("getElementValueClassName(%s, %s, ...)", anno, element);
}
// TODO: Is it a problem that this returns the type parameters too? Should I cut them off?
@CanonicalName Name result = ct.asElement().getQualifiedName();
return result;
}
use of org.checkerframework.checker.signature.qual.CanonicalName in project checker-framework by typetools.
the class AnnotationUtils method annotationName.
// **********************************************************************
// Helper methods to handle annotations. mainly workaround
// AnnotationMirror.equals undesired property
// (I think the undesired property is that it's reference equality.)
// **********************************************************************
/**
* Returns the fully-qualified name of an annotation as a String.
*
* @param annotation the annotation whose name to return
* @return the fully-qualified name of an annotation as a String
*/
@CanonicalName
public static final String annotationName(AnnotationMirror annotation) {
if (annotation instanceof AnnotationBuilder.CheckerFrameworkAnnotationMirror) {
return ((AnnotationBuilder.CheckerFrameworkAnnotationMirror) annotation).annotationName;
}
final DeclaredType annoType = annotation.getAnnotationType();
final TypeElement elm = (TypeElement) annoType.asElement();
// JDK needs annotations
@SuppressWarnings("signature:assignment") @CanonicalName String name = elm.getQualifiedName().toString();
return name;
}
use of org.checkerframework.checker.signature.qual.CanonicalName in project checker-framework by typetools.
the class InterningVisitor method typeToCheck.
/**
* Returns the type to check.
*
* @return the type to check
*/
DeclaredType typeToCheck() {
// user input
@SuppressWarnings("signature:assignment") @CanonicalName String className = checker.getOption("checkclass");
if (className == null) {
return null;
}
TypeElement classElt = elements.getTypeElement(className);
if (classElt == null) {
return null;
}
return types.getDeclaredType(classElt);
}
Aggregations