use of org.eclipse.ceylon.model.loader.mirror.AnnotationMirror in project ceylon by eclipse.
the class AnnotationLoader method loadLiteralAnnotationTerm.
/**
* Loads a LiteralAnnotationTerm according to the presence of
* <ul>
* <li>{@code @StringValue} <li>{@code @IntegerValue} <li>etc
* </ul>
* @param ctorParam
*/
private LiteralAnnotationTerm loadLiteralAnnotationTerm(LazyFunction method, Parameter parameter, AnnotatedMirror mm) {
// FIXME: store iterable info somewhere else
boolean singleValue = !typeFactory.isIterableType(parameter.getType()) || parameter.getType().isString();
AnnotationMirror valueAnnotation = mm.getAnnotation(AbstractModelLoader.CEYLON_STRING_VALUE_ANNOTATION);
if (valueAnnotation != null) {
return readStringValuesAnnotation(valueAnnotation, singleValue);
}
valueAnnotation = mm.getAnnotation(AbstractModelLoader.CEYLON_INTEGER_VALUE_ANNOTATION);
if (valueAnnotation != null) {
return readIntegerValuesAnnotation(valueAnnotation, singleValue);
}
valueAnnotation = mm.getAnnotation(AbstractModelLoader.CEYLON_BOOLEAN_VALUE_ANNOTATION);
if (valueAnnotation != null) {
return readBooleanValuesAnnotation(valueAnnotation, singleValue);
}
valueAnnotation = mm.getAnnotation(AbstractModelLoader.CEYLON_DECLARATION_VALUE_ANNOTATION);
if (valueAnnotation != null) {
return readDeclarationValuesAnnotation(valueAnnotation, singleValue);
}
valueAnnotation = mm.getAnnotation(AbstractModelLoader.CEYLON_OBJECT_VALUE_ANNOTATION);
if (valueAnnotation != null) {
return readObjectValuesAnnotation(ModelUtil.getModuleContainer(method), valueAnnotation, singleValue);
}
valueAnnotation = mm.getAnnotation(AbstractModelLoader.CEYLON_CHARACTER_VALUE_ANNOTATION);
if (valueAnnotation != null) {
return readCharacterValuesAnnotation(valueAnnotation, singleValue);
}
valueAnnotation = mm.getAnnotation(AbstractModelLoader.CEYLON_FLOAT_VALUE_ANNOTATION);
if (valueAnnotation != null) {
return readFloatValuesAnnotation(valueAnnotation, singleValue);
}
return null;
}
use of org.eclipse.ceylon.model.loader.mirror.AnnotationMirror in project ceylon by eclipse.
the class AbstractModelLoader method addInnerClassesFromAnnotation.
private void addInnerClassesFromAnnotation(ClassOrInterface klass, AnnotationMirror membersAnnotation) {
@SuppressWarnings("unchecked") List<AnnotationMirror> members = (List<AnnotationMirror>) membersAnnotation.getValue();
for (AnnotationMirror member : members) {
TypeMirror javaClassMirror = (TypeMirror) member.getValue("klass");
String javaClassName;
// void.class is the default value, I guess it's a primitive?
if (javaClassMirror != null && !javaClassMirror.isPrimitive()) {
javaClassName = javaClassMirror.getQualifiedName();
} else {
// we get the class name as a string
String name = (String) member.getValue("javaClassName");
ClassMirror container = null;
if (klass instanceof LazyClass) {
container = ((LazyClass) klass).classMirror;
} else if (klass instanceof LazyInterface) {
if (((LazyInterface) klass).isCeylon())
container = ((LazyInterface) klass).companionClass;
else
container = ((LazyInterface) klass).classMirror;
}
if (container == null)
throw new ModelResolutionException("Unknown container type: " + klass + " when trying to load inner class " + name);
javaClassName = container.getQualifiedName() + "$" + name;
}
Declaration innerDecl = convertToDeclaration(ModelUtil.getModuleContainer(klass), klass, javaClassName, DeclarationType.TYPE);
if (innerDecl == null)
throw new ModelResolutionException("Failed to load inner type " + javaClassName + " for outer type " + klass.getQualifiedNameString());
if (shouldLinkNatives(innerDecl)) {
initNativeHeaderMember(innerDecl);
}
}
}
use of org.eclipse.ceylon.model.loader.mirror.AnnotationMirror in project ceylon by eclipse.
the class AbstractModelLoader method readModelAnnotation.
private Annotation readModelAnnotation(AnnotationMirror annotation) {
Annotation modelAnnotation = new Annotation();
modelAnnotation.setName((String) annotation.getValue());
@SuppressWarnings("unchecked") List<String> arguments = (List<String>) annotation.getValue("arguments");
if (arguments != null) {
modelAnnotation.getPositionalArguments().addAll(arguments);
} else {
@SuppressWarnings("unchecked") List<AnnotationMirror> namedArguments = (List<AnnotationMirror>) annotation.getValue("namedArguments");
if (namedArguments != null) {
for (AnnotationMirror namedArgument : namedArguments) {
String argName = (String) namedArgument.getValue("name");
String argValue = (String) namedArgument.getValue("value");
modelAnnotation.getNamedArguments().put(argName, argValue);
}
}
}
return modelAnnotation;
}
use of org.eclipse.ceylon.model.loader.mirror.AnnotationMirror in project ceylon by eclipse.
the class AbstractModelLoader method addLocalDeclarations.
private void addLocalDeclarations(LocalDeclarationContainer container, ClassMirror classContainerMirror, AnnotatedMirror annotatedMirror) {
if (!needsLocalDeclarations())
return;
AnnotationMirror annotation = annotatedMirror.getAnnotation(CEYLON_LOCAL_DECLARATIONS_ANNOTATION);
if (annotation == null)
return;
List<String> values = getAnnotationStringValues(annotation, "value");
String parentClassName = classContainerMirror.getQualifiedName();
Package pkg = ModelUtil.getPackageContainer(container);
Module module = pkg.getModule();
for (String scope : values) {
// assemble the name with the parent
String name;
if (scope.startsWith("::")) {
// interface pulled to toplevel
name = pkg.getNameAsString() + "." + scope.substring(2);
} else {
name = parentClassName;
name += "$" + scope;
}
Declaration innerDecl = convertToDeclaration(module, (Declaration) container, name, DeclarationType.TYPE);
if (innerDecl == null)
throw new ModelResolutionException("Failed to load local type " + name + " for outer type " + container.getQualifiedNameString());
}
}
use of org.eclipse.ceylon.model.loader.mirror.AnnotationMirror in project ceylon by eclipse.
the class AbstractModelLoader method makeLazyInterface.
protected LazyInterface makeLazyInterface(ClassMirror classMirror, boolean isNativeHeader) {
LazyInterface iface = new LazyInterface(classMirror, this);
iface.setSealed(classMirror.getAnnotation(CEYLON_LANGUAGE_SEALED_ANNOTATION) != null);
iface.setDynamic(classMirror.getAnnotation(CEYLON_DYNAMIC_ANNOTATION) != null);
if (iface.isCeylon()) {
AnnotationMirror container = classMirror.getAnnotation(CEYLON_CONTAINER_ANNOTATION);
if (container != null) {
Object value = container.getValue("isStatic");
if (value != null) {
iface.setStatic(Boolean.TRUE.equals(value));
}
}
} else {
iface.setStatic(classMirror.getEnclosingClass() != null);
}
manageNativeBackend(iface, classMirror, isNativeHeader);
return iface;
}
Aggregations