diff --git a/scalafix-tests/input/src/main/scala/test/organizeImports/InlineCommentMoves.scala b/scalafix-tests/input/src/main/scala/test/organizeImports/InlineCommentMoves.scala new file mode 100644 index 000000000..ab3e4c392 --- /dev/null +++ b/scalafix-tests/input/src/main/scala/test/organizeImports/InlineCommentMoves.scala @@ -0,0 +1,14 @@ +/* +rules = [OrganizeImports] + */ + +package test.organizeImports + +import z.Z // commentZ + +import a.A + +object InlineCommentMoves { + val keep = (null: AnyRef) +} + diff --git a/scalafix-tests/input/src/main/scala/test/organizeImports/InlineCommentMultiple.scala b/scalafix-tests/input/src/main/scala/test/organizeImports/InlineCommentMultiple.scala new file mode 100644 index 000000000..3a04572f4 --- /dev/null +++ b/scalafix-tests/input/src/main/scala/test/organizeImports/InlineCommentMultiple.scala @@ -0,0 +1,14 @@ +/* +rules = [OrganizeImports] + */ + +package test.organizeImports + +import b.B // bnote + +import a.A // anote + +object InlineCommentMultiple { + val keep = 1 +} + diff --git a/scalafix-tests/input/src/main/scala/test/organizeImports/InlineCommentRemoved.scala b/scalafix-tests/input/src/main/scala/test/organizeImports/InlineCommentRemoved.scala new file mode 100644 index 000000000..c48c6ca0d --- /dev/null +++ b/scalafix-tests/input/src/main/scala/test/organizeImports/InlineCommentRemoved.scala @@ -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] +} + diff --git a/scalafix-tests/input/src/main/scala/test/organizeImports/StandaloneComment.scala b/scalafix-tests/input/src/main/scala/test/organizeImports/StandaloneComment.scala new file mode 100644 index 000000000..b2299c87e --- /dev/null +++ b/scalafix-tests/input/src/main/scala/test/organizeImports/StandaloneComment.scala @@ -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 +} + diff --git a/scalafix-tests/output/src/main/scala/test/organizeImports/InlineCommentMoves.scala b/scalafix-tests/output/src/main/scala/test/organizeImports/InlineCommentMoves.scala new file mode 100644 index 000000000..07bd8990a --- /dev/null +++ b/scalafix-tests/output/src/main/scala/test/organizeImports/InlineCommentMoves.scala @@ -0,0 +1,9 @@ +package test.organizeImports + +import a.A +import z.Z // commentZ + +object InlineCommentMoves { + val keep = (null: AnyRef) +} + diff --git a/scalafix-tests/output/src/main/scala/test/organizeImports/InlineCommentMultiple.scala b/scalafix-tests/output/src/main/scala/test/organizeImports/InlineCommentMultiple.scala new file mode 100644 index 000000000..59504d67b --- /dev/null +++ b/scalafix-tests/output/src/main/scala/test/organizeImports/InlineCommentMultiple.scala @@ -0,0 +1,10 @@ +package test.organizeImports + +import a.A // anote +import b.B // bnote +import c.C + +object InlineCommentMultiple { + val keep = 1 +} + diff --git a/scalafix-tests/output/src/main/scala/test/organizeImports/InlineCommentRemoved.scala b/scalafix-tests/output/src/main/scala/test/organizeImports/InlineCommentRemoved.scala new file mode 100644 index 000000000..d04fb09a4 --- /dev/null +++ b/scalafix-tests/output/src/main/scala/test/organizeImports/InlineCommentRemoved.scala @@ -0,0 +1,8 @@ +package test.organizeImports + +import other.P + +object InlineCommentRemoved { + val keep: P = null.asInstanceOf[P] +} + diff --git a/scalafix-tests/output/src/main/scala/test/organizeImports/StandaloneComment.scala b/scalafix-tests/output/src/main/scala/test/organizeImports/StandaloneComment.scala new file mode 100644 index 000000000..bf608a756 --- /dev/null +++ b/scalafix-tests/output/src/main/scala/test/organizeImports/StandaloneComment.scala @@ -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 +} + diff --git a/scalafix-tests/shared/src/main/scala/test/organizeImports/InlineCommentFixtures.scala b/scalafix-tests/shared/src/main/scala/test/organizeImports/InlineCommentFixtures.scala new file mode 100644 index 000000000..1554f57f4 --- /dev/null +++ b/scalafix-tests/shared/src/main/scala/test/organizeImports/InlineCommentFixtures.scala @@ -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 +} +