Package com.strobel.assembler.metadata

Examples of com.strobel.assembler.metadata.ParameterDefinition


                    }

                    final MethodDefinition definition = method.resolve();

                    if (definition != null) {
                        final ParameterDefinition p = getOrDefault(
                            definition.getParameters(),
                            parent.getCode() != AstCode.InitObject && !definition.isStatic() ? i - 1 : i
                        );

                        if (p != null && p.hasName() && !StringUtilities.isNullOrEmpty(p.getName())) {
                            return cleanUpVariableName(p.getName());
                        }
                    }
                }

                break;
View Full Code Here


        @Override
        public Void visitIdentifierExpression(final IdentifierExpression node, final Void _) {
            final Variable variable = node.getUserData(Keys.VARIABLE);

            if (variable != null && variable.isParameter()) {
                final ParameterDefinition parameter = variable.getOriginalParameter();

                if (areMethodsEquivalent((MethodReference) parameter.getMethod(), context.getCurrentMethod())) {
                    final AstNode replacement = _argumentMappings.get(parameter);

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

                        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 &&
View Full Code Here

        node.getBaseType().acceptVisitor(this, _);

        boolean isVarArgs = false;

        if (node.getParent() instanceof ParameterDeclaration) {
            final ParameterDefinition parameter = node.getParent().getUserData(Keys.PARAMETER_DEFINITION);

            if (parameter.getPosition() == parameter.getMethod().getParameters().size() - 1 &&
                parameter.getParameterType().isArray() &&
                parameter.getMethod() instanceof MethodReference) {

                final MethodReference method = (MethodReference) parameter.getMethod();
                final MethodDefinition resolvedMethod = method.resolve();

                if (resolvedMethod != null && Flags.testAny(resolvedMethod.getFlags(), Flags.ACC_VARARGS | Flags.VARARGS)) {
                    isVarArgs = true;
                }
View Full Code Here

        if (node instanceof Identifier && node.getParent() != null) {
            node = node.getParent();
        }

        final ParameterDefinition parameter = node.getUserData(Keys.PARAMETER_DEFINITION);

        if (parameter != null) {
            return parameter;
        }
View Full Code Here

            final Set<ParameterDefinition> unassignedParameters = new HashSet<>();
            final AstNodeCollection<ParameterDeclaration> parameters = node.getChildrenByRole(Roles.PARAMETER);
            final Map<ParameterDefinition, ParameterDeclaration> declarationMap = new HashMap<>();

            for (final ParameterDeclaration parameter : parameters) {
                final ParameterDefinition definition = parameter.getUserData(Keys.PARAMETER_DEFINITION);

                if (definition != null) {
                    unassignedParameters.add(definition);
                    declarationMap.put(definition, parameter);
                }
View Full Code Here

            if (variable != null && variable.isParameter()) {
                _unassignedParameters.remove(variable.getOriginalParameter());
                return super.visitAssignmentExpression(node, _);
            }

            ParameterDefinition parameter = left.getUserData(Keys.PARAMETER_DEFINITION);

            if (parameter == null && left instanceof IdentifierExpression) {
                parameter = _parametersByName.get(((IdentifierExpression) left).getIdentifier());
            }
View Full Code Here

            switch (node.getOperator()) {
                case INCREMENT:
                case DECREMENT:
                case POST_INCREMENT:
                case POST_DECREMENT: {
                    ParameterDefinition parameter = operand.getUserData(Keys.PARAMETER_DEFINITION);

                    if (parameter == null && operand instanceof IdentifierExpression) {
                        parameter = _parametersByName.get(((IdentifierExpression) operand).getIdentifier());
                    }
View Full Code Here

            output.write("(");

            final List<ParameterDefinition> parameters = method.getParameters();

            for (int i = 0; i < parameters.size(); i++) {
                final ParameterDefinition parameter = parameters.get(i);

                if (i != 0) {
                    output.write(", ");
                }

                DecompilerHelpers.writeType(output, parameter.getParameterType(), NameSyntax.TYPE_NAME);
                output.write(' ');
                output.writeReference(parameter.getName(), parameter);
            }

            output.write(")");
        }
    }
View Full Code Here

    public final void setOriginalVariable(final VariableDefinition originalVariable) {
        _originalVariable = originalVariable;
    }

    public final ParameterDefinition getOriginalParameter() {
        final ParameterDefinition originalParameter = _originalParameter;

        if (originalParameter != null) {
            return originalParameter;
        }
View Full Code Here

TOP

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

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.