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

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


        } else if (node instanceof Attribute) {
            Attribute a = (Attribute) node;
            name = ((NameTok) a.attr).id;

        } else if (node instanceof Name) {
            Name a = (Name) node;
            name = a.id;

        } else if (node instanceof NameTok) {
            NameTok a = (NameTok) node;
            name = a.id;
View Full Code Here


                            if (add) {
                                //only add if it was something valid
                                if (lineContents.indexOf('.') != -1) {
                                    List<String> dotSplit = StringUtils.dotSplit(lineContents);
                                    if (dotSplit.size() == 2 && dotSplit.get(0).equals("self")) {
                                        Attribute attribute = new Attribute(new Name("self", Name.Load, false),
                                                new NameTok(dotSplit.get(1), NameTok.Attrib), Attribute.Load);
                                        targets.add(attribute);
                                    }

                                } else {
                                    Name name = new Name(lineContents, Name.Store, false);
                                    targets.add(name);
                                }
                            }
                        }
View Full Code Here

    public GlobalModelVisitor(int visitWhat, String moduleName, boolean onlyAllowTokensIn__all__,
            boolean lookingInLocalContext) {
        this.visitWhat = visitWhat;
        this.moduleName = moduleName;
        this.onlyAllowTokensIn__all__ = onlyAllowTokensIn__all__;
        this.tokens.add(new SourceToken(new Name("__dict__", Name.Load, false), "__dict__", "", "", moduleName));
        if (moduleName != null && moduleName.endsWith("__init__")) {
            this.tokens.add(new SourceToken(new Name("__path__", Name.Load, false), "__path__", "", "", moduleName));
        }
        if (!lookingInLocalContext && ((this.visitWhat & GLOBAL_TOKENS) != 0)) {
            //__file__ is always available for any module
            this.tokens.add(new SourceToken(new Name("__file__", Name.Load, false), "__file__", "", "", moduleName));
            this.tokens.add(new SourceToken(new Name("__name__", Name.Load, false), "__name__", "", "", moduleName));
        }
    }
View Full Code Here

                        name = NodeUtils.getNameFromNameTok((NameTok) (functionDefToken).name);
                    } else if (token instanceof Attribute) {
                        Attribute attributeToken = (Attribute) token;
                        name = NodeUtils.getNameFromNameTok((NameTok) (attributeToken).attr);
                    } else if (token instanceof Name) {
                        Name nameToken = (Name) token;
                        name = nameToken.id;
                    } else if (token instanceof NameTok) {
                        NameTok nameTokToken = (NameTok) token;
                        name = NodeUtils.getNameFromNameTok(nameTokToken);
                    }
View Full Code Here

                    if (token instanceof FunctionDef) {
                        FunctionDef functionDefToken = (FunctionDef) token;
                        if (functionDefToken.decs != null) {
                            for (decoratorsType decorator : functionDefToken.decs) {
                                if (decorator.func instanceof Name) {
                                    Name decoratorFuncName = (Name) decorator.func;
                                    if (decoratorFuncName.id.equals("staticmethod")) {
                                        return false;
                                    }
                                }
                            }
View Full Code Here

            }
            String decorationIcon = null;
            if (functionDefToken.decs != null) {
                for (decoratorsType decorator : functionDefToken.decs) {
                    if (decorator.func instanceof Name) {
                        Name decoratorFuncName = (Name) decorator.func;
                        if (decoratorFuncName.id.equals("staticmethod")) {
                            decorationIcon = UIConstants.DECORATION_STATIC;
                        } else if (decoratorFuncName.id.equals("classmethod")) {
                            decorationIcon = UIConstants.DECORATION_CLASS;
                        }
                    }
                }
            }
            if (qualifierIcon != null) {
                //it's OK if the decorationIcon is null as that's properly handled in getImageDecorated.
                return imageCache.getImageDecorated(UIConstants.METHOD_ICON, qualifierIcon,
                        ImageCache.DECORATION_LOCATION_BOTTOM_RIGHT, decorationIcon,
                        ImageCache.DECORATION_LOCATION_TOP_RIGHT);

            } else if (decorationIcon != null) {
                return imageCache.getImageDecorated(UIConstants.METHOD_ICON, decorationIcon,
                        ImageCache.DECORATION_LOCATION_TOP_RIGHT);
            }

            return imageCache.get(UIConstants.METHOD_ICON);

        } else if (token instanceof Import) {
            return imageCache.get(UIConstants.IMPORT_ICON);
        } else if (token instanceof If && NodeUtils.isIfMAinNode((If) token)) {
            return imageCache.get(UIConstants.MAIN_FUNCTION_ICON);
        } else if (token instanceof ImportFrom) {
            return imageCache.get(UIConstants.IMPORT_ICON);
        } else if (token instanceof commentType) {
            return imageCache.get(UIConstants.COMMENT);
        } else if (token instanceof Attribute || token instanceof Name || token instanceof NameTok) {
            String name = null;
            if (token instanceof Attribute) {
                Attribute attributeToken = (Attribute) token;
                name = NodeUtils.getNameFromNameTok((NameTok) (attributeToken).attr);
            } else if (token instanceof Name) {
                Name nameToken = (Name) token;
                name = nameToken.id;
            } else {
                NameTok nameTokToken = (NameTok) token;
                name = NodeUtils.getNameFromNameTok(nameTokToken);
            }
View Full Code Here

            this.doc = kw;
        }
    }

    private Name createNone() {
        return new Name("None", Name.Param, true);
    }
View Full Code Here

    private void setMethod(exprType expr, int i) {
        if (nodeHelper.isStr(expr)) {
            doc = expr;
        } else if (nodeHelper.isName(expr)) {
            Name name = (Name) expr;
            switch (i) {
                case 0:
                    getter = name;
                    break;
                case 1:
View Full Code Here

        //get the annotations to add
        for (ASTEntry entry : occurrences) {
            if (!markOccurrencesInStrings) {
                if (entry.node instanceof Name) {
                    Name name = (Name) entry.node;
                    if (name.ctx == Name.Artificial) {
                        continue;
                    }
                }
            }
View Full Code Here

                "";

        FunctionDef functionDef = astFactory.createFunctionDef("__init__");
        functionDef.args = astFactory.createArguments(true, "arg", "attribute");
        astFactory.setBody(functionDef, astFactory.createCall("A.__init__", "self", "arg"), astFactory.createAssign(
                astFactory.createAttribute("self.attribute"), new Name("attribute", Name.Load, false)));
        checkExpected(functionDef, expected);
    }
View Full Code Here

TOP

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

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.