-
Notifications
You must be signed in to change notification settings - Fork 510
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Don't autoformat imports if the import list contains top-level comments #441
Conversation
@@ -23,10 +25,17 @@ class ImportOrderingRule : Rule("import-ordering") { | |||
val children = node.getChildren(null) | |||
if (children.isNotEmpty()) { | |||
val imports = children.filter { it.elementType == IMPORT_DIRECTIVE } | |||
val hasComments = children.find { it.elementType == BLOCK_COMMENT || it.elementType == EOL_COMMENT } != null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a broad brush. should we check for the suppression message? though perhaps unlikely to be a problem in practice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The suppression message causes a real problem, but it would also seem annoying if you had comments (for some reason?) in an import list that they'd get blown away by the autoformatter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
true. sounds good.
@@ -23,10 +25,17 @@ class ImportOrderingRule : Rule("import-ordering") { | |||
val children = node.getChildren(null) | |||
if (children.isNotEmpty()) { | |||
val imports = children.filter { it.elementType == IMPORT_DIRECTIVE } | |||
val hasComments = children.find { it.elementType == BLOCK_COMMENT || it.elementType == EOL_COMMENT } != null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
true. sounds good.
Fixes #408
Refusing to auto-import seemed much easier than trying to figure out which imports the comments were attached to.