mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-06 03:21:12 +07:00
FUS: extract a method to retrieve project id
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
package com.intellij.configurationStore.statistic.eventLog
|
||||
|
||||
import com.intellij.internal.statistic.eventLog.FeatureUsageLogger
|
||||
import com.intellij.internal.statistic.utils.getProjectId
|
||||
import com.intellij.openapi.components.State
|
||||
import com.intellij.openapi.diagnostic.Logger
|
||||
import com.intellij.openapi.project.Project
|
||||
@@ -53,7 +54,7 @@ open class FeatureUsageSettingsEventPrinter {
|
||||
}
|
||||
|
||||
val isDefaultProject = project?.isDefault == true
|
||||
val hash = if (!isDefaultProject) toHash(project?.name) else null
|
||||
val hash = if (!isDefaultProject) toHash(project) else null
|
||||
|
||||
for (accessor in accessors) {
|
||||
val type = accessor.genericType
|
||||
@@ -84,9 +85,9 @@ open class FeatureUsageSettingsEventPrinter {
|
||||
FeatureUsageLogger.logState(groupId, eventId, data)
|
||||
}
|
||||
|
||||
internal fun toHash(projectName: String?): String? {
|
||||
return projectName?.let {
|
||||
return projectName.hashCode().toString()
|
||||
internal fun toHash(project: Project?): String? {
|
||||
return project?.let {
|
||||
return getProjectId(project)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,9 +24,8 @@ class FeatureUsageSettingsEventsTest {
|
||||
|
||||
@Test
|
||||
fun projectNameToHash() {
|
||||
val name = "project-name"
|
||||
val printer = TestFeatureUsageSettingsEventsPrinter()
|
||||
assertNotNull(printer.toHash(name))
|
||||
assertNotNull(printer.toHash(projectRule.project))
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -19,10 +19,16 @@ import com.intellij.ide.plugins.PluginManager
|
||||
import com.intellij.ide.plugins.PluginManagerMain
|
||||
import com.intellij.internal.statistic.beans.UsageDescriptor
|
||||
import com.intellij.openapi.extensions.PluginId
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.project.getProjectCacheFileName
|
||||
import com.intellij.util.containers.ObjectIntHashMap
|
||||
import gnu.trove.THashSet
|
||||
import java.util.*
|
||||
|
||||
fun getProjectId(project: Project): String {
|
||||
return project.getProjectCacheFileName(false, ".").hashCode().toString()
|
||||
}
|
||||
|
||||
fun isDevelopedByJetBrains(pluginId: PluginId?): Boolean {
|
||||
val plugin = PluginManager.getPlugin(pluginId)
|
||||
return plugin == null || plugin.isBundled || PluginManagerMain.isDevelopedByJetBrains(plugin.vendor)
|
||||
|
||||
Reference in New Issue
Block a user