use of com.oracle.truffle.dsl.processor.model.MessageContainer in project graal by oracle.
the class AbstractParser method parse.
public final M parse(Element element) {
M model = null;
try {
AnnotationMirror mirror = null;
if (getAnnotationType() != null) {
mirror = ElementUtils.findAnnotationMirror(processingEnv, element.getAnnotationMirrors(), getAnnotationType());
}
if (!context.getTruffleTypes().verify(context, element, mirror)) {
return null;
}
model = parse(element, mirror);
if (model == null) {
return null;
}
redirectMessages(new HashSet<MessageContainer>(), model, model);
model.emitMessages(context, log);
if (model instanceof NodeData) {
return model;
} else {
return filterErrorElements(model);
}
} catch (CompileErrorException e) {
log.message(Kind.WARNING, element, null, null, "The truffle processor could not parse class due to error: %s", e.getMessage());
return null;
}
}
use of com.oracle.truffle.dsl.processor.model.MessageContainer in project graal by oracle.
the class AbstractParser method redirectMessages.
private void redirectMessages(Set<MessageContainer> visitedSinks, MessageContainer model, MessageContainer baseContainer) {
List<Message> messages = model.getMessages();
for (int i = messages.size() - 1; i >= 0; i--) {
Message message = messages.get(i);
if (!ElementUtils.isEnclosedIn(baseContainer.getMessageElement(), message.getOriginalContainer().getMessageElement())) {
// redirect message
MessageContainer original = message.getOriginalContainer();
String text = wrapText(original.getMessageElement(), original.getMessageAnnotation(), message.getText());
Message redirectedMessage = new Message(null, null, baseContainer, text, message.getKind());
model.getMessages().remove(i);
baseContainer.getMessages().add(redirectedMessage);
}
}
for (MessageContainer childContainer : model) {
if (visitedSinks.contains(childContainer)) {
continue;
}
visitedSinks.add(childContainer);
MessageContainer newBase = baseContainer;
if (childContainer.getBaseContainer() != null) {
newBase = childContainer.getBaseContainer();
}
redirectMessages(visitedSinks, childContainer, newBase);
}
}
Aggregations