use of javax.lang.model.element.TypeElement in project neo4j by neo4j.
the class ServiceProcessor method process.
@SuppressWarnings("unchecked")
@Override
protected void process(TypeElement annotationType, Element annotated, AnnotationMirror annotation, Map<? extends ExecutableElement, ? extends AnnotationValue> values) throws IOException {
for (AnnotationValue o : (List<? extends AnnotationValue>) values.values().iterator().next().getValue()) {
TypeMirror service = (TypeMirror) o.getValue();
addTo(((TypeElement) annotated).getQualifiedName().toString(), "META-INF", "services", service.toString());
}
}
use of javax.lang.model.element.TypeElement in project OpenAM by OpenRock.
the class UpgradeStepProcessor method process.
@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
if (!roundEnv.processingOver()) {
Set<? extends Element> elements = roundEnv.getElementsAnnotatedWith(UpgradeStepInfo.class);
for (Element element : elements) {
Set<DependencyInfo> depends = new LinkedHashSet<DependencyInfo>(2);
String annotatedType = element.asType().toString();
UpgradeStepInfo annotation = element.getAnnotation(UpgradeStepInfo.class);
for (String name : annotation.dependsOn()) {
DependencyInfo depInfo = stepMappings.get(name);
if (depInfo == null) {
depInfo = new DependencyInfo(name);
stepMappings.put(name, depInfo);
}
depends.add(depInfo);
}
DependencyInfo depInfo = stepMappings.get(annotatedType);
if (depInfo == null) {
depInfo = new DependencyInfo(annotatedType);
stepMappings.put(annotatedType, depInfo);
}
for (DependencyInfo dep : depends) {
depInfo.dependencies.add(dep);
}
}
createDAG();
}
return true;
}
use of javax.lang.model.element.TypeElement in project butterknife by JakeWharton.
the class ButterKnifeProcessor method parseRClass.
private void parseRClass(String respectivePackageName, String rClass) {
Element element;
try {
element = elementUtils.getTypeElement(rClass);
} catch (MirroredTypeException mte) {
element = typeUtils.asElement(mte.getTypeMirror());
}
JCTree tree = (JCTree) trees.getTree(element);
if (tree != null) {
// tree can be null if the references are compiled types and not source
IdScanner idScanner = new IdScanner(symbols, elementUtils.getPackageOf(element).getQualifiedName().toString(), respectivePackageName);
tree.accept(idScanner);
} else {
parseCompiledR(respectivePackageName, (TypeElement) element);
}
}
use of javax.lang.model.element.TypeElement in project ig-json-parser by Instagram.
the class JsonAnnotationProcessor method isFieldAnnotationValid.
private boolean isFieldAnnotationValid(Class<? extends Annotation> annotationClass, Element element) {
TypeElement enclosingElement = (TypeElement) element.getEnclosingElement();
// Verify containing type.
if (enclosingElement.getKind() != CLASS) {
error(enclosingElement, "@%s field may only be contained in classes. (%s.%s)", annotationClass.getSimpleName(), enclosingElement.getQualifiedName(), element.getSimpleName());
return false;
}
Annotation annotation = enclosingElement.getAnnotation(JsonType.class);
if (annotation == null) {
error(enclosingElement, "@%s field may only be contained in classes annotated with @%s (%s.%s)", annotationClass.getSimpleName(), JsonType.class.toString(), enclosingElement.getQualifiedName(), element.getSimpleName());
return false;
}
// Verify containing class visibility is not private.
if (enclosingElement.getModifiers().contains(PRIVATE)) {
error(enclosingElement, "@%s %s may not be contained in private classes. (%s.%s)", annotationClass.getSimpleName(), enclosingElement.getQualifiedName(), element.getSimpleName());
return false;
}
return true;
}
use of javax.lang.model.element.TypeElement 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;
}
Aggregations