List of usage examples for org.eclipse.jdt.core.dom CatchClause getBody
public Block getBody()
From source file:at.bestsolution.fxide.jdt.corext.dom.ASTFlattener.java
License:Open Source License
@Override public boolean visit(CatchClause node) { this.fBuffer.append("catch (");//$NON-NLS-1$ node.getException().accept(this); this.fBuffer.append(") ");//$NON-NLS-1$ node.getBody().accept(this); return false; }
From source file:boa.datagen.util.Java7Visitor.java
License:Apache License
@Override public boolean visit(CatchClause node) { boa.types.Ast.Statement.Builder b = boa.types.Ast.Statement.newBuilder(); // b.setPosition(pos.build()); List<boa.types.Ast.Statement> list = statements.peek(); b.setKind(boa.types.Ast.Statement.StatementKind.CATCH); SingleVariableDeclaration ex = node.getException(); Variable.Builder vb = Variable.newBuilder(); // vb.setPosition(pos.build());// FIXME vb.setName(ex.getName().getFullyQualifiedName()); for (Object m : ex.modifiers()) { if (((IExtendedModifier) m).isAnnotation()) ((Annotation) m).accept(this); else//from w w w . j ava 2 s. c o m ((org.eclipse.jdt.core.dom.Modifier) m).accept(this); vb.addModifiers(modifiers.pop()); } boa.types.Ast.Type.Builder tb = boa.types.Ast.Type.newBuilder(); String name = typeName(ex.getType()); for (int i = 0; i < ex.getExtraDimensions(); i++) name += "[]"; tb.setName(getIndex(name)); tb.setKind(boa.types.Ast.TypeKind.OTHER); vb.setVariableType(tb.build()); if (ex.getInitializer() != null) { ex.getInitializer().accept(this); vb.setInitializer(expressions.pop()); } b.setVariableDeclaration(vb.build()); statements.push(new ArrayList<boa.types.Ast.Statement>()); for (Object s : node.getBody().statements()) ((org.eclipse.jdt.core.dom.Statement) s).accept(this); for (boa.types.Ast.Statement s : statements.pop()) b.addStatements(s); list.add(b.build()); return false; }
From source file:br.uff.ic.gems.resources.ast.Visitor.java
@Override public boolean visit(CatchClause node) { int beginLine = cu.getLineNumber(node.getStartPosition()); int endLine = cu.getLineNumber(node.getStartPosition() + node.getLength()); int beginColumn = cu.getColumnNumber(node.getStartPosition()); int endColumn = cu.getColumnNumber(node.getStartPosition() + node.getLength()); Block body = node.getBody(); if (body != null) { int beginLineBody = cu.getLineNumber(body.getStartPosition()); int endLineBody = cu.getLineNumber(body.getStartPosition() + body.getLength()); int beginColumnBody = cu.getColumnNumber(body.getStartPosition()); int endColumnBody = cu.getColumnNumber(body.getStartPosition() + body.getLength()); languageConstructs.add(new LanguageConstruct(node.getClass().getSimpleName(), beginLine, endLine, beginColumn, endColumn, beginLineBody, endLineBody, beginColumnBody, endColumnBody, null)); } else {// w w w.j a v a 2s. co m languageConstructs.add(new LanguageConstruct(node.getClass().getSimpleName(), beginLine, endLine, beginColumn, endColumn)); } return true; }
From source file:changetypes.ASTVisitorAtomicChange.java
License:Open Source License
public boolean visit(TryStatement node) { if (this.mtbStack.isEmpty()) { return true; }/*from w w w. j av a 2s . c o m*/ String bodyStr = node.getBody() != null ? node.getBody().toString() : ""; bodyStr = edit_str(bodyStr); StringBuilder catchClauses = new StringBuilder(); for (Object o : node.catchClauses()) { if (catchClauses.length() > 0) { catchClauses.append(","); } CatchClause c = (CatchClause) o; catchClauses.append(getQualifiedName(c.getException().getType().resolveBinding())); catchClauses.append(":"); if (c.getBody() != null) { catchClauses.append(edit_str(c.getBody().toString())); } } String finallyStr = node.getFinally() != null ? node.getFinally().toString() : ""; finallyStr = edit_str(finallyStr); IMethodBinding mtb = (IMethodBinding) this.mtbStack.peek(); String methodStr = getQualifiedName(mtb); this.facts.add(Fact.makeTryCatchFact(bodyStr, catchClauses.toString(), finallyStr, methodStr)); return true; }
From source file:chibi.gumtreediff.gen.jdt.cd.CdJdtVisitor.java
License:Open Source License
@Override public boolean visit(CatchClause node) { pushNode(node, ((SimpleType) node.getException().getType()).getName().getFullyQualifiedName()); // since exception type is used as value, visit children by hand node.getBody().accept(this); return false; }
From source file:coloredide.utils.CopiedNaiveASTFlattener.java
License:Open Source License
public boolean visit(CatchClause node) { this.buffer.append("catch (");//$NON-NLS-1$ node.getException().accept(this); this.buffer.append(") ");//$NON-NLS-1$ node.getBody().accept(this); return false; }
From source file:com.bsiag.eclipse.jdt.java.formatter.SpacePreparator.java
License:Open Source License
@Override public boolean visit(CatchClause node) { handleToken(node, TokenNameLPAREN, this.options.insert_space_before_opening_paren_in_catch, this.options.insert_space_after_opening_paren_in_catch); handleTokenBefore(node.getBody(), TokenNameRPAREN, this.options.insert_space_before_closing_paren_in_catch, false);/* w ww . j a v a 2 s . com*/ return true; }
From source file:com.google.devtools.j2cpp.gen.CppStatementGenerator.java
License:Open Source License
@Override public boolean visit(CatchClause node) { buffer.append("@catch ("); node.getException().accept(this); buffer.append(") "); node.getBody().accept(this); return false; }
From source file:com.google.devtools.j2objc.ast.DebugASTPrinter.java
License:Apache License
@Override public boolean visit(CatchClause node) { sb.print("catch ("); node.getException().accept(this); sb.print(") "); node.getBody().accept(this); return false; }
From source file:com.google.googlejavaformat.java.JavaInputAstVisitor.java
License:Apache License
/** Helper method for {@link CatchClause}s. */ private void visitCatchClause(CatchClause node, AllowTrailingBlankLine allowTrailingBlankLine) { sync(node);/*from ww w. java 2s . c o m*/ builder.space(); token("catch"); builder.space(); token("("); builder.open(plusFour); builder.breakOp(); builder.open(ZERO); visit(node.getException()); builder.close(); builder.close(); token(")"); builder.space(); visitBlock(node.getBody(), CollapseEmptyOrNot.NO, AllowLeadingBlankLine.YES, allowTrailingBlankLine); }