1
0
forked from VimPlug/jedi

Remove the user_scope from the user_context module.

This commit is contained in:
Dave Halter
2016-06-27 08:35:24 +02:00
parent bb4ab45131
commit 0445d51d34
5 changed files with 30 additions and 28 deletions
-21
View File
@@ -5,7 +5,6 @@ from collections import namedtuple
from jedi import cache
from jedi.parser import ParserWithRecovery
from jedi.parser.fast import FastParser
from jedi.parser import tree
# TODO this should be part of the tokenizer not just of this user_context.
Token = namedtuple('Token', ['type', 'string', 'start_pos', 'prefix'])
@@ -38,25 +37,5 @@ class UserContextParser(object):
self._parser_done_callback(parser)
return parser
@cache.underscore_memoization
def user_scope(self):
"""
Returns the scope in which the user resides. This includes flows.
"""
user_stmt = self.module().get_statement_for_position(self._position)
if user_stmt is None:
def scan(scope):
for s in scope.children:
if s.start_pos <= self._position <= s.end_pos:
if isinstance(s, (tree.Scope, tree.Flow)):
return scan(s) or s
elif s.type in ('suite', 'decorated'):
return scan(s)
return None
return scan(self.module()) or self.module()
else:
return user_stmt.get_parent_scope(include_flows=True)
def module(self):
return self._parser().module