diff --git a/jvm/jvm-analysis-java-tests/testSrc/com/intellij/logging/resolve/JavaLoggingArgumentSymbolReferenceProviderTest.kt b/jvm/jvm-analysis-java-tests/testSrc/com/intellij/logging/resolve/JavaLoggingArgumentSymbolReferenceProviderTest.kt index 8ffcef3481af..40220f143ee7 100644 --- a/jvm/jvm-analysis-java-tests/testSrc/com/intellij/logging/resolve/JavaLoggingArgumentSymbolReferenceProviderTest.kt +++ b/jvm/jvm-analysis-java-tests/testSrc/com/intellij/logging/resolve/JavaLoggingArgumentSymbolReferenceProviderTest.kt @@ -512,6 +512,35 @@ class JavaLoggingArgumentSymbolReferenceProviderTest : LoggingArgumentSymbolRefe )) } + fun `test should not resolve with consecutive escape characters in simple string log4j2`() { + myFixture.configureByText("Logging.java", """ + import org.apache.logging.log4j.*; + class Logging { + private static final Logger LOG = LogManager.getLogger(); + void m(int i) { + LOG.info("\s\\{}", 1); + } + } + """.trimIndent()) + doTest(mapOf(TextRange(5, 7) to "1")) + } + + fun `test should not resolve with consecutive escape characters in multiline string log4j2`() { + val multilineString = "\"\"\"\n" + + "\\s\\\\{}" + + "\"\"\"" + myFixture.configureByText("Logging.java", """ + import org.apache.logging.log4j.*; + class Logging { + private static final Logger LOG = LogManager.getLogger(); + void m(int i) { + LOG.info($multilineString, 1); + } + } + """.trimIndent()) + doTest(mapOf(TextRange(8, 10) to "1")) + } + fun `test resolve with escape characters in simple string slf4j`() { myFixture.configureByText("Logging.java", """ import org.slf4j.*; @@ -557,4 +586,33 @@ class JavaLoggingArgumentSymbolReferenceProviderTest : LoggingArgumentSymbolRefe TextRange(36, 38) to "7", )) } + + fun `test should not resolve with consecutive escape characters in simple string slf4j`() { + myFixture.configureByText("Logging.java", """ + import org.slf4j.*; + class Logging { + private static final Logger LOG = LoggerFactory.getLogger(); + void m(int i) { + LOG.info("\s\\{}", 1); + } + } + """.trimIndent()) + doTest(emptyMap()) + } + + fun `test should not resolve with consecutive escape characters in multiline string slf4j`() { + val multilineString = "\"\"\"\n" + + "\\s\\\\{}" + + "\"\"\"" + myFixture.configureByText("Logging.java", """ + import org.slf4j.*; + class Logging { + private static final Logger LOG = LoggerFactory.getLogger(); + void m(int i) { + LOG.info($multilineString, 1); + } + } + """.trimIndent()) + doTest(emptyMap()) + } } \ No newline at end of file diff --git a/jvm/jvm-analysis-kotlin-tests/testSrc/com/intellij/logging/resolve/KotlinLoggingArgumentSymbolReferenceProviderTest.kt b/jvm/jvm-analysis-kotlin-tests/testSrc/com/intellij/logging/resolve/KotlinLoggingArgumentSymbolReferenceProviderTest.kt index fce8b65a840a..fa839a74b129 100644 --- a/jvm/jvm-analysis-kotlin-tests/testSrc/com/intellij/logging/resolve/KotlinLoggingArgumentSymbolReferenceProviderTest.kt +++ b/jvm/jvm-analysis-kotlin-tests/testSrc/com/intellij/logging/resolve/KotlinLoggingArgumentSymbolReferenceProviderTest.kt @@ -515,21 +515,50 @@ class KotlinLoggingArgumentSymbolReferenceProviderTest : LoggingArgumentSymbolRe class Logging { val LOG: Logger = LogManager.getLogger(Logging.class) fun m(i: Int) { - LOG.info("$multilineString", 1, 2, 3, 4, 5, 6, 7) + LOG.info($multilineString, 1, 2, 3, 4, 5, 6, 7) } } """.trimIndent()) doTest(mapOf( - TextRange(7, 9) to "1", - TextRange(12, 14) to "2", - TextRange(17, 19) to "3", - TextRange(22, 24) to "4", - TextRange(27, 29) to "5", - TextRange(32, 34) to "6", - TextRange(37, 39) to "7", + TextRange(6, 8) to "1", + TextRange(11, 13) to "2", + TextRange(16, 18) to "3", + TextRange(21, 23) to "4", + TextRange(26, 28) to "5", + TextRange(31, 33) to "6", + TextRange(36, 38) to "7", )) } + fun `test should not resolve with consecutive escape characters in simple string log4j2`() { + myFixture.configureByText("Logging.kt", """ + import org.apache.logging.log4j.* + class Logging { + val LOG: Logger = LogManager.getLogger(Logging.class) + fun m(i: Int) { + LOG.info("\s\\{}", 1) + } + } + """.trimIndent()) + doTest(mapOf(TextRange(5, 7) to "1")) + } + + fun `test should not resolve with consecutive escape characters in multiline string log4j2`() { + val multilineString = "\"\"\"\n" + + "\\s\\{}" + + "\"\"\"" + myFixture.configureByText("Logging.kt", """ + import org.apache.logging.log4j.* + class Logging { + val LOG: Logger = LogManager.getLogger(Logging.class) + fun m(i: Int) { + LOG.info($multilineString, 1) + } + } + """.trimIndent()) + doTest(mapOf(TextRange(7, 9) to "1")) + } + fun `test resolve with escape characters in simple string slf4j`() { myFixture.configureByText("Logging.kt", """ import org.slf4j.* @@ -561,18 +590,47 @@ class KotlinLoggingArgumentSymbolReferenceProviderTest : LoggingArgumentSymbolRe class Logging { val LOG: Logger = LoggerFactory.getLogger() fun m(i: Int) { - LOG.info("$multilineString", 1, 2, 3, 4, 5, 6, 7) + LOG.info($multilineString, 1, 2, 3, 4, 5, 6, 7) } } """.trimIndent()) doTest(mapOf( - TextRange(7, 9) to "1", - TextRange(12, 14) to "2", - TextRange(17, 19) to "3", - TextRange(22, 24) to "4", - TextRange(27, 29) to "5", - TextRange(32, 34) to "6", - TextRange(37, 39) to "7", + TextRange(6, 8) to "1", + TextRange(11, 13) to "2", + TextRange(16, 18) to "3", + TextRange(21, 23) to "4", + TextRange(26, 28) to "5", + TextRange(31, 33) to "6", + TextRange(36, 38) to "7", )) } + + fun `test should not resolve with consecutive escape characters in simple string slf4j`() { + myFixture.configureByText("Logging.kt", """ + import org.slf4j.* + class Logging { + val LOG: Logger = LoggerFactory.getLogger() + fun m(i: Int) { + LOG.info("\s\\{}", 1) + } + } + """.trimIndent()) + doTest(emptyMap()) + } + + fun `test should not resolve with consecutive escape characters in multiline string slf4j`() { + val multilineString = "\"\"\"\n" + + "\\s\\{}" + + "\"\"\"" + myFixture.configureByText("Logging.kt", """ + import org.slf4j.* + class Logging { + val LOG: Logger = LoggerFactory.getLogger() + fun m(i: Int) { + LOG.info($multilineString, 1) + } + } + """.trimIndent()) + doTest(emptyMap()) + } } \ No newline at end of file