Search in sources :

Example 1 with Labeled

use of org.teiid.query.sql.proc.Statement.Labeled in project teiid by teiid.

the class ValidationVisitor method visit.

@Override
public void visit(BranchingStatement obj) {
    boolean matchedLabel = false;
    boolean inLoop = false;
    for (LanguageObject lo : stack) {
        if (lo instanceof LoopStatement || lo instanceof WhileStatement) {
            inLoop = true;
            if (obj.getLabel() == null) {
                break;
            }
            matchedLabel |= obj.getLabel().equalsIgnoreCase(((Labeled) lo).getLabel());
        } else if (obj.getLabel() != null && lo instanceof Block && obj.getLabel().equalsIgnoreCase(((Block) lo).getLabel())) {
            matchedLabel = true;
            if (obj.getMode() != BranchingMode.LEAVE) {
                // $NON-NLS-1$
                handleValidationError(QueryPlugin.Util.getString("ValidationVisitor.invalid_label", obj.getLabel()), obj);
            }
        }
    }
    if (obj.getMode() != BranchingMode.LEAVE && !inLoop) {
        // $NON-NLS-1$
        handleValidationError(QueryPlugin.Util.getString("ValidationVisitor.no_loop"), obj);
    }
    if (obj.getLabel() != null && !matchedLabel) {
        // $NON-NLS-1$
        handleValidationError(QueryPlugin.Util.getString("ValidationVisitor.unknown_block_label", obj.getLabel()), obj);
    }
}
Also used : Labeled(org.teiid.query.sql.proc.Statement.Labeled) Block(org.teiid.query.sql.proc.Block) LoopStatement(org.teiid.query.sql.proc.LoopStatement) WhileStatement(org.teiid.query.sql.proc.WhileStatement) LanguageObject(org.teiid.query.sql.LanguageObject)

Aggregations

LanguageObject (org.teiid.query.sql.LanguageObject)1 Block (org.teiid.query.sql.proc.Block)1 LoopStatement (org.teiid.query.sql.proc.LoopStatement)1 Labeled (org.teiid.query.sql.proc.Statement.Labeled)1 WhileStatement (org.teiid.query.sql.proc.WhileStatement)1