PY-17017 Properly add DEDENT tokens after a series of trailing comments

This commit is contained in:
Mikhail Golubev
2017-10-02 15:20:24 +03:00
parent 34ed303b18
commit 98cc3d928c
9 changed files with 208 additions and 25 deletions
@@ -0,0 +1,4 @@
def f():
def g():
pass
# comment
@@ -0,0 +1,25 @@
PyFile:CommentAtTheEndOfBlock.py
PyFunction('f')
PsiElement(Py:DEF_KEYWORD)('def')
PsiWhiteSpace(' ')
PsiElement(Py:IDENTIFIER)('f')
PyParameterList
PsiElement(Py:LPAR)('(')
PsiElement(Py:RPAR)(')')
PsiElement(Py:COLON)(':')
PsiWhiteSpace('\n ')
PyStatementList
PyFunction('g')
PsiElement(Py:DEF_KEYWORD)('def')
PsiWhiteSpace(' ')
PsiElement(Py:IDENTIFIER)('g')
PyParameterList
PsiElement(Py:LPAR)('(')
PsiElement(Py:RPAR)(')')
PsiElement(Py:COLON)(':')
PsiWhiteSpace('\n ')
PyStatementList
PyPassStatement
PsiElement(Py:PASS_KEYWORD)('pass')
PsiWhiteSpace('\n ')
PsiComment(Py:END_OF_LINE_COMMENT)('# comment')
@@ -25,7 +25,7 @@ PyFile:CommentBetweenClasses.py
PyStatementList
PyPassStatement
PsiElement(Py:PASS_KEYWORD)('pass')
PsiWhiteSpace('\n\n')
PsiWhiteSpace('\n\n')
PsiComment(Py:END_OF_LINE_COMMENT)('# comment about T2')
PsiWhiteSpace('\n\n')
PyClass: T2
@@ -0,0 +1,7 @@
def foo():
def bar():
def baz():
pass
# baz
# bar
# foo
@@ -0,0 +1,39 @@
PyFile:RaggedTrailingComments.py
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
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
PyFunction('baz')
PsiElement(Py:DEF_KEYWORD)('def')
PsiWhiteSpace(' ')
PsiElement(Py:IDENTIFIER)('baz')
PyParameterList
PsiElement(Py:LPAR)('(')
PsiElement(Py:RPAR)(')')
PsiElement(Py:COLON)(':')
PsiWhiteSpace('\n ')
PyStatementList
PyPassStatement
PsiElement(Py:PASS_KEYWORD)('pass')
PsiWhiteSpace('\n ')
PsiComment(Py:END_OF_LINE_COMMENT)('# baz')
PsiWhiteSpace('\n ')
PsiComment(Py:END_OF_LINE_COMMENT)('# bar')
PsiWhiteSpace('\n ')
PsiComment(Py:END_OF_LINE_COMMENT)('# foo')
@@ -0,0 +1,8 @@
def foo():
def bar():
def baz():
pass
# baz
# bar
# foo
pass
@@ -0,0 +1,42 @@
PyFile:RaggedTrailingCommentsWithTrailingStatement.py
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
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
PyFunction('baz')
PsiElement(Py:DEF_KEYWORD)('def')
PsiWhiteSpace(' ')
PsiElement(Py:IDENTIFIER)('baz')
PyParameterList
PsiElement(Py:LPAR)('(')
PsiElement(Py:RPAR)(')')
PsiElement(Py:COLON)(':')
PsiWhiteSpace('\n ')
PyStatementList
PyPassStatement
PsiElement(Py:PASS_KEYWORD)('pass')
PsiWhiteSpace('\n ')
PsiComment(Py:END_OF_LINE_COMMENT)('# baz')
PsiWhiteSpace('\n ')
PsiComment(Py:END_OF_LINE_COMMENT)('# bar')
PsiWhiteSpace('\n ')
PsiComment(Py:END_OF_LINE_COMMENT)('# foo')
PsiWhiteSpace('\n')
PyPassStatement
PsiElement(Py:PASS_KEYWORD)('pass')