[uast-inspection] IDEA-350483 New inspection LoggingGuardedByConditionInspection also deletes comments

- support comments

GitOrigin-RevId: b5add2dcbe56eaca7d8c90319734bacda3e68923
This commit is contained in:
Mikhail Pyltsin
2024-04-02 14:45:13 +02:00
committed by intellij-monorepo-bot
parent 992e3b7bdc
commit e84bc31482
3 changed files with 121 additions and 1 deletions

View File

@@ -188,4 +188,43 @@ class JavaLoggingGuardedByConditionInspectionTest : LoggingGuardedByConditionIns
hint = JvmAnalysisBundle.message("jvm.inspection.log.guarded.fix.family.name")
)
}
fun `test slf4j with comment fix`() {
myFixture.testQuickFix(
testPreview = true,
lang = JvmLanguage.JAVA,
before = """
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
class X {
private static final Logger LOG = LoggerFactory.getLogger(X.class);
void n(String arg) {
if(<caret>LOG.isDebugEnabled()) {//comment1
//comment2
LOG.debug("test" + arg);
//comment3
//comment4
}
}
}
""".trimIndent(),
after = """
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
class X {
private static final Logger LOG = LoggerFactory.getLogger(X.class);
void n(String arg) {
//comment1
//comment2
LOG.debug("test" + arg);
//comment3
//comment4
}
}
""".trimIndent(),
hint = JvmAnalysisBundle.message("jvm.inspection.log.guarded.fix.family.name")
)
}
}