def visit_arguments(self, node):
     self.visit(node.defaults)
     with self._isInDefinitionMgr(True):
         self.visit(node.args)
     if node.vararg is not None:
         self._boundVarsWithPos.add(
             VarWithPosition(var=node.vararg,
                             pos=NodeVisitorBases.PositionInFile(
                                 lineno=node.lineno,
                                 col_offset=node.col_offset)))
     if node.kwarg is not None:
         self._boundVarsWithPos.add(
             VarWithPosition(var=node.kwarg,
                             pos=NodeVisitorBases.PositionInFile(
                                 lineno=node.lineno,
                                 col_offset=node.col_offset)))
 def visit_Name(self, node):
     if self._isInDefinition:
         self._boundVarsWithPos.add(
             VarWithPosition(var=node.id,
                             pos=NodeVisitorBases.PositionInFile(
                                 lineno=node.lineno,
                                 col_offset=node.col_offset)))
Beispiel #3
0
 def visit_ClassDef(self, node):
     self._boundNamesWithPos.add(
         VarWithPosition(var=node.name,
                         pos=NodeVisitorBases.PositionInFile(
                             lineno=node.lineno,
                             col_offset=node.col_offset)))
     return node
 def visit_FunctionDef(self, node):
     # exclude synthetic wrapper FunctionDef nodes
     if node.name != '':
         self._boundNamesWithPos.add(
             VarWithPosition(var=node.name,
                             pos=NodeVisitorBases.PositionInFile(
                                 lineno=node.lineno,
                                 col_offset=node.col_offset)))
 def visit_Name(self, node):
     identifier = node.id
     if isinstance(node.ctx, ast.Store):
         self._boundInScopeSoFar.add(identifier)
     elif not self.isBoundSoFar(identifier) and \
        isinstance(node.ctx, ast.Load):
         self._freeVariableMemberAccessChainsWithPos.add(
             VarWithPosition(var=(identifier, ),
                             pos=NodeVisitorBases.PositionInFile(
                                 lineno=node.lineno,
                                 col_offset=node.col_offset)))
 def visit_Attribute(self, node):
     chainOrNone = _memberAccessChainOrNone(node)
     if chainOrNone is not None:
         if chainOrNone[0] not in self._boundValues:
             self._freeVariableMemberAccessChainsWithPos.add(
                 VarWithPosition(var=chainOrNone,
                                 pos=NodeVisitorBases.PositionInFile(
                                     lineno=node.lineno,
                                     col_offset=node.col_offset)))
     else:
         #required to recurse deeper into the AST, but only do it if
         #_freeVariableMemberAccessChain was None, indicating that it
         #doesn't want to consume the whole expression
         self.generic_visit(node.value)
Beispiel #7
0
 def addFreeVariableMemberAccessChain(self, chain, lineno, col_offset):
     pos = NodeVisitorBases.PositionInFile(lineno=lineno,
                                           col_offset=col_offset)
     self._freeVariableMemberAccessChainsWithPos[chain].add(pos)
     self._freeVariablesWithPos[chain[0]].add(pos)