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

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


        exprType returnValue = null;
        if (returnList.size() == 1) {
            returnValue = returnList.get(0);

        } else if (returnList.size() > 1) {
            returnValue = new Tuple(returnList.toArray(new exprType[0]), Tuple.Load, false);

        } else if (body.size() == 1) {
            // return expression as-is (note: body must be cleared)
            if (body.get(0) instanceof Expr) {
                Expr expression = (Expr) body.get(0);
View Full Code Here


                returnExpr.add(new Name(returnVar, Name.Store, false));
            }

            exprType[] expr = returnExpr.toArray(new exprType[0]);
            if (expr.length > 1) {
                expr = new exprType[] { new Tuple(expr, Tuple.Load, false) };
            }

            return new Assign(expr, methodCall);
        }
    }
View Full Code Here

                    }
                }
            }

            final exprType[] exp = makeExprs();
            Tuple t = new Tuple(exp, Tuple.Load, endsWithComma);
            addSpecialsAndClearOriginal(n, t);
            return t;
        } catch (ClassCastException e) {
            if (e.getMessage().equals(ExtraArgValue.class.getName())) {
                this.stack.getGrammar().addAndReport(
                        new ParseException("Token: '*' is not expected inside tuples.", lastPop),
                        "Treated class cast exception on tuple");
            }
            this.stack.getGrammar().addAndReport(new ParseException("Syntax error while detecting tuple.", lastPop),
                    "Treated class cast exception on tuple");

            while (stack.nodeArity() > 0) {
                //clear whatever we had in this construct...
                stack.popNode();
            }

            //recover properly!
            return new Tuple(new exprType[0], Tuple.Load, false);

        }
    }
View Full Code Here

            return;
        }
        for (int i = 0; i < targets.length; i++) {
            exprType t = targets[i];
            if (t instanceof Tuple) {
                Tuple tuple = (Tuple) t;
                visitTargetsInAssign(visitor, tuple.elts);
            }
            visitTargetInAssign(visitor, t);
        }
    }
View Full Code Here

            return val;
        }

        if (node instanceof Tuple) {
            StringBuffer buf = new StringBuffer();
            Tuple t = (Tuple) node;
            for (exprType e : t.elts) {
                buf.append(getRepresentationString(e, useTypeRepr));
                buf.append(", ");
            }
            if (t.elts.length > 0) {
View Full Code Here

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

            }

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

        visited.add(node);
        exprType[] args = node.args.args;
        for (int i = 0; i < args.length; i++) {
            if (args[i] != null) {
                if (args[i] instanceof Tuple) {
                    Tuple t = (Tuple) args[i];
                    for (int j = 0; j < t.elts.length; j++) {
                        t.elts[j].accept(this);
                    }
                } else {
                    args[i].accept(this);
View Full Code Here

                            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) {
                                        addRepresentationIfPossible(ret, expr);
                                    }
                                } else {
                                    //case: isinstance(obj, Class)
View Full Code Here

                        }
                    }

                } else if (node.targets[i] instanceof Tuple && inFuncDef == false) {
                    //that's for finding the definition: a,b,c = range(3) inside a class definition
                    Tuple tuple = (Tuple) node.targets[i];
                    for (exprType t : tuple.elts) {
                        if (t instanceof Name) {
                            String id = ((Name) t).id;
                            if (id != null) {
                                addToken(t);
View Full Code Here

TOP

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

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.