mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-13 06:59:44 +07:00
[Java. Logging] add tests for logging reference resolver
IDEA-357019 GitOrigin-RevId: 2882457613a0c5d0bc55fc2e483de2a27af6df5c
This commit is contained in:
committed by
intellij-monorepo-bot
parent
1226a355c3
commit
bc8f0bf7c5
@@ -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",))
|
||||
}
|
||||
}
|
||||
@@ -634,4 +634,77 @@ abstract class KotlinLoggingArgumentSymbolReferenceProviderTest : LoggingArgumen
|
||||
""".trimIndent())
|
||||
doTest(emptyMap())
|
||||
}
|
||||
|
||||
fun `test lazy init in init block`() {
|
||||
myFixture.configureByText("Logging.kt", """
|
||||
import org.apache.logging.log4j.LogManager
|
||||
import org.apache.logging.log4j.Logger
|
||||
|
||||
class Initialization {
|
||||
init {
|
||||
log.debug("{<caret>}", 1)
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val log : Logger
|
||||
init {
|
||||
log = LogManager.getLogger()
|
||||
}
|
||||
}
|
||||
}
|
||||
""".trimIndent())
|
||||
doTest(mapOf(TextRange(1, 3) to "1"))
|
||||
}
|
||||
|
||||
fun `test lazy init in init block with condition`() {
|
||||
myFixture.configureByText("Logging.kt", """
|
||||
import org.apache.logging.log4j.LogManager
|
||||
import org.apache.logging.log4j.Logger
|
||||
|
||||
class StaticInitializerBuilder2 {
|
||||
init {
|
||||
log.log("{<caret>}", 1)
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val log: LogBuilder
|
||||
|
||||
init {
|
||||
if (1 == 1) {
|
||||
log = LogManager.getLogger().atDebug()
|
||||
} else {
|
||||
log = LogManager.getFormatterLogger().atDebug()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
""".trimIndent())
|
||||
doTest(emptyMap())
|
||||
}
|
||||
|
||||
fun `test lazy init in constructors`() {
|
||||
myFixture.configureByText("Logging.kt", """
|
||||
import org.apache.logging.log4j.LogManager
|
||||
import org.apache.logging.log4j.Logger
|
||||
|
||||
internal class ConstructorInitializer {
|
||||
private val log: Logger
|
||||
|
||||
constructor() {
|
||||
log = LogManager.getLogger()
|
||||
}
|
||||
|
||||
constructor(i) {
|
||||
log = LogManager.getLogger()
|
||||
}
|
||||
|
||||
fun test() {
|
||||
log.info("{<caret>} {}", 1, 2)
|
||||
}
|
||||
}
|
||||
""".trimIndent())
|
||||
doTest(mapOf(
|
||||
TextRange(1, 3) to "1",
|
||||
TextRange(4, 6) to "2",))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user