Check whether this variable is what the call is acting on. For example, if we had 'obj' from obj = Obj() as a variable and a call of obj.do_something() Those would match and we would return the "do_something" node from obj. :param var
(self, variable)
| 211 | return self.owner_token is not None |
| 212 | |
| 213 | def matches_variable(self, variable): |
| 214 | """ |
| 215 | Check whether this variable is what the call is acting on. |
| 216 | For example, if we had 'obj' from |
| 217 | obj = Obj() |
| 218 | as a variable and a call of |
| 219 | obj.do_something() |
| 220 | Those would match and we would return the "do_something" node from obj. |
| 221 | |
| 222 | :param variable Variable: |
| 223 | :rtype: Node |
| 224 | """ |
| 225 | |
| 226 | if self.is_attr(): |
| 227 | if self.owner_token == variable.token: |
| 228 | for node in getattr(variable.points_to, 'nodes', []): |
| 229 | if self.token == node.token: |
| 230 | return node |
| 231 | for inherit_nodes in getattr(variable.points_to, 'inherits', []): |
| 232 | for node in inherit_nodes: |
| 233 | if self.token == node.token: |
| 234 | return node |
| 235 | if variable.points_to in OWNER_CONST: |
| 236 | return variable.points_to |
| 237 | |
| 238 | # This section is specifically for resolving namespace variables |
| 239 | if isinstance(variable.points_to, Group) \ |
| 240 | and variable.points_to.group_type == GROUP_TYPE.NAMESPACE: |
| 241 | parts = self.owner_token.split('.') |
| 242 | if len(parts) != 2: |
| 243 | return None |
| 244 | if parts[0] != variable.token: |
| 245 | return None |
| 246 | for node in variable.points_to.all_nodes(): |
| 247 | if parts[1] == node.namespace_ownership() \ |
| 248 | and self.token == node.token: |
| 249 | return node |
| 250 | |
| 251 | return None |
| 252 | if self.token == variable.token: |
| 253 | if isinstance(variable.points_to, Node): |
| 254 | return variable.points_to |
| 255 | if isinstance(variable.points_to, Group) \ |
| 256 | and variable.points_to.group_type == GROUP_TYPE.CLASS \ |
| 257 | and variable.points_to.get_constructor(): |
| 258 | return variable.points_to.get_constructor() |
| 259 | return None |
| 260 | |
| 261 | |
| 262 | class Node(): |
no test coverage detected