1.1 --- a/common.py Sun Feb 19 17:56:06 2017 +0100
1.2 +++ b/common.py Mon Feb 20 00:35:08 2017 +0100
1.3 @@ -741,14 +741,17 @@
1.4
1.5 return isinstance(node.expr, compiler.ast.Getattr)
1.6
1.7 - def get_name_for_tracking(self, name, ref=None):
1.8 + def get_name_for_tracking(self, name, name_ref=None):
1.9
1.10 """
1.11 Return the name to be used for attribute usage observations involving
1.12 - the given 'name' in the current namespace. If 'ref' is indicated and
1.13 - the name is being used outside a function, return the origin information
1.14 - from 'ref'; otherwise, return a path computed using the current
1.15 - namespace and the given name.
1.16 + the given 'name' in the current namespace.
1.17 +
1.18 + If the name is being used outside a function, and if 'name_ref' is
1.19 + given, a path featuring the name in the global namespace is returned
1.20 + where 'name_ref' indicates a global, or a static reference is used if
1.21 + 'name_ref' provides such a reference. Otherwise, a path computed using
1.22 + the current namespace and the given name is returned.
1.23
1.24 The intention of this method is to provide a suitably-qualified name
1.25 that can be tracked across namespaces. Where globals are being
1.26 @@ -766,15 +769,15 @@
1.27 if self.in_function:
1.28 return name
1.29
1.30 - # For static namespaces, use the given qualified name.
1.31 + # For static references, use the reference origin.
1.32
1.33 - elif ref and ref.static():
1.34 - return ref.get_origin()
1.35 + elif name_ref and name_ref.final():
1.36 + return name_ref.final()
1.37
1.38 - # For non-static objects in static namespaces, use any alias.
1.39 + # For global names outside functions, use a global name.
1.40
1.41 - elif ref and ref.get_name():
1.42 - return ref.get_name()
1.43 + elif name_ref and name_ref.is_global_name():
1.44 + return self.get_global_path(name)
1.45
1.46 # Otherwise, establish a name in the current namespace.
1.47