Example usage for org.eclipse.jdt.core.dom ThrowStatement EXPRESSION_PROPERTY

List of usage examples for org.eclipse.jdt.core.dom ThrowStatement EXPRESSION_PROPERTY

Introduction

In this page you can find the example usage for org.eclipse.jdt.core.dom ThrowStatement EXPRESSION_PROPERTY.

Prototype

ChildPropertyDescriptor EXPRESSION_PROPERTY

To view the source code for org.eclipse.jdt.core.dom ThrowStatement EXPRESSION_PROPERTY.

Click Source Link

Document

The "expression" structural property of this node type (child type: Expression ).

Usage

From source file:org.moe.natjgen.MethodEditor.java

License:Apache License

@SuppressWarnings("unchecked")
public void setBodyAsProtocolDefaultMethod(Type rettype) {
    Block code = (Block) getRewrite().get(methodDecl, MethodDeclaration.BODY_PROPERTY);
    if (code == null) {
        code = getAST().newBlock();/*from  w w  w .j  a v  a2 s. co m*/
        getRewrite().set(methodDecl, MethodDeclaration.BODY_PROPERTY, code, getEditGroup());
    }
    ListRewrite statements = getRewrite().getListRewrite(code, Block.STATEMENTS_PROPERTY);
    for (ASTNode object : (List<ASTNode>) statements.getRewrittenList()) {
        statements.remove(object, getEditGroup());
    }

    Name uoe = getAST().newName("java.lang.UnsupportedOperationException");
    SimpleType uoet = getAST().newSimpleType(uoe);
    ClassInstanceCreation cic = getAST().newClassInstanceCreation();
    getRewrite().set(cic, ClassInstanceCreation.TYPE_PROPERTY, uoet, getEditGroup());
    ThrowStatement th = getAST().newThrowStatement();
    getRewrite().set(th, ThrowStatement.EXPRESSION_PROPERTY, cic, getEditGroup());
    statements.insertLast(th, getEditGroup());
}