-
Notifications
You must be signed in to change notification settings - Fork 191
test(organizeimports): add failing IO tests for inline comment behavior (issue #2267) #2324
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| /* | ||
| rules = [OrganizeImports] | ||
| */ | ||
|
|
||
| package test.organizeImports | ||
|
|
||
| import z.Z // commentZ | ||
|
|
||
| import a.A | ||
|
|
||
| object InlineCommentMoves { | ||
| val keep = (null: AnyRef) | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,14 @@ | ||||||||||
| /* | ||||||||||
| rules = [OrganizeImports] | ||||||||||
| */ | ||||||||||
|
|
||||||||||
| package test.organizeImports | ||||||||||
|
|
||||||||||
| import b.B // bnote | ||||||||||
|
|
||||||||||
| import a.A // anote | ||||||||||
|
|
||||||||||
| object InlineCommentMultiple { | ||||||||||
| val keep = 1 | ||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: we can remove that if
|
||||||||||
| val keep = 1 | |
| val keep = 1 | |
| val keepA: a.A = ??? // use a.A to keep import | |
| val keepB: b.B = ??? // use b.B to keep import |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| /* | ||
| rules = [OrganizeImports] | ||
| OrganizeImports.removeUnused = true | ||
| */ | ||
|
|
||
| package test.organizeImports | ||
|
|
||
| import my.pkg.K // noteK | ||
|
|
||
| import other.P | ||
|
|
||
| object InlineCommentRemoved { | ||
| val keep: P = null.asInstanceOf[P] | ||
| } | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| /* | ||
| rules = [OrganizeImports] | ||
| */ | ||
|
|
||
| package test.organizeImports | ||
|
|
||
| // This comment is ambiguous and not linked to a specific import | ||
| import y.Y | ||
| import x.X | ||
|
|
||
| object StandaloneComment { | ||
| val keep = new X | ||
| val alsoKeep = new Y | ||
| } | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| package test.organizeImports | ||
|
|
||
| import a.A | ||
| import z.Z // commentZ | ||
|
|
||
| object InlineCommentMoves { | ||
| val keep = (null: AnyRef) | ||
| } | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| package test.organizeImports | ||
|
|
||
| import a.A // anote | ||
| import b.B // bnote | ||
| import c.C | ||
|
|
||
| object InlineCommentMultiple { | ||
| val keep = 1 | ||
| } | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| package test.organizeImports | ||
|
|
||
| import other.P | ||
|
|
||
| object InlineCommentRemoved { | ||
| val keep: P = null.asInstanceOf[P] | ||
| } | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| package test.organizeImports | ||
|
|
||
| // This comment is ambiguous and not linked to a specific import | ||
| import x.X | ||
| import y.Y | ||
|
|
||
| object StandaloneComment { | ||
| val keep = new X | ||
| val alsoKeep = new Y | ||
| } | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| package a { | ||
| class A | ||
| } | ||
|
|
||
| package b { | ||
| class B | ||
| } | ||
|
|
||
| package c { | ||
| class C | ||
| } | ||
|
|
||
| package z { | ||
| class Z | ||
| } | ||
|
|
||
| package my.pkg { | ||
| class K | ||
| } | ||
|
|
||
| package other { | ||
| class P | ||
| } | ||
|
|
||
| package x { | ||
| class X | ||
| } | ||
|
|
||
| package y { | ||
| class Y | ||
| } | ||
|
|
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 imports
z.Zanda.Aare declared but not used in the object body (onlyval keep = (null: AnyRef)is defined). Without explicitly settingremoveUnused = falsein the configuration, these imports may be removed during the test execution if unused import removal is enabled by default. Consider either:OrganizeImports.removeUnused = falseto the configuration block, orval keep: A = ???)