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

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


    public String getSignature() {
        return arguments.getSignature();
    }

    public String getNodeBodyIndent() {
        FunctionDef functionNode = getASTNode();
        if (functionNode.body == null || functionNode.body.length == 0) {
            PySelection pySelection = new PySelection(getModule().getDoc());
            String indentationFromLine = PySelection.getIndentationFromLine(pySelection
                    .getLine(functionNode.beginLine - 1));
            return indentationFromLine + DefaultIndentPrefs.get().getIndentationString();
View Full Code Here


                        functionArguments.args = new exprType[] { name };
                        functionArguments.vararg = new NameTok("args", NameTok.VarArg);
                        functionArguments.kwarg = new NameTok("kwargs", NameTok.KwArg);
                    }
                    //                System.out.println(tok.getRepresentation()+tok.getArgs());
                    FunctionDef functionDef = new FunctionDef(
                            new NameTok(tok.getRepresentation(), NameTok.FunctionName), functionArguments, null, null,
                            null);
                    cache.add(new FunctionDefAdapter(this.getModule(), null, functionDef, adapterPrefs));
                }
            }
View Full Code Here

    }

    public FunctionDefAdapter getFirstInit() {
        for (stmtType b : this.classDef.body) {
            if (b instanceof FunctionDef) {
                FunctionDef functionDef = (FunctionDef) b;
                if (((NameTok) functionDef.name).id.equals("__init__")) {
                    return new FunctionDefAdapter(module, null, (FunctionDef) b, adapterPrefs);
                }
            }
        }
View Full Code Here

    public List<FunctionDefAdapter> getFunctionsInitFiltered() {
        ArrayList<FunctionDefAdapter> ret = new ArrayList<FunctionDefAdapter>();
        for (stmtType b : this.classDef.body) {
            if (b instanceof FunctionDef) {
                FunctionDef functionDef = (FunctionDef) b;
                if (((NameTok) functionDef.name).id.equals("__init__")) {
                    continue;
                }
                ret.add(new FunctionDefAdapter(module, null, functionDef, adapterPrefs));
            }
View Full Code Here

        for (Iterator<SimpleNode> iter = this.scope.iterator(); iter.hasNext();) {
            SimpleNode element = iter.next();

            stmtType[] body = null;
            if (element instanceof FunctionDef) {
                FunctionDef f = (FunctionDef) element;
                final argumentsType args = f.args;

                for (int i = 0; i < args.args.length; i++) {
                    String s = NodeUtils.getRepresentationString(args.args[i]);
                    comps.add(new SourceToken(args.args[i], s, "", "", "", IToken.TYPE_PARAM));
View Full Code Here

        ArrayList<IToken> importedModules = new ArrayList<IToken>();
        for (Iterator<SimpleNode> iter = this.scope.iterator(); iter.hasNext();) {
            SimpleNode element = iter.next();

            if (element instanceof FunctionDef) {
                FunctionDef f = (FunctionDef) element;
                for (int i = 0; i < f.body.length; i++) {
                    stmtType stmt = f.body[i];
                    if (stmt != null) {
                        importedModules.addAll(GlobalModelVisitor.getTokens(stmt, GlobalModelVisitor.ALIAS_MODULES,
                                moduleName, null, false));
View Full Code Here

                }
            }
        };
        if (simpleNode instanceof FunctionDef) {
            //all that because we don't want to visit the name of the function if we've started in a function scope
            FunctionDef d = (FunctionDef) simpleNode;
            try {
                //decorators
                if (d.decs != null) {
                    for (decoratorsType dec : d.decs) {
                        if (dec != null) {
View Full Code Here

        assertEquals(1, m.body.length);
        ClassDef classDef = ((ClassDef) m.body[0]);
        assertEquals("Bar", ((NameTok) classDef.name).id);
        assertEquals(1, classDef.body.length); //method

        FunctionDef funcDef = (FunctionDef) classDef.body[0];
        assertEquals("m1", ((NameTok) funcDef.name).id);
        assertNull(funcDef.body);
    }
View Full Code Here

        assertEquals(1, m.body.length);
        ClassDef classDef = ((ClassDef) m.body[0]);
        assertEquals("Bar", ((NameTok) classDef.name).id);
        assertEquals(1, classDef.body.length); //method

        FunctionDef funcDef = (FunctionDef) classDef.body[0];
        assertEquals("m1", ((NameTok) funcDef.name).id);

        assertNull(funcDef.body[1]);
        Assign assign = (Assign) funcDef.body[0];
        assertEquals(1, assign.targets.length);
View Full Code Here

        assertEquals(1, m.body.length);
        ClassDef classDef = ((ClassDef) m.body[0]);
        assertEquals("Bar", ((NameTok) classDef.name).id);
        assertEquals(1, classDef.body.length); //method

        FunctionDef funcDef = (FunctionDef) classDef.body[0];
        assertEquals("m1", ((NameTok) funcDef.name).id);

        for (int i = 0; i < 3; i++) {
            Assign assign = (Assign) funcDef.body[i];
            assertEquals(1, assign.targets.length);
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.