IDEA-CR-62942: FUS-661 Make it possible to filter spellchecker from completion quality logs

GitOrigin-RevId: 0aea45d0f6470426a8050413f54353815bc35ae9
This commit is contained in:
Olga Strizhenko
2020-05-29 12:18:44 +03:00
committed by intellij-monorepo-bot
parent 71cd340039
commit 449375385c
3 changed files with 32 additions and 1 deletions
@@ -33,5 +33,6 @@
<applicationService serviceImplementation="com.intellij.spellchecker.state.CachedDictionaryState"/>
<statistics.projectUsagesCollector implementation="com.intellij.spellchecker.statistics.SpellcheckerConfigCollector"/>
<notificationWhitelist groupIds="Spell Checker Dictionary;Spellchecker"/>
<lookup.usageDetails implementation="com.intellij.spellchecker.statistics.SpellcheckerLookupUsageDescriptor"/>
</extensions>
</idea-plugin>
@@ -4,6 +4,7 @@ package com.intellij.spellchecker.quickfixes;
import com.intellij.codeInsight.lookup.LookupElement;
import com.intellij.codeInsight.lookup.LookupElementBuilder;
import com.intellij.codeInsight.lookup.LookupManager;
import com.intellij.codeInsight.lookup.impl.LookupImpl;
import com.intellij.codeInspection.ProblemDescriptor;
import com.intellij.codeInspection.ProblemDescriptorBase;
import com.intellij.ide.DataManager;
@@ -17,6 +18,7 @@ import com.intellij.openapi.util.TextRange;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.PsiElement;
import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil;
import com.intellij.spellchecker.statistics.SpellcheckerLookupUsageDescriptor;
import com.intellij.spellchecker.util.SpellCheckerBundle;
import org.jetbrains.annotations.NotNull;
@@ -67,7 +69,10 @@ public class ChangeTo extends ShowSuggestions implements SpellCheckerQuickFix {
.stream()
.map(LookupElementBuilder::create)
.toArray(LookupElement[]::new);
LookupManager.getInstance(project).showLookup(editor, items);
final LookupImpl lookup = (LookupImpl)LookupManager.getInstance(project).showLookup(editor, items);
if (lookup != null) {
lookup.putUserDataIfAbsent(SpellcheckerLookupUsageDescriptor.Companion.getSPELLCHECKER_KEY(), true);
}
});
}
@@ -0,0 +1,25 @@
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.spellchecker.statistics
import com.intellij.codeInsight.lookup.Lookup
import com.intellij.codeInsight.lookup.impl.LookupImpl
import com.intellij.codeInsight.lookup.impl.LookupUsageDescriptor
import com.intellij.internal.statistic.eventLog.FeatureUsageData
import com.intellij.openapi.util.Key
class SpellcheckerLookupUsageDescriptor : LookupUsageDescriptor {
companion object {
private const val SPELLCHECKER = "spellchecker"
val SPELLCHECKER_KEY = Key<Boolean>(SPELLCHECKER)
}
override fun getExtensionKey(): String = SPELLCHECKER
override fun fillUsageData(lookup: Lookup, usageData: FeatureUsageData) {
if (lookup is LookupImpl && lookup.getUserData(SPELLCHECKER_KEY) == true) {
usageData.apply {
addData(SPELLCHECKER, true)
}
}
}
}