當前位置: 首頁>>代碼示例>>Java>>正文


Java ThrowStatement類代碼示例

本文整理匯總了Java中org.codehaus.groovy.ast.stmt.ThrowStatement的典型用法代碼示例。如果您正苦於以下問題:Java ThrowStatement類的具體用法?Java ThrowStatement怎麽用?Java ThrowStatement使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ThrowStatement類屬於org.codehaus.groovy.ast.stmt包,在下文中一共展示了ThrowStatement類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createCatchBlockForOuterNewTryCatchStatement

import org.codehaus.groovy.ast.stmt.ThrowStatement; //導入依賴的package包/類
private CatchStatement createCatchBlockForOuterNewTryCatchStatement(String primaryExcName) {
    // { ... }
    BlockStatement blockStatement = new BlockStatement();
    String tExcName = this.genTExcName();

    // #primaryExc = #t;
    ExpressionStatement primaryExcAssignStatement =
            new ExpressionStatement(
                    new BinaryExpression(
                            new VariableExpression(primaryExcName),
                            org.codehaus.groovy.syntax.Token.newSymbol(Types.ASSIGN, -1, -1),
                            new VariableExpression(tExcName)));
    astBuilder.appendStatementsToBlockStatement(blockStatement, primaryExcAssignStatement);

    // throw #t;
    ThrowStatement throwTExcStatement = new ThrowStatement(new VariableExpression(tExcName));
    astBuilder.appendStatementsToBlockStatement(blockStatement, throwTExcStatement);

    // Throwable #t
    Parameter tExcParameter = new Parameter(ClassHelper.make(Throwable.class), tExcName);

    return new CatchStatement(tExcParameter, blockStatement);
}
 
開發者ID:apache,項目名稱:groovy,代碼行數:24,代碼來源:TryWithResourcesASTTransformation.java

示例2: statementReturns

import org.codehaus.groovy.ast.stmt.ThrowStatement; //導入依賴的package包/類
private static boolean statementReturns(Statement last) {
    return (
            last instanceof ReturnStatement ||
            last instanceof BlockStatement ||
            last instanceof IfStatement ||
            last instanceof ExpressionStatement ||
            last instanceof EmptyStatement ||
            last instanceof TryCatchStatement ||
            last instanceof BytecodeSequence ||
            last instanceof ThrowStatement ||
            last instanceof SynchronizedStatement
            );
}
 
開發者ID:apache,項目名稱:groovy,代碼行數:14,代碼來源:ReturnAdder.java

示例3: writeThrow

import org.codehaus.groovy.ast.stmt.ThrowStatement; //導入依賴的package包/類
public void writeThrow(ThrowStatement statement) {
    controller.getAcg().onLineNumber(statement, "visitThrowStatement");
    writeStatementLabel(statement);
    MethodVisitor mv = controller.getMethodVisitor();

    statement.getExpression().visit(controller.getAcg());

    // we should infer the type of the exception from the expression
    mv.visitTypeInsn(CHECKCAST, "java/lang/Throwable");
    mv.visitInsn(ATHROW);
    
    controller.getOperandStack().remove(1);
}
 
開發者ID:apache,項目名稱:groovy,代碼行數:14,代碼來源:StatementWriter.java

示例4: visitThrowStatement

import org.codehaus.groovy.ast.stmt.ThrowStatement; //導入依賴的package包/類
@Override
public void visitThrowStatement(final ThrowStatement statement) {
    super.visitThrowStatement(statement);
    tryFind(ThrowStatement.class, statement);
}
 
開發者ID:apache,項目名稱:groovy,代碼行數:6,代碼來源:ASTFinder.java

示例5: visitThrowStatement

import org.codehaus.groovy.ast.stmt.ThrowStatement; //導入依賴的package包/類
@Override
public void visitThrowStatement(final ThrowStatement statement) {
    pushContext(statement);
    super.visitThrowStatement(statement);
    popContext();
}
 
開發者ID:apache,項目名稱:groovy,代碼行數:7,代碼來源:ContextualClassCodeVisitor.java

示例6: visitThrowStmtAlt

import org.codehaus.groovy.ast.stmt.ThrowStatement; //導入依賴的package包/類
@Override
public ThrowStatement visitThrowStmtAlt(ThrowStmtAltContext ctx) {
    return configureAST(
            new ThrowStatement((Expression) this.visit(ctx.expression())),
            ctx);
}
 
開發者ID:apache,項目名稱:groovy,代碼行數:7,代碼來源:AstBuilder.java

示例7: visitThrowStatement

import org.codehaus.groovy.ast.stmt.ThrowStatement; //導入依賴的package包/類
public void visitThrowStatement(final ThrowStatement statement) {
    assertStatementAuthorized(statement);
    statement.getExpression().visit(this);
}
 
開發者ID:apache,項目名稱:groovy,代碼行數:5,代碼來源:SecureASTCustomizer.java

示例8: visitThrowStatement

import org.codehaus.groovy.ast.stmt.ThrowStatement; //導入依賴的package包/類
public void visitThrowStatement(ThrowStatement ts) {
    ts.setExpression(transform(ts.getExpression()));
}
 
開發者ID:apache,項目名稱:groovy,代碼行數:4,代碼來源:ClassCodeExpressionTransformer.java

示例9: visitThrowStatement

import org.codehaus.groovy.ast.stmt.ThrowStatement; //導入依賴的package包/類
@Override
public void visitThrowStatement(final ThrowStatement statement) {
    super.visitThrowStatement(statement);
    trn.visitThrowStatement(statement);
}
 
開發者ID:apache,項目名稱:groovy,代碼行數:6,代碼來源:TransformingCodeVisitor.java

示例10: visitThrowStatement

import org.codehaus.groovy.ast.stmt.ThrowStatement; //導入依賴的package包/類
public void visitThrowStatement(ThrowStatement statement) {
    statement.getExpression().visit(this);
}
 
開發者ID:apache,項目名稱:groovy,代碼行數:4,代碼來源:CodeVisitorSupport.java

示例11: visitThrowStatement

import org.codehaus.groovy.ast.stmt.ThrowStatement; //導入依賴的package包/類
public void visitThrowStatement(ThrowStatement statement) {
    visitStatement(statement);
    super.visitThrowStatement(statement);
}
 
開發者ID:apache,項目名稱:groovy,代碼行數:5,代碼來源:ClassCodeVisitorSupport.java

示例12: throwS

import org.codehaus.groovy.ast.stmt.ThrowStatement; //導入依賴的package包/類
public static ThrowStatement throwS(Expression expr) {
    return new ThrowStatement(expr);
}
 
開發者ID:apache,項目名稱:groovy,代碼行數:4,代碼來源:GeneralUtils.java

示例13: visitThrowStatement

import org.codehaus.groovy.ast.stmt.ThrowStatement; //導入依賴的package包/類
public void visitThrowStatement(ThrowStatement statement) {
    controller.getStatementWriter().writeThrow(statement);
}
 
開發者ID:apache,項目名稱:groovy,代碼行數:4,代碼來源:AsmClassGenerator.java

示例14: createValidateMethod

import org.codehaus.groovy.ast.stmt.ThrowStatement; //導入依賴的package包/類
private void createValidateMethod() {
    assertNoValidateMethodDeclared();

    Validation.Mode mode = getEnumMemberValue(CommonAstHelper.getAnnotation(annotatedClass, VALIDATION_ANNOTATION), "mode", Validation.Mode.class, Validation.Mode.AUTOMATIC);

    if (dslParent == null) {
        // add manual validation only to root of hierarchy
        // TODO field could be added to rw as well
        annotatedClass.addField("$manualValidation", ACC_PROTECTED | ACC_SYNTHETIC, ClassHelper.Boolean_TYPE, new ConstantExpression(mode == Validation.Mode.MANUAL));
        createPublicMethod("manualValidation")
                .param(Boolean_TYPE, "validation", constX(true))
                .assignS(propX(varX(NAME_OF_MODEL_FIELD_IN_RW_CLASS), "$manualValidation"), varX("validation"))
                .addTo(rwClass);
    }

    DslMethodBuilder methodBuilder = createPublicMethod(VALIDATE_METHOD);

    if (dslParent != null) {
        methodBuilder.statement(callSuperX(VALIDATE_METHOD));
    }

    BlockStatement block = new BlockStatement();
    validateFields(block);
    validateCustomMethods(block);

    TryCatchStatement tryCatchStatement = new TryCatchStatement(block, EmptyStatement.INSTANCE);
    tryCatchStatement.addCatch(new CatchStatement(
            param(ASSERTION_ERROR_TYPE, "e"),
            new ThrowStatement(ctorX(VALIDATION_EXCEPTION_TYPE, args(propX(varX("e"), "message"), varX("e"))))
            )
    );
    tryCatchStatement.addCatch(new CatchStatement(
            param(EXCEPTION_TYPE, "e"),
            new ThrowStatement(ctorX(VALIDATION_EXCEPTION_TYPE, args(propX(varX("e"), "message"), varX("e"))))
            )
    );

    methodBuilder
            .statement(tryCatchStatement)
            .addTo(annotatedClass);
}
 
開發者ID:klum-dsl,項目名稱:klum-ast,代碼行數:42,代碼來源:DSLASTTransformation.java

示例15: throwS

import org.codehaus.groovy.ast.stmt.ThrowStatement; //導入依賴的package包/類
/**
 * Represents how to throw an exception
 *
 * <strong>AST</strong>
 * <pre><code>throwS(newX(IllegalStateException, constX('wrong value')))</code></pre>
 *
 * <strong>Result</strong>
 * <pre><code>throw new IllegalStateException('wrong value')</code></pre>
 *
 * @param expression it will be normally a representation of a new
 * instance of a given Throwable type
 * @return an instance of {@link ThrowStatement}
 * @since 0.2.4
 */
public static ThrowStatement throwS(final Expression expression) {
    return new ThrowStatement(expression);
}
 
開發者ID:grooviter,項目名稱:asteroid,代碼行數:18,代碼來源:Statements.java


注:本文中的org.codehaus.groovy.ast.stmt.ThrowStatement類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。