Search in sources :

Example 16 with Structure

use of net.sourceforge.pmd.lang.dfa.Structure in project pmd by pmd.

the class StatementAndBraceFinder method visit.

@Override
public Object visit(ASTUnlabelledStatement node, Object data) {
    if (!(data instanceof Structure)) {
        return data;
    }
    Structure dataFlow = (Structure) data;
    super.visit(node, data);
    if (node.jjtGetParent() instanceof ASTLabelledStatement) {
        dataFlow.pushOnStack(NodeType.LABEL_LAST_STATEMENT, dataFlow.getLast());
        if (LOGGER.isLoggable(Level.FINEST)) {
            LOGGER.finest("pushOnStack (ASTUnlabelledStatement) LABEL_LAST_STATEMENT: line " + node.getBeginLine() + ", column " + node.getBeginColumn());
        }
    }
    return data;
}
Also used : ASTLabelledStatement(net.sourceforge.pmd.lang.plsql.ast.ASTLabelledStatement) Structure(net.sourceforge.pmd.lang.dfa.Structure)

Example 17 with Structure

use of net.sourceforge.pmd.lang.dfa.Structure in project pmd by pmd.

the class StatementAndBraceFinder method visit.

@Override
public Object visit(ASTCaseWhenClause node, Object data) {
    if (!(data instanceof Structure)) {
        return data;
    }
    Structure dataFlow = (Structure) data;
    // Java ASTSwitchLabel
    // SRT dataFlow.createNewNode(node);
    dataFlow.pushOnStack(NodeType.CASE_LAST_STATEMENT, dataFlow.getLast());
    if (LOGGER.isLoggable(Level.FINEST)) {
        LOGGER.finest("pushOnStack CASE_LAST_STATEMENT: line " + node.getBeginLine() + ", column " + node.getBeginColumn());
    }
    super.visit(node, data);
    // dataFlow.createNewNode(node);
    dataFlow.pushOnStack(NodeType.BREAK_STATEMENT, dataFlow.getLast());
    if (LOGGER.isLoggable(Level.FINEST)) {
        LOGGER.finest("pushOnStack (ASTCaseWhenClause) BREAK_STATEMENT: line " + node.getBeginLine() + ", column " + node.getBeginColumn());
    }
    return data;
}
Also used : Structure(net.sourceforge.pmd.lang.dfa.Structure)

Example 18 with Structure

use of net.sourceforge.pmd.lang.dfa.Structure in project pmd by pmd.

the class StatementAndBraceFinder method visit.

/* */
@Override
public Object visit(ASTVariableOrConstantDeclarator node, Object data) {
    if (!(data instanceof Structure)) {
        return data;
    }
    Structure dataFlow = (Structure) data;
    dataFlow.createNewNode(node);
    if (LOGGER.isLoggable(Level.FINEST)) {
        LOGGER.finest("createNewNode ASTVariableOrConstantDeclarator: line " + node.getBeginLine() + ", column " + node.getBeginColumn());
    }
    return super.visit(node, data);
}
Also used : Structure(net.sourceforge.pmd.lang.dfa.Structure)

Example 19 with Structure

use of net.sourceforge.pmd.lang.dfa.Structure in project pmd by pmd.

the class StatementAndBraceFinder method visit.

@Override
public Object visit(ASTElseClause node, Object data) {
    if (!(data instanceof Structure)) {
        return data;
    }
    Structure dataFlow = (Structure) data;
    if (node.jjtGetParent() instanceof ASTIfStatement) {
        dataFlow.pushOnStack(NodeType.IF_LAST_STATEMENT, dataFlow.getLast());
        if (LOGGER.isLoggable(Level.FINEST)) {
            LOGGER.finest("pushOnStack (Visit ASTElseClause) IF_LAST_STATEMENT: line " + node.getBeginLine() + ", column " + node.getBeginColumn());
            LOGGER.finest("ElseClause) super.visit line");
        }
    } else {
        // SRT dataFlow.createNewNode(node);
        dataFlow.pushOnStack(NodeType.SWITCH_LAST_DEFAULT_STATEMENT, dataFlow.getLast());
        if (LOGGER.isLoggable(Level.FINEST)) {
            LOGGER.finest("pushOnStack SWITCH_LAST_DEFAULT_STATEMENT: line " + node.getBeginLine() + ", column " + node.getBeginColumn());
        }
    }
    super.visit(node, data);
    return data;
}
Also used : ASTIfStatement(net.sourceforge.pmd.lang.plsql.ast.ASTIfStatement) Structure(net.sourceforge.pmd.lang.dfa.Structure)

Example 20 with Structure

use of net.sourceforge.pmd.lang.dfa.Structure in project pmd by pmd.

the class StatementAndBraceFinder method visit.

@Override
public Object visit(ASTExpression node, Object data) {
    if (LOGGER.isLoggable(Level.FINEST)) {
        LOGGER.finest("Entry ASTExpression: line " + node.getBeginLine() + ", column " + node.getBeginColumn());
    }
    if (!(data instanceof Structure)) {
        if (LOGGER.isLoggable(Level.FINEST)) {
            LOGGER.finest("immediate return ASTExpression: line " + node.getBeginLine() + ", column " + node.getBeginColumn());
        }
        return data;
    }
    Structure dataFlow = (Structure) data;
    // an UnLabelledStatement
    if (node.jjtGetParent() instanceof ASTUnlabelledStatement) {
        if (LOGGER.isLoggable(Level.FINEST)) {
            LOGGER.finest("createNewNode ASTSUnlabelledStatement: line " + node.getBeginLine() + ", column " + node.getBeginColumn());
        }
        dataFlow.createNewNode(node);
    } else if (node.jjtGetParent() instanceof ASTIfStatement) {
        // TODO what about throw stmts?
        // START IF
        dataFlow.createNewNode(node);
        dataFlow.pushOnStack(NodeType.IF_EXPR, dataFlow.getLast());
        if (LOGGER.isLoggable(Level.FINEST)) {
            LOGGER.finest("pushOnStack parent IF_EXPR: line " + node.getBeginLine() + ", column " + node.getBeginColumn());
        }
    } else if (node.jjtGetParent() instanceof ASTElsifClause) {
        if (LOGGER.isLoggable(Level.FINEST)) {
            LOGGER.finest("parent (Elsif) IF_EXPR at  " + node.getBeginLine() + ", column " + node.getBeginColumn());
        }
        // START IF
        dataFlow.createNewNode(node);
        dataFlow.pushOnStack(NodeType.IF_EXPR, dataFlow.getLast());
        if (LOGGER.isLoggable(Level.FINEST)) {
            LOGGER.finest("pushOnStack parent (Elsif) IF_EXPR: line " + node.getBeginLine() + ", column " + node.getBeginColumn());
        }
    } else if (node.jjtGetParent() instanceof ASTWhileStatement) {
        // START WHILE
        dataFlow.createNewNode(node);
        dataFlow.pushOnStack(NodeType.WHILE_EXPR, dataFlow.getLast());
        if (LOGGER.isLoggable(Level.FINEST)) {
            LOGGER.finest("pushOnStack parent WHILE_EXPR: line " + node.getBeginLine() + ", column " + node.getBeginColumn());
        }
    } else if (node.jjtGetParent() instanceof ASTCaseStatement) {
        // START SWITCH
        dataFlow.createNewNode(node);
        dataFlow.pushOnStack(NodeType.SWITCH_START, dataFlow.getLast());
        if (LOGGER.isLoggable(Level.FINEST)) {
            LOGGER.finest("pushOnStack parent SWITCH_START: line " + node.getBeginLine() + ", column " + node.getBeginColumn());
        }
    } else if (node.jjtGetParent() instanceof ASTForStatement) {
        /*
             * A PL/SQL loop control: [<REVERSE>] Expression()[".."Expression()]
             */
        if (node.equals(node.jjtGetParent().getFirstChildOfType(ASTExpression.class))) {
            // FOR EXPR
            dataFlow.createNewNode(node);
            dataFlow.pushOnStack(NodeType.FOR_EXPR, dataFlow.getLast());
            if (LOGGER.isLoggable(Level.FINEST)) {
                LOGGER.finest("pushOnStack parent FOR_EXPR: line " + node.getBeginLine() + ", column " + node.getBeginColumn());
            }
        }
        if (LOGGER.isLoggable(Level.FINEST)) {
            LOGGER.finest("parent (ASTForStatement): line " + node.getBeginLine() + ", column " + node.getBeginColumn());
        }
    } else if (node.jjtGetParent() instanceof ASTLoopStatement) {
        // DO EXPR
        dataFlow.createNewNode(node);
        dataFlow.pushOnStack(NodeType.DO_EXPR, dataFlow.getLast());
        if (LOGGER.isLoggable(Level.FINEST)) {
            LOGGER.finest("pushOnStack parent DO_EXPR: line " + node.getBeginLine() + ", column " + node.getBeginColumn());
        }
    }
    return super.visit(node, data);
}
Also used : ASTWhileStatement(net.sourceforge.pmd.lang.plsql.ast.ASTWhileStatement) ASTCaseStatement(net.sourceforge.pmd.lang.plsql.ast.ASTCaseStatement) ASTIfStatement(net.sourceforge.pmd.lang.plsql.ast.ASTIfStatement) ASTElsifClause(net.sourceforge.pmd.lang.plsql.ast.ASTElsifClause) ASTLoopStatement(net.sourceforge.pmd.lang.plsql.ast.ASTLoopStatement) Structure(net.sourceforge.pmd.lang.dfa.Structure) ASTForStatement(net.sourceforge.pmd.lang.plsql.ast.ASTForStatement) ASTUnlabelledStatement(net.sourceforge.pmd.lang.plsql.ast.ASTUnlabelledStatement)

Aggregations

Structure (net.sourceforge.pmd.lang.dfa.Structure)36 Node (net.sourceforge.pmd.lang.ast.Node)2 Linker (net.sourceforge.pmd.lang.dfa.Linker)2 LinkerException (net.sourceforge.pmd.lang.dfa.LinkerException)2 SequenceException (net.sourceforge.pmd.lang.dfa.SequenceException)2 ASTDoStatement (net.sourceforge.pmd.lang.java.ast.ASTDoStatement)2 ASTForStatement (net.sourceforge.pmd.lang.java.ast.ASTForStatement)2 ASTIfStatement (net.sourceforge.pmd.lang.java.ast.ASTIfStatement)2 ASTMethodDeclaration (net.sourceforge.pmd.lang.java.ast.ASTMethodDeclaration)2 ASTWhileStatement (net.sourceforge.pmd.lang.java.ast.ASTWhileStatement)2 ASTElseClause (net.sourceforge.pmd.lang.plsql.ast.ASTElseClause)2 ASTElsifClause (net.sourceforge.pmd.lang.plsql.ast.ASTElsifClause)2 ASTForStatement (net.sourceforge.pmd.lang.plsql.ast.ASTForStatement)2 ASTIfStatement (net.sourceforge.pmd.lang.plsql.ast.ASTIfStatement)2 ASTLabelledStatement (net.sourceforge.pmd.lang.plsql.ast.ASTLabelledStatement)2 ASTLoopStatement (net.sourceforge.pmd.lang.plsql.ast.ASTLoopStatement)2 ASTWhileStatement (net.sourceforge.pmd.lang.plsql.ast.ASTWhileStatement)2 List (java.util.List)1 ASTAssertStatement (net.sourceforge.pmd.lang.java.ast.ASTAssertStatement)1 ASTConstructorDeclaration (net.sourceforge.pmd.lang.java.ast.ASTConstructorDeclaration)1