[java-inspections] IDEA-337706 Support conversion System.out to log calls

- fix lombok test

GitOrigin-RevId: 09fc8a64fab84df1c3aa661f2107bb451b447420
This commit is contained in:
Mikhail Pyltsin
2024-04-03 11:12:36 +02:00
committed by intellij-monorepo-bot
parent 77cac2bb83
commit 0f3e50ed04
7 changed files with 19 additions and 9 deletions

View File

@@ -11,6 +11,7 @@ import com.intellij.psi.util.parentOfType
class JvmLoggerLookupElement(private val logger: JvmLogger, private val place: PsiClass) : LookupElement(), JavaCompletionStatistician.CustomStatisticsInfoProvider {
val typeName: String = logger.loggerTypeName
val typeId: String = logger.id
override fun getLookupString(): String {
return logger.getLogFieldName(place) ?: JvmLoggerFieldDelegate.LOGGER_IDENTIFIER

View File

@@ -3,9 +3,10 @@ package de.plushnikov.intellij.plugin.logging
import com.intellij.lang.logging.JvmLogger
import com.siyeh.ig.psiutils.JavaLoggingUtils
class LombokApacheCommonsLogger : JvmLogger by JvmLoggerAnnotationDelegate(
JavaLoggingUtils.COMMONS_LOGGING,
"Lombok Apache Commons Logging",
LombokLoggingUtils.ID_LOMBOK_APACHE_COMMONS_LOGGING,
LombokLoggingUtils.COMMONS_ANNOTATION,
500
) {

View File

@@ -3,9 +3,10 @@ package de.plushnikov.intellij.plugin.logging
import com.intellij.lang.logging.JvmLogger
import com.siyeh.ig.psiutils.JavaLoggingUtils
class LombokLog4j2Logger : JvmLogger by JvmLoggerAnnotationDelegate(
JavaLoggingUtils.LOG4J2,
"Lombok Log4j2",
LombokLoggingUtils.ID_LOMBOK_LOG_4_J_2,
LombokLoggingUtils.LOG4J2_ANNOTATION,
600
) {

View File

@@ -3,9 +3,10 @@ package de.plushnikov.intellij.plugin.logging
import com.intellij.lang.logging.JvmLogger
import com.siyeh.ig.psiutils.JavaLoggingUtils
class LombokLog4jLogger : JvmLogger by JvmLoggerAnnotationDelegate(
JavaLoggingUtils.LOG4J,
"Lombok Log4j",
LombokLoggingUtils.ID_LOMBOK_LOG_4_J,
LombokLoggingUtils.LOG4J_ANNOTATION,
400
) {

View File

@@ -5,4 +5,9 @@ object LombokLoggingUtils {
const val LOG4J2_ANNOTATION = "lombok.extern.log4j.Log4j2"
const val LOG4J_ANNOTATION = "lombok.extern.log4j.Log4j"
const val COMMONS_ANNOTATION = "lombok.extern.apachecommons.CommonsLog"
const val ID_LOMBOK_APACHE_COMMONS_LOGGING = "Lombok Apache Commons Logging"
const val ID_LOMBOK_SLF_4_J = "Lombok Slf4j"
const val ID_LOMBOK_LOG_4_J_2 = "Lombok Log4j2"
const val ID_LOMBOK_LOG_4_J = "Lombok Log4j"
}

View File

@@ -3,9 +3,10 @@ package de.plushnikov.intellij.plugin.logging
import com.intellij.lang.logging.JvmLogger
import com.siyeh.ig.psiutils.JavaLoggingUtils
class LombokSlf4jLogger : JvmLogger by JvmLoggerAnnotationDelegate(
JavaLoggingUtils.SLF4J,
"Lombok Slf4j",
LombokLoggingUtils.ID_LOMBOK_SLF_4_J,
LombokLoggingUtils.SLF4J_ANNOTATION,
700
) {

View File

@@ -15,28 +15,28 @@ class LombokLoggerCompletionTest : LightFixtureCompletionTestCase() {
fun testSlf4j() {
JvmLoggerTestSetupUtil.setupSlf4j(myFixture)
doTest(LombokLoggingUtils.SLF4J_ANNOTATION, "long", "log", "log", "clone")
doTest(LombokLoggingUtils.ID_LOMBOK_SLF_4_J, "long", "log", "log", "clone")
}
@NeedsIndex.SmartMode(reason = "Logger completion is not supported in the dumb mode")
fun testLog4j2() {
JvmLoggerTestSetupUtil.setupLog4j2(myFixture)
doTest(LombokLoggingUtils.LOG4J2_ANNOTATION, "long", "log", "log", "clone")
doTest(LombokLoggingUtils.ID_LOMBOK_LOG_4_J_2, "long", "log", "log", "clone")
}
@NeedsIndex.SmartMode(reason = "Logger completion is not supported in the dumb mode")
fun testLog4j() {
JvmLoggerTestSetupUtil.setupLog4j(myFixture)
doTest(LombokLoggingUtils.LOG4J_ANNOTATION, "long", "log", "log", "clone")
doTest(LombokLoggingUtils.ID_LOMBOK_LOG_4_J, "long", "log", "log", "clone")
}
@NeedsIndex.SmartMode(reason = "Logger completion is not supported in the dumb mode")
fun testApacheCommons() {
JvmLoggerTestSetupUtil.setupApacheCommons(myFixture)
doTest(LombokLoggingUtils.COMMONS_ANNOTATION, "long", "log", "log", "clone")
doTest(LombokLoggingUtils.ID_LOMBOK_APACHE_COMMONS_LOGGING, "long", "log", "log", "clone")
}
override fun getBasePath(): String = "community/plugins/lombok/testData/completion/logger"
@@ -48,7 +48,7 @@ class LombokLoggerCompletionTest : LightFixtureCompletionTestCase() {
configureByFile("before$name.java")
assertStringItems(*names)
val item = lookup.items.find { it is JvmLoggerLookupElement && it.typeName == typeName }
val item = lookup.items.find { it is JvmLoggerLookupElement && it.typeId == typeName }
TestCase.assertNotNull(item)
selectItem(item)
checkResultByFile("after$name.java")