1
0
forked from VimPlug/jedi

FastModule should inherit from SubModule, because it has almost all the same properties.

This commit is contained in:
Dave Halter
2015-01-28 14:59:00 +01:00
parent 6ec89e6785
commit d0589430bb
4 changed files with 16 additions and 21 deletions

View File

@@ -16,7 +16,7 @@ from jedi.parser.tokenize import (source_tokens, FLOWS, NEWLINE,
ENDMARKER, INDENT, DEDENT)
class FastModule(pr.Module, pr.Simple):
class FastModule(pr.SubModule):
type = 'file_input'
def __init__(self):
@@ -48,13 +48,6 @@ class FastModule(pr.Module, pr.Simple):
"""
return MergedNamesDict([m.used_names for m in self.modules])
def _search_in_scope(self, typ):
return pr.Scope._search_in_scope(self, typ)
@property
def subscopes(self):
return self._search_in_scope(pr.Scope)
def __repr__(self):
return "<fast.%s: %s@%s-%s>" % (type(self).__name__, self.name,
self.start_pos[0], self.end_pos[0])
@@ -556,7 +549,7 @@ class FastTokenizer(object):
if self._parentheses_level:
# Parentheses ignore the indentation rules.
pass
elif indent < self._parser_indent: # -> dedent
elif False and indent < self._parser_indent: # -> dedent
raise NotImplementedError
self._parser_indent = indent
self._new_indent = False
@@ -574,18 +567,18 @@ class FastTokenizer(object):
if self._in_flow:
print('INFLOW', self._indent_counter)
self._flow_indent_counter = self._indent_counter
self._old_parser_indent = self._parser_indent
self._parser_indent += 1 # new scope: must be higher
self._new_indent = True
#self._old_parser_indent = self._parser_indent
#self._parser_indent += 1 # new scope: must be higher
#self._new_indent = True
elif value in breaks:
if not self._is_decorator:
return self._close()
self._is_decorator = '@' == value
if not self._is_decorator:
self._old_parser_indent = self._parser_indent
self._parser_indent += 1 # new scope: must be higher
self._new_indent = True
#if not self._is_decorator:
#self._old_parser_indent = self._parser_indent
#self._parser_indent += 1 # new scope: must be higher
#self._new_indent = True
if value != '@':
if self._first_stmt and not self._new_indent:

View File

@@ -97,7 +97,9 @@ with_item: test ['as' expr]
with_var: 'as' expr
# NB compile.c makes sure that the default except clause is last
except_clause: 'except' [test [(',' | 'as') test]]
suite: simple_stmt | NEWLINE INDENT stmt+ DEDENT
# Edit by David Halter: The stmt is now optional. This reflects how Jedi allows
# classes and functions to be empty, which is beneficial for autocompletion.
suite: simple_stmt | NEWLINE INDENT stmt* DEDENT
# Backward compatibility cruft to support:
# [ x for x in lambda: True, lambda: False if x() ]

View File

@@ -533,7 +533,6 @@ class Scope(Simple, DocstringMixin):
def imports(self):
return self._search_in_scope(Import)
@Python3Method
def _search_in_scope(self, typ):
def scan(children):
elements = []

View File

@@ -113,14 +113,15 @@ def test_if():
x = 3
if x:
def y():
x
x = 3
return x
return y()
pass
func()
''')
# Two parsers needed, one for pass and one for the function.
check_fp(src, 2)
assert [d.name for d in jedi.Script(src, 8, 6).goto_definitions()] == ['int']
def test_incomplete_function():