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

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

Introduction

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

Prototype

ChildPropertyDescriptor EXPRESSION_PROPERTY

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

Click Source Link

Document

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

Usage

From source file:org.eclipse.wb.internal.core.parser.AbstractParseFactory.java

License:Open Source License

public JavaInfo create(AstEditor editor, Expression expression) throws Exception {
    // (Type) super.someMethodInvocation()
    if (expression instanceof CastExpression) {
        CastExpression castExpression = (CastExpression) expression;
        if (castExpression.getExpression() instanceof SuperMethodInvocation) {
            // prepare component Class
            Class<?> componentClass;
            {/*  ww  w.j a  va2 s .  co  m*/
                String componentClassName = AstNodeUtils.getFullyQualifiedName(expression, true);
                componentClass = EditorState.get(editor).getEditorLoader().loadClass(componentClassName);
            }
            // create JavaInfo
            return JavaInfoUtils.createJavaInfo(editor, componentClass,
                    new CastedSuperInvocationCreationSupport(castExpression));
        }
    }
    // super.someMethodInvocation()
    if (expression instanceof SuperMethodInvocation
            && expression.getLocationInParent() != CastExpression.EXPRESSION_PROPERTY) {
        SuperMethodInvocation invocation = (SuperMethodInvocation) expression;
        ITypeBinding typeBinding = AstNodeUtils.getTypeBinding(invocation);
        if (isToolkitObject(editor, typeBinding)) {
            // prepare component Class
            Class<?> componentClass;
            {
                String componentClassName = AstNodeUtils.getFullyQualifiedName(typeBinding, true);
                componentClass = EditorState.get(editor).getEditorLoader().loadClass(componentClassName);
            }
            // create JavaInfo
            return JavaInfoUtils.createJavaInfo(editor, componentClass,
                    new SuperInvocationCreationSupport(invocation));
        }
    }
    // can not create model
    return null;
}

From source file:org.eclipse.wb.internal.core.parser.JavaInfoResolver.java

License:Open Source License

private JavaInfo getJavaInfo0(Expression expression) throws Exception {
    // check for nodes that can not be JavaInfo
    if (expression instanceof NullLiteral || expression instanceof BooleanLiteral
            || expression instanceof NumberLiteral || expression instanceof StringLiteral
            || expression instanceof TypeLiteral || expression instanceof Assignment
            || expression instanceof ArrayCreation || expression instanceof ArrayInitializer) {
        return null;
    }//from ww  w. j  a  va2s. com
    // "null" or "this"
    if (expression == null || expression instanceof ThisExpression) {
        if (!m_thisJavaInfoReady) {
            m_thisJavaInfoReady = true;
            for (JavaInfo component : getComponents()) {
                if (component.getCreationSupport() instanceof ThisCreationSupport) {
                    m_thisJavaInfo = component;
                    break;
                }
            }
        }
        if (m_thisJavaInfo != null) {
            m_thisJavaInfo.addRelatedNode(expression);
        }
        return m_thisJavaInfo;
    }
    // try to find tracked value
    {
        ExecutionFlowDescription flowDescription = m_editorState.getFlowDescription();
        ExpressionValue value = ExecutionFlowUtils2.getValue(flowDescription, expression);
        if (value != null) {
            // may be bound JavaInfo creation/access
            JavaInfo javaInfo = (JavaInfo) value.getModel();
            if (javaInfo != null) {
                boolean expressionPartOfCasted = javaInfo
                        .getCreationSupport() instanceof CastedSuperInvocationCreationSupport
                        && expression.getLocationInParent() == CastExpression.EXPRESSION_PROPERTY;
                if (!expressionPartOfCasted) {
                    javaInfo.addRelatedNode(expression);
                }
                return javaInfo;
            }
            // resolve "this"
            {
                Expression newExpression = value.getExpression();
                if (newExpression instanceof ThisExpression && newExpression != expression) {
                    return getJavaInfo0(newExpression);
                }
            }
        }
    }
    // XXX special support for RCP FormToolkit
    if (AstNodeUtils.isSuccessorOf(expression, "org.eclipse.ui.forms.widgets.FormToolkit")) {
        for (JavaInfo component : getComponents()) {
            if (component instanceof InstanceFactoryInfo) {
                if (component.getCreationSupport().isJavaInfo(expression)) {
                    ExecutionFlowUtils2.ensurePermanentValue(expression).setModel(component);
                    component.addRelatedNode(expression);
                    return component;
                }
            }
        }
    }
    // invocation
    if (expression instanceof MethodInvocation) {
        MethodInvocation invocation = (MethodInvocation) expression;
        String invName = invocation.getName().getIdentifier();
        // XXX special support for GWT RootPanel
        if (invName.equals("get")
                && AstNodeUtils.isSuccessorOf(invocation, "com.google.gwt.user.client.ui.RootPanel")) {
            for (JavaInfo component : getComponents()) {
                if (component.getCreationSupport().isJavaInfo(invocation)) {
                    ExecutionFlowUtils2.ensurePermanentValue(expression).setModel(component);
                    component.addRelatedNode(expression);
                    return component;
                }
            }
        }
        // generic get()
        if (invName.startsWith("get")) {
            JavaInfo expressionJavaInfo = getJavaInfo(invocation.getExpression());
            // getContentPane()
            {
                JavaInfo result = getExposedJavaInfo(expressionJavaInfo, invocation);
                if (result != null) {
                    return result;
                }
            }
            // viewer.getTable()
            if (expressionJavaInfo instanceof IWrapperInfo) {
                IWrapperInfo wrapperInfo = (IWrapperInfo) expressionJavaInfo;
                IWrapper wrapper = wrapperInfo.getWrapper();
                JavaInfo javaInfo = wrapper.getWrappedInfo();
                if (wrapper.isWrappedInfo(invocation)) {
                    ExecutionFlowUtils2.ensurePermanentValue(expression).setModel(javaInfo);
                    javaInfo.addRelatedNode(expression);
                    return javaInfo;
                }
            }
        }
        return null;
    }
    // m_exposedField
    if (expression instanceof SimpleName) {
        SimpleName simpleName = (SimpleName) expression;
        JavaInfo thisJavaInfo = getJavaInfo(null);
        String fieldName = simpleName.getIdentifier();
        return getExposedJavaInfo(thisJavaInfo, expression, fieldName);
    }
    // someJavaInfo.m_exposedField
    if (expression instanceof QualifiedName) {
        QualifiedName qualifiedName = (QualifiedName) expression;
        JavaInfo hostJavaInfo = getJavaInfo(qualifiedName.getQualifier());
        String fieldName = qualifiedName.getName().getIdentifier();
        return getExposedJavaInfo(hostJavaInfo, expression, fieldName);
    }
    // no
    return null;
}