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

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


        if (__all__ != null) {
            SimpleNode ast = __all__.getAst();
            //just checking it
            if (__all__AssignTargets != null && __all__AssignTargets.length == 1 && __all__AssignTargets[0] == ast) {
                HashSet<String> validTokensInAll = new HashSet<String>();
                exprType value = __all__Assign.value;
                exprType[] elts = null;
                if (value instanceof List) {
                    List valueList = (List) value;
                    if (valueList.elts != null) {
                        elts = valueList.elts;
                    }
                } else if (value instanceof Tuple) {
                    Tuple valueList = (Tuple) value;
                    if (valueList.elts != null) {
                        elts = valueList.elts;
                    }
                }

                if (elts != null) {
                    int len = elts.length;
                    for (int i = 0; i < len; i++) {
                        exprType elt = elts[i];
                        if (elt instanceof Str) {
                            Str str = (Str) elt;
                            validTokensInAll.add(str.s);
                        }
                    }
View Full Code Here


        if (foundAsDefinition && !scope.equals(definitionFound.scope)) { //if it is found as a definition it is an 'exact' match, so, we do not keep checking it
            return null;
        }

        for (int i = 0; i < node.targets.length; i++) {
            exprType target = node.targets[i];
            if (target instanceof Subscript) {
                continue; //assigning to an element and not the variable itself. E.g.: mydict[1] = 10 (instead of mydict = 10)
            }

            if (target instanceof Tuple) {
                //if assign is xxx, yyy = 1, 2
                //let's separate those as different assigns and analyze one by one
                Tuple targetTuple = (Tuple) target;
                if (node.value instanceof Tuple) {
                    Tuple valueTuple = (Tuple) node.value;
                    checkTupleAssignTarget(targetTuple, valueTuple.elts);

                } else if (node.value instanceof org.python.pydev.parser.jython.ast.List) {
                    org.python.pydev.parser.jython.ast.List valueList = (org.python.pydev.parser.jython.ast.List) node.value;
                    checkTupleAssignTarget(targetTuple, valueList.elts);

                } else {
                    checkTupleAssignTarget(targetTuple, new exprType[] { node.value });
                }

            } else {
                String rep = NodeUtils.getFullRepresentationString(target);

                if (tokenToFind.equals(rep)) { //note, order of equals is important (because one side may be null).
                    exprType nodeValue = node.value;
                    String value = NodeUtils.getFullRepresentationString(nodeValue);
                    if (value == null) {
                        value = "";
                    }
View Full Code Here

        checkWithAllGrammars(new ICallback<Boolean, Integer>() {

            public Boolean call(Integer version) {
                Module module = (Module) parseLegalDocStr(s);
                exprType value = ((Expr) module.body[0]).value;
                Return node = new Return((exprType) value.createCopy());
                try {
                    MakeAstValidForPrettyPrintingVisitor.makeValid(node);
                } catch (Exception e) {
                    throw new RuntimeException(e);
                }
View Full Code Here

                Call call = (Call) entry.node;
                if ("hasattr".equals(NodeUtils.getFullRepresentationString(call.func)) && call.args != null
                        && call.args.length == 2) {
                    String rep = NodeUtils.getFullRepresentationString(call.args[0]);
                    if (rep.equals(activationToken)) {
                        exprType node = call.args[1];
                        if (node instanceof Str) {
                            Str str = (Str) node;
                            String attrName = str.s;
                            if (NodeUtils.isValidNameRepresentation(attrName)) {
                                comps.add(new SourceToken(node, attrName, "", "", "",
View Full Code Here

                        //in all cases, the instance is the 1st parameter.
                        String foundActTok = NodeUtils.getFullRepresentationString(call.args[0]);

                        if (foundActTok != null && foundActTok.equals(actTok)) {
                            if (classIndex > 0) {
                                exprType type = call.args[classIndex - 1];

                                if (type instanceof Tuple) {
                                    //case: isinstance(obj, (Class1,Class2))
                                    Tuple tuple = (Tuple) type;
                                    for (exprType expr : tuple.elts) {
View Full Code Here

     */
    public Object visitAssign(Assign node) throws Exception {
        if (how == IN_ASSIGN) {
            inAssing = true;

            exprType value = node.value;
            String rep = NodeUtils.getRepresentationString(value);
            SourceToken methodTok = null;
            if (rep != null) {
                methodTok = repToTokenWithArgs.get(rep);
                //The use case is the following: we have a method and an assign to it:
View Full Code Here

     * @param base the visitor that should visit the elements inside the attribute
     * @return true if there's no need to keep visiting other stuff in the attribute
     * @throws Exception
     */
    public static boolean visitNeededAttributeParts(final Attribute node, VisitorBase base) throws Exception {
        exprType value = node.value;
        boolean valueVisited = false;
        boolean doReturn = false;
        if (value instanceof Subscript) {
            Subscript subs = (Subscript) value;
            base.traverse(subs.slice);
View Full Code Here

        if (node instanceof FunctionDef) {
            FunctionDef def = (FunctionDef) node;
            node = def.name;
        }
        if (node instanceof Attribute) {
            exprType value = ((Attribute) node).value;
            if (value instanceof Call) {
                Call c = (Call) value;
                node = c.func;
            }
        }
View Full Code Here

    }

    public void testFullRep() throws Exception {
        Module node = (Module) parseLegalDocStr("a.b.c.d");
        exprType attr = ((Expr) node.body[0]).value;
        assertEquals("a.b.c.d", NodeUtils.getFullRepresentationString(attr));
        exprType attr1 = NodeUtils.makeAttribute("a.b.c.d");
        assertEquals("a.b.c.d", NodeUtils.getFullRepresentationString(attr1));
        assertEquals(attr1.toString(), attr.toString());

        node = (Module) parseLegalDocStr("a.b.c.d()");
        exprType callAttr = NodeUtils.makeAttribute("a.b.c.d()");
        assertEquals(((Expr) node.body[0]).value.toString(), callAttr.toString());

        SequencialASTIteratorVisitor visitor = SequencialASTIteratorVisitor
                .create(parseLegalDocStr("print a.b.c().d.__class__"));

        Iterator<ASTEntry> iterator = visitor.getIterator();
View Full Code Here

        return ((Str) node).s;
    }

    public int getLineDefinition(SimpleNode node) {
        while (isAttribute(node)) {
            exprType expr = ((Attribute) node).value;
            if (!(isCall(expr))) {
                node = expr;
            } else {
                break;
            }
View Full Code Here

TOP

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

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.