Better error recovery for lines with single 'class' or 'def' keywords and normal functions defined below

This commit is contained in:
Andrey Vlasovskikh
2014-02-26 19:29:15 +04:00
parent a39c3b7998
commit ae1e6ca3e7
10 changed files with 91 additions and 11 deletions
@@ -2,7 +2,7 @@ PyFile:KeywordAsFunctionName.py
PyFunction('null')
PsiElement(Py:DEF_KEYWORD)('def')
PsiWhiteSpace(' ')
PsiErrorElement:function name expected
PsiErrorElement:Identifier expected
PsiElement(Py:FROM_KEYWORD)('from')
PyParameterList
PsiElement(Py:LPAR)('(')
@@ -0,0 +1,5 @@
class
def foo():
pass
@@ -0,0 +1,25 @@
PyFile:SingleClassBeforeFunction.py
PyClass: null
PsiElement(Py:CLASS_KEYWORD)('class')
PsiErrorElement:Identifier expected
<empty list>
PyArgumentList
<empty list>
PsiErrorElement:Colon expected
<empty list>
PsiWhiteSpace('\n\n\n')
PyStatementList
PsiErrorElement:Indent expected
<empty list>
PyFunction('foo')
PsiElement(Py:DEF_KEYWORD)('def')
PsiWhiteSpace(' ')
PsiElement(Py:IDENTIFIER)('foo')
PyParameterList
PsiElement(Py:LPAR)('(')
PsiElement(Py:RPAR)(')')
PsiElement(Py:COLON)(':')
PsiWhiteSpace('\n ')
PyStatementList
PyPassStatement
PsiElement(Py:PASS_KEYWORD)('pass')
@@ -0,0 +1,5 @@
def
def bar():
x = 1
@@ -0,0 +1,31 @@
PyFile:SingleDefBeforeFunction.py
PyFunction('null')
PsiElement(Py:DEF_KEYWORD)('def')
PsiErrorElement:Identifier expected
<empty list>
PsiErrorElement:'(' expected
<empty list>
PyParameterList
<empty list>
PsiWhiteSpace('\n\n\n')
PyStatementList
PsiErrorElement:Indent expected
<empty list>
PyFunction('bar')
PsiElement(Py:DEF_KEYWORD)('def')
PsiWhiteSpace(' ')
PsiElement(Py:IDENTIFIER)('bar')
PyParameterList
PsiElement(Py:LPAR)('(')
PsiElement(Py:RPAR)(')')
PsiElement(Py:COLON)(':')
PsiWhiteSpace('\n ')
PyStatementList
PyAssignmentStatement
PyTargetExpression: x
PsiElement(Py:IDENTIFIER)('x')
PsiWhiteSpace(' ')
PsiElement(Py:EQ)('=')
PsiWhiteSpace(' ')
PyNumericLiteralExpression
PsiElement(Py:INTEGER_LITERAL)('1')