ML4SE-698 Implement features in plugin

- Added new plugin to collect initial data for future Federated Compute model
- Based on https://jetbrains.team/p/ij/reviews/133737/timeline

Merge-request: IJ-MR-135570
Merged-by: Iurii Akatov <Iurii.Akatov@jetbrains.com>

GitOrigin-RevId: b2bff07b4abcf82198564707809cb56379d0084f
This commit is contained in:
Iurii Akatov
2024-06-07 20:21:29 +00:00
committed by intellij-monorepo-bot
parent cc2e5564bc
commit c06a2a961f
10 changed files with 62 additions and 13 deletions

View File

@@ -910,6 +910,8 @@ advanced.setting.search.everywhere.wait.for.contributors.description=Enabling th
advanced.setting.search.everywhere.contributors.wait.timeout=Contributors waiting timeout (ms)
advanced.setting.search.everywhere.recent.at.top=Show recent files at the top of results list
advanced.setting.search.everywhere.recent.at.top.description=When enabled, recent files are always displayed at the top of the results list. Therefore, even if these files match the search pattern less precisely than other results, they will remain at the top.
advanced.setting.search.everywhere.send.search.history.statistics=Contribute anonymous data for Federated Compute project research
advanced.setting.search.everywhere.send.search.history.statistics.description=By enabling this option, you, as a JetBrains employee, agree to provide anonymous data for research in the Federated Compute project. This process will only involve JetBrains employees from the @jetbrains.com domain. Please note that this data will be used responsibly for enhancing the system and overall user experience.
advanced.setting.floating.codeToolbar.hide=Hide floating toolbar for code editing
group.advanced.settings.other=Other
group.advanced.settings.ide=IDE

View File

@@ -54,7 +54,8 @@ interface SearchEverywhereMlService {
fun onItemSelected(project: Project?, tabId: String,
indexes: IntArray, selectedItems: List<Any>,
elementsProvider: () -> List<SearchEverywhereFoundElementInfo>,
closePopup: Boolean)
closePopup: Boolean,
query: String)
fun onSearchFinished(project: Project?, elementsProvider: () -> List<SearchEverywhereFoundElementInfo>)

View File

@@ -1334,7 +1334,7 @@ public final class SearchEverywhereUI extends BigPopupUI implements DataProvider
if (myMlService != null) {
var tabId = myHeader.getSelectedTab().getID();
myMlService.onItemSelected(myProject, tabId, indexes, selectedItems, () -> myListModel.getFoundElementsInfo(), closePopup);
myMlService.onItemSelected(myProject, tabId, indexes, selectedItems, () -> myListModel.getFoundElementsInfo(), closePopup, searchText);
}
if (closePopup) {

View File

@@ -29,6 +29,7 @@ import com.intellij.internal.statistic.eventLog.events.ObjectEventData as IJObje
import com.intellij.internal.statistic.eventLog.events.ObjectEventField as IJObjectEventField
import com.intellij.internal.statistic.eventLog.events.ObjectListEventField as IJObjectListEventField
import com.intellij.internal.statistic.eventLog.events.StringEventField as IJStringEventField
import com.intellij.platform.ml.impl.logs.CustomEventField as MLCustomEventField
import com.intellij.platform.ml.impl.logs.LanguageEventField as MLLanguageEventField
import com.intellij.platform.ml.impl.logs.VersionEventField as MLVersionEventField
import com.intellij.platform.ml.logs.schema.BooleanEventField as MLBooleanEventField
@@ -68,7 +69,11 @@ class ComponentAsFusEventRegister(private val baseEventGroup: IJEventLogGroup) :
@Suppress("UNCHECKED_CAST")
private fun <L> createConverter(mlEventField: MLEventField<L>): IJEventPairConverter<L, *> = when (mlEventField) {
is MLObjectEventField -> ConverterOfObject(mlEventField.name, mlEventField.description, mlEventField.objectDescription) as IJEventPairConverter<L, *>
is MLObjectEventField -> ConverterOfObject(
mlEventField.name,
mlEventField.description,
mlEventField.objectDescription
) as IJEventPairConverter<L, *>
is MLBooleanEventField -> ConverterOfPrimitiveType(mlEventField) { n, d -> IJBooleanEventField(n, d) } as IJEventPairConverter<L, *>
is MLIntEventField -> ConverterOfPrimitiveType(mlEventField) { n, d -> IJIntEventField(n, d) } as IJEventPairConverter<L, *>
is MLLongEventField -> ConverterOfPrimitiveType(mlEventField) { n, d -> IJLongEventField(n, d) } as IJEventPairConverter<L, *>
@@ -80,11 +85,38 @@ private fun <L> createConverter(mlEventField: MLEventField<L>): IJEventPairConve
is MLVersionEventField -> ConverterOfVersion(mlEventField) as IJEventPairConverter<L, *>
is MLLanguageEventField -> ConverterOfLanguage(mlEventField) as IJEventPairConverter<L, *>
is MLStringEventField -> ConverterOfString(mlEventField) as IJEventPairConverter<L, *>
else -> throw NotImplementedError("Implement converter for the ${mlEventField.javaClass.simpleName}")
is IJSpecificEventField<*> -> {
when (mlEventField) {
is MLCustomEventField -> ConverterOfCustom(mlEventField)
is MLLanguageEventField -> ConverterOfLanguage(mlEventField) as IJEventPairConverter<L, *>
is MLVersionEventField -> ConverterOfVersion(mlEventField) as IJEventPairConverter<L, *>
}
}
else -> throw IllegalArgumentException(
"""
Conversion of ${mlEventField.javaClass.simpleName} is not possible.
If you want to create your own field, you must add an inheritor of
${MLCustomEventField::class.qualifiedName}
""".trimIndent()
)
}
private class ConverterOfCustom<T>(mlEventField: MLCustomEventField<T>) : IJEventPairConverter<T, T> {
override val ijEventField: IJEventField<T> = mlEventField.baseIJEventField
override fun buildEventPair(mlEventPair: EventPair<T>): IJEventPair<T> {
return ijEventField with mlEventPair.data
}
}
private class ConverterOfString(mlEventField: MLStringEventField) : IJEventPairConverter<String, String?> {
override val ijEventField: IJEventField<String?> = IJStringEventField.ValidatedByAllowedValues(mlEventField.name, allowedValues = mlEventField.possibleValues, description = mlEventField.description)
override val ijEventField: IJEventField<String?> = IJStringEventField.ValidatedByAllowedValues(
mlEventField.name,
allowedValues = mlEventField.possibleValues,
description = mlEventField.description
)
override fun buildEventPair(mlEventPair: EventPair<String>): IJEventPair<String?> {
return ijEventField with mlEventPair.data
@@ -116,7 +148,8 @@ private class ConverterOfVersion(mlEventField: MLVersionEventField) : IJEventPai
}
}
private class ConvertObjectList(mlEventField: MLObjectListEventField) : IJEventPairConverter<List<MLObjectEventData>, List<IJObjectEventData>> {
private class ConvertObjectList(mlEventField: MLObjectListEventField) :
IJEventPairConverter<List<MLObjectEventData>, List<IJObjectEventData>> {
private val innerObjectConverter = ConverterOfObject(mlEventField.name, mlEventField.description, mlEventField.internalObjectDescription)
// FIXME: description is not passed

View File

@@ -5,9 +5,16 @@ import com.intellij.lang.Language
import com.intellij.openapi.util.Version
import com.intellij.platform.ml.logs.schema.CustomRuleEventField
import org.jetbrains.annotations.ApiStatus
import com.intellij.internal.statistic.eventLog.events.EventField as IJEventField
@ApiStatus.Internal
class VersionEventField(name: String, description: String?) : CustomRuleEventField<Version>(name, description)
sealed class IJSpecificEventField<T>(name: String, description: String?) : CustomRuleEventField<T>(name, description)
@ApiStatus.Internal
class LanguageEventField(name: String, description: String?) : CustomRuleEventField<Language>(name, description)
class VersionEventField(name: String, description: String?) : IJSpecificEventField<Version>(name, description)
@ApiStatus.Internal
class LanguageEventField(name: String, description: String?) : IJSpecificEventField<Language>(name, description)
@ApiStatus.Internal
open class CustomEventField<T>(val baseIJEventField: IJEventField<T>) : IJSpecificEventField<T>(baseIJEventField.name, baseIJEventField.description)

View File

@@ -7,6 +7,7 @@ import com.intellij.ide.ui.search.SearchableOptionsRegistrar
import com.intellij.internal.statistic.collectors.fus.ui.SettingsCounterUsagesCollector
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.application.ApplicationBundle
import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.options.Configurable
import com.intellij.openapi.options.DslConfigurableBase
import com.intellij.openapi.options.SearchableConfigurable
@@ -154,6 +155,7 @@ class AdvancedSettingsConfigurable : DslConfigurableBase(), SearchableConfigurab
private fun AdvancedSettingBean.isApplicable(): Boolean =
when (id) {
"project.view.do.not.autoscroll.to.libraries" -> !ProjectJdkTable.getInstance().allJdks.isEmpty()
"search.everywhere.send.search.history.statistics" -> ApplicationManager.getApplication().isEAP && ApplicationManager.getApplication().isInternal
else -> true
}

View File

@@ -1632,6 +1632,7 @@
<advancedSetting id="search.everywhere.wait.for.contributors" default="true" groupKey="group.advanced.settings.se"/>
<advancedSetting id="search.everywhere.contributors.wait.timeout" default="2000" groupKey="group.advanced.settings.se"/>
<advancedSetting id="search.everywhere.recent.at.top" default="true" groupKey="group.advanced.settings.se"/>
<advancedSetting id="search.everywhere.send.search.history.statistics" default="true" groupKey="group.advanced.settings.se"/>
<applicationInitializedListener implementation="com.intellij.lang.documentation.ide.impl.QuickDocAutoPopupInEAPInitializer"/>

View File

@@ -143,7 +143,8 @@ class SearchEverywhereMlRankingService : SearchEverywhereMlService {
override fun onItemSelected(project: Project?, tabId: String, indexes: IntArray, selectedItems: List<Any>,
elementsProvider: () -> List<SearchEverywhereFoundElementInfo>,
closePopup: Boolean) {
closePopup: Boolean,
query: String) {
getCurrentSession()?.onItemSelected(project, experiment, indexes, selectedItems, closePopup, mapElementsProvider(elementsProvider))
}

View File

@@ -9,5 +9,6 @@ interface SearchEverywhereItemSelectedListener {
indexes: IntArray,
selectedItems: List<Any>,
elementsProvider: () -> List<SearchEverywhereFoundElementInfo>,
closePopup: Boolean)
closePopup: Boolean,
query: String)
}

View File

@@ -21,8 +21,9 @@ class SearchEverywhereMlServiceImpl : SearchEverywhereMlService by RANKING_SERVI
indexes: IntArray,
selectedItems: List<Any>,
elementsProvider: () -> List<SearchEverywhereFoundElementInfo>,
closePopup: Boolean) {
RANKING_SERVICE.onItemSelected(project, tabId, indexes, selectedItems, elementsProvider, closePopup)
ITEM_SELECTED_LISTENERS.forEach { it.onItemSelected(project, tabId, indexes, selectedItems, elementsProvider, closePopup) }
closePopup: Boolean,
query: String) {
RANKING_SERVICE.onItemSelected(project, tabId, indexes, selectedItems, elementsProvider, closePopup, query)
ITEM_SELECTED_LISTENERS.forEach { it.onItemSelected(project, tabId, indexes, selectedItems, elementsProvider, closePopup, query) }
}
}