Package org.codehaus.groovy.ast

Examples of org.codehaus.groovy.ast.Parameter


               if (expression.getNodeMetaData(StaticTypesMarker.CLOSURE_ARGUMENTS)!=null) {
                   closureParamTypes = expression.getNodeMetaData(StaticTypesMarker.CLOSURE_ARGUMENTS);
               }
               final Parameter[] parameters = sam.getParameters();
               for (int i = 0; i < parameters.length; i++) {
                   final Parameter parameter = parameters[i];
                   if (parameter.getOriginType().isUsingGenerics() && closureParamTypes.length>i) {
                       genericsToConnect.add(new ClassNode[]{closureParamTypes[i], parameter.getOriginType()});
                   }
               }
               for (ClassNode[] classNodes : genericsToConnect) {
                   ClassNode found = classNodes[0];
                   ClassNode expected = classNodes[1];
View Full Code Here


        if (!typeCheckMethodsWithGenerics(receiver, arguments, candidateMethod)) {
            Map<String, GenericsType> classGTs = GenericsUtils.extractPlaceholders(receiver);
            ClassNode[] ptypes = new ClassNode[candidateMethod.getParameters().length];
            final Parameter[] parameters = candidateMethod.getParameters();
            for (int i = 0; i < parameters.length; i++) {
                final Parameter parameter = parameters[i];
                ClassNode type = parameter.getType();
                ptypes[i] = fullyResolveType(type, classGTs);
            }
            addStaticTypeError("Cannot call " + toMethodGenericTypesString(candidateMethod) + receiver.toString(false) + "#" +
                    toMethodParametersString(candidateMethod.getName(), ptypes) +
                    " with arguments " + formatArgumentList(arguments), location);
View Full Code Here

                fixGenerics(secondGetter, cNode);
                cNode.addMethod(secondGetter);
            }
        }
        if (setterBlock != null) {
            Parameter[] setterParameterTypes = {new Parameter(node.getType(), "value")};
            VariableExpression var = (VariableExpression) ((BinaryExpression) ((ExpressionStatement) setterBlock).getExpression()).getRightExpression();
            var.setAccessedVariable(setterParameterTypes[0]);
            MethodNode setter =
                    new MethodNode(setterName, propNodeModifiers, ClassHelper.VOID_TYPE, setterParameterTypes, ClassNode.EMPTY_ARRAY, setterBlock);
            setter.setSynthetic(true);
View Full Code Here

        // define setter/getter helper methods
        fieldHelper.addMethod(
                Traits.helperSetterName(field),
                ACC_PUBLIC | ACC_ABSTRACT,
                field.getOriginType(),
                new Parameter[]{new Parameter(field.getOriginType(), "val")},
                ClassNode.EMPTY_ARRAY,
                null
        );
        fieldHelper.addMethod(
                Traits.helperGetterName(field),
View Full Code Here

    }

    private Parameter createSelfParameter(final ClassNode traitClass, boolean isStatic) {
        final ClassNode rawType = traitClass.getPlainNodeReference();
        ClassNode type = createReceiverType(isStatic, rawType);
        return new Parameter(type, isStatic?Traits.STATIC_THIS_OBJECT:Traits.THIS_OBJECT);
    }
View Full Code Here

                hasThisCons = true;
            }
        }
        if (!hasThisCons) {
            BlockStatement initBody = new BlockStatement();
            Parameter initParam = param(GenericsUtils.nonGeneric(cNode), "other");
            final Expression other = varX(initParam);
            boolean hasParent = cNode.getSuperClass() != ClassHelper.OBJECT_TYPE;
            if (hasParent) {
                initBody.addStatement(stmt(ctorX(ClassNode.SUPER, other)));
            }
View Full Code Here

            stmt(callThisX("cloneOrCopyMembers", args(result))),
            returnS(result)));
    }

    private void addSimpleCloneHelperMethod(ClassNode cNode, List<FieldNode> fieldNodes, List<String> excludes) {
        Parameter methodParam = new Parameter(GenericsUtils.nonGeneric(cNode), "other");
        final Expression other = varX(methodParam);
        boolean hasParent = cNode.getSuperClass() != ClassHelper.OBJECT_TYPE;
        BlockStatement methodBody = new BlockStatement();
        if (hasParent) {
            methodBody.addStatement(stmt(callSuperX("cloneOrCopyMembers", args(other))));
View Full Code Here

        }
    }

    private void createWriteExternal(ClassNode cNode, List<String> excludes, List<FieldNode> list) {
        final BlockStatement body = new BlockStatement();
        Parameter out = param(OBJECTOUTPUT_TYPE, "out");
        for (FieldNode fNode : list) {
            if (excludes.contains(fNode.getName())) continue;
            if ((fNode.getModifiers() & ACC_TRANSIENT) != 0) continue;
            body.addStatement(stmt(callX(varX(out), "write" + suffixForField(fNode), varX(fNode))));
        }
View Full Code Here

        cNode.addMethod("writeExternal", ACC_PUBLIC, ClassHelper.VOID_TYPE, params(out), exceptions, body);
    }

    private void createReadExternal(ClassNode cNode, List<String> excludes, List<FieldNode> list) {
        final BlockStatement body = new BlockStatement();
        Parameter oin = param(OBJECTINPUT_TYPE, "oin");
        for (FieldNode fNode : list) {
            if (excludes.contains(fNode.getName())) continue;
            if ((fNode.getModifiers() & ACC_TRANSIENT) != 0) continue;
            String suffix = suffixForField(fNode);
            Expression readObject = callX(varX(oin), "read" + suffix);
View Full Code Here

        List<MethodNode> constructorList = findMethod(node, "<init>", arguments);
        if (constructorList.isEmpty()) {
            if (isBeingCompiled(node) && arguments.length==1 && LINKEDHASHMAP_CLASSNODE.equals(arguments[0])) {
                // there will be a default hash map constructor added later
                ConstructorNode cn = new ConstructorNode(Opcodes.ACC_PUBLIC, new Parameter[]{
                        new Parameter(LINKEDHASHMAP_CLASSNODE, "args")
                }, ClassNode.EMPTY_ARRAY, EmptyStatement.INSTANCE);
                return cn;
            } else {
                addStaticTypeError("No matching constructor found: " + node + toMethodParametersString("<init>", arguments), source);
                return null;
View Full Code Here

TOP

Related Classes of org.codehaus.groovy.ast.Parameter

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.