List of usage examples for org.eclipse.jdt.core.dom CatchClause accept
public final void accept(ASTVisitor visitor)
From source file:at.bestsolution.fxide.jdt.corext.dom.ASTFlattener.java
License:Open Source License
@Override public boolean visit(TryStatement node) { this.fBuffer.append("try ");//$NON-NLS-1$ if (node.getAST().apiLevel() >= JLS4) { if (!node.resources().isEmpty()) { this.fBuffer.append("(");//$NON-NLS-1$ for (Iterator<VariableDeclarationExpression> it = node.resources().iterator(); it.hasNext();) { VariableDeclarationExpression var = it.next(); var.accept(this); if (it.hasNext()) { this.fBuffer.append(",");//$NON-NLS-1$ }//from w w w . j ava 2s .c o m } this.fBuffer.append(") ");//$NON-NLS-1$ } } node.getBody().accept(this); this.fBuffer.append(" ");//$NON-NLS-1$ for (Iterator<CatchClause> it = node.catchClauses().iterator(); it.hasNext();) { CatchClause cc = it.next(); cc.accept(this); } if (node.getFinally() != null) { this.fBuffer.append("finally ");//$NON-NLS-1$ node.getFinally().accept(this); } return false; }
From source file:coloredide.utils.CopiedNaiveASTFlattener.java
License:Open Source License
public boolean visit(TryStatement node) { printIndent();//from ww w.j a v a2 s . c o m this.buffer.append("try ");//$NON-NLS-1$ node.getBody().accept(this); this.buffer.append(" ");//$NON-NLS-1$ for (Iterator it = node.catchClauses().iterator(); it.hasNext();) { CatchClause cc = (CatchClause) it.next(); cc.accept(this); } if (node.getFinally() != null) { this.buffer.append(" finally ");//$NON-NLS-1$ node.getFinally().accept(this); } return false; }
From source file:com.google.devtools.j2cpp.gen.CppStatementGenerator.java
License:Open Source License
@Override public boolean visit(TryStatement node) { buffer.append("@try "); node.getBody().accept(this); buffer.append(' '); for (Iterator<?> it = node.catchClauses().iterator(); it.hasNext();) { CatchClause cc = (CatchClause) it.next(); cc.accept(this); }//from w w w .jav a 2 s.co m if (node.getFinally() != null) { buffer.append(" @finally "); node.getFinally().accept(this); } return false; }
From source file:edu.cmu.cs.crystal.cfg.eclipse.EclipseCFG.java
License:Open Source License
@Override public boolean visit(TryStatement node) { EclipseCFGNode tryNode = nodeMap.get(node); EclipseCFGNode finallyNode = null, catchNode, bodyNode; blockStack.overrideIfExists(node, tryNode, null); // first analyze the finally if (node.getFinally() != null) { node.getFinally().accept(this); finallyNode = nodeMap.get(node.getFinally()); exceptionMap.pushFinally(finallyNode); }/*from w w w .j a va2 s. com*/ // then analyze the catches for (CatchClause catchClause : (List<CatchClause>) node.catchClauses()) { catchClause.accept(this); catchNode = nodeMap.get(catchClause); exceptionMap.pushCatch(catchNode, catchClause.getException().getType().resolveBinding()); } // analyze body now that the exceptionMap is set up node.getBody().accept(this); bodyNode = nodeMap.get(node.getBody()); // remove the catches for (int ndx = 0; ndx < node.catchClauses().size(); ndx++) exceptionMap.popCatch(); // set up normal flow if (finallyNode != null) { exceptionMap.popFinally(); if (bodyNode.getEnd() != null) { // if the try has no normal ending, don't attach it to the // finally createEdge(bodyNode.getEnd(), finallyNode.getStart()); createEdge(finallyNode.getEnd(), tryNode); } } else createEdge(bodyNode.getEnd(), tryNode); // set up exceptional flow for (CatchClause catchClause : (List<CatchClause>) node.catchClauses()) { catchNode = nodeMap.get(catchClause); if (finallyNode != null) createEdge(catchNode.getEnd(), finallyNode.getStart()); else createEdge(catchNode.getEnd(), tryNode); } tryNode.setStart(bodyNode.getStart()); tryNode.setName("try"); return false; }
From source file:org.codemucker.jmutate.ast.JAstFlattener.java
License:Open Source License
public boolean visit(TryStatement node) { printIndent();/* ww w. j a v a2 s.c o m*/ this.buffer.append("try ");//$NON-NLS-1$ if (node.getAST().apiLevel() >= JLS4) { List resources = node.resources(); if (!resources.isEmpty()) { this.buffer.append('('); for (Iterator it = resources.iterator(); it.hasNext();) { VariableDeclarationExpression variable = (VariableDeclarationExpression) it.next(); variable.accept(this); if (it.hasNext()) { this.buffer.append(';'); } } this.buffer.append(')'); } } node.getBody().accept(this); this.buffer.append(" ");//$NON-NLS-1$ for (Iterator it = node.catchClauses().iterator(); it.hasNext();) { CatchClause cc = (CatchClause) it.next(); cc.accept(this); } if (node.getFinally() != null) { this.buffer.append(" finally ");//$NON-NLS-1$ node.getFinally().accept(this); } return false; }
From source file:org.eclipse.recommenders.codesearch.rcp.index.indexer.DeclaredFieldNamesIndexer.java
License:Open Source License
@Override public void indexTryCatchBlock(final Document document, final TryStatement tryStatement, final CatchClause catchClause) { final ASTVisitor visitor = new ASTVisitor() { @Override/*from www.j a v a 2 s . c om*/ public boolean visit(final VariableDeclarationStatement node) { addVariableNames(document, node); return false; } }; catchClause.accept(visitor); }
From source file:org.eclipse.recommenders.codesearch.rcp.index.indexer.DeclaredFieldTypesIndexer.java
License:Open Source License
@Override public void indexTryCatchBlock(final Document document, final TryStatement tryStatement, final CatchClause catchClause) { final ASTVisitor visitor = new ASTVisitor() { @Override//ww w . j a v a 2 s . c o m public boolean visit(final VariableDeclarationStatement node) { addDeclaredFieldType(document, node); return false; } }; catchClause.accept(visitor); }
From source file:org.eclipse.recommenders.codesearch.rcp.index.indexer.InstanceOfIndexer.java
License:Open Source License
@Override public void indexTryCatchBlock(final Document document, final TryStatement tryStatement, final CatchClause catchClause) { final InstanceOfVisitor visitor = new InstanceOfVisitor(document); catchClause.accept(visitor); }
From source file:org.eclipse.recommenders.codesearch.rcp.index.indexer.UsedMethodsIndexer.java
License:Open Source License
@Override public void indexTryCatchBlock(final Document document, final TryStatement tryStatement, final CatchClause catchClause) { final ASTVisitor visitor = new MethodCallVisitor() { @Override// ww w.j a va 2s . c om protected void handleMethodCall(final IMethodBinding methodBinding) { final Optional<String> opt = BindingHelper.getIdentifier(methodBinding); if (opt.isPresent()) { CodeIndexer.addFieldToDocument(document, Fields.USED_METHODS, opt.get()); } }; }; catchClause.accept(visitor); }
From source file:org.eclipse.recommenders.codesearch.rcp.index.indexer.UsedTypesIndexer.java
License:Open Source License
@Override public void indexTryCatchBlock(final Document document, final TryStatement tryStatement, final CatchClause catchClause) { final TypeUseVisitor visitor = new TypeUseVisitor() { @Override//w ww .j a v a2 s . com protected void handleTypeUse(final ITypeBinding typeBinding) { addUsedType(document, typeBinding); } }; catchClause.accept(visitor); }