当前位置: 首页>>代码示例>>Java>>正文


Java CatchClause类代码示例

本文整理汇总了Java中com.github.javaparser.ast.stmt.CatchClause的典型用法代码示例。如果您正苦于以下问题:Java CatchClause类的具体用法?Java CatchClause怎么用?Java CatchClause使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


CatchClause类属于com.github.javaparser.ast.stmt包,在下文中一共展示了CatchClause类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: visit

import com.github.javaparser.ast.stmt.CatchClause; //导入依赖的package包/类
@Override public void visit(final TryStmt n, final A arg) {
	visitComment(n.getComment(), arg);
	if (n.getResources() != null) {
		for (final VariableDeclarationExpr v : n.getResources()) {
			v.accept(this, arg);
		}
	}
	n.getTryBlock().accept(this, arg);
	if (n.getCatchs() != null) {
		for (final CatchClause c : n.getCatchs()) {
			c.accept(this, arg);
		}
	}
	if (n.getFinallyBlock() != null) {
		n.getFinallyBlock().accept(this, arg);
	}
}
 
开发者ID:plum-umd,项目名称:java-sketch,代码行数:18,代码来源:VoidVisitorAdapter.java

示例2: visit

import com.github.javaparser.ast.stmt.CatchClause; //导入依赖的package包/类
@Override public void visit(final TryStmt n, final A arg) {
    jw.write(n); 
    visitComment(n.getComment(), arg);
    if (n.getResources() != null) {
        for (final VariableDeclarationExpr v : n.getResources()) {
            v.accept(this, arg);
        }
    }
    n.getTryBlock().accept(this, arg);
    if (n.getCatchs() != null) {
        for (final CatchClause c : n.getCatchs()) {
            c.accept(this, arg);
        }
    }
    if (n.getFinallyBlock() != null) {
        n.getFinallyBlock().accept(this, arg);
    }
}
 
开发者ID:plum-umd,项目名称:java-sketch,代码行数:19,代码来源:JsonVisitorAdapter.java

示例3: solveMultiCatchType

import com.github.javaparser.ast.stmt.CatchClause; //导入依赖的package包/类
@Test
public void solveMultiCatchType() {
    String code = "class A {\n" +
            "        public void foo() {\n" +
            "            try {\n" +
            "                \n" +
            "            } catch (IllegalStateException | IllegalArgumentException e) {\n" +
            "                \n" +
            "            }\n" +
            "        }\n" +
            "    }";
    CompilationUnit cu = parseWithTypeSolver(code);
    CatchClause catchClause = Navigator.findNodeOfGivenClass(cu, CatchClause.class);
    Type jpType = catchClause.getParameter().getType();
    ResolvedType jssType = jpType.resolve();
    assertEquals(true, jssType instanceof ResolvedUnionType);
}
 
开发者ID:javaparser,项目名称:javasymbolsolver,代码行数:18,代码来源:JavaParserFacadeResolutionTest.java

示例4: visit

import com.github.javaparser.ast.stmt.CatchClause; //导入依赖的package包/类
@Override public Node visit(final TryStmt n, final A arg) {
	visitComment(n, arg);
	final List<VariableDeclarationExpr> types = n.getResources();
	for (int i = 0; i < types.size(); i++) {
		n.getResources().set(i,
				(VariableDeclarationExpr) n.getResources().get(i).accept(this, arg));
	}
	n.setTryBlock((BlockStmt) n.getTryBlock().accept(this, arg));
	final List<CatchClause> catchs = n.getCatchs();
	if (catchs != null) {
		for (int i = 0; i < catchs.size(); i++) {
			catchs.set(i, (CatchClause) catchs.get(i).accept(this, arg));
		}
		removeNulls(catchs);
	}
	if (n.getFinallyBlock() != null) {
		n.setFinallyBlock((BlockStmt) n.getFinallyBlock().accept(this, arg));
	}
	return n;
}
 
开发者ID:javaparser,项目名称:javasymbolsolver,代码行数:21,代码来源:ModifierVisitorAdapter.java

示例5: visit

import com.github.javaparser.ast.stmt.CatchClause; //导入依赖的package包/类
@Override
public void visit(final TryStmt n, final Void arg) {
	if (canAddNewLine(n)) printer.println();

	printJavaComment(n.getComment(), arg);
	printer.print("try ");
	if (!n.getResources().isEmpty()) {
		printer.print("(");
		Iterator<Expression> resources = n.getResources().iterator();
		boolean first = true;
		while (resources.hasNext()) {
			resources.next().accept(this, arg);
			if (resources.hasNext()) {
				printer.print(";");
				printer.println();
				if (first) {
					printer.indent();
				}
			}
			first = false;
		}
		if (n.getResources().size() > 1) {
			printer.unindent();
		}
		printer.print(") ");
	}
	n.getTryBlock().accept(this, arg);
	for (final CatchClause c : n.getCatchClauses()) {
		c.accept(this, arg);
	}
	if (n.getFinallyBlock().isPresent()) {
		printer.print(" finally ");
		n.getFinallyBlock().get().accept(this, arg);
	}

	if (getNext(n) != null) printer.println();
}
 
开发者ID:sfPlayer1,项目名称:Matcher,代码行数:38,代码来源:SrcRemapper.java

示例6: visit

import com.github.javaparser.ast.stmt.CatchClause; //导入依赖的package包/类
@Override
public void visit(final TryStmt n, final Object arg) {
    printer.printLn("TryStmt");
    printJavaComment(n.getComment(), arg);
    printer.print("try ");
    if (!n.getResources().isEmpty()) {
        printer.print("(");
        Iterator<VariableDeclarationExpr> resources = n.getResources().iterator();
        boolean first = true;
        while (resources.hasNext()) {
            visit(resources.next(), arg);
            if (resources.hasNext()) {
                printer.print(";");
                printer.printLn();
                if (first) {
                    printer.indent();
                }
            }
            first = false;
        }
        if (n.getResources().size() > 1) {
            printer.unindent();
        }
        printer.print(") ");
    }
    n.getTryBlock().accept(this, arg);
    if (n.getCatchs() != null) {
        for (final CatchClause c : n.getCatchs()) {
            c.accept(this, arg);
        }
    }
    if (n.getFinallyBlock() != null) {
        printer.print(" finally ");
        n.getFinallyBlock().accept(this, arg);
    }
}
 
开发者ID:pcgomes,项目名称:javaparser2jctree,代码行数:37,代码来源:ASTDumpVisitor.java

示例7: visit

import com.github.javaparser.ast.stmt.CatchClause; //导入依赖的package包/类
@Override
public JCTree visit(final CatchClause n, final Object arg) {
    //JCVariableDecl param
    JCVariableDecl arg0 = (JCVariableDecl) n.getExcept().accept(this, arg);

    //ARG1: JCBlock body
    JCBlock arg1 = (JCBlock) n.getCatchBlock().accept(this, arg);

    return new AJCCatch(make.Catch(arg0, arg1), ((n.getComment() != null) ? n.getComment().getContent() : null));
}
 
开发者ID:pcgomes,项目名称:javaparser2jctree,代码行数:11,代码来源:JavaParser2JCTree.java

示例8: visit

import com.github.javaparser.ast.stmt.CatchClause; //导入依赖的package包/类
@Override public Boolean visit(final CatchClause n1, final Node arg) {
	final CatchClause n2 = (CatchClause) arg;

	if (!nodeEquals(n1.getParam(), n2.getParam())) {
		return Boolean.FALSE;
	}

	if (!nodeEquals(n1.getCatchBlock(), n2.getCatchBlock())) {
		return Boolean.FALSE;
	}

	return Boolean.TRUE;
}
 
开发者ID:plum-umd,项目名称:java-sketch,代码行数:14,代码来源:EqualsVisitor.java

示例9: visit

import com.github.javaparser.ast.stmt.CatchClause; //导入依赖的package包/类
@Override public void visit(final TryStmt n, final Object arg) {
printJavaComment(n.getComment(), arg);
printer.print("try ");
if (!n.getResources().isEmpty()) {
    printer.print("(");
    Iterator<VariableDeclarationExpr> resources = n.getResources().iterator();
    boolean first = true;
    while (resources.hasNext()) {
	visit(resources.next(), arg);
	if (resources.hasNext()) {
	    printer.print(";");
	    printer.printLn();
	    if (first) {
		printer.indent();
	    }
	}
	first = false;
    }
    if (n.getResources().size() > 1) {
	printer.unindent();
    }
    printer.print(") ");
}
n.getTryBlock().accept(this, arg);
if (n.getCatchs() != null) {
    for (final CatchClause c : n.getCatchs()) {
	c.accept(this, arg);
    }
}
if (n.getFinallyBlock() != null) {
    printer.print(" finally ");
    n.getFinallyBlock().accept(this, arg);
}
   }
 
开发者ID:plum-umd,项目名称:java-sketch,代码行数:35,代码来源:DumpVisitor.java

示例10: visit

import com.github.javaparser.ast.stmt.CatchClause; //导入依赖的package包/类
@Override public Node visit(final TryStmt n, final A arg) {
	n.setTryBlock((BlockStmt) n.getTryBlock().accept(this, arg));
	final List<CatchClause> catchs = n.getCatchs();
	if (catchs != null) {
		for (int i = 0; i < catchs.size(); i++) {
			catchs.set(i, (CatchClause) catchs.get(i).accept(this, arg));
		}
		removeNulls(catchs);
	}
	if (n.getFinallyBlock() != null) {
		n.setFinallyBlock((BlockStmt) n.getFinallyBlock().accept(this, arg));
	}
	return n;
}
 
开发者ID:plum-umd,项目名称:java-sketch,代码行数:15,代码来源:ModifierVisitorAdapter.java

示例11: visit

import com.github.javaparser.ast.stmt.CatchClause; //导入依赖的package包/类
@Override public Boolean visit(final CatchClause n1, final Node arg) {
	final CatchClause n2 = (CatchClause) arg;

	if (!nodeEquals(n1.getParam(), n2.getParam())) {
		return false;
	}

	if (!nodeEquals(n1.getBody(), n2.getBody())) {
		return false;
	}

	return true;
}
 
开发者ID:javaparser,项目名称:javasymbolsolver,代码行数:14,代码来源:EqualsVisitor.java

示例12: visit

import com.github.javaparser.ast.stmt.CatchClause; //导入依赖的package包/类
@Override
public Node visit(TryStmt _n, Object _arg) {
	List<VariableDeclarationExpr> resources = visit(_n.getResources(),_arg);
	BlockStmt tryBlock = cloneNodes(_n.getTryBlock(), _arg);
	List<CatchClause> catchs = visit(_n.getCatchs(), _arg);
	BlockStmt finallyBlock = cloneNodes(_n.getFinallyBlock(), _arg);
	Comment comment = cloneNodes(_n.getComment(), _arg);

	TryStmt r = new TryStmt(
			_n.getRange(),
			resources, tryBlock, catchs, finallyBlock
	);
	r.setComment(comment);
	return r;
}
 
开发者ID:javaparser,项目名称:javasymbolsolver,代码行数:16,代码来源:CloneVisitor.java

示例13: visit

import com.github.javaparser.ast.stmt.CatchClause; //导入依赖的package包/类
@Override public Boolean visit(final CatchClause n1, final Node arg) {
	final CatchClause n2 = (CatchClause) arg;

	if (!nodeEquals(n1.getExcept(), n2.getExcept())) {
		return Boolean.FALSE;
	}

	if (!nodeEquals(n1.getCatchBlock(), n2.getCatchBlock())) {
		return Boolean.FALSE;
	}

	return Boolean.TRUE;
}
 
开发者ID:javaparser,项目名称:javasymbolsolver,代码行数:14,代码来源:EqualsVisitor.java

示例14: visit

import com.github.javaparser.ast.stmt.CatchClause; //导入依赖的package包/类
@Override public void visit(final TryStmt n, final Object arg) {
	printJavaComment(n.getComment(), arg);
	printer.print("try ");
	if (!n.getResources().isEmpty()) {
		printer.print("(");
		Iterator<VariableDeclarationExpr> resources = n.getResources().iterator();
		boolean first = true;
		while (resources.hasNext()) {
			visit(resources.next(), arg);
			if (resources.hasNext()) {
				printer.print(";");
				printer.printLn();
				if (first) {
					printer.indent();
				}
			}
			first = false;
		}
		if (n.getResources().size() > 1) {
			printer.unindent();
		}
		printer.print(") ");
	}
	n.getTryBlock().accept(this, arg);
	if (n.getCatchs() != null) {
		for (final CatchClause c : n.getCatchs()) {
			c.accept(this, arg);
		}
	}
	if (n.getFinallyBlock() != null) {
		printer.print(" finally ");
		n.getFinallyBlock().accept(this, arg);
	}
}
 
开发者ID:javaparser,项目名称:javasymbolsolver,代码行数:35,代码来源:DumpVisitor.java

示例15: visit

import com.github.javaparser.ast.stmt.CatchClause; //导入依赖的package包/类
@Override
public Node visit(
    CatchClause n, Map<Node, Node> arg
) {
  if (arg.containsKey(n)) {
    return arg.get(n);
  }
  return super.visit(n, arg);
}
 
开发者ID:WeTheInternet,项目名称:xapi,代码行数:10,代码来源:ConcreteModifierVisitor.java


注:本文中的com.github.javaparser.ast.stmt.CatchClause类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。