return new String(newName);
}
private void addValue(ClassOrInterface klass, String ceylonName, FieldMirror fieldMirror, boolean isCeylon) {
// make sure it's a FieldValue so we can figure it out in the backend
Value value = new FieldValue(fieldMirror.getName());
value.setContainer(klass);
value.setScope(klass);
// use the name annotation if present (used by Java arrays)
String nameAnnotation = getAnnotationStringValue(fieldMirror, CEYLON_NAME_ANNOTATION);
value.setName(nameAnnotation != null ? nameAnnotation : ceylonName);
value.setUnit(klass.getUnit());
value.setShared(fieldMirror.isPublic() || fieldMirror.isProtected() || fieldMirror.isDefaultAccess());
value.setProtectedVisibility(fieldMirror.isProtected());
value.setPackageVisibility(fieldMirror.isDefaultAccess());
value.setStaticallyImportable(fieldMirror.isStatic());
// field can't be abstract or interface, so not formal
// can we override fields? good question. Not really, but from an external point of view?
// FIXME: figure this out: (default)
// FIXME: for the same reason, can it be an overriding field? (actual)
value.setVariable(!fieldMirror.isFinal());
// figure out if it's an enum subtype in a final static field
if(fieldMirror.getType().getKind() == TypeKind.DECLARED
&& fieldMirror.getType().getDeclaredClass() != null
&& fieldMirror.getType().getDeclaredClass().isEnum()
&& fieldMirror.isFinal()
&& fieldMirror.isStatic())
value.setEnumValue(true);
ProducedType type = obtainType(fieldMirror.getType(), fieldMirror, klass, Decl.getModuleContainer(klass), VarianceLocation.INVARIANT,
"field '"+value.getName()+"'", klass);
if (value.isEnumValue()) {
Class enumValueType = new Class();
enumValueType.setAnonymous(true);
enumValueType.setExtendedType(type);
enumValueType.setContainer(value.getContainer());
enumValueType.setScope(value.getContainer());
enumValueType.setDeprecated(value.isDeprecated());
enumValueType.setName(value.getName());
enumValueType.setFinal(true);
enumValueType.setUnit(value.getUnit());
enumValueType.setStaticallyImportable(value.isStaticallyImportable());
value.setType(enumValueType.getType());
value.setUncheckedNullType(false);
} else {
value.setType(type);
value.setUncheckedNullType((!isCeylon && !fieldMirror.getType().isPrimitive()) || isUncheckedNull(fieldMirror));
}
type.setRaw(isRaw(Decl.getModuleContainer(klass), fieldMirror.getType()));
markUnboxed(value, null, fieldMirror.getType());
markTypeErased(value, fieldMirror, fieldMirror.getType());