mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[Java. Logging] Disable completion on reference expressions for logger
IDEA-359882 GitOrigin-RevId: f5550041a59d0b89cf1b18a3ccd8104eed0fb240
This commit is contained in:
committed by
intellij-monorepo-bot
parent
dcb5bc120c
commit
3f4982e47d
+7
-3
@@ -4,7 +4,7 @@ package com.intellij.codeInsight.completion
|
||||
import com.intellij.lang.logging.JvmLogger
|
||||
import com.intellij.openapi.module.ModuleUtil
|
||||
import com.intellij.patterns.PlatformPatterns.psiElement
|
||||
import com.intellij.patterns.StandardPatterns
|
||||
import com.intellij.psi.PsiExpression
|
||||
import com.intellij.psi.PsiReferenceExpression
|
||||
import com.intellij.util.ProcessingContext
|
||||
import com.siyeh.ig.psiutils.ExpressionUtils
|
||||
@@ -12,8 +12,8 @@ import com.siyeh.ig.psiutils.ExpressionUtils
|
||||
class JvmLoggerCompletionContributor : CompletionContributor() {
|
||||
init {
|
||||
extend(CompletionType.BASIC,
|
||||
StandardPatterns.or(
|
||||
psiElement().withParent(PsiReferenceExpression::class.java)),
|
||||
psiElement().withParent(PsiReferenceExpression::class.java).andNot(
|
||||
psiElement().withParent(psiElement(PsiReferenceExpression::class.java).withChild(psiElement(PsiExpression::class.java)))),
|
||||
object : CompletionProvider<CompletionParameters>() {
|
||||
override fun addCompletions(parameters: CompletionParameters, context: ProcessingContext, result: CompletionResultSet) {
|
||||
val parent = parameters.position.parent ?: return
|
||||
@@ -38,4 +38,8 @@ class JvmLoggerCompletionContributor : CompletionContributor() {
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
override fun fillCompletionVariants(parameters: CompletionParameters, result: CompletionResultSet) {
|
||||
super.fillCompletionVariants(parameters, result)
|
||||
}
|
||||
}
|
||||
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
public class A {
|
||||
static void f() {
|
||||
A a = new A().lo<caret>;
|
||||
}
|
||||
|
||||
A logMethod() {
|
||||
return null;
|
||||
}
|
||||
|
||||
A anotherLogMethod() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
public class A {
|
||||
static void logMethod() {
|
||||
A.lo<caret>
|
||||
}
|
||||
|
||||
static void anotherLogMethod() {}
|
||||
}
|
||||
+12
@@ -195,6 +195,18 @@ class LoggerCompletionTest : LightFixtureCompletionTestCase() {
|
||||
doTest(1, "long", "log", "clone")
|
||||
}
|
||||
|
||||
@NeedsIndex.SmartMode(reason = SMART_MODE_REASON_MESSAGE)
|
||||
fun testNoAutoCompletionAfterReferenceExpression() {
|
||||
JvmLoggerTestSetupUtil.setupSlf4j(myFixture)
|
||||
doAntiTest("logMethod", "anotherLogMethod")
|
||||
}
|
||||
|
||||
@NeedsIndex.SmartMode(reason = SMART_MODE_REASON_MESSAGE)
|
||||
fun testNoAutoCompletionAfterNewExpression() {
|
||||
JvmLoggerTestSetupUtil.setupSlf4j(myFixture)
|
||||
doAntiTest("logMethod", "anotherLogMethod", "clone")
|
||||
}
|
||||
|
||||
override fun getBasePath() = JavaTestUtil.getRelativeJavaTestDataPath() + "/codeInsight/completion/logger"
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user