Fix all the normal issues with the NameFinder change. Now goto...

This commit is contained in:
Dave Halter
2014-09-10 16:30:22 +02:00
parent 657a2c7d4f
commit a93a389d5c
2 changed files with 7 additions and 4 deletions

View File

@@ -103,7 +103,6 @@ class NameFinder(object):
or isinstance(stmt, pr.ExprStmt) and stmt.is_global():
# Always reachable.
result.append(name.names[-1])
assert name == name.names[-1].parent
else:
check = flow_analysis.break_check(self._evaluator,
name_list_scope,
@@ -269,7 +268,7 @@ class NameFinder(object):
p = stmt.parent
# TODO this looks really hacky, improve parser representation!
if isinstance(p, pr.Flow) and p.command == 'except' \
and p.inputs and p.inputs[0].as_names == [name]:
and p.inputs and p.inputs[0].as_names[0].names[-1] == name:
# TODO check for types that are not classes and add it to the
# static analysis report.
types = list(chain.from_iterable(

View File

@@ -234,10 +234,14 @@ class ArrayMethod(IterableWrapper):
super(ArrayMethod, self).__init__()
self.name = name
@property
@underscore_memoization
def names(self):
return [pr.NamePart(unicode(n), self, n.start_pos) for n in self.name.names]
def __getattr__(self, name):
# Set access privileges:
if name not in ['parent', 'names', 'start_pos', 'end_pos', 'get_code',
'get_definition']:
if name not in ['parent', 'start_pos', 'end_pos', 'get_code', 'get_definition']:
raise AttributeError('Strange access on %s: %s.' % (self, name))
return getattr(self.name, name)