Search in sources :

Example 1 with Linker

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

the class StatementAndBraceFinder method buildDataFlowFor.

public void buildDataFlowFor(JavaNode node) {
    if (!(node instanceof ASTMethodDeclaration) && !(node instanceof ASTConstructorDeclaration)) {
        throw new RuntimeException("Can't build a data flow for anything other than a method or a constructor");
    }
    this.dataFlow = new Structure(dataFlowHandler);
    this.dataFlow.createStartNode(node.getBeginLine());
    this.dataFlow.createNewNode(node);
    node.jjtAccept(this, dataFlow);
    this.dataFlow.createEndNode(node.getEndLine());
    if (LOGGER.isLoggable(Level.FINE)) {
        // TODO SRT Remove after development
        LOGGER.fine("DataFlow is " + this.dataFlow.dump());
    }
    Linker linker = new Linker(dataFlowHandler, dataFlow.getBraceStack(), dataFlow.getContinueBreakReturnStack());
    try {
        linker.computePaths();
    } catch (SequenceException | LinkerException e) {
        e.printStackTrace();
    }
}
Also used : LinkerException(net.sourceforge.pmd.lang.dfa.LinkerException) ASTConstructorDeclaration(net.sourceforge.pmd.lang.java.ast.ASTConstructorDeclaration) ASTMethodDeclaration(net.sourceforge.pmd.lang.java.ast.ASTMethodDeclaration) SequenceException(net.sourceforge.pmd.lang.dfa.SequenceException) Structure(net.sourceforge.pmd.lang.dfa.Structure) Linker(net.sourceforge.pmd.lang.dfa.Linker)

Example 2 with Linker

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

the class StatementAndBraceFinder method buildDataFlowFor.

public void buildDataFlowFor(PLSQLNode node) {
    LOGGER.entering(this.getClass().getCanonicalName(), "buildDataFlowFor");
    if (LOGGER.isLoggable(Level.FINEST)) {
        LOGGER.finest("buildDataFlowFor: node class " + node.getClass().getCanonicalName() + " @ line " + node.getBeginLine() + ", column " + node.getBeginColumn() + " --- " + new Throwable().getStackTrace());
    }
    if (!(node instanceof ASTMethodDeclaration) && !(node instanceof ASTProgramUnit) && !(node instanceof ASTTypeMethod) && !(node instanceof ASTTriggerUnit) && !(node instanceof ASTTriggerTimingPointSection)) {
        throw new RuntimeException("Can't build a data flow for anything other than a Method or a Trigger");
    }
    this.dataFlow = new Structure(dataFlowHandler);
    this.dataFlow.createStartNode(node.getBeginLine());
    this.dataFlow.createNewNode(node);
    node.jjtAccept(this, dataFlow);
    this.dataFlow.createEndNode(node.getEndLine());
    if (LOGGER.isLoggable(Level.FINE)) {
        LOGGER.fine("DataFlow is " + this.dataFlow.dump());
    }
    Linker linker = new Linker(dataFlowHandler, dataFlow.getBraceStack(), dataFlow.getContinueBreakReturnStack());
    try {
        linker.computePaths();
    } catch (LinkerException e) {
        LOGGER.severe("LinkerException");
        e.printStackTrace();
    } catch (SequenceException e) {
        LOGGER.severe("SequenceException");
        e.printStackTrace();
    }
    LOGGER.exiting(this.getClass().getCanonicalName(), "buildDataFlowFor");
}
Also used : ASTTypeMethod(net.sourceforge.pmd.lang.plsql.ast.ASTTypeMethod) LinkerException(net.sourceforge.pmd.lang.dfa.LinkerException) ASTTriggerUnit(net.sourceforge.pmd.lang.plsql.ast.ASTTriggerUnit) ASTMethodDeclaration(net.sourceforge.pmd.lang.plsql.ast.ASTMethodDeclaration) SequenceException(net.sourceforge.pmd.lang.dfa.SequenceException) ASTTriggerTimingPointSection(net.sourceforge.pmd.lang.plsql.ast.ASTTriggerTimingPointSection) Structure(net.sourceforge.pmd.lang.dfa.Structure) Linker(net.sourceforge.pmd.lang.dfa.Linker) ASTProgramUnit(net.sourceforge.pmd.lang.plsql.ast.ASTProgramUnit)

Aggregations

Linker (net.sourceforge.pmd.lang.dfa.Linker)2 LinkerException (net.sourceforge.pmd.lang.dfa.LinkerException)2 SequenceException (net.sourceforge.pmd.lang.dfa.SequenceException)2 Structure (net.sourceforge.pmd.lang.dfa.Structure)2 ASTConstructorDeclaration (net.sourceforge.pmd.lang.java.ast.ASTConstructorDeclaration)1 ASTMethodDeclaration (net.sourceforge.pmd.lang.java.ast.ASTMethodDeclaration)1 ASTMethodDeclaration (net.sourceforge.pmd.lang.plsql.ast.ASTMethodDeclaration)1 ASTProgramUnit (net.sourceforge.pmd.lang.plsql.ast.ASTProgramUnit)1 ASTTriggerTimingPointSection (net.sourceforge.pmd.lang.plsql.ast.ASTTriggerTimingPointSection)1 ASTTriggerUnit (net.sourceforge.pmd.lang.plsql.ast.ASTTriggerUnit)1 ASTTypeMethod (net.sourceforge.pmd.lang.plsql.ast.ASTTypeMethod)1