mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-20 12:31:14 +08:00
remove PyFuzzyParser attributes in favor of local vars
This commit is contained in:
@@ -1156,13 +1156,12 @@ class PyFuzzyParser(object):
|
|||||||
self._line_offset = line_offset
|
self._line_offset = line_offset
|
||||||
|
|
||||||
if tokenize_gen is None:
|
if tokenize_gen is None:
|
||||||
self.code = code + '\n' # end with \n, because the parser needs it
|
code = code + '\n' # end with \n, because the parser needs it
|
||||||
self.parse()
|
buf = StringIO(code)
|
||||||
|
self.gen = common.NoErrorTokenizer(buf.readline)
|
||||||
# delete code again, only the parser needs it
|
|
||||||
del self.code
|
|
||||||
else:
|
else:
|
||||||
self.parse(tokenize_gen)
|
self.gen = tokenize_gen
|
||||||
|
self.parse()
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return "<%s: %s>" % (type(self).__name__, self.module)
|
return "<%s: %s>" % (type(self).__name__, self.module)
|
||||||
@@ -1590,7 +1589,7 @@ class PyFuzzyParser(object):
|
|||||||
type, tok, self._tokenize_start_pos, self._tokenize_end_pos, \
|
type, tok, self._tokenize_start_pos, self._tokenize_end_pos, \
|
||||||
self.parserline = next(self.gen)
|
self.parserline = next(self.gen)
|
||||||
except StopIteration:
|
except StopIteration:
|
||||||
# set end_pos correctly, if we finish
|
# on finish, set end_pos correctly
|
||||||
s = self.scope
|
s = self.scope
|
||||||
while s is not None:
|
while s is not None:
|
||||||
s.end_pos = self.end_pos
|
s.end_pos = self.end_pos
|
||||||
@@ -1618,9 +1617,6 @@ class PyFuzzyParser(object):
|
|||||||
|
|
||||||
:raises: IndentationError
|
:raises: IndentationError
|
||||||
"""
|
"""
|
||||||
self.buf = StringIO(self.code)
|
|
||||||
self.gen = common.NoErrorTokenizer(self.buf.readline)
|
|
||||||
|
|
||||||
extended_flow = ['else', 'elif', 'except', 'finally']
|
extended_flow = ['else', 'elif', 'except', 'finally']
|
||||||
statement_toks = ['{', '[', '(', '`']
|
statement_toks = ['{', '[', '(', '`']
|
||||||
|
|
||||||
@@ -1808,6 +1804,3 @@ class PyFuzzyParser(object):
|
|||||||
tokenize.ENDMARKER]:
|
tokenize.ENDMARKER]:
|
||||||
debug.warning('token not classified', tok, token_type,
|
debug.warning('token not classified', tok, token_type,
|
||||||
self.start_pos[0])
|
self.start_pos[0])
|
||||||
|
|
||||||
del self.buf
|
|
||||||
return self.module
|
|
||||||
|
|||||||
Reference in New Issue
Block a user