mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-16 22:51:17 +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.
26 lines
349 B
Python
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)
|