mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Python function parsing fixed: any function has statement list now
This commit is contained in:
@@ -111,6 +111,7 @@ public class FunctionParsing extends Parsing {
|
||||
myBuilder.error(message("PARSE.expected.@.or.def"));
|
||||
PsiBuilder.Marker parameterList = myBuilder.mark(); // To have non-empty parameters list at all the time.
|
||||
parameterList.done(PyElementTypes.PARAMETER_LIST);
|
||||
myBuilder.mark().done(PyElementTypes.STATEMENT_LIST); // To have non-empty empty statement list
|
||||
endMarker.done(getFunctionType());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
class Foo(object):
|
||||
@staticmethod
|
||||
def bad_method(): #test
|
||||
pass
|
||||
@@ -0,0 +1,44 @@
|
||||
PyFile:BadDecoratorNotMethod.py
|
||||
PyClass: Foo
|
||||
PsiElement(Py:CLASS_KEYWORD)('class')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(Py:IDENTIFIER)('Foo')
|
||||
PyArgumentList
|
||||
PsiElement(Py:LPAR)('(')
|
||||
PyReferenceExpression: object
|
||||
PsiElement(Py:IDENTIFIER)('object')
|
||||
PsiElement(Py:RPAR)(')')
|
||||
PsiElement(Py:COLON)(':')
|
||||
PsiWhiteSpace('\n ')
|
||||
PyStatementList
|
||||
PyFunction('null')
|
||||
PyDecoratorList
|
||||
PyDecorator: @staticmethod
|
||||
PsiElement(Py:AT)('@')
|
||||
PyReferenceExpression: staticmethod
|
||||
PsiElement(Py:IDENTIFIER)('staticmethod')
|
||||
PyArgumentList
|
||||
<empty list>
|
||||
PsiErrorElement:'@' or 'def' expected
|
||||
<empty list>
|
||||
PsiWhiteSpace('\n ')
|
||||
PyParameterList
|
||||
<empty list>
|
||||
PyStatementList
|
||||
<empty list>
|
||||
PsiErrorElement:Unexpected indent
|
||||
<empty list>
|
||||
PyFunction('bad_method')
|
||||
PsiElement(Py:DEF_KEYWORD)('def')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(Py:IDENTIFIER)('bad_method')
|
||||
PyParameterList
|
||||
PsiElement(Py:LPAR)('(')
|
||||
PsiElement(Py:RPAR)(')')
|
||||
PsiElement(Py:COLON)(':')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiComment(Py:END_OF_LINE_COMMENT)('#test')
|
||||
PsiWhiteSpace('\n ')
|
||||
PyStatementList
|
||||
PyPassStatement
|
||||
PsiElement(Py:PASS_KEYWORD)('pass')
|
||||
@@ -251,6 +251,10 @@ public class PythonParsingTest extends ParsingTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testBadDecoratorNotMethod() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testCommentAtEndOfMethod() { // PY-2137
|
||||
doTest();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user