mirror of
https://github.com/davidhalter/jedi.git
synced 2026-01-09 05:22:19 +08:00
removed parentheses counting from generate_tokens
This commit is contained in:
@@ -63,7 +63,6 @@ class Parser(object):
|
||||
while s is not None:
|
||||
s.end_pos = self.end_pos
|
||||
s = s.parent
|
||||
pass
|
||||
|
||||
# clean up unused decorators
|
||||
for d in self._decorators:
|
||||
@@ -157,7 +156,9 @@ class Parser(object):
|
||||
brackets = True
|
||||
token_type, tok = self.next()
|
||||
if brackets and tok == '\n':
|
||||
self.next()
|
||||
token_type, tok = self.next()
|
||||
if token_type == tokenize.INDENT:
|
||||
continue # TODO REMOVE, after removing the indents.
|
||||
i, token_type, tok = self._parse_dot_name(self._current)
|
||||
if not i:
|
||||
defunct = True
|
||||
|
||||
@@ -153,7 +153,6 @@ def generate_tokens(readline, line_offset=0):
|
||||
Modified to not care about dedents.
|
||||
"""
|
||||
lnum = line_offset
|
||||
parenlev = 0
|
||||
continued = False
|
||||
numchars = '0123456789'
|
||||
contstr, needcont = '', 0
|
||||
@@ -190,7 +189,7 @@ def generate_tokens(readline, line_offset=0):
|
||||
contline = contline + line
|
||||
continue
|
||||
|
||||
elif parenlev == 0 and not continued: # new statement
|
||||
elif not continued: # new statement
|
||||
if not line:
|
||||
break
|
||||
column = 0
|
||||
@@ -216,9 +215,7 @@ def generate_tokens(readline, line_offset=0):
|
||||
yield TokenInfo(NEWLINE, line[nl_pos:], (lnum, nl_pos),
|
||||
(lnum, len(line)))
|
||||
else:
|
||||
yield TokenInfo(
|
||||
(NEWLINE, COMMENT)[line[pos] == '#'], line[pos:],
|
||||
(lnum, pos), (lnum, len(line)))
|
||||
yield TokenInfo(NEWLINE, line[pos:], (lnum, pos), (lnum, len(line)))
|
||||
continue
|
||||
|
||||
if column > indents[-1]: # count indents or dedents
|
||||
@@ -244,8 +241,7 @@ def generate_tokens(readline, line_offset=0):
|
||||
(initial == '.' and token != '.' and token != '...')):
|
||||
yield TokenInfo(NUMBER, token, spos, epos)
|
||||
elif initial in '\r\n':
|
||||
yield TokenInfo(NEWLINE,
|
||||
token, spos, epos)
|
||||
yield TokenInfo(NEWLINE, token, spos, epos)
|
||||
elif initial == '#':
|
||||
assert not token.endswith("\n")
|
||||
yield TokenInfo(COMMENT, token, spos, epos)
|
||||
@@ -278,10 +274,6 @@ def generate_tokens(readline, line_offset=0):
|
||||
elif initial == '\\': # continued stmt
|
||||
continued = True
|
||||
else:
|
||||
if initial in '([{':
|
||||
parenlev += 1
|
||||
elif initial in ')]}':
|
||||
parenlev -= 1
|
||||
yield TokenInfo(OP, token, spos, epos)
|
||||
else:
|
||||
yield TokenInfo(ERRORTOKEN, line[pos],
|
||||
|
||||
Reference in New Issue
Block a user