StatementAndBraceFinder extends PLSQLParserVisitorAdapter { 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"); } StatementAndBraceFinder(DataFlowHandler dataFlowHandler); void buildDataFlowFor(PLSQLNode node); @Override Object visit(ASTSqlStatement node, Object data); @Override Object visit(ASTEmbeddedSqlStatement node, Object data); @Override Object visit(ASTCloseStatement node, Object data); @Override Object visit(ASTOpenStatement node, Object data); @Override Object visit(ASTFetchStatement node, Object data); @Override Object visit(ASTPipelineStatement node, Object data); @Override Object visit(ASTVariableOrConstantDeclarator node, Object data); @Override Object visit(ASTExpression node, Object data); @Override Object visit(ASTLabelledStatement node, Object data); @Override Object visit(ASTLoopStatement node, Object data); @Override Object visit(ASTWhileStatement node, Object data); @Override Object visit(ASTStatement node, Object data); @Override Object visit(ASTUnlabelledStatement node, Object data); @Override Object visit(ASTCaseStatement node, Object data); @Override Object visit(ASTCaseWhenClause node, Object data); @Override Object visit(ASTIfStatement node, Object data); @Override Object visit(ASTElseClause node, Object data); @Override Object visit(ASTElsifClause node, Object data); @Override Object visit(ASTContinueStatement node, Object data); @Override Object visit(ASTExitStatement node, Object data); @Override Object visit(ASTGotoStatement node, Object data); @Override Object visit(ASTReturnStatement node, Object data); @Override Object visit(ASTRaiseStatement node, Object data);  }
@Test public void testOnlyWorksForMethodsAndConstructors() { StatementAndBraceFinder sbf = new StatementAndBraceFinder(plsql.getDefaultHandler().getDataFlowHandler()); PLSQLNode node = new ASTMethodDeclaration(1); ((AbstractNode) node).testingOnlySetBeginColumn(1); sbf.buildDataFlowFor(node); node = new ASTProgramUnit(1); ((AbstractNode) node).testingOnlySetBeginColumn(1); sbf.buildDataFlowFor(node); }