forked from VimPlug/jedi
Create an ExprStatement class to replace the Statement class in the future and separate array parts of actual statements
This commit is contained in:
@@ -153,7 +153,11 @@ class BaseDefinition(object):
|
||||
stripped = stripped.parent
|
||||
if isinstance(stripped, iterable.Array):
|
||||
return 'instance'
|
||||
return type(stripped).__name__.lower().replace('wrapper', '')
|
||||
string = type(stripped).__name__.lower().replace('wrapper', '')
|
||||
if string == 'exprstatement':
|
||||
return 'statement'
|
||||
else:
|
||||
return string
|
||||
|
||||
def _path(self):
|
||||
"""The module path."""
|
||||
|
||||
@@ -190,7 +190,7 @@ class Parser(object):
|
||||
# Classes don't have params, a Class works more like a function
|
||||
# call.
|
||||
param, tok = self._parse_statement(added_breaks=breaks,
|
||||
stmt_class=pr.Statement
|
||||
stmt_class=pr.ExprStatement
|
||||
if is_class else pr.Param)
|
||||
if is_class:
|
||||
if param is not None:
|
||||
@@ -280,7 +280,7 @@ class Parser(object):
|
||||
return pr.Class(self.module, cname, superclasses, first_pos)
|
||||
|
||||
def _parse_statement(self, pre_used_token=None, added_breaks=None,
|
||||
stmt_class=pr.Statement, names_are_set_vars=False,
|
||||
stmt_class=pr.ExprStatement, names_are_set_vars=False,
|
||||
maybe_docstr=False):
|
||||
"""
|
||||
Parses statements like::
|
||||
@@ -292,8 +292,8 @@ class Parser(object):
|
||||
|
||||
:param pre_used_token: The pre parsed token.
|
||||
:type pre_used_token: set
|
||||
:return: Statement + last parsed token.
|
||||
:rtype: (Statement, str)
|
||||
:return: ExprStatement + last parsed token.
|
||||
:rtype: (ExprStatement, str)
|
||||
"""
|
||||
set_vars = []
|
||||
level = 0 # The level of parentheses
|
||||
|
||||
@@ -1223,7 +1223,19 @@ class Statement(Simple, DocstringMixin):
|
||||
self._expression_list = lst
|
||||
|
||||
|
||||
class Param(Statement):
|
||||
class ExprStatement(Statement):
|
||||
"""
|
||||
This class exists temporarily, to be able to distinguish real statements
|
||||
(``small_stmt`` in Python grammar) from the so called ``test`` parts, that
|
||||
may be used to defined part of an array, but are never a whole statement.
|
||||
|
||||
The reason for this class is purely historical. It was easier to just use
|
||||
Statement nested, than to create a new class for Test (plus Jedi's fault
|
||||
tolerant parser just makes things very complicated).
|
||||
"""
|
||||
|
||||
|
||||
class Param(ExprStatement):
|
||||
"""
|
||||
The class which shows definitions of params of classes and functions.
|
||||
But this is not to define function calls.
|
||||
|
||||
Reference in New Issue
Block a user