[Java. Logging] add tests for logging reference resolver

IDEA-357019

GitOrigin-RevId: 2882457613a0c5d0bc55fc2e483de2a27af6df5c
This commit is contained in:
Georgii Ustinov
2024-09-09 11:09:24 +03:00
committed by intellij-monorepo-bot
parent 1226a355c3
commit bc8f0bf7c5
2 changed files with 121 additions and 0 deletions

View File

@@ -615,4 +615,52 @@ class JavaLoggingArgumentSymbolReferenceProviderTest : LoggingArgumentSymbolRefe
""".trimIndent())
doTest(emptyMap())
}
fun `test lazy init in init block`() {
myFixture.configureByText("Logging.java", """
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
class StaticInitializer {
private static final Logger log;
static {
log = LogManager.getLogger();
}
public StaticInitializer() {
log.info("{<caret>} {}", 1, 2);
}
}
""".trimIndent())
doTest(mapOf(
TextRange(1, 3) to "1",
TextRange(4, 6) to "2",))
}
fun `test lazy init in constructors`() {
myFixture.configureByText("Logging.java", """
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
class ConstructorInitializer {
private final Logger log;
public ConstructorInitializer() {
log = LogManager.getLogger();
}
public ConstructorInitializer(int i) {
log = LogManager.getLogger();
}
public void test() {
log.info("{<caret>} {}", 1, 2);
}
}
""".trimIndent())
doTest(mapOf(
TextRange(1, 3) to "1",
TextRange(4, 6) to "2",))
}
}