From aec2d04db5e54c2b97348de010b8805f536b3f18 Mon Sep 17 00:00:00 2001 From: Mikhail Pyltsin Date: Thu, 6 Apr 2023 12:18:52 +0200 Subject: [PATCH] [java-inspections] IDEA-316635 Convert PlaceholderCountMatchesArgumentCountInspection to UAST inspection. Improve test GitOrigin-RevId: c5a8123c52ada1b70d68c4244e737f500646cb8c --- ...CountMatchesArgumentCountInspectionTest.kt | 24 ++++++++++++------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/jvm/jvm-analysis-kotlin-tests/testSrc/com/intellij/codeInspection/tests/kotlin/logging/KotlinLoggingPlaceholderCountMatchesArgumentCountInspectionTest.kt b/jvm/jvm-analysis-kotlin-tests/testSrc/com/intellij/codeInspection/tests/kotlin/logging/KotlinLoggingPlaceholderCountMatchesArgumentCountInspectionTest.kt index ecf64339346e..ad7bff23edef 100644 --- a/jvm/jvm-analysis-kotlin-tests/testSrc/com/intellij/codeInspection/tests/kotlin/logging/KotlinLoggingPlaceholderCountMatchesArgumentCountInspectionTest.kt +++ b/jvm/jvm-analysis-kotlin-tests/testSrc/com/intellij/codeInspection/tests/kotlin/logging/KotlinLoggingPlaceholderCountMatchesArgumentCountInspectionTest.kt @@ -424,12 +424,18 @@ class KotlinLoggingPlaceholderCountMatchesArgumentCountInspectionTest { internal class X { - fun foo() { - val logger = LoggerFactory.getLogger() - logger.info( "string {} {}" , 1, RuntimeException()) - logger.atError().log( "{}" , RuntimeException("test")) - LoggerFactory.getLogger().atError().log( "{} {}" , 1, RuntimeException("test")) - LoggerFactory.getLogger().atError().log("{}", 1, RuntimeException("test")) + fun foo(s: String) { + val logger = LoggerFactory.getLogger() + logger.info( "string {} {}" , 1, RuntimeException()) + logger.info(s + "string {} {}" , 1, RuntimeException()) + logger.info(s + "string {} {}" , 1, 2) + logger.atError().log( "{}" , RuntimeException("test")) + LoggerFactory.getLogger().atError().log( "{} {}" , 1, RuntimeException("test")) + LoggerFactory.getLogger().atError().log("{}", 1, RuntimeException("test")) + LoggerFactory.getLogger().atError().log(s + "{}", 1, RuntimeException("test")) + LoggerFactory.getLogger().atError().log(s + "{}", 1, 2) + LoggerFactory.getLogger().atError().log("", 1, RuntimeException("test")) + LoggerFactory.getLogger().atError().log(s + "{} {} {}", 1, RuntimeException("test")) } } """.trimIndent().commentsToWarn()) @@ -509,7 +515,7 @@ class KotlinLoggingPlaceholderCountMatchesArgumentCountInspectionTest { myFixture.testHighlighting(JvmLanguage.KOTLIN, """ import org.slf4j.LoggerFactory import java.util.* - + internal class X { var logger = LoggerFactory.getLogger() fun m(t: String) { @@ -530,14 +536,14 @@ class KotlinLoggingPlaceholderCountMatchesArgumentCountInspectionTest { temp = "{}${'$'}t" logger.info(temp, 1) } - + fun m(i: Int, s: String) { logger.info( "test1 {}" ) logger.info( "test1 {}${'$'}s" ) logger.info( "test1 {}${'$'}i" ) } - + companion object { private val logText = "{} {}" + something private val logText2 = "{} {}" + 1 + "{}" + something