use of org.graalvm.compiler.nodeinfo.NodeInfo in project graal by oracle.
the class GraphNodeProcessor method process.
@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
if (roundEnv.processingOver()) {
return false;
}
GraphNodeVerifier verifier = new GraphNodeVerifier(this);
for (Element element : roundEnv.getElementsAnnotatedWith(NodeInfo.class)) {
scope = element;
try {
if (!isNodeType(element)) {
errorMessage(element, "%s can only be applied to Node subclasses", NodeInfo.class.getSimpleName());
continue;
}
NodeInfo nodeInfo = element.getAnnotation(NodeInfo.class);
if (nodeInfo == null) {
errorMessage(element, "Cannot get %s annotation from annotated element", NodeInfo.class.getSimpleName());
continue;
}
TypeElement typeElement = (TypeElement) element;
Set<Modifier> modifiers = typeElement.getModifiers();
if (!modifiers.contains(Modifier.FINAL) && !modifiers.contains(Modifier.ABSTRACT)) {
// TODO(thomaswue): Reenable this check.
// errorMessage(element, "%s annotated class must be either final or abstract",
// NodeInfo.class.getSimpleName());
// continue;
}
boolean found = false;
for (Element e : typeElement.getEnclosedElements()) {
if (e.getKind() == ElementKind.FIELD) {
if (e.getSimpleName().toString().equals("TYPE")) {
found = true;
break;
}
}
}
if (!found) {
errorMessage(element, "%s annotated class must have a field named TYPE", NodeInfo.class.getSimpleName());
}
if (!typeElement.equals(verifier.Node) && !modifiers.contains(Modifier.ABSTRACT)) {
verifier.verify(typeElement);
}
} catch (ElementException ee) {
errorMessage(ee.element, ee.getMessage());
} catch (Throwable t) {
reportException(isBug367599(t) ? Kind.NOTE : Kind.ERROR, element, t);
} finally {
scope = null;
}
}
return false;
}
Aggregations