* Continues resolution of the given {@link Annotation}.
*
* @param annotation the {@link Annotation} to resolve
*/
private void resolveAnnotationElement(Annotation annotation) {
SimpleIdentifier nameNode1;
SimpleIdentifier nameNode2;
{
Identifier annName = annotation.getName();
if (annName instanceof PrefixedIdentifier) {
PrefixedIdentifier prefixed = (PrefixedIdentifier) annName;
nameNode1 = prefixed.getPrefix();
nameNode2 = prefixed.getIdentifier();
} else {
nameNode1 = (SimpleIdentifier) annName;
nameNode2 = null;
}
}
SimpleIdentifier nameNode3 = annotation.getConstructorName();
ConstructorElement constructor = null;
//
// CONST or Class(args)
//
if (nameNode1 != null && nameNode2 == null && nameNode3 == null) {
Element element1 = nameNode1.getStaticElement();
// CONST
if (element1 instanceof PropertyAccessorElement) {
resolveAnnotationElementGetter(annotation, (PropertyAccessorElement) element1);
return;
}
// Class(args)
if (element1 instanceof ClassElement) {
ClassElement classElement = (ClassElement) element1;
constructor = new InterfaceTypeImpl(classElement).lookUpConstructor(null, definingLibrary);
}
}
//
// prefix.CONST or prefix.Class() or Class.CONST or Class.constructor(args)
//
if (nameNode1 != null && nameNode2 != null && nameNode3 == null) {
Element element1 = nameNode1.getStaticElement();
Element element2 = nameNode2.getStaticElement();
// Class.CONST - not resolved yet
if (element1 instanceof ClassElement) {
ClassElement classElement = (ClassElement) element1;
element2 = classElement.lookUpGetter(nameNode2.getName(), definingLibrary);
}
// prefix.CONST or Class.CONST
if (element2 instanceof PropertyAccessorElement) {
nameNode2.setStaticElement(element2);
annotation.setElement(element2);
resolveAnnotationElementGetter(annotation, (PropertyAccessorElement) element2);
return;
}
// prefix.Class()
if (element2 instanceof ClassElement) {
ClassElement classElement = (ClassElement) element2;
constructor = classElement.getUnnamedConstructor();
}
// Class.constructor(args)
if (element1 instanceof ClassElement) {
ClassElement classElement = (ClassElement) element1;
constructor = new InterfaceTypeImpl(classElement).lookUpConstructor(
nameNode2.getName(),
definingLibrary);
nameNode2.setStaticElement(constructor);
}
}
//
// prefix.Class.CONST or prefix.Class.constructor(args)
//
if (nameNode1 != null && nameNode2 != null && nameNode3 != null) {
Element element2 = nameNode2.getStaticElement();
// element2 should be ClassElement
if (element2 instanceof ClassElement) {
ClassElement classElement = (ClassElement) element2;
String name3 = nameNode3.getName();
// prefix.Class.CONST
PropertyAccessorElement getter = classElement.lookUpGetter(name3, definingLibrary);
if (getter != null) {
nameNode3.setStaticElement(getter);
annotation.setElement(element2);
resolveAnnotationElementGetter(annotation, getter);
return;
}
// prefix.Class.constructor(args)
constructor = new InterfaceTypeImpl(classElement).lookUpConstructor(name3, definingLibrary);
nameNode3.setStaticElement(constructor);
}
}
// we need constructor
if (constructor == null) {
resolver.reportErrorForNode(CompileTimeErrorCode.INVALID_ANNOTATION, annotation);