mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-16 14:23:28 +07:00
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.
31 lines
354 B
Python
31 lines
354 B
Python
#!/bin/python
|
|
# top-level comment
|
|
# continuation of the top-level comment
|
|
|
|
# comment after the top-level one
|
|
|
|
|
|
|
|
# comment for b
|
|
import b
|
|
|
|
# dangling comment 1
|
|
|
|
# comment for a 1
|
|
# comment for a 2
|
|
import a
|
|
|
|
# dangling comment 2
|
|
|
|
# comment for sys
|
|
import sys
|
|
|
|
# dangling comment 3
|
|
|
|
# dangling comment 4
|
|
|
|
# comment for abc
|
|
import abc
|
|
|
|
print(a, b, abc, sys)
|