diff --git a/.circleci/config.yml b/.circleci/config.yml index 5b36e313fc8..8972769354d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -29,7 +29,6 @@ commands: - save_cache: key: gradle-dependencies-{{ checksum "build.gradle.kts" }} paths: - - ~/rewrite/rewrite-java-8/.tools/ - ~/.gradle - run: name: run gradle command diff --git a/rewrite-java/src/main/java/org/openrewrite/java/OrderImports.java b/rewrite-java/src/main/java/org/openrewrite/java/OrderImports.java index 50311d72c42..a997b07656c 100644 --- a/rewrite-java/src/main/java/org/openrewrite/java/OrderImports.java +++ b/rewrite-java/src/main/java/org/openrewrite/java/OrderImports.java @@ -206,6 +206,7 @@ public ImportPackage(boolean statik, String packageWildcard, boolean withSubpack this.classCountToUseStarImport = classCountToUseStarImport; this.nameCountToUseStarImport = nameCountToUseStarImport; this.packageWildcard = Pattern.compile(packageWildcard + .replace(".", "\\.") .replace("*", withSubpackages ? ".+" : "[^.]+")); } diff --git a/rewrite-test/src/main/kotlin/org/openrewrite/java/OrderImportTest.kt b/rewrite-test/src/main/kotlin/org/openrewrite/java/OrderImportTest.kt index 75c10d9277c..5a959a446d2 100644 --- a/rewrite-test/src/main/kotlin/org/openrewrite/java/OrderImportTest.kt +++ b/rewrite-test/src/main/kotlin/org/openrewrite/java/OrderImportTest.kt @@ -229,4 +229,23 @@ interface OrderImportTest { } """.trimIndent()) } + + @Test + fun packagePatternEscapesDots(jp: JavaParser) { + val a = jp.parse(""" + import javax.annotation.Nonnull; + + public class A {} + """.trimIndent()) + + val fixed = a.refactor().visit(OrderImports.intellij().apply { + setRemoveUnused(false) + }).fix().fixed + + assertRefactored(fixed, """ + import javax.annotation.Nonnull; + + public class A {} + """.trimIndent()) + } } \ No newline at end of file