use of javax.lang.model.element.TypeElement in project auto by google.
the class GwtCompatibility method gwtCompatibleAnnotationString.
String gwtCompatibleAnnotationString() {
if (gwtCompatibleAnnotation.isPresent()) {
AnnotationMirror annotation = gwtCompatibleAnnotation.get();
TypeElement annotationElement = (TypeElement) annotation.getAnnotationType().asElement();
String annotationArguments;
if (annotation.getElementValues().isEmpty()) {
annotationArguments = "";
} else {
List<String> elements = Lists.newArrayList();
for (Map.Entry<ExecutableElement, AnnotationValue> entry : getElementValues(annotation).entrySet()) {
elements.add(entry.getKey().getSimpleName() + " = " + entry.getValue());
}
annotationArguments = "(" + Joiner.on(", ").join(elements) + ")";
}
return "@" + annotationElement.getQualifiedName() + annotationArguments;
} else {
return "";
}
}
use of javax.lang.model.element.TypeElement in project squidb by yahoo.
the class ConstantCopyingPlugin method afterProcessVariableElements.
@Override
public void afterProcessVariableElements() {
// Look for additional constants in @Constant annotated inner classes
List<? extends Element> elements = modelSpec.getModelSpecElement().getEnclosedElements();
for (Element element : elements) {
if (element instanceof TypeElement && element.getAnnotation(Constants.class) != null) {
if (!element.getModifiers().containsAll(Arrays.asList(Modifier.PUBLIC, Modifier.STATIC))) {
utils.getMessager().printMessage(Diagnostic.Kind.WARNING, "@Constants annotated class is not " + "public static, will be ignored", element);
continue;
}
TypeElement constantClass = (TypeElement) element;
List<VariableElement> constantList = new ArrayList<>();
innerClassConstants.put(constantClass.getSimpleName().toString(), constantList);
for (Element e : constantClass.getEnclosedElements()) {
if (e instanceof VariableElement && e.getAnnotation(Ignore.class) == null) {
TypeName typeName = utils.getTypeNameFromTypeMirror(e.asType());
if (!(typeName instanceof DeclaredTypeName)) {
utils.getMessager().printMessage(Diagnostic.Kind.WARNING, "Element type " + typeName + " is not a concrete type, will be ignored", e);
} else {
processVariableElement((VariableElement) e, constantList);
}
}
}
}
}
}
use of javax.lang.model.element.TypeElement in project squidb by yahoo.
the class ImplementsPlugin method parseInterfaces.
private void parseInterfaces() {
TypeElement modelSpecElement = modelSpec.getModelSpecElement();
if (modelSpecElement.getAnnotation(Implements.class) != null) {
List<DeclaredTypeName> typeNames = utils.getTypeNamesFromAnnotationValue(utils.getAnnotationValue(modelSpecElement, Implements.class, "interfaceClasses"));
if (!AptUtils.isEmpty(typeNames)) {
interfaces.addAll(typeNames);
}
AnnotationValue value = utils.getAnnotationValue(modelSpecElement, Implements.class, "interfaceDefinitions");
List<AnnotationMirror> interfaceSpecs = utils.getValuesFromAnnotationValue(value, AnnotationMirror.class);
for (AnnotationMirror spec : interfaceSpecs) {
AnnotationValue interfaceClassValue = utils.getAnnotationValueFromMirror(spec, "interfaceClass");
List<DeclaredTypeName> interfaceClassList = utils.getTypeNamesFromAnnotationValue(interfaceClassValue);
if (!AptUtils.isEmpty(interfaceClassList)) {
DeclaredTypeName interfaceClass = interfaceClassList.get(0);
AnnotationValue interfaceTypeArgsValue = utils.getAnnotationValueFromMirror(spec, "interfaceTypeArgs");
List<DeclaredTypeName> typeArgs = utils.getTypeNamesFromAnnotationValue(interfaceTypeArgsValue);
if (AptUtils.isEmpty(typeArgs)) {
List<String> typeArgNames = utils.getValuesFromAnnotationValue(utils.getAnnotationValueFromMirror(spec, "interfaceTypeArgNames"), String.class);
for (String typeArgName : typeArgNames) {
typeArgs.add(new DeclaredTypeName(typeArgName));
}
}
interfaceClass.setTypeArgs(typeArgs);
interfaces.add(interfaceClass);
}
}
}
}
use of javax.lang.model.element.TypeElement in project j2objc by google.
the class JdtTypes method resolvePrimitiveType.
private void resolvePrimitiveType(AST ast, TypeKind kind, String pName, String cName) {
PrimitiveType primitiveType = (PrimitiveType) BindingConverter.getType(ast.resolveWellKnownType(pName));
TypeElement classElement = BindingConverter.getTypeElement(ast.resolveWellKnownType(cName));
primitiveTypes.put(kind, primitiveType);
boxedClasses.put(kind, classElement);
unboxedTypes.put(classElement, primitiveType);
}
use of javax.lang.model.element.TypeElement in project j2objc by google.
the class TreeConverter method addImplicitSuperCall.
private static void addImplicitSuperCall(MethodDeclaration node) {
ExecutableElement method = node.getExecutableElement();
DeclaredType superType = (DeclaredType) ElementUtil.getDeclaringClass(method).getSuperclass();
TypeElement superClass = TypeUtil.asTypeElement(superType);
ExecutableElement superConstructor = findDefaultConstructorElement(superClass);
SuperConstructorInvocation invocation = new SuperConstructorInvocation(new ExecutablePair(superConstructor, (ExecutableType) JdtTypes.asMemberOfInternal(superType, superConstructor))).setVarargsType(getVarargsType(BindingConverter.unwrapExecutableElement(superConstructor), Collections.emptyList()));
node.getBody().addStatement(0, invocation);
}
Aggregations