From 5cb2d1dfd233f5725926b4d9da47512df1bc1217 Mon Sep 17 00:00:00 2001 From: Anastasia Ivanova Date: Mon, 2 Nov 2020 16:28:47 +0100 Subject: [PATCH] FUS: get rid of StatisticsEventProvider annotation GitOrigin-RevId: f2ac0d5b788b11ade1eb78dda678ce93e7d86bc1 --- .../internal/statistic/beans/MetricEvent.kt | 3 +-- .../statistic/beans/MetricEventFactory.kt | 18 ----------------- .../statistic/beans/MetricEventUtil.kt | 13 ------------ .../beans/StatisticsEventProvider.kt | 20 ------------------- 4 files changed, 1 insertion(+), 53 deletions(-) delete mode 100644 platform/statistics/src/com/intellij/internal/statistic/beans/StatisticsEventProvider.kt diff --git a/platform/statistics/src/com/intellij/internal/statistic/beans/MetricEvent.kt b/platform/statistics/src/com/intellij/internal/statistic/beans/MetricEvent.kt index fc895dbc40c8..20181390de13 100644 --- a/platform/statistics/src/com/intellij/internal/statistic/beans/MetricEvent.kt +++ b/platform/statistics/src/com/intellij/internal/statistic/beans/MetricEvent.kt @@ -18,8 +18,7 @@ import java.util.* * @see newCounterMetric */ @ApiStatus.Internal -class MetricEvent @JvmOverloads @StatisticsEventProvider(eventIdIndex = 0, dataIndex = 1) constructor(@NonNls val eventId: String, - data: FeatureUsageData? = null) { +class MetricEvent @JvmOverloads constructor(@NonNls val eventId: String, data: FeatureUsageData? = null) { val data: FeatureUsageData = data ?: FeatureUsageData() override fun equals(other: Any?): Boolean { diff --git a/platform/statistics/src/com/intellij/internal/statistic/beans/MetricEventFactory.kt b/platform/statistics/src/com/intellij/internal/statistic/beans/MetricEventFactory.kt index 6752212885cf..062c12703a6d 100644 --- a/platform/statistics/src/com/intellij/internal/statistic/beans/MetricEventFactory.kt +++ b/platform/statistics/src/com/intellij/internal/statistic/beans/MetricEventFactory.kt @@ -14,7 +14,6 @@ import java.util.* * * merging this metric with another one, e.g. eventId="has.config.file", eventData={"type":"dockerfile"} or eventData={"type":"docker-compose.yml"}; * * adding more information about this metric, e.g. eventId="has.dockerfile", eventData={"version":"2.3", "location":"project.root"}; */ -@StatisticsEventProvider(eventIdIndex = 0) fun newMetric(@NonNls eventId: String): MetricEvent { return MetricEvent(eventId, null) } @@ -25,7 +24,6 @@ fun newMetric(@NonNls eventId: String): MetricEvent { * eventId="breakpoint", eventData={"type":"line", "lang":"Java", "count":5} * eventId="gradle", eventData={"version":"2.3.1"} */ -@StatisticsEventProvider(eventIdIndex = 0, dataIndex = 1) fun newMetric(@NonNls eventId: String, data: FeatureUsageData?): MetricEvent { return MetricEvent(eventId, data) } @@ -35,7 +33,6 @@ fun newMetric(@NonNls eventId: String, data: FeatureUsageData?): MetricEvent { * * eventId="upload.files", eventData={"value":"ON_SAVE"} */ -@StatisticsEventProvider(eventIdIndex = 0, additionalDataFields = ["value::1"]) fun newMetric(@NonNls eventId: String, value: String): MetricEvent { return newMetric(eventId, value, null) } @@ -45,7 +42,6 @@ fun newMetric(@NonNls eventId: String, value: String): MetricEvent { * * eventId="upload.files", eventData={"value":"ON_SAVE"} */ -@StatisticsEventProvider(eventIdIndex = 0, dataIndex = 2, additionalDataFields = ["value::1"]) fun newMetric(@NonNls eventId: String, value: String, data: FeatureUsageData?): MetricEvent { val newData = data?.copy() ?: FeatureUsageData() return MetricEvent(eventId, newData.addValue(value)) @@ -56,7 +52,6 @@ fun newMetric(@NonNls eventId: String, value: String, data: FeatureUsageData?): * * eventId="upload.files", eventData={"value":"ON_SAVE"} */ -@StatisticsEventProvider(eventIdIndex = 0, additionalDataFields = ["value::1"]) fun newMetric(@NonNls eventId: String, value: Enum<*>?): MetricEvent { return newMetric(eventId, value, null) } @@ -66,7 +61,6 @@ fun newMetric(@NonNls eventId: String, value: Enum<*>?): MetricEvent { * * eventId="upload.files", eventData={"value":"ON_SAVE"} */ -@StatisticsEventProvider(eventIdIndex = 0, dataIndex = 2, additionalDataFields = ["value::1"]) fun newMetric(@NonNls eventId: String, value: Enum<*>?, data: FeatureUsageData?): MetricEvent { val newData = data?.copy() ?: FeatureUsageData() val newValue = value?.name?.toLowerCase(Locale.ENGLISH) ?: "unknown" @@ -78,7 +72,6 @@ fun newMetric(@NonNls eventId: String, value: Enum<*>?, data: FeatureUsageData?) * * eventId="allowed.connections", eventData={"value":3} */ -@StatisticsEventProvider(eventIdIndex = 0, additionalDataFields = ["value:regexp#integer"]) fun newMetric(@NonNls eventId: String, value: Int): MetricEvent { return newMetric(eventId, value, null) } @@ -88,7 +81,6 @@ fun newMetric(@NonNls eventId: String, value: Int): MetricEvent { * * eventId="allowed.connections", eventData={"value":3} */ -@StatisticsEventProvider(eventIdIndex = 0, dataIndex = 2, additionalDataFields = ["value:regexp#integer"]) fun newMetric(@NonNls eventId: String, value: Int, data: FeatureUsageData?): MetricEvent { val newData = data?.copy() ?: FeatureUsageData() return MetricEvent(eventId, newData.addValue(value)) @@ -99,7 +91,6 @@ fun newMetric(@NonNls eventId: String, value: Int, data: FeatureUsageData?): Met * * eventId="line.spacing", eventData={"value":1.2} */ -@StatisticsEventProvider(eventIdIndex = 0, additionalDataFields = ["value:regexp#float"]) fun newMetric(@NonNls eventId: String, value: Float): MetricEvent { return newMetric(eventId, value, null) } @@ -109,7 +100,6 @@ fun newMetric(@NonNls eventId: String, value: Float): MetricEvent { * * eventId="line.spacing", eventData={"value":1.2} */ -@StatisticsEventProvider(eventIdIndex = 0, dataIndex = 2, additionalDataFields = ["value:regexp#float"]) fun newMetric(@NonNls eventId: String, value: Float, data: FeatureUsageData?): MetricEvent { val newData = data?.copy() ?: FeatureUsageData() return MetricEvent(eventId, newData.addValue(value)) @@ -120,7 +110,6 @@ fun newMetric(@NonNls eventId: String, value: Float, data: FeatureUsageData?): M * * eventId="font.ligatures", eventData={"enabled":true} */ -@StatisticsEventProvider(eventIdIndex = 0, additionalDataFields = ["enabled:enum#boolean"]) fun newBooleanMetric(@NonNls eventId: String, enabled: Boolean): MetricEvent { return newBooleanMetric(eventId, enabled, null) } @@ -130,7 +119,6 @@ fun newBooleanMetric(@NonNls eventId: String, enabled: Boolean): MetricEvent { * * eventId="font.ligatures", eventData={"enabled":true} */ -@StatisticsEventProvider(eventIdIndex = 0, dataIndex = 2, additionalDataFields = ["enabled:enum#boolean"]) fun newBooleanMetric(@NonNls eventId: String, enabled: Boolean, data: FeatureUsageData?): MetricEvent { val newData = data?.copy() ?: FeatureUsageData() return MetricEvent(eventId, newData.addEnabled(enabled)) @@ -141,7 +129,6 @@ fun newBooleanMetric(@NonNls eventId: String, enabled: Boolean, data: FeatureUsa * * eventId="tool.is.under.project.root", eventData={"value":true} */ -@StatisticsEventProvider(eventIdIndex = 0, additionalDataFields = ["value:enum#boolean"]) fun newMetric(@NonNls eventId: String, value: Boolean): MetricEvent { return newMetric(eventId, value, null) } @@ -151,7 +138,6 @@ fun newMetric(@NonNls eventId: String, value: Boolean): MetricEvent { * * eventId="tool.is.under.project.root", eventData={"value":true} */ -@StatisticsEventProvider(eventIdIndex = 0, dataIndex = 2, additionalDataFields = ["value:enum#boolean"]) fun newMetric(@NonNls eventId: String, value: Boolean, data: FeatureUsageData? = null): MetricEvent { val newData = data?.copy() ?: FeatureUsageData() return MetricEvent(eventId, newData.addValue(value)) @@ -162,7 +148,6 @@ fun newMetric(@NonNls eventId: String, value: Boolean, data: FeatureUsageData? = * * eventId="source_roots", eventData={"count":3} */ -@StatisticsEventProvider(eventIdIndex = 0, additionalDataFields = ["count:regexp#integer"]) fun newCounterMetric(@NonNls eventId: String, count: Int): MetricEvent { return newCounterMetric(eventId, count, null) } @@ -172,7 +157,6 @@ fun newCounterMetric(@NonNls eventId: String, count: Int): MetricEvent { * * eventId="source_roots", eventData={"count":3} */ -@StatisticsEventProvider(eventIdIndex = 0, dataIndex = 2, additionalDataFields = ["count:regexp#integer"]) fun newCounterMetric(@NonNls eventId: String, count: Int, data: FeatureUsageData?): MetricEvent { val newData = data?.copy() ?: FeatureUsageData() return MetricEvent(eventId, newData.addCount(count)) @@ -186,7 +170,6 @@ fun newCounterMetric(@NonNls eventId: String, count: Int, data: FeatureUsageData * @see newCounterMetric(java.lang.String, int) */ @Deprecated("Only for existing counter metrics, new metrics should report absolute counter value") -@StatisticsEventProvider(eventIdIndex = 0, dataIndex = 2, additionalDataFields = ["count:regexp#integer", "count_group"]) fun newCounterRangeMetric(@NonNls eventId: String, count: Int, data: FeatureUsageData? = null): MetricEvent { val newData = data?.copy() ?: FeatureUsageData() newData.addCount(count).addData("count_group", getCountingUsage(count)) @@ -201,7 +184,6 @@ fun newCounterRangeMetric(@NonNls eventId: String, count: Int, data: FeatureUsag * @see newCounterMetric(java.lang.String, int) */ @Deprecated("Only for existing counter metrics, new metrics should report absolute counter value") -@StatisticsEventProvider(eventIdIndex = 0, dataIndex = 3, additionalDataFields = ["count:regexp#integer", "count_group"]) fun newCounterRangeMetric(@NonNls eventId: String, count: Int, steps: List, data: FeatureUsageData? = null): MetricEvent { val newData = data?.copy() ?: FeatureUsageData() newData.addCount(count).addData("count_group", getCountingUsage(count, steps)) diff --git a/platform/statistics/src/com/intellij/internal/statistic/beans/MetricEventUtil.kt b/platform/statistics/src/com/intellij/internal/statistic/beans/MetricEventUtil.kt index cc26817d5473..01832880b74d 100644 --- a/platform/statistics/src/com/intellij/internal/statistic/beans/MetricEventUtil.kt +++ b/platform/statistics/src/com/intellij/internal/statistic/beans/MetricEventUtil.kt @@ -7,7 +7,6 @@ import com.intellij.openapi.util.Comparing /** * Reports numerical or string value of the setting if it's not default. */ -@StatisticsEventProvider(eventIdIndex = 4, additionalDataFields = ["value"]) fun addIfDiffers(set: MutableSet, settingsBean: T, defaultSettingsBean: T, valueFunction: Function1, eventId: String) { addIfDiffers(set, settingsBean, defaultSettingsBean, valueFunction, eventId, null) @@ -16,7 +15,6 @@ fun addIfDiffers(set: MutableSet, settingsBean: T, defaultSe /** * Reports numerical or string value of the setting if it's not default. */ -@StatisticsEventProvider(eventIdIndex = 4, dataIndex = 5, additionalDataFields = ["value"]) fun addIfDiffers(set: MutableSet, settingsBean: T, defaultSettingsBean: T, valueFunction: Function1, eventId: String, data: FeatureUsageData?) { addMetricIfDiffers(set, settingsBean, defaultSettingsBean, valueFunction) { @@ -31,7 +29,6 @@ fun addIfDiffers(set: MutableSet, settingsBean: T, defaultSe /** * Reports the value of boolean setting (i.e. enabled or disabled) if it's not default. */ -@StatisticsEventProvider(eventIdIndex = 4, additionalDataFields = ["enabled:enum#boolean"]) fun addBoolIfDiffers(set: MutableSet, settingsBean: T, defaultSettingsBean: T, valueFunction: Function1, eventId: String) { addBoolIfDiffers(set, settingsBean, defaultSettingsBean, valueFunction, eventId, null) @@ -40,7 +37,6 @@ fun addBoolIfDiffers(set: MutableSet, settingsBean: T, defau /** * Reports the value of boolean setting (i.e. enabled or disabled) if it's not default. */ -@StatisticsEventProvider(eventIdIndex = 4, dataIndex = 5, additionalDataFields = ["enabled:enum#boolean"]) fun addBoolIfDiffers(set: MutableSet, settingsBean: T, defaultSettingsBean: T, valueFunction: Function1, eventId: String, data: FeatureUsageData?) { addMetricIfDiffers(set, settingsBean, defaultSettingsBean, valueFunction) { newBooleanMetric(eventId, it, data) } @@ -49,7 +45,6 @@ fun addBoolIfDiffers(set: MutableSet, settingsBean: T, defau /** * Adds counter value if count is greater than 0 */ -@StatisticsEventProvider(eventIdIndex = 1, additionalDataFields = ["count:regexp#integer"]) fun addCounterIfNotZero(set: MutableSet, eventId: String, count: Int) { if (count > 0) { set.add(newCounterMetric(eventId, count)) @@ -59,50 +54,42 @@ fun addCounterIfNotZero(set: MutableSet, eventId: String, co /** * Adds counter value if count is greater than 0 */ -@StatisticsEventProvider(eventIdIndex = 1, dataIndex = 3, additionalDataFields = ["count:regexp#integer"]) fun addCounterIfNotZero(set: MutableSet, eventId: String, count: Int, data: FeatureUsageData?) { if (count > 0) { set.add(newCounterMetric(eventId, count, data)) } } -@StatisticsEventProvider(eventIdIndex = 4, additionalDataFields = ["count:regexp#integer"]) fun addCounterIfDiffers(set: MutableSet, settingsBean: T, defaultSettingsBean: T, valueFunction: Function1, eventId: String) { addMetricIfDiffers(set, settingsBean, defaultSettingsBean, valueFunction) { newCounterMetric(eventId, it) } } -@StatisticsEventProvider(eventIdIndex = 4, dataIndex = 5, additionalDataFields = ["count:regexp#integer"]) fun addCounterIfDiffers(set: MutableSet, settingsBean: T, defaultSettingsBean: T, valueFunction: Function1, eventId: String, data: FeatureUsageData?) { addMetricIfDiffers(set, settingsBean, defaultSettingsBean, valueFunction) { newCounterMetric(eventId, it, data) } } -@StatisticsEventProvider(eventIdIndex = 4, dataIndex = 5, additionalDataFields = ["count:regexp#integer", "count_group"]) fun addCounterRangeIfDiffers(set: MutableSet, settingsBean: T, defaultSettingsBean: T, valueFunction: Function1, eventId: String, data: FeatureUsageData?) { addMetricIfDiffers(set, settingsBean, defaultSettingsBean, valueFunction) { newCounterRangeMetric(eventId, it, data) } } -@StatisticsEventProvider(eventIdIndex = 4, additionalDataFields = ["count:regexp#integer", "count_group"]) fun addCounterRangeIfDiffers(set: MutableSet, settingsBean: T, defaultSettingsBean: T, valueFunction: Function1, eventId: String) { addMetricIfDiffers(set, settingsBean, defaultSettingsBean, valueFunction) { newCounterRangeMetric(eventId, it) } } -@StatisticsEventProvider(eventIdIndex = 4, dataIndex = 6, additionalDataFields = ["count:regexp#integer", "count_group"]) fun addCounterRangeIfDiffers(set: MutableSet, settingsBean: T, defaultSettingsBean: T, valueFunction: Function1, featureId: String, steps: List, data: FeatureUsageData?) { addMetricIfDiffers(set, settingsBean, defaultSettingsBean, valueFunction) { newCounterRangeMetric(featureId, it, steps, data) } } -@StatisticsEventProvider(eventIdIndex = 4, additionalDataFields = ["count:regexp#integer", "count_group"]) fun addCounterRangeIfDiffers(set: MutableSet, settingsBean: T, defaultSettingsBean: T, valueFunction: Function1, eventId: String, steps: List) { addMetricIfDiffers(set, settingsBean, defaultSettingsBean, valueFunction) { newCounterRangeMetric(eventId, it, steps) } } -@StatisticsEventProvider(eventIdIndex = 4, additionalDataFields = ["value"]) fun > addEnumIfDiffers(set: MutableSet, settingsBean: T, defaultSettingsBean: T, valueFunction: Function1, eventId: String) { addMetricIfDiffers(set, settingsBean, defaultSettingsBean, valueFunction) { newMetric(eventId, it, null) } diff --git a/platform/statistics/src/com/intellij/internal/statistic/beans/StatisticsEventProvider.kt b/platform/statistics/src/com/intellij/internal/statistic/beans/StatisticsEventProvider.kt deleted file mode 100644 index 8dc95392cc1d..000000000000 --- a/platform/statistics/src/com/intellij/internal/statistic/beans/StatisticsEventProvider.kt +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2000-2019 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.internal.statistic.beans - -/** - * Mark the methods that create or modify FeatureUsageData. Annotation is used to facilitate analysis. - * @param dataIndex - FeatureUsageData index in the signature of factory method, starts at 0 - * @param eventIdIndex - event id index in the signature of factory method, starts at 0 - * @param additionalDataFields - an array of event data fields, that the factory method adds to FeatureUsageData. - * You can describe validation rules for each field as "<fieldName>:<validationRule>". For example, "count:regexp#integer" - * If you can't describe validation rule, you can pass value index in the signature of factory method, - * starts at 0 ("<fieldName>::<valueIndex>"). For example, "count::4" - * - * @see newBooleanMetric - * @see newMetric - */ -@Retention(AnnotationRetention.RUNTIME) -@Target(AnnotationTarget.FUNCTION, AnnotationTarget.CONSTRUCTOR) -annotation class StatisticsEventProvider(val dataIndex: Int = -1, - val eventIdIndex: Int = -1, - val additionalDataFields: Array = [])