use of javax.lang.model.type.TypeMirror in project j2objc by google.
the class TreeConverter method needsImplicitSuperCall.
private static boolean needsImplicitSuperCall(MethodDeclaration node) {
ExecutableElement method = node.getExecutableElement();
if (!ElementUtil.isConstructor(method)) {
return false;
}
TypeMirror superType = ElementUtil.getDeclaringClass(method).getSuperclass();
if (TypeUtil.isNone(superType)) {
// java.lang.Object supertype is null.
return false;
}
List<Statement> stmts = node.getBody().getStatements();
if (stmts.isEmpty()) {
return true;
}
Statement firstStmt = stmts.get(0);
return !(firstStmt instanceof SuperConstructorInvocation || firstStmt instanceof ConstructorInvocation);
}
use of javax.lang.model.type.TypeMirror in project j2objc by google.
the class JdtIntersectionType method fromJdtIntersection.
static JdtIntersectionType fromJdtIntersection(ITypeBinding t) {
List<TypeMirror> bounds = new ArrayList<>();
ITypeBinding superclass = t.getSuperclass();
if (superclass != null) {
bounds.add(BindingConverter.getType(superclass));
}
for (ITypeBinding intrface : t.getInterfaces()) {
bounds.add(BindingConverter.getType(intrface));
}
return new JdtIntersectionType(t, bounds);
}
use of javax.lang.model.type.TypeMirror in project j2objc by google.
the class TreeConverter method convertIntersectionType.
private static TreeNode convertIntersectionType(org.eclipse.jdt.core.dom.IntersectionType node) {
TypeMirror type = BindingConverter.getType(node.resolveBinding());
IntersectionType newNode = new IntersectionType(type);
for (Object x : node.types()) {
newNode.addType((Type) convert(x));
}
return newNode;
}
use of javax.lang.model.type.TypeMirror in project error-prone by google.
the class RequiredAnnotationProcessor method validateElement.
private void validateElement(final Element element) {
TypeMirror requiredAnnotationTypeMirror = processingEnv.getElementUtils().getTypeElement(RequiredAnnotation.class.getName()).asType();
for (final AnnotationMirror annotation : processingEnv.getElementUtils().getAllAnnotationMirrors(element)) {
AnnotationMirror requiredAnnotationMirror = getAnnotationMirror(annotation.getAnnotationType().asElement(), requiredAnnotationTypeMirror);
if (requiredAnnotationMirror == null) {
continue;
}
AnnotationValue value = getAnnotationValue(requiredAnnotationMirror, "value");
if (value == null) {
continue;
}
new SimpleAnnotationValueVisitor7<Void, Void>() {
@Override
public Void visitType(TypeMirror t, Void p) {
if (getAnnotationMirror(element, t) == null) {
printError(element, annotation, "Annotation %s on %s also requires %s", annotation, element, t);
}
return null;
}
@Override
public Void visitArray(List<? extends AnnotationValue> vals, Void p) {
for (AnnotationValue val : vals) {
visit(val);
}
return null;
}
}.visit(value);
}
validateElements(element.getEnclosedElements());
}
use of javax.lang.model.type.TypeMirror in project camel by apache.
the class CoreEipAnnotationProcessor method findClassProperties.
protected void findClassProperties(ProcessingEnvironment processingEnv, PrintWriter writer, RoundEnvironment roundEnv, Set<EipOption> eipOptions, TypeElement originalClassType, TypeElement classElement, String prefix, String modelName) {
while (true) {
List<VariableElement> fieldElements = ElementFilter.fieldsIn(classElement.getEnclosedElements());
for (VariableElement fieldElement : fieldElements) {
String fieldName = fieldElement.getSimpleName().toString();
XmlAttribute attribute = fieldElement.getAnnotation(XmlAttribute.class);
if (attribute != null) {
boolean skip = processAttribute(processingEnv, roundEnv, originalClassType, classElement, fieldElement, fieldName, attribute, eipOptions, prefix, modelName);
if (skip) {
continue;
}
}
XmlValue value = fieldElement.getAnnotation(XmlValue.class);
if (value != null) {
processValue(processingEnv, roundEnv, originalClassType, classElement, fieldElement, fieldName, value, eipOptions, prefix, modelName);
}
XmlElements elements = fieldElement.getAnnotation(XmlElements.class);
if (elements != null) {
processElements(processingEnv, roundEnv, classElement, elements, fieldElement, eipOptions, prefix);
}
XmlElement element = fieldElement.getAnnotation(XmlElement.class);
if (element != null) {
processElement(processingEnv, roundEnv, classElement, element, fieldElement, eipOptions, prefix);
}
// special for eips which has outputs or requires an expressions
XmlElementRef elementRef = fieldElement.getAnnotation(XmlElementRef.class);
if (elementRef != null) {
// special for routes
processRoutes(roundEnv, originalClassType, elementRef, fieldElement, fieldName, eipOptions, prefix);
// special for outputs
processOutputs(processingEnv, roundEnv, originalClassType, elementRef, fieldElement, fieldName, eipOptions, prefix);
// special for when clauses (choice eip)
processRefWhenClauses(processingEnv, roundEnv, originalClassType, elementRef, fieldElement, fieldName, eipOptions, prefix);
// special for rests (rest-dsl)
processRests(roundEnv, originalClassType, elementRef, fieldElement, fieldName, eipOptions, prefix);
// special for verbs (rest-dsl)
processVerbs(processingEnv, roundEnv, originalClassType, elementRef, fieldElement, fieldName, eipOptions, prefix);
// special for expression
processRefExpression(processingEnv, roundEnv, originalClassType, classElement, elementRef, fieldElement, fieldName, eipOptions, prefix);
}
}
// special when we process these nodes as they do not use JAXB annotations on fields, but on methods
if ("OptionalIdentifiedDefinition".equals(classElement.getSimpleName().toString())) {
processIdentified(processingEnv, roundEnv, originalClassType, classElement, eipOptions, prefix);
} else if ("RouteDefinition".equals(classElement.getSimpleName().toString())) {
processRoute(processingEnv, roundEnv, originalClassType, classElement, eipOptions, prefix);
}
// check super classes which may also have fields
TypeElement baseTypeElement = null;
TypeMirror superclass = classElement.getSuperclass();
if (superclass != null) {
String superClassName = canonicalClassName(superclass.toString());
baseTypeElement = findTypeElement(processingEnv, roundEnv, superClassName);
}
if (baseTypeElement != null) {
classElement = baseTypeElement;
} else {
break;
}
}
}
Aggregations