forked from VimPlug/jedi
rename some parser functions (add underlines)
This commit is contained in:
+17
-17
@@ -1317,7 +1317,7 @@ class Parser(object):
|
|||||||
else:
|
else:
|
||||||
self.user_stmt = simple
|
self.user_stmt = simple
|
||||||
|
|
||||||
def _parsedotname(self, pre_used_token=None):
|
def _parse_dot_name(self, pre_used_token=None):
|
||||||
"""
|
"""
|
||||||
The dot name parser parses a name, variable or function and returns
|
The dot name parser parses a name, variable or function and returns
|
||||||
their names.
|
their names.
|
||||||
@@ -1356,7 +1356,7 @@ class Parser(object):
|
|||||||
else None
|
else None
|
||||||
return n, token_type, tok
|
return n, token_type, tok
|
||||||
|
|
||||||
def _parseimportlist(self):
|
def _parse_import_list(self):
|
||||||
"""
|
"""
|
||||||
The parser for the imports. Unlike the class and function parse
|
The parser for the imports. Unlike the class and function parse
|
||||||
function, this returns no Import class, but rather an import list,
|
function, this returns no Import class, but rather an import list,
|
||||||
@@ -1386,12 +1386,12 @@ class Parser(object):
|
|||||||
if tok == '(': # python allows only one `(` in the statement.
|
if tok == '(': # python allows only one `(` in the statement.
|
||||||
brackets = True
|
brackets = True
|
||||||
self.next()
|
self.next()
|
||||||
i, token_type, tok = self._parsedotname(self.current)
|
i, token_type, tok = self._parse_dot_name(self.current)
|
||||||
if not i:
|
if not i:
|
||||||
defunct = True
|
defunct = True
|
||||||
name2 = None
|
name2 = None
|
||||||
if tok == 'as':
|
if tok == 'as':
|
||||||
name2, token_type, tok = self._parsedotname()
|
name2, token_type, tok = self._parse_dot_name()
|
||||||
imports.append((i, name2, defunct))
|
imports.append((i, name2, defunct))
|
||||||
while tok not in continue_kw:
|
while tok not in continue_kw:
|
||||||
token_type, tok = self.next()
|
token_type, tok = self.next()
|
||||||
@@ -1399,7 +1399,7 @@ class Parser(object):
|
|||||||
break
|
break
|
||||||
return imports
|
return imports
|
||||||
|
|
||||||
def _parseparen(self):
|
def _parse_parentheses(self):
|
||||||
"""
|
"""
|
||||||
Functions and Classes have params (which means for classes
|
Functions and Classes have params (which means for classes
|
||||||
super-classes). They are parsed here and returned as Statements.
|
super-classes). They are parsed here and returned as Statements.
|
||||||
@@ -1428,7 +1428,7 @@ class Parser(object):
|
|||||||
|
|
||||||
return names
|
return names
|
||||||
|
|
||||||
def _parsefunction(self):
|
def _parse_function(self):
|
||||||
"""
|
"""
|
||||||
The parser for a text functions. Process the tokens, which follow a
|
The parser for a text functions. Process the tokens, which follow a
|
||||||
function definition.
|
function definition.
|
||||||
@@ -1447,7 +1447,7 @@ class Parser(object):
|
|||||||
token_type, open = self.next()
|
token_type, open = self.next()
|
||||||
if open != '(':
|
if open != '(':
|
||||||
return None
|
return None
|
||||||
params = self._parseparen()
|
params = self._parse_parentheses()
|
||||||
|
|
||||||
token_type, colon = self.next()
|
token_type, colon = self.next()
|
||||||
annotation = None
|
annotation = None
|
||||||
@@ -1470,7 +1470,7 @@ class Parser(object):
|
|||||||
self.user_scope = scope
|
self.user_scope = scope
|
||||||
return scope
|
return scope
|
||||||
|
|
||||||
def _parseclass(self):
|
def _parse_class(self):
|
||||||
"""
|
"""
|
||||||
The parser for a text class. Process the tokens, which follow a
|
The parser for a text class. Process the tokens, which follow a
|
||||||
class definition.
|
class definition.
|
||||||
@@ -1491,7 +1491,7 @@ class Parser(object):
|
|||||||
super = []
|
super = []
|
||||||
token_type, next = self.next()
|
token_type, next = self.next()
|
||||||
if next == '(':
|
if next == '(':
|
||||||
super = self._parseparen()
|
super = self._parse_parentheses()
|
||||||
token_type, next = self.next()
|
token_type, next = self.next()
|
||||||
|
|
||||||
if next != ':':
|
if next != ':':
|
||||||
@@ -1564,7 +1564,7 @@ class Parser(object):
|
|||||||
string += " %s " % tok
|
string += " %s " % tok
|
||||||
token_type, tok = self.next()
|
token_type, tok = self.next()
|
||||||
if token_type == tokenize.NAME:
|
if token_type == tokenize.NAME:
|
||||||
n, token_type, tok = self._parsedotname(self.current)
|
n, token_type, tok = self._parse_dot_name(self.current)
|
||||||
if n:
|
if n:
|
||||||
set_vars.append(n)
|
set_vars.append(n)
|
||||||
tok_list.append(n)
|
tok_list.append(n)
|
||||||
@@ -1650,7 +1650,7 @@ class Parser(object):
|
|||||||
string += tok.get_code()
|
string += tok.get_code()
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
n, token_type, tok = self._parsedotname(self.current)
|
n, token_type, tok = self._parse_dot_name(self.current)
|
||||||
# removed last entry, because we add Name
|
# removed last entry, because we add Name
|
||||||
tok_list.pop()
|
tok_list.pop()
|
||||||
if n:
|
if n:
|
||||||
@@ -1774,7 +1774,7 @@ class Parser(object):
|
|||||||
SubModule) else self.scope
|
SubModule) else self.scope
|
||||||
first_pos = self.start_pos
|
first_pos = self.start_pos
|
||||||
if tok == 'def':
|
if tok == 'def':
|
||||||
func = self._parsefunction()
|
func = self._parse_function()
|
||||||
if func is None:
|
if func is None:
|
||||||
debug.warning("function: syntax error@%s" %
|
debug.warning("function: syntax error@%s" %
|
||||||
self.start_pos[0])
|
self.start_pos[0])
|
||||||
@@ -1783,7 +1783,7 @@ class Parser(object):
|
|||||||
self.scope = self.scope.add_scope(func, self._decorators)
|
self.scope = self.scope.add_scope(func, self._decorators)
|
||||||
self._decorators = []
|
self._decorators = []
|
||||||
elif tok == 'class':
|
elif tok == 'class':
|
||||||
cls = self._parseclass()
|
cls = self._parse_class()
|
||||||
if cls is None:
|
if cls is None:
|
||||||
debug.warning("class: syntax error@%s" % self.start_pos[0])
|
debug.warning("class: syntax error@%s" % self.start_pos[0])
|
||||||
continue
|
continue
|
||||||
@@ -1792,7 +1792,7 @@ class Parser(object):
|
|||||||
self._decorators = []
|
self._decorators = []
|
||||||
# import stuff
|
# import stuff
|
||||||
elif tok == 'import':
|
elif tok == 'import':
|
||||||
imports = self._parseimportlist()
|
imports = self._parse_import_list()
|
||||||
for m, alias, defunct in imports:
|
for m, alias, defunct in imports:
|
||||||
i = Import(self.module, first_pos, self.end_pos, m, alias,
|
i = Import(self.module, first_pos, self.end_pos, m, alias,
|
||||||
defunct=defunct)
|
defunct=defunct)
|
||||||
@@ -1813,7 +1813,7 @@ class Parser(object):
|
|||||||
break
|
break
|
||||||
relative_count += 1
|
relative_count += 1
|
||||||
# the from import
|
# the from import
|
||||||
mod, token_type, tok = self._parsedotname(self.current)
|
mod, token_type, tok = self._parse_dot_name(self.current)
|
||||||
if str(mod) == 'import' and relative_count:
|
if str(mod) == 'import' and relative_count:
|
||||||
self._gen.push_last_back()
|
self._gen.push_last_back()
|
||||||
tok = 'import'
|
tok = 'import'
|
||||||
@@ -1823,7 +1823,7 @@ class Parser(object):
|
|||||||
defunct = True
|
defunct = True
|
||||||
if tok != 'import':
|
if tok != 'import':
|
||||||
self._gen.push_last_back()
|
self._gen.push_last_back()
|
||||||
names = self._parseimportlist()
|
names = self._parse_import_list()
|
||||||
for name, alias, defunct2 in names:
|
for name, alias, defunct2 in names:
|
||||||
star = name is not None and name.names[0] == '*'
|
star = name is not None and name.names[0] == '*'
|
||||||
if star:
|
if star:
|
||||||
@@ -1871,7 +1871,7 @@ class Parser(object):
|
|||||||
if command == 'except' and tok in added_breaks:
|
if command == 'except' and tok in added_breaks:
|
||||||
# the except statement defines a var
|
# the except statement defines a var
|
||||||
# this is only true for python 2
|
# this is only true for python 2
|
||||||
n, token_type, tok = self._parsedotname()
|
n, token_type, tok = self._parse_dot_name()
|
||||||
if n:
|
if n:
|
||||||
statement.set_vars.append(n)
|
statement.set_vars.append(n)
|
||||||
statement.code += ',' + n.get_code()
|
statement.code += ',' + n.get_code()
|
||||||
|
|||||||
Reference in New Issue
Block a user