diff options
| author | Emile Anclin <emile.anclin@logilab.fr> | 2009-11-25 16:06:46 +0100 |
|---|---|---|
| committer | Emile Anclin <emile.anclin@logilab.fr> | 2009-11-25 16:06:46 +0100 |
| commit | a2c0b368ae7f92184a4dd9d9f2129303a2bb8c9c (patch) | |
| tree | 8427b2baeba41b5d3de2f6a16d657361f2bdc4ce /node_classes.py | |
| parent | af0121dd62d033491c15bdc2d40bb9166c2335b2 (diff) | |
| download | astroid-git-a2c0b368ae7f92184a4dd9d9f2129303a2bb8c9c.tar.gz | |
move special cases of _infer_name to concrete classes
--HG--
branch : rebuild
Diffstat (limited to 'node_classes.py')
| -rw-r--r-- | node_classes.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/node_classes.py b/node_classes.py index 6cdd0e07..1cd2f5f8 100644 --- a/node_classes.py +++ b/node_classes.py @@ -38,6 +38,11 @@ SIMPLE_LOOKUPS = (AssName, DelName, Name) class ArgumentsNG(NodeNG): """class representing an Arguments node""" + def _infer_name(self, frame, name): + if self.parent is frame: + return name + return None + def format_args(self): """return arguments formatted as string""" result = [_format_args(self.args, self.defaults)] @@ -73,6 +78,7 @@ class ArgumentsNG(NodeNG): return _find_arg(argname, self.args, rec) return None, None + def _find_arg(argname, args, rec=False): for i, arg in enumerate(args): if isinstance(arg, Tuple): @@ -273,6 +279,9 @@ class ForNG(BlockRangeMixIn, StmtMixIn, NodeNG): class FromImportMixIn(BaseClass): """MixIn for From and Import Nodes""" + def _infer_name(self, frame, name): + return name + def do_import_module(node, modname): """return the ast for a module whose name is <modname> imported by <node> """ @@ -314,6 +323,8 @@ class GetattrNG(NodeNG): class GlobalNG(StmtMixIn, NodeNG): """class representing a Global node""" + def _infer_name(self, frame, name): + return name class IfNG(BlockRangeMixIn, StmtMixIn, NodeNG): @@ -395,6 +406,8 @@ class SubscriptNG(NodeNG): class TryExceptNG(BlockRangeMixIn, StmtMixIn, NodeNG): """class representing a TryExcept node""" + def _infer_name(self, frame, name): + return name def _blockstart_toline(self): return self.lineno |
