use of org.teiid.query.sql.navigator.PreOrderNavigator in project teiid by teiid.
the class Validator method executeValidation.
private static final void executeValidation(LanguageObject object, final QueryMetadataInterface metadata, final AbstractValidationVisitor visitor) throws TeiidComponentException {
// Reset visitor
visitor.reset();
visitor.setMetadata(metadata);
setTempMetadata(metadata, visitor, object);
PreOrderNavigator nav = new PreOrderNavigator(visitor) {
protected void visitNode(LanguageObject obj) {
QueryMetadataInterface previous = visitor.getMetadata();
setTempMetadata(metadata, visitor, obj);
super.visitNode(obj);
visitor.setMetadata(previous);
}
@Override
protected void preVisitVisitor(LanguageObject obj) {
super.preVisitVisitor(obj);
visitor.stack.add(obj);
}
@Override
protected void postVisitVisitor(LanguageObject obj) {
visitor.stack.pop();
}
};
object.acceptVisitor(nav);
// If an error occurred, throw an exception
TeiidComponentException e = visitor.getException();
if (e != null) {
throw e;
}
}
use of org.teiid.query.sql.navigator.PreOrderNavigator in project teiid by teiid.
the class CommandCollectorVisitor method getCommands.
public static final List<Command> getCommands(Command command, boolean includeExpanded) {
CommandCollectorVisitor visitor = new CommandCollectorVisitor();
visitor.collectExpanded = includeExpanded;
final boolean visitCommands = command instanceof SetQuery;
PreOrderNavigator navigator = new PreOrderNavigator(visitor) {
@Override
protected void visitNode(LanguageObject obj) {
if (!visitCommands && obj instanceof Command) {
return;
}
super.visitNode(obj);
}
};
command.acceptVisitor(navigator);
return visitor.getCommands();
}
Aggregations