diff options
author | Matthew Gharrity <gharrma@google.com> | 2021-10-20 19:04:25 -0400 |
---|---|---|
committer | Matthew Gharrity <gharrma@google.com> | 2021-10-21 16:07:50 +0000 |
commit | 1eda687ec0345d14550edb8d5bb25270dab1e91c (patch) | |
tree | 6713392bc8f0e7b092b94d1dbef49494de29fc3d /lint/src | |
parent | 0c748c6b6702487ebf3903311f7552387ba6ef89 (diff) | |
download | idea-1eda687ec0345d14550edb8d5bb25270dab1e91c.tar.gz |
LintIdeSupport: use service instead of EP
...and fix 'cyclic extension initialization' which was caused by
querying the extension point in the static initializer of the
extension base class.
This is a recapitulation of commit e42c03d2 from JetBrains.
Test: AndroidLintTest
Change-Id: Iebb37a7f2718daee30e748d035f5a1e5b400863b
Diffstat (limited to 'lint/src')
-rw-r--r-- | lint/src/com/android/tools/idea/lint/common/LintIdeSupport.kt | 17 |
1 files changed, 3 insertions, 14 deletions
diff --git a/lint/src/com/android/tools/idea/lint/common/LintIdeSupport.kt b/lint/src/com/android/tools/idea/lint/common/LintIdeSupport.kt index d5219cb89fa..3e699e721cd 100644 --- a/lint/src/com/android/tools/idea/lint/common/LintIdeSupport.kt +++ b/lint/src/com/android/tools/idea/lint/common/LintIdeSupport.kt @@ -30,7 +30,7 @@ import com.intellij.codeInspection.LocalQuickFix import com.intellij.ide.highlighter.JavaFileType import com.intellij.ide.highlighter.XmlFileType import com.intellij.lang.properties.PropertiesFileType -import com.intellij.openapi.extensions.ExtensionPointName +import com.intellij.openapi.application.ApplicationManager.getApplication import com.intellij.openapi.fileTypes.FileTypes import com.intellij.openapi.module.Module import com.intellij.openapi.project.Project @@ -53,20 +53,9 @@ abstract class LintIdeSupport { LintClient.clientName = CLIENT_STUDIO } companion object { - private val EP_NAME = ExtensionPointName.create<LintIdeSupport>("com.android.tools.idea.lint.common.lintIdeSupport") - - private val INSTANCE: LintIdeSupport // these are all stateless - init { - val extensions = EP_NAME.extensions - when (extensions.size) { - 1 -> INSTANCE = extensions[0] - 0 -> INSTANCE = object : LintIdeSupport() { } - else -> error("Multiple lint customizer extensions found: ${extensions.toList()}") - } - } - @JvmStatic - fun get(): LintIdeSupport = INSTANCE + fun get(): LintIdeSupport = getApplication().getService(LintIdeSupport::class.java) + ?: object : LintIdeSupport() {} } open fun getIssueRegistry(): IssueRegistry = LintIdeIssueRegistry() |