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

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

Introduction

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

Prototype

ChildPropertyDescriptor EXPRESSION_PROPERTY

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

Click Source Link

Document

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

Usage

From source file:org.autorefactor.refactoring.rules.UseDiamondOperatorRefactoring.java

License:Open Source License

private boolean parentAllowsDiamondOperator(ClassInstanceCreation node) {
    final ASTNode parentInfo = getFirstParentOfType(node, ParenthesizedExpression.class);
    final StructuralPropertyDescriptor locationInParent = parentInfo.getLocationInParent();

    switch (parentInfo.getParent().getNodeType()) {
    case ASSIGNMENT:
        return Assignment.RIGHT_HAND_SIDE_PROPERTY.equals(locationInParent);
    case METHOD_INVOCATION:
        return false; // FIXME some of them can be refactored
    case RETURN_STATEMENT:
        return ReturnStatement.EXPRESSION_PROPERTY.equals(locationInParent);
    case VARIABLE_DECLARATION_FRAGMENT:
        return VariableDeclarationFragment.INITIALIZER_PROPERTY.equals(locationInParent);
    default://from  w  w  w. j  a  va2 s.co m
        return false;
    }
}

From source file:org.eclipse.wb.internal.rcp.model.jface.ApplicationWindowInfo.java

License:Open Source License

public ApplicationWindowInfo(AstEditor editor, ComponentDescription description,
        CreationSupport creationSupport) throws Exception {
    super(editor, description, creationSupport);
    addBroadcastListener(new GenericPropertyGetValue() {
        public void invoke(GenericPropertyImpl property, Object[] value) throws Exception {
            // return status manager's 'message' property as value of ApplicationWindow.status property.
            if (isStatusManagerMessageProperty(property)) {
                value[0] = m_this.getPropertyByTitle("status").getValue();
            }/* w  w  w.j  av  a 2  s.  c  o  m*/
        }
    });
    addBroadcastListener(new JavaEventListener() {
        @Override
        public void bindComponents(List<JavaInfo> components) throws Exception {
            // bind IContributionManager's to ApplicationWindow
            for (JavaInfo component : components) {
                if (component.getParent() == null
                        && ReflectionUtils.isSuccessorOf(component.getDescription().getComponentClass(),
                                "org.eclipse.jface.action.IContributionManager")
                        && isReturnedFromMethod(component)) {
                    addChild(component);
                    component.setAssociation(new EmptyAssociation());
                    if (isStatusLineManager(component)) {
                        m_statusLineManager = component;
                    }
                }
            }
        }

        private boolean isReturnedFromMethod(JavaInfo javaInfo) {
            for (ASTNode node : javaInfo.getRelatedNodes()) {
                if (node.getLocationInParent() == ReturnStatement.EXPRESSION_PROPERTY) {
                    return true;
                }
            }
            return false;
        }

        @Override
        public void setPropertyExpression(GenericPropertyImpl property, String[] source, Object[] value,
                boolean[] shouldSet) throws Exception {
            // set status manager's 'message' property as value of ApplicationWindow.status property.
            if (isStatusManagerMessageProperty(property)) {
                m_this.getPropertyByTitle("status").setValue(value[0]);
                shouldSet[0] = false;
            }
        }
    });
}

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

License:Apache License

@SuppressWarnings("unchecked")
public void setBodyAsMethodCaller(String jmethod, Type rettype, ArrayList<CalleeArgument> arguments) {
    Block code = (Block) getRewrite().get(methodDecl, MethodDeclaration.BODY_PROPERTY);
    if (code == null) {
        code = getAST().newBlock();//from   www  .ja  v a2s .  c  o 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());
    }

    MethodInvocation invoke = getAST().newMethodInvocation();
    getRewrite().set(invoke, MethodInvocation.NAME_PROPERTY, getAST().newSimpleName(jmethod), getEditGroup());

    if (rettype.isVoid()) {
        ExpressionStatement expr_stmt = getAST().newExpressionStatement(invoke);
        statements.insertLast(expr_stmt, getEditGroup());
    } else {
        ReturnStatement return_stmt = getAST().newReturnStatement();
        statements.insertLast(return_stmt, getEditGroup());
        getRewrite().set(return_stmt, ReturnStatement.EXPRESSION_PROPERTY, invoke, getEditGroup());
    }

    if (arguments.size() > 0) {
        ListRewrite args = getRewrite().getListRewrite(invoke, MethodInvocation.ARGUMENTS_PROPERTY);
        for (CalleeArgument arg : arguments) {
            args.insertLast(getAST().newSimpleName(arg.getName()), getEditGroup());
        }
    }
}