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

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


                int lastReturnedLine = it.getLastReturnedLine();

                NameTok nameTok = createNameTok(classMatcher, lastReturnedLine, NameTok.ClassName, ps);

                if (nameTok != null) {
                    ClassDef classDef = createClassDef(lastReturnedLine, nameTok,
                            PySelection.getFirstCharPosition(line));

                    if (!addStatement(body, classDef)) {
                        return body;
                    }
View Full Code Here


        functionDef.beginColumn = matchedCol + 1;
        return functionDef;
    }

    private ClassDef createClassDef(int lastReturnedLine, NameTok nameTok, int matchedCol) {
        ClassDef classDef = new ClassDef(nameTok, EMTPY_EXPR_TYPE, EMTPY_STMT_TYPE, null, null, null, null);
        classDef.beginLine = lastReturnedLine + 1;
        classDef.beginColumn = matchedCol + 1;
        return classDef;
    }
View Full Code Here

            case JJTCLASSDEF:
                suite = (Suite) stack.popNode();
                body = suite.body;
                exprType[] bases = makeExprs(stack.nodeArity() - 1);
                nameTok = makeName(NameTok.ClassName);
                ClassDef classDef = new ClassDef(nameTok, bases, body, null, null, null, null);
                addSpecialsAndClearOriginal(suite, classDef);
                setParentForFuncOrClass(body, classDef);
                return classDef;
            case JJTBEGIN_RETURN_STMT:
                return new Return(null);
View Full Code Here

     */
    protected NameTok getNameNode(stmtType defNode) {
        NameTok node = null;
        if (defNode != null) {
            if (defNode instanceof ClassDef) {
                ClassDef def = (ClassDef) defNode;
                node = (NameTok) def.name;
            }
            if (defNode instanceof FunctionDef) {
                FunctionDef def = (FunctionDef) defNode;
                node = (NameTok) def.name;
View Full Code Here

                    }
                    SimpleNode token = astThis.node;

                    String name = null;
                    if (token instanceof ClassDef) {
                        ClassDef classDefToken = (ClassDef) token;
                        name = NodeUtils.getNameFromNameTok((NameTok) (classDefToken).name);
                    } else if (token instanceof FunctionDef) {
                        FunctionDef functionDefToken = (FunctionDef) token;
                        name = NodeUtils.getNameFromNameTok((NameTok) (functionDefToken).name);
                    } else if (token instanceof Attribute) {
View Full Code Here

            } catch (CompletionRecursionException e) {
                Log.log(e); //Just keep going.
            }

            if (definition.ast instanceof ClassDef) {
                ClassDef d = (ClassDef) definition.ast;
                String fullName = NodeUtils.getRepresentationString(d) + "." + methodToCreate;
                IToken repInModule = nature.getAstManager().getRepInModule(definition.module, fullName, nature);
                if (repInModule != null) {
                    //System.out.println("Skipping creation of: " + fullName); //We found it, so, don't suggest it.
                    continue;
View Full Code Here

    private boolean checkInitCreation(PyEdit edit, PySelection callPs, ItemPointer[] pointers,
            List<ICompletionProposal> ret) {
        for (ItemPointer pointer : pointers) {
            Definition definition = pointer.definition;
            if (definition != null && definition.ast instanceof ClassDef) {
                ClassDef d = (ClassDef) definition.ast;
                ASTEntry initEntry = findInitInClass(d);

                if (initEntry == null) {
                    //Give the user a chance to create the __init__.
                    PyCreateMethodOrField pyCreateMethod = new PyCreateMethodOrField();
View Full Code Here

    }

    @Override
    public void traverse(SimpleNode node) throws Exception {
        if (nodeHelper.isClassDef(node)) {
            ClassDef classDef = (ClassDef) node;
            visit(classDef.body);
        } else {
            super.traverse(node);
        }
    }
View Full Code Here

                    LineStartingScope scopeStart = pySelection.getPreviousLineThatStartsScope(
                            PySelection.CLASS_AND_FUNC_TOKENS, false, firstCharPosition);

                    if (scopeStart == null) {
                        Log.log("Could not get proper scope to create code inside class.");
                        ClassDef astNode = targetClass.getASTNode();
                        if (astNode.body.length > 0) {
                            offset = NodeUtils.getLineEnd(astNode.body[astNode.body.length - 1]);

                        } else {
                            offset = NodeUtils.getLineEnd(astNode);
View Full Code Here

                                //Add option to create class at the given module!
                                addCreateClassOption(ps, edit, props, markerContents, parametersAfterCall, file);

                                addCreateMethodOption(ps, edit, props, markerContents, parametersAfterCall, file);
                            } else if (definition.ast instanceof ClassDef) {
                                ClassDef classDef = (ClassDef) definition.ast;
                                //Ok, we should create a field or method in this case (accessing a classmethod or staticmethod)
                                PyCreateMethodOrField pyCreateMethod = new PyCreateMethodOrField();
                                String className = NodeUtils.getNameFromNameTok(classDef.name);
                                pyCreateMethod.setCreateInClass(className);
                                pyCreateMethod.setCreateAs(PyCreateMethodOrField.CLASSMETHOD);
View Full Code Here

TOP

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

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.