Package org.python.pydev.parser.jython.ast

Examples of org.python.pydev.parser.jython.ast.FunctionDef


    }

    @SuppressWarnings("unchecked")
    /*default*/void checkAttrFound(Call callNode, TokenFoundStructure found) throws Exception,
            CompletionRecursionException {
        FunctionDef functionDefinitionReferenced;
        SourceToken nameToken;
        boolean callingBoundMethod;
        if (found != null && found.defined && found.token instanceof SourceToken) {
            nameToken = (SourceToken) found.token;
            String rep = nameToken.getRepresentation();
View Full Code Here


    }

    private final Map<ClassDef, SimpleNode> defToConsideredInit = new HashMap<ClassDef, SimpleNode>();

    /*default*/void checkNameFound(Call callNode, SourceToken sourceToken) throws Exception {
        FunctionDef functionDefinitionReferenced;
        boolean callingBoundMethod = false;
        SimpleNode ast = sourceToken.getAst();
        if (ast instanceof FunctionDef) {
            functionDefinitionReferenced = (FunctionDef) ast;
            analyzeCallAndFunctionMatch(callNode, functionDefinitionReferenced, sourceToken, callingBoundMethod);
View Full Code Here

        if (stack.size() > 0) {
            if (!scope.getPrevScopeItems().getIsInSubSubScope()) {
                String exists = stack.peek().get(name);
                if (exists != null) {
                    if (node instanceof FunctionDef) {
                        FunctionDef functionDef = (FunctionDef) node;
                        if (functionDef.decs != null && functionDef.decs.length > 0) {
                            for (decoratorsType dec : functionDef.decs) {
                                if (dec.func != null) {
                                    String fullRepresentationString = NodeUtils.getFullRepresentationString(dec.func);
                                    if (fullRepresentationString.startsWith(name + ".")) {
View Full Code Here

            Tuple<Expected, FunctionDef> tup = maybeNoSelfDefinedItems.peek().get(rep);
            if (tup == null) {
                return;
            }

            FunctionDef def = tup.o2;
            if (def == null) {
                return;
            }

            //ok, it may be a staticmethod, let's check its value (should be a call)
View Full Code Here

                if (type == IAnalysisPreferences.TYPE_UNUSED_PARAMETER) {
                    // just add unused parameters in methods that have some content (not only 'pass' and 'strings')

                    if (node instanceof FunctionDef) {
                        addMessage = false;
                        FunctionDef def = (FunctionDef) node;
                        for (stmtType b : def.body) {
                            if (b instanceof Pass) {
                                continue;
                            }
                            if (b instanceof Expr) {
View Full Code Here

    @Override
    protected SimpleNode getEditNode() {
        List<stmtType> body = initExtractedBody();
        List<exprType> argsList = initExtractedMethodArguments();
        addReturnValue(body);
        FunctionDef extractedMethod = initExtractedMethod(body, argsList);
        applyRenamedVariables(extractedMethod);

        return extractedMethod;
    }
View Full Code Here

    private FunctionDef initExtractedMethod(List<stmtType> body, List<exprType> argsList) {
        argumentsType args = new argumentsType(argsList.toArray(new exprType[0]), null, null, null, null, null, null,
                null, null, null);

        FunctionDef extractedMethod = new FunctionDef(new NameTok(methodName, NameTok.FunctionName), args,
                body.toArray(new stmtType[0]), null, null);
        return extractedMethod;
    }
View Full Code Here

            Assign initParam = initParam1;
            body.add(initParam);
        }

        //create function def
        return new FunctionDef(new NameTok(NodeHelper.KEYWORD_INIT, NameTok.FunctionName), args,
                body.toArray(new stmtType[0]), null, null);
    }
View Full Code Here

        String delimiter = PySelection.getDelimiter(document);

        PyAstFactory factory = new PyAstFactory(new AdapterPrefs(delimiter, versionProvider));
        stmtType overrideBody = factory.createOverrideBody(this.functionDef, parentClassName, currentClassName); //Note that the copy won't have a parent.

        FunctionDef functionDef = this.functionDef.createCopy(false);
        functionDef.body = new stmtType[] { overrideBody != null ? overrideBody : new Pass() };

        try {
            MakeAstValidForPrettyPrintingVisitor.makeValid(functionDef);
        } catch (Exception e) {
View Full Code Here

                Decorators decorators = (Decorators) stack.popNode();
                if (def instanceof ClassDef) {
                    ClassDef classDef = (ClassDef) def;
                    classDef.decs = decorators.exp;
                } else {
                    FunctionDef fDef = (FunctionDef) def;
                    fDef.decs = decorators.exp;
                }
                return def;
            case JJTCALL_OP:
                exprType starargs = null;
                exprType kwargs = null;

                java.util.List<exprType> args = new ArrayList<exprType>();
                java.util.List<keywordType> keywords = new ArrayList<keywordType>();

                for (int i = arity - 2; i >= 0; i--) {
                    SimpleNode node = stack.popNode();
                    if (node instanceof keywordType) {
                        keywords.add(0, (keywordType) node);

                    } else if (node.getId() == JJTEXTRAARGVALUELIST) {
                        ExtraArgValue nstarargs = (ExtraArgValue) node;
                        starargs = nstarargs.value;
                        this.addSpecialsAndClearOriginal(nstarargs, starargs);

                    } else if (node.getId() == JJTEXTRAKEYWORDVALUELIST) {
                        ExtraArgValue nkwargs = (ExtraArgValue) node;
                        kwargs = nkwargs.value;
                        this.addSpecialsAndClearOriginal(nkwargs, kwargs);

                    } else if (node instanceof ComprehensionCollection) {
                        //what can happen is something like print sum(x for x in y), where we have already passed x in the args, and then get 'for x in y'
                        args.add(
                                0,
                                new ListComp((exprType) stack.popNode(), ((ComprehensionCollection) node)
                                        .getGenerators(), ListComp.EmptyCtx));
                        i--; //popped node

                    } else {
                        args.add(0, (exprType) node);
                    }
                }

                exprType func = (exprType) stack.popNode();
                Call c = new Call(func, args.toArray(new exprType[args.size()]),
                        keywords.toArray(new keywordType[keywords.size()]), starargs, kwargs);
                addSpecialsAndClearOriginal(n, c);
                return c;
            case JJTFUNCDEF:
                suite = (Suite) stack.popNode();
                body = suite.body;

                argumentsType arguments = makeArguments(stack.nodeArity() - 1);
                NameTok nameTok = makeName(NameTok.FunctionName);
                //decorator is always null at this point... it's decorated later on
                FunctionDef funcDef = new FunctionDef(nameTok, arguments, body, null, null);
                addSpecialsAndClearOriginal(suite, funcDef);
                setParentForFuncOrClass(body, funcDef);
                return funcDef;
            case JJTDEFAULTARG:
                value = (arity == 1) ? null : ((exprType) stack.popNode());
View Full Code Here

TOP

Related Classes of org.python.pydev.parser.jython.ast.FunctionDef

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.