use of javax.lang.model.type.DeclaredType in project ig-json-parser by Instagram.
the class TypeUtils method getParseType.
public ParseType getParseType(TypeMirror typeMirror, Class<? extends Annotation> typeAnnotationClass) {
if (typeMirror == null) {
return ParseType.UNSUPPORTED;
} else if (JAVA_LANG_STRING.equals(typeMirror.toString())) {
return ParseType.STRING;
} else if (typeMirror.getKind() == TypeKind.BOOLEAN) {
return ParseType.BOOLEAN;
} else if (JAVA_LANG_BOOLEAN.equals(typeMirror.toString())) {
return ParseType.BOOLEAN_OBJECT;
} else if (typeMirror.getKind() == TypeKind.INT) {
return ParseType.INTEGER;
} else if (JAVA_LANG_INTEGER.equals(typeMirror.toString())) {
return ParseType.INTEGER_OBJECT;
} else if (typeMirror.getKind() == TypeKind.LONG) {
return ParseType.LONG;
} else if (JAVA_LANG_LONG.equals(typeMirror.toString())) {
return ParseType.LONG_OBJECT;
} else if (typeMirror.getKind() == TypeKind.FLOAT) {
return ParseType.FLOAT;
} else if (JAVA_LANG_FLOAT.equals(typeMirror.toString())) {
return ParseType.FLOAT_OBJECT;
} else if (typeMirror.getKind() == TypeKind.DOUBLE) {
return ParseType.DOUBLE;
} else if (JAVA_LANG_DOUBLE.equals(typeMirror.toString())) {
return ParseType.DOUBLE_OBJECT;
} else if (typeMirror instanceof DeclaredType) {
DeclaredType type = (DeclaredType) typeMirror;
Element element = type.asElement();
Annotation annotation = element.getAnnotation(typeAnnotationClass);
if (annotation != null) {
return ParseType.PARSABLE_OBJECT;
}
// is it an enum?
if (element instanceof TypeElement) {
TypeElement typeElement = (TypeElement) element;
TypeMirror superclass = typeElement.getSuperclass();
if (superclass instanceof DeclaredType) {
DeclaredType superclassDeclaredType = (DeclaredType) superclass;
if (JAVA_LANG_ENUM.equals(getCanonicalTypeName(superclassDeclaredType))) {
return ParseType.ENUM_OBJECT;
}
}
}
}
return ParseType.UNSUPPORTED;
}
use of javax.lang.model.type.DeclaredType in project spring-framework by spring-projects.
the class TypeHelper method getType.
public String getType(TypeMirror type) {
if (type == null) {
return null;
}
if (type instanceof DeclaredType) {
DeclaredType declaredType = (DeclaredType) type;
Element enclosingElement = declaredType.asElement().getEnclosingElement();
if (enclosingElement != null && enclosingElement instanceof TypeElement) {
return getQualifiedName(enclosingElement) + "$" + declaredType.asElement().getSimpleName().toString();
} else {
return getQualifiedName(declaredType.asElement());
}
}
return type.toString();
}
use of javax.lang.model.type.DeclaredType in project ceylon-compiler by ceylon.
the class P method process.
@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
if (!ran) {
ran = true;
ExecutableElement m = getFirstMethodIn("C");
System.err.println("method: " + m);
TypeMirror type = (DeclaredType) m.getParameters().get(0).asType();
System.err.println("parameters[0]: " + type);
if (!isParameterized(type))
throw new AssertionError(type);
type = ((ExecutableType) m.asType()).getParameterTypes().get(0);
System.err.println("parameterTypes[0]: " + type);
if (!isParameterized(type))
throw new AssertionError(type);
System.err.println();
}
return true;
}
use of javax.lang.model.type.DeclaredType in project ceylon-compiler by ceylon.
the class MyScanner method testParseType.
void testParseType(TypeElement clazz) {
DeclaredType type = (DeclaredType) task.parseType("List<String>", clazz);
for (Element member : elements.getAllMembers((TypeElement) type.asElement())) {
TypeMirror mt = types.asMemberOf(type, member);
System.out.format("%s : %s -> %s%n", member.getSimpleName(), member.asType(), mt);
numParseTypeElements++;
}
}
use of javax.lang.model.type.DeclaredType in project ceylon-compiler by ceylon.
the class TestResolveError method testParseType.
void testParseType(TypeElement clazz) {
DeclaredType type = (DeclaredType) task.parseType("List<String>", clazz);
for (Element member : elements.getAllMembers((TypeElement) type.asElement())) {
TypeMirror mt = types.asMemberOf(type, member);
System.out.format("%s : %s -> %s%n", member.getSimpleName(), member.asType(), mt);
}
}
Aggregations