本文整理汇总了Java中org.eclipse.jdt.core.dom.TryStatement.getFinally方法的典型用法代码示例。如果您正苦于以下问题:Java TryStatement.getFinally方法的具体用法?Java TryStatement.getFinally怎么用?Java TryStatement.getFinally使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.core.dom.TryStatement
的用法示例。
在下文中一共展示了TryStatement.getFinally方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: visit
import org.eclipse.jdt.core.dom.TryStatement; //导入方法依赖的package包/类
@Override
public boolean visit(TryStatement node) {
if (traverseNode(node)) {
fFlowContext.pushExcptions(node);
for (Iterator<VariableDeclarationExpression> iterator = node.resources().iterator(); iterator.hasNext();) {
iterator.next().accept(this);
}
node.getBody().accept(this);
fFlowContext.popExceptions();
List<CatchClause> catchClauses = node.catchClauses();
for (Iterator<CatchClause> iter = catchClauses.iterator(); iter.hasNext();) {
iter.next().accept(this);
}
Block finallyBlock = node.getFinally();
if (finallyBlock != null) {
finallyBlock.accept(this);
}
}
return false;
}
示例2: endVisit
import org.eclipse.jdt.core.dom.TryStatement; //导入方法依赖的package包/类
@Override
public void endVisit(TryStatement node) {
ASTNode firstSelectedNode = getFirstSelectedNode();
if (getSelection().getEndVisitSelectionMode(node) == Selection.AFTER) {
if (firstSelectedNode == node.getBody() || firstSelectedNode == node.getFinally()) {
invalidSelection(RefactoringCoreMessages.StatementAnalyzer_try_statement);
} else {
List<CatchClause> catchClauses = node.catchClauses();
for (Iterator<CatchClause> iterator = catchClauses.iterator(); iterator.hasNext();) {
CatchClause element = iterator.next();
if (element == firstSelectedNode || element.getBody() == firstSelectedNode) {
invalidSelection(RefactoringCoreMessages.StatementAnalyzer_try_statement);
} else if (element.getException() == firstSelectedNode) {
invalidSelection(RefactoringCoreMessages.StatementAnalyzer_catch_argument);
}
}
}
}
super.endVisit(node);
}
示例3: endVisit
import org.eclipse.jdt.core.dom.TryStatement; //导入方法依赖的package包/类
@Override
public void endVisit(TryStatement node) {
ASTNode firstSelectedNode = getFirstSelectedNode();
if (getSelection().getEndVisitSelectionMode(node) == Selection.AFTER) {
if (firstSelectedNode == node.getBody() || firstSelectedNode == node.getFinally()) {
invalidSelection(RefactoringCoreMessages.StatementAnalyzer_try_statement);
} else {
List<CatchClause> catchClauses = node.catchClauses();
for (Iterator<CatchClause> iterator = catchClauses.iterator(); iterator.hasNext(); ) {
CatchClause element = iterator.next();
if (element == firstSelectedNode || element.getBody() == firstSelectedNode) {
invalidSelection(RefactoringCoreMessages.StatementAnalyzer_try_statement);
} else if (element.getException() == firstSelectedNode) {
invalidSelection(RefactoringCoreMessages.StatementAnalyzer_catch_argument);
}
}
}
}
super.endVisit(node);
}
示例4: visit
import org.eclipse.jdt.core.dom.TryStatement; //导入方法依赖的package包/类
@Override
public boolean visit(TryStatement node) {
if (traverseNode(node)) {
fFlowContext.pushExcptions(node);
node.getBody().accept(this);
fFlowContext.popExceptions();
List<CatchClause> catchClauses= node.catchClauses();
for (Iterator<CatchClause> iter= catchClauses.iterator(); iter.hasNext();) {
iter.next().accept(this);
}
Block finallyBlock= node.getFinally();
if (finallyBlock != null) {
finallyBlock.accept(this);
}
}
return false;
}
示例5: endVisit
import org.eclipse.jdt.core.dom.TryStatement; //导入方法依赖的package包/类
@Override
public void endVisit(TryStatement node) {
ASTNode firstSelectedNode= getFirstSelectedNode();
if (getSelection().getEndVisitSelectionMode(node) == Selection.AFTER) {
if (firstSelectedNode == node.getBody() || firstSelectedNode == node.getFinally()) {
invalidSelection(RefactoringCoreMessages.StatementAnalyzer_try_statement);
} else {
List<CatchClause> catchClauses= node.catchClauses();
for (Iterator<CatchClause> iterator= catchClauses.iterator(); iterator.hasNext();) {
CatchClause element= iterator.next();
if (element == firstSelectedNode || element.getBody() == firstSelectedNode) {
invalidSelection(RefactoringCoreMessages.StatementAnalyzer_try_statement);
} else if (element.getException() == firstSelectedNode) {
invalidSelection(RefactoringCoreMessages.StatementAnalyzer_catch_argument);
}
}
}
}
super.endVisit(node);
}
示例6: getAddFinallyProposals
import org.eclipse.jdt.core.dom.TryStatement; //导入方法依赖的package包/类
private static boolean getAddFinallyProposals(IInvocationContext context, ASTNode node, Collection<ICommandAccess> resultingCollections) {
TryStatement tryStatement= ASTResolving.findParentTryStatement(node);
if (tryStatement == null || tryStatement.getFinally() != null) {
return false;
}
Statement statement= ASTResolving.findParentStatement(node);
if (tryStatement != statement && tryStatement.getBody() != statement) {
return false; // an node inside a catch or finally block
}
if (resultingCollections == null) {
return true;
}
AST ast= tryStatement.getAST();
ASTRewrite rewrite= ASTRewrite.create(ast);
Block finallyBody= ast.newBlock();
rewrite.set(tryStatement, TryStatement.FINALLY_PROPERTY, finallyBody, null);
String label= CorrectionMessages.QuickAssistProcessor_addfinallyblock_description;
Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_ADD);
ASTRewriteCorrectionProposal proposal= new ASTRewriteCorrectionProposal(label, context.getCompilationUnit(), rewrite, IProposalRelevance.ADD_FINALLY_BLOCK, image);
resultingCollections.add(proposal);
return true;
}
示例7: getAddFinallyProposals
import org.eclipse.jdt.core.dom.TryStatement; //导入方法依赖的package包/类
private static boolean getAddFinallyProposals(IInvocationContext context, ASTNode node, Collection<ICommandAccess> resultingCollections) {
TryStatement tryStatement= ASTResolving.findParentTryStatement(node);
if (tryStatement == null || tryStatement.getFinally() != null) {
return false;
}
Statement statement= ASTResolving.findParentStatement(node);
if (tryStatement != statement && tryStatement.getBody() != statement) {
return false; // an node inside a catch or finally block
}
if (resultingCollections == null) {
return true;
}
AST ast= tryStatement.getAST();
ASTRewrite rewrite= ASTRewrite.create(ast);
Block finallyBody= ast.newBlock();
rewrite.set(tryStatement, TryStatement.FINALLY_PROPERTY, finallyBody, null);
String label= CorrectionMessages.QuickAssistProcessor_addfinallyblock_description;
Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_ADD);
ASTRewriteCorrectionProposal proposal= new ASTRewriteCorrectionProposal(label, context.getCompilationUnit(), rewrite, 1, image);
resultingCollections.add(proposal);
return true;
}
示例8: visit
import org.eclipse.jdt.core.dom.TryStatement; //导入方法依赖的package包/类
public boolean visit(TryStatement node) {
if (mtbStack.isEmpty()) // not part of a method
return true;
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 = mtbStack.peek();
String methodStr = getQualifiedName(mtb);
facts.add(Fact.makeTryCatchFact(bodyStr, catchClauses.toString(),
finallyStr, methodStr));
return true;
}
示例9: visit
import org.eclipse.jdt.core.dom.TryStatement; //导入方法依赖的package包/类
@Override
public boolean visit(TryStatement node) {
fCurrentExceptions = new ArrayList<>(1);
fTryStack.push(fCurrentExceptions);
// visit try block
node.getBody().accept(this);
List<VariableDeclarationExpression> resources = node.resources();
for (Iterator<VariableDeclarationExpression> iterator = resources.iterator(); iterator.hasNext();) {
iterator.next().accept(this);
}
// Remove those exceptions that get catch by following catch blocks
List<CatchClause> catchClauses = node.catchClauses();
if (!catchClauses.isEmpty()) {
handleCatchArguments(catchClauses);
}
List<ITypeBinding> current = fTryStack.pop();
fCurrentExceptions = fTryStack.peek();
for (Iterator<ITypeBinding> iter = current.iterator(); iter.hasNext();) {
addException(iter.next(), node.getAST());
}
// visit catch and finally
for (Iterator<CatchClause> iter = catchClauses.iterator(); iter.hasNext();) {
iter.next().accept(this);
}
if (node.getFinally() != null) {
node.getFinally().accept(this);
}
// return false. We have visited the body by ourselves.
return false;
}
示例10: visit
import org.eclipse.jdt.core.dom.TryStatement; //导入方法依赖的package包/类
public boolean visit(TryStatement node)
{
if (this.mtbStack.isEmpty()) {
return true;
}
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;
}
示例11: visit
import org.eclipse.jdt.core.dom.TryStatement; //导入方法依赖的package包/类
@Override
public boolean visit(TryStatement node) {
fCurrentExceptions = new ArrayList<ITypeBinding>(1);
fTryStack.push(fCurrentExceptions);
// visit try block
node.getBody().accept(this);
List<VariableDeclarationExpression> resources = node.resources();
for (Iterator<VariableDeclarationExpression> iterator = resources.iterator();
iterator.hasNext(); ) {
iterator.next().accept(this);
}
// Remove those exceptions that get catch by following catch blocks
List<CatchClause> catchClauses = node.catchClauses();
if (!catchClauses.isEmpty()) handleCatchArguments(catchClauses);
List<ITypeBinding> current = fTryStack.pop();
fCurrentExceptions = fTryStack.peek();
for (Iterator<ITypeBinding> iter = current.iterator(); iter.hasNext(); ) {
addException(iter.next(), node.getAST());
}
// visit catch and finally
for (Iterator<CatchClause> iter = catchClauses.iterator(); iter.hasNext(); ) {
iter.next().accept(this);
}
if (node.getFinally() != null) node.getFinally().accept(this);
// return false. We have visited the body by ourselves.
return false;
}
示例12: visit
import org.eclipse.jdt.core.dom.TryStatement; //导入方法依赖的package包/类
@Override
public boolean visit(TryStatement node) {
fCurrentExceptions= new ArrayList<ITypeBinding>(1);
fTryStack.push(fCurrentExceptions);
// visit try block
node.getBody().accept(this);
List<VariableDeclarationExpression> resources= node.resources();
for (Iterator<VariableDeclarationExpression> iterator= resources.iterator(); iterator.hasNext();) {
iterator.next().accept(this);
}
// Remove those exceptions that get catch by following catch blocks
List<CatchClause> catchClauses= node.catchClauses();
if (!catchClauses.isEmpty())
handleCatchArguments(catchClauses);
List<ITypeBinding> current= fTryStack.pop();
fCurrentExceptions= fTryStack.peek();
for (Iterator<ITypeBinding> iter= current.iterator(); iter.hasNext();) {
addException(iter.next(), node.getAST());
}
// visit catch and finally
for (Iterator<CatchClause> iter= catchClauses.iterator(); iter.hasNext(); ) {
iter.next().accept(this);
}
if (node.getFinally() != null)
node.getFinally().accept(this);
// return false. We have visited the body by ourselves.
return false;
}
示例13: visit
import org.eclipse.jdt.core.dom.TryStatement; //导入方法依赖的package包/类
@Override
public boolean visit(TryStatement node) {
int currentSize= fCaughtExceptions.size();
List<CatchClause> catchClauses= node.catchClauses();
for (Iterator<CatchClause> iter= catchClauses.iterator(); iter.hasNext();) {
Type type= iter.next().getException().getType();
if (type instanceof UnionType) {
List<Type> types= ((UnionType) type).types();
for (Iterator<Type> iterator= types.iterator(); iterator.hasNext();) {
addCaughtException(iterator.next());
}
} else {
addCaughtException(type);
}
}
node.getBody().accept(this);
handleResourceDeclarations(node);
int toRemove= fCaughtExceptions.size() - currentSize;
for (int i= toRemove; i > 0; i--) {
fCaughtExceptions.remove(currentSize);
}
// visit catch and finally
for (Iterator<CatchClause> iter= catchClauses.iterator(); iter.hasNext();) {
iter.next().accept(this);
}
if (node.getFinally() != null)
node.getFinally().accept(this);
// return false. We have visited the body by ourselves.
return false;
}
示例14: visit
import org.eclipse.jdt.core.dom.TryStatement; //导入方法依赖的package包/类
@Override
public boolean visit(TryStatement node) {
fCurrentExceptions= new ArrayList<ITypeBinding>(1);
fTryStack.push(fCurrentExceptions);
// visit try block
node.getBody().accept(this);
if (node.getAST().apiLevel() >= AST.JLS4) {
List<VariableDeclarationExpression> resources= node.resources();
for (Iterator<VariableDeclarationExpression> iterator= resources.iterator(); iterator.hasNext();) {
iterator.next().accept(this);
}
}
// Remove those exceptions that get catch by following catch blocks
List<CatchClause> catchClauses= node.catchClauses();
if (!catchClauses.isEmpty())
handleCatchArguments(catchClauses);
List<ITypeBinding> current= fTryStack.pop();
fCurrentExceptions= fTryStack.peek();
for (Iterator<ITypeBinding> iter= current.iterator(); iter.hasNext();) {
addException(iter.next());
}
// visit catch and finally
for (Iterator<CatchClause> iter= catchClauses.iterator(); iter.hasNext(); ) {
iter.next().accept(this);
}
if (node.getFinally() != null)
node.getFinally().accept(this);
// return false. We have visited the body by ourselves.
return false;
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:36,代码来源:AbstractExceptionAnalyzer.java
示例15: visit
import org.eclipse.jdt.core.dom.TryStatement; //导入方法依赖的package包/类
@Override
public boolean visit(TryStatement node) {
this.fBuffer.append("try ");//$NON-NLS-1$
if (node.getAST().apiLevel() >= AST.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$
}
}
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;
}