forked from VimPlug/jedi
moved user_stmt up in api
This commit is contained in:
@@ -113,6 +113,20 @@ class Script(object):
|
|||||||
cache.save_parser(path, None, parser, pickling=False)
|
cache.save_parser(path, None, parser, pickling=False)
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
|
def _user_stmt(self, is_completion=False):
|
||||||
|
user_stmt = self._parser.user_stmt
|
||||||
|
|
||||||
|
debug.speed('parsed')
|
||||||
|
|
||||||
|
if is_completion and not user_stmt:
|
||||||
|
# for statements like `from x import ` (cursor not in statement)
|
||||||
|
pos = next(self._user_context.get_context(yield_positions=True))
|
||||||
|
last_stmt = pos and self._parser.module.get_statement_for_position(
|
||||||
|
pos, include_imports=True)
|
||||||
|
if isinstance(last_stmt, pr.Import):
|
||||||
|
user_stmt = last_stmt
|
||||||
|
return user_stmt
|
||||||
|
|
||||||
def completions(self):
|
def completions(self):
|
||||||
"""
|
"""
|
||||||
Return :class:`classes.Completion` objects. Those objects contain
|
Return :class:`classes.Completion` objects. Those objects contain
|
||||||
@@ -211,19 +225,6 @@ class Script(object):
|
|||||||
completions.append((c, s))
|
completions.append((c, s))
|
||||||
return completions
|
return completions
|
||||||
|
|
||||||
def _user_stmt(self, is_completion=False):
|
|
||||||
user_stmt = self._parser.user_stmt
|
|
||||||
debug.speed('parsed')
|
|
||||||
|
|
||||||
if is_completion and not user_stmt:
|
|
||||||
# for statements like `from x import ` (cursor not in statement)
|
|
||||||
pos = next(self._user_context.get_context(yield_positions=True))
|
|
||||||
last_stmt = pos and self._parser.module.get_statement_for_position(
|
|
||||||
pos, include_imports=True)
|
|
||||||
if isinstance(last_stmt, pr.Import):
|
|
||||||
user_stmt = last_stmt
|
|
||||||
return user_stmt
|
|
||||||
|
|
||||||
def _prepare_goto(self, goto_path, is_completion=False):
|
def _prepare_goto(self, goto_path, is_completion=False):
|
||||||
"""
|
"""
|
||||||
Base for completions/goto. Basically it returns the resolved scopes
|
Base for completions/goto. Basically it returns the resolved scopes
|
||||||
|
|||||||
@@ -123,9 +123,8 @@ def source_to_unicode(source, encoding=None):
|
|||||||
def detect_encoding():
|
def detect_encoding():
|
||||||
"""
|
"""
|
||||||
For the implementation of encoding definitions in Python, look at:
|
For the implementation of encoding definitions in Python, look at:
|
||||||
http://www.python.org/dev/peps/pep-0263/
|
- http://www.python.org/dev/peps/pep-0263/
|
||||||
http://docs.python.org/2/reference/lexical_analysis.html#encoding-\
|
- http://docs.python.org/2/reference/lexical_analysis.html#encoding-declarations
|
||||||
declarations
|
|
||||||
"""
|
"""
|
||||||
byte_mark = literal_eval(r"b'\xef\xbb\xbf'")
|
byte_mark = literal_eval(r"b'\xef\xbb\xbf'")
|
||||||
if source.startswith(byte_mark):
|
if source.startswith(byte_mark):
|
||||||
|
|||||||
Reference in New Issue
Block a user