Files
openide/python/testData/optimizeImports/stackDanglingCommentsAtEnd.after.py
Mikhail Golubev 6de5015a72 PY-23125 Preserve blank lines before the first comment in optimize imports
I tweaked Python import optimizer so that it inserts new imports
and their comments after the last of original imports, not before the
first of them (and then deletes the old ones). The reason is that it
turned out to be practically impossible to use PsiComment as the anchor
for PsiElement#addRangeBefore(), because of the hardcoded behavior of
CodeEditUtil.addChildren() which skips preceding whitespaces in this
scenario.

Otherwise, if the blank line before "# noinspection" comment preceding
the first imports statement gets removed, next time this comment will be
left in place, considered part of the top-level module comment
e.g. license.
2017-03-17 14:44:29 +03:00

26 lines
349 B
Python

#!/bin/python
# top-level comment
# continuation of the top-level comment
# comment after the top-level one
# comment for abc
import abc
# comment for sys
import sys
# comment for a 1
# comment for a 2
import a
# comment for b
import b
# dangling comment 1
# dangling comment 2
# dangling comment 3
# dangling comment 4
print(a, b, abc, sys)