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

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


            } else if (t instanceof Attribute) {

                //we are in a method from the class
                if (isInClassMethodDecl()) {
                    Attribute a = (Attribute) t;
                    if (a.value instanceof Name) {

                        //it is an instance variable attribute
                        Name n = (Name) a.value;
                        if (n.id.equals("self")) {
View Full Code Here


        if (node instanceof aliasType) {
            aliasType type = (aliasType) node;
            return ((NameTok) type.name).id;
        }
        if (node instanceof Attribute) {
            Attribute attribute = (Attribute) node;
            return discoverRep(attribute.attr);

        }

        if (node instanceof keywordType) {
View Full Code Here

    public static exprType makeAttribute(String attrString) {
        List<String> dotSplit = StringUtils.dotSplit(attrString);
        Assert.isTrue(dotSplit.size() > 1);

        exprType first = null;
        Attribute last = null;
        Attribute attr = null;
        for (int i = dotSplit.size() - 1; i > 0; i--) {
            Call call = null;
            String part = dotSplit.get(i);
            if (part.endsWith("()")) {
                if (i == dotSplit.size() - 1) {
                    part = part.substring(0, part.length() - 2);
                    call = new Call(null, new exprType[0], new keywordType[0], null, null);
                    first = call;
                } else {
                    throw new RuntimeException("Call only accepted in the last part.");
                }
            }
            attr = new Attribute(null, new NameTok(part, NameTok.Attrib), Attribute.Load);
            if (call != null) {
                call.func = attr;
            }
            if (last != null) {
                last.value = attr;
View Full Code Here

        } else if (t instanceof Attribute) {

            //we are in a method from the class
            if (visitor.isInClassMethodDecl()) {
                Attribute a = (Attribute) t;
                if (a.value instanceof Name) {

                    //it is an instance variable attribute
                    Name n = (Name) a.value;
                    if (n.id.equals("self")) {
View Full Code Here

                buffer.append("*");
            }
            name = buffer.toString();

        } 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;
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 {
View Full Code Here

                        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) {
                        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) {
View Full Code Here

        } 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 {
View Full Code Here

            if (node instanceof ClassDef) {
                ClassDef def = (ClassDef) node;
                node = def.name;

            } else if (node instanceof Attribute) {
                Attribute attribute = (Attribute) node;
                node = attribute.attr;

            } else if (node instanceof FunctionDef) {
                FunctionDef def = (FunctionDef) node;
                node = def.name;
View Full Code Here

        checkExpected(astFactory.createSetterFunctionDef("setFoo", "foo"), expected);
    }

    public void testCreateAttribute() throws Exception {

        Attribute attribute = astFactory.createAttribute("a.b.c.d.e");
        checkExpected(attribute, "a.b.c.d.e\n");
    }
View Full Code Here

TOP

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

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.