Package org.python.pydev.refactoring.ast.adapters

Examples of org.python.pydev.refactoring.ast.adapters.FunctionDefAdapter


        NameTokType kwArg = null;

        Set<String> argsNames = new LinkedHashSet<String>();

        for (IClassDefAdapter baseClass : bases) {
            FunctionDefAdapter init = baseClass.getFirstInit();
            if (init != null) {
                if (!init.getArguments().hasOnlySelf()) {
                    argsNames.addAll(init.getArguments().getSelfFilteredArgNames());
                }
                if (varArg == null && init.getArguments().hasVarArg()) {
                    varArg = new NameTok(ARGS, NameTok.VarArg);
                }

                if (kwArg == null && init.getArguments().hasKwArg()) {
                    kwArg = new NameTok(KWARGS, NameTok.KwArg);
                }
            }
        }
View Full Code Here


        return new FunctionDef(new NameTok(NodeHelper.KEYWORD_INIT, NameTok.FunctionName), args,
                body.toArray(new stmtType[0]), null, null);
    }

    private Expr extractConstructorInit(IClassDefAdapter base) {
        FunctionDefAdapter init = base.getFirstInit();
        if (init != null) {
            if (!init.getArguments().hasOnlySelf()) {
                Attribute classInit = new Attribute(new Name(moduleAdapter.getBaseContextName(this.classAdapter,
                        base.getName()), Name.Load, false), new NameTok(NodeHelper.KEYWORD_INIT, NameTok.Attrib),
                        Attribute.Load);
                List<exprType> constructorParameters = init.getArguments().getSelfFilteredArgs();

                Name selfArg = new Name(NodeHelper.KEYWORD_SELF, Name.Load, false);
                constructorParameters.add(0, selfArg);

                exprType[] argExp = constructorParameters.toArray(new exprType[0]);
                Name varArg = null;
                Name kwArg = null;

                if (init.getArguments().hasVarArg()) {
                    varArg = new Name(ARGS, Name.Load, false);
                }

                if (init.getArguments().hasKwArg()) {
                    kwArg = new Name(KWARGS, Name.Load, false);
                }

                Call initCall = new Call(classInit, argExp, null, varArg, kwArg);
                return new Expr(initCall);
View Full Code Here

                        return createProposal(pySelection, constant, offsetAndIndent, false, replacePassStatement);

                    case FIELD:

                        parametersAfterCall = checkFirst(parametersAfterCall, "self");
                        FunctionDefAdapter firstInit = targetClass.getFirstInit();
                        if (firstInit != null) {
                            FunctionDef astNode = firstInit.getASTNode();
                            replacePassStatement = getLastPassFromNode(astNode);

                            //Create the field as the last line in the __init__
                            int nodeLastLine = firstInit.getNodeLastLine() - 1;
                            indent = firstInit.getNodeBodyIndent();
                            String pattern;

                            if (replacePassStatement == null) {
                                pattern = com.aptana.shared_core.string.StringUtils.format("\nself.%s = ${None}${cursor}", actTok);
                                try {
View Full Code Here

        AbstractScopeNode<?> parent = parents.peek();

        if (nodeHelper.isClassDef(node)) {
            return new ClassDefAdapter(moduleAdapter, parent, (ClassDef) node, moduleAdapter.getAdapterPrefs());
        } else if (nodeHelper.isFunctionDef(node)) {
            return new FunctionDefAdapter(moduleAdapter, parent, (FunctionDef) node, moduleAdapter.getAdapterPrefs());
        } else {
            return new SimpleAdapter(moduleAdapter, parent, node, moduleAdapter.getAdapterPrefs());
        }
    }
View Full Code Here

        super(module, parent);
    }

    @Override
    protected FunctionDefAdapter createAdapter(AbstractScopeNode<?> parent, SimpleNode node) {
        return new FunctionDefAdapter(moduleAdapter, parent, (FunctionDef) node, moduleAdapter.getAdapterPrefs());
    }
View Full Code Here

TOP

Related Classes of org.python.pydev.refactoring.ast.adapters.FunctionDefAdapter

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.