/** * @see * org.python.pydev.parser.jython.ast.VisitorBase#visitAssign(org.python.pydev.parser.jython.ast.Assign) */ public Object visitAssign(Assign node) throws Exception { ILocalScope scope = new LocalScope(this.defsStack); 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 = ""; } // get the line and column correspondent to the target int line = NodeUtils.getLineDefinition(target); int col = NodeUtils.getColDefinition(target); AssignDefinition definition = new AssignDefinition(value, rep, i, node, line, col, scope, module.get()); // mark it as global (if it was found as global in some of the previous contexts). for (Set<String> globals : globalDeclarationsStack) { if (globals.contains(rep)) { definition.foundAsGlobal = true; } } definitions.add(definition); } } } return null; }