@Override public void visit(Tree.BaseMemberExpression bme) { if (annotationConstructor != null) { Declaration declaration = bme.getDeclaration(); if (checkingInvocationPrimary && isAnnotationConstructor(bme.getDeclaration())) { Method ctor = (Method) bme.getDeclaration(); instantiation.setPrimary(ctor); if (ctor.getAnnotationConstructor() != null) { instantiation .getConstructorParameters() .addAll( ((AnnotationInvocation) ctor.getAnnotationConstructor()) .getConstructorParameters()); } } else if (checkingArguments || checkingDefaults) { if (declaration instanceof Value && ((Value) declaration).isParameter()) { Value constructorParameter = (Value) declaration; ParameterAnnotationTerm a = new ParameterAnnotationTerm(); a.setSpread(spread); // XXX Is this right? a.setSourceParameter(constructorParameter.getInitializerParameter()); this.term = a; } else if (isBooleanTrue(declaration)) { LiteralAnnotationTerm argument = new BooleanLiteralAnnotationTerm(true); appendLiteralArgument(bme, argument); } else if (isBooleanFalse(declaration)) { LiteralAnnotationTerm argument = new BooleanLiteralAnnotationTerm(false); appendLiteralArgument(bme, argument); } else if (bme.getUnit().isEmptyType(bme.getTypeModel()) && bme.getUnit().isIterableType(bme.getTypeModel()) && elements == null) { // If we're dealing with an iterable, empty means empty collection, not object endCollection(startCollection(bme), bme); } else if (Decl.isAnonCaseOfEnumeratedType(bme)) { LiteralAnnotationTerm argument = new ObjectLiteralAnnotationTerm(bme.getTypeModel()); appendLiteralArgument(bme, argument); } else { bme.addError( "compiler bug: unsupported base member expression in annotation constructor"); } } else { bme.addError("compiler bug: unsupported base member expression in annotation constructor"); } } }
private boolean isConstantValue(Declaration d) { if (d instanceof Value) { Value value = (Value) d; if (value.isShared() && !value.isVariable()) { Unit unit = value.getUnit(); TypeDeclaration type = value.getTypeDeclaration(); if (type == unit.getSequentialDeclaration()) { ProducedType elementType = unit.getIteratedType(value.getType()); type = elementType.getDeclaration(); } if (unit.getStringDeclaration().equals(type) || unit.getIntegerDeclaration().equals(type) || unit.getFloatDeclaration().equals(type) || unit.getCharacterDeclaration().equals(type)) { return true; } } } return false; }