Package com.strobel.assembler.metadata

Examples of com.strobel.assembler.metadata.MemberReference


        //
        // TODO: Remove the `if` below once overload resolution is written and integrated.
        //
        if (node.getRole() == Roles.ARGUMENT) {
            final MemberReference member = parent.getUserData(Keys.MEMBER_REFERENCE);

            if (member instanceof MethodReference) {
                final MethodReference method = (MethodReference) parent.getUserData(Keys.MEMBER_REFERENCE);

                if (method == null || MetadataHelper.isOverloadCheckingRequired(method)) {
View Full Code Here


        if (!(target instanceof MemberReferenceExpression)) {
            return;
        }

        final MemberReference reference = e.getUserData(Keys.MEMBER_REFERENCE);

        if (!(reference instanceof MethodReference)) {
            return;
        }

        final String key = reference.getFullName() + ":" + reference.getSignature();

        if (!UNBOX_METHODS.contains(key)) {
            return;
        }
View Full Code Here

        // TODO: Use overload checking (once implemented).  As is, we may remove necessary casts.
        //

        final AstNode parent = e.getParent();

        final MemberReference unboxMethod = e.getUserData(Keys.MEMBER_REFERENCE);
        final MemberReference outerBoxMethod = parent.getUserData(Keys.MEMBER_REFERENCE);

        if (!(unboxMethod instanceof MethodReference && outerBoxMethod instanceof MethodReference)) {
            return;
        }

        final String unboxMethodKey = unboxMethod.getFullName() + ":" + unboxMethod.getSignature();
        final String boxMethodKey = outerBoxMethod.getFullName() + ":" + outerBoxMethod.getSignature();

        if (!UNBOX_METHODS.contains(unboxMethodKey)) {
            return;
        }
View Full Code Here

    private void removeBoxing(final InvocationExpression node) {
        if (!isValidPrimitiveParent(node, node.getParent())) {
            return;
        }

        final MemberReference reference = node.getUserData(Keys.MEMBER_REFERENCE);

        if (!(reference instanceof MethodReference)) {
            return;
        }

        final String key = reference.getFullName() + ":" + reference.getSignature();

        if (!BOX_METHODS.contains(key)) {
            return;
        }
View Full Code Here

                    if (variable == null || !variable.isParameter()) {
                        return null;
                    }

                    final MemberReferenceExpression memberReference = (MemberReferenceExpression) left;
                    final MemberReference member = memberReference.getUserData(Keys.MEMBER_REFERENCE);

                    if (member instanceof FieldReference &&
                        memberReference.getTarget() instanceof ThisReferenceExpression) {

                        final FieldDefinition resolvedField = ((FieldReference) member).resolve();

                        if (resolvedField != null && resolvedField.isSynthetic()) {
                            final ParameterDefinition parameter = variable.getOriginalParameter();
                            final int parameterIndex = parameter.getPosition();

                            if (parameterIndex >= 0 && parameterIndex < _originalArguments.size()) {
                                final Expression argument = _originalArguments.get(parameterIndex);

                                if (argument != null) {
                                    _nodesToRemove.add(argument);
                                }

                                if (argument instanceof ThisReferenceExpression) {
                                    //
                                    // Don't replace outer class references; they will be rewritten later.
                                    //
                                    markConstructorParameterForRemoval(node, parameter);
                                    return null;
                                }

                                _parametersToRemove.add(parameter);

                                final String fullName = member.getFullName();

                                if (!hasSideEffects(argument)) {
                                    _replacements.put(fullName, argument);
                                }
                                else {
                                    context.getForcedVisibleMembers().add(resolvedField);
                                    _initializers.put(fullName, argument);
                                }

                                if (node.getParent() instanceof ExpressionStatement) {
                                    _nodesToRemove.add(node.getParent());
                                }

                                markConstructorParameterForRemoval(node, parameter);
                            }
                        }
                        else if (_baseConstructorCalled &&
                                 resolvedField != null &&
                                 context.getCurrentMethod().isConstructor() &&
                                 (!context.getCurrentMethod().isSynthetic() ||
                                  context.getSettings().getShowSyntheticMembers())) {

                            final MemberReferenceExpression leftMemberReference = (MemberReferenceExpression) left;
                            final MemberReference leftMember = leftMemberReference.getUserData(Keys.MEMBER_REFERENCE);
                            final Variable rightVariable = right.getUserData(Keys.VARIABLE);

                            if (rightVariable.isParameter()) {
                                final ParameterDefinition parameter = variable.getOriginalParameter();
                                final int parameterIndex = parameter.getPosition();

                                if (parameterIndex >= 0 && parameterIndex < _originalArguments.size()) {
                                    final Expression argument = _originalArguments.get(parameterIndex);

                                    if (parameterIndex == 0 &&
                                        argument instanceof ThisReferenceExpression &&
                                        context.getCurrentType().isLocalClass()) {

                                        //
                                        // Don't replace outer class references; they will be rewritten later.
                                        //
                                        return null;
                                    }

                                    final FieldDefinition resolvedTargetField = ((FieldReference) leftMember).resolve();

                                    if (resolvedTargetField != null && !resolvedTargetField.isSynthetic()) {
                                        _parametersToRemove.add(parameter);
                                        _initializers.put(resolvedTargetField.getFullName(), argument);

                                        if (node.getParent() instanceof ExpressionStatement) {
                                            _nodesToRemove.add(node.getParent());
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                else if (_baseConstructorCalled && right instanceof MemberReferenceExpression) {
                    final MemberReferenceExpression leftMemberReference = (MemberReferenceExpression) left;
                    final MemberReference leftMember = leftMemberReference.getUserData(Keys.MEMBER_REFERENCE);
                    final MemberReferenceExpression rightMemberReference = (MemberReferenceExpression) right;
                    final MemberReference rightMember = right.getUserData(Keys.MEMBER_REFERENCE);

                    if (rightMember instanceof FieldReference &&
                        rightMemberReference.getTarget() instanceof ThisReferenceExpression) {

                        final FieldDefinition resolvedTargetField = ((FieldReference) leftMember).resolve();
                        final FieldDefinition resolvedSourceField = ((FieldReference) rightMember).resolve();

                        if (resolvedSourceField != null &&
                            resolvedTargetField != null &&
                            resolvedSourceField.isSynthetic() &&
                            !resolvedTargetField.isSynthetic()) {

                            final Expression initializer = _replacements.get(rightMember.getFullName());

                            if (initializer != null) {
                                _initializers.put(resolvedTargetField.getFullName(), initializer);

                                if (node.getParent() instanceof ExpressionStatement) {
View Full Code Here

                return null;
            }

            if (node.getTarget() instanceof ThisReferenceExpression) {
                final MemberReference member = node.getUserData(Keys.MEMBER_REFERENCE);

                if (member instanceof FieldReference) {
                    final Expression replacement = _replacements.get(member.getFullName());

                    if (replacement != null) {
                        node.replaceWith(replacement.clone());
                    }
                }
View Full Code Here

    }

    private MemberReference getCurrentMemberReference() {
        final AstNode node = nodeStack.peek();

        MemberReference member = node.getUserData(Keys.MEMBER_REFERENCE);

        if (member == null &&
            node.getRole() == Roles.TARGET_EXPRESSION &&
            (node.getParent() instanceof InvocationExpression || node.getParent() instanceof ObjectCreationExpression)) {
View Full Code Here

        if (node instanceof LabelStatement) {
            final LabelStatement label = (LabelStatement) node;

            for (int i = nodeStack.size() - 1; i >= 0; i--) {
                final AstNode n = nodeStack.get(i);
                final MemberReference methodReference = n.getUserData(Keys.MEMBER_REFERENCE);

                if (methodReference instanceof MethodReference) {
                    return methodReference + label.getLabel();
                }
            }
View Full Code Here

    @Override
    public boolean matches(final INode other, final Match match) {
        if (other instanceof AstNode) {
            final AstNode reference = (AstNode) other;
            final MemberReference memberReference = reference.getUserData(Keys.MEMBER_REFERENCE);
           
            if (_target.matches(reference, match) &&
                _referenceType.isInstance(memberReference)) {

                match.add(_groupName, reference);
View Full Code Here

                    ((PrimitiveExpression) argument).getValue() instanceof String) {

                    atLeastOneStringArgument = true;
                }
                else {
                    final MemberReference member = parent.getUserData(Keys.MEMBER_REFERENCE);

                    if (member instanceof MethodReference) {
                        final List<ParameterDefinition> p = ((MethodReference) member).getParameters();

                        if (p.size() == 1 &&
View Full Code Here

TOP

Related Classes of com.strobel.assembler.metadata.MemberReference

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.