[Java. Logging] Properly handling with logging placeholders resolve with backslash character

IDEA-342484

GitOrigin-RevId: 70cbc9a537943dd3520282206ef8ddb20f01ad5f
This commit is contained in:
Georgii Ustinov
2024-04-22 13:07:17 +03:00
committed by intellij-monorepo-bot
parent 44598e3b3b
commit c25c1ba670
5 changed files with 161 additions and 9 deletions

View File

@@ -464,4 +464,64 @@ class JavaLoggingArgumentSymbolReferenceProviderTest : LoggingArgumentSymbolRefe
""".trimIndent())
doTest(emptyMap())
}
fun `test should resolve with escape character 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("\\{<caret>}", i);
}
}
""".trimIndent())
doTest(mapOf(TextRange(3, 5) to "i"))
}
fun `test should resolve with escape character in multiline string log4j2`() {
val multilineString = "\"\"\"\n" +
"\\\\{<caret>}" +
"\"\"\""
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, i);
}
}
""".trimIndent())
doTest(mapOf(TextRange(6, 8) to "i"))
}
fun `test should not resolve with escape character in simple string slf4j`() {
myFixture.configureByText("Logging.java", """
import org.slf4j.*;
class Logging {
private static final Logger LOG = LoggerFactory.getLogger(Logging.class);
void m(int i) {
LOG.info("\\{<caret>}", i);
}
}
""".trimIndent())
doTest(emptyMap())
}
fun `test should not resolve with escape character in multiline string slf4j`() {
val multilineString = "\"\"\"\n" +
"\\\\{<caret>}" +
"\"\"\""
myFixture.configureByText("Logging.java", """
import org.slf4j.*;
class Logging {
private static final Logger LOG = LoggerFactory.getLogger(Logging.class);
void m(int i) {
LOG.info($multilineString, i);
}
}
""".trimIndent())
doTest(emptyMap())
}
}