本文整理匯總了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);
}
示例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
);
}
示例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);
}
示例4: visitThrowStatement
import org.codehaus.groovy.ast.stmt.ThrowStatement; //導入依賴的package包/類
@Override
public void visitThrowStatement(final ThrowStatement statement) {
super.visitThrowStatement(statement);
tryFind(ThrowStatement.class, statement);
}
示例5: visitThrowStatement
import org.codehaus.groovy.ast.stmt.ThrowStatement; //導入依賴的package包/類
@Override
public void visitThrowStatement(final ThrowStatement statement) {
pushContext(statement);
super.visitThrowStatement(statement);
popContext();
}
示例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);
}
示例7: visitThrowStatement
import org.codehaus.groovy.ast.stmt.ThrowStatement; //導入依賴的package包/類
public void visitThrowStatement(final ThrowStatement statement) {
assertStatementAuthorized(statement);
statement.getExpression().visit(this);
}
示例8: visitThrowStatement
import org.codehaus.groovy.ast.stmt.ThrowStatement; //導入依賴的package包/類
public void visitThrowStatement(ThrowStatement ts) {
ts.setExpression(transform(ts.getExpression()));
}
示例9: visitThrowStatement
import org.codehaus.groovy.ast.stmt.ThrowStatement; //導入依賴的package包/類
@Override
public void visitThrowStatement(final ThrowStatement statement) {
super.visitThrowStatement(statement);
trn.visitThrowStatement(statement);
}
示例10: visitThrowStatement
import org.codehaus.groovy.ast.stmt.ThrowStatement; //導入依賴的package包/類
public void visitThrowStatement(ThrowStatement statement) {
statement.getExpression().visit(this);
}
示例11: visitThrowStatement
import org.codehaus.groovy.ast.stmt.ThrowStatement; //導入依賴的package包/類
public void visitThrowStatement(ThrowStatement statement) {
visitStatement(statement);
super.visitThrowStatement(statement);
}
示例12: throwS
import org.codehaus.groovy.ast.stmt.ThrowStatement; //導入依賴的package包/類
public static ThrowStatement throwS(Expression expr) {
return new ThrowStatement(expr);
}
示例13: visitThrowStatement
import org.codehaus.groovy.ast.stmt.ThrowStatement; //導入依賴的package包/類
public void visitThrowStatement(ThrowStatement statement) {
controller.getStatementWriter().writeThrow(statement);
}
示例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);
}
示例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);
}