Fix issue when proximity features were tracked only as UNDEFINED
authorVitaliy.Bibaev <vitaliy.bibaev@jetbrains.com>
Fri, 12 Jan 2018 10:24:21 +0000 (13:24 +0300)
committerVitaliy.Bibaev <vitaliy.bibaev@jetbrains.com>
Fri, 12 Jan 2018 10:24:21 +0000 (13:24 +0300)
plugins/stats-collector/src/com/intellij/stats/completion/LookupCompletedTracker.kt

index 2b81c113041cb63065f2ee3f284c7612ec5b7714..08e752f7d808b8a5a3d995b8edaea3ceeaf55b30 100644 (file)
@@ -23,6 +23,7 @@ import com.intellij.codeInsight.lookup.impl.LookupImpl
 import com.intellij.completion.FeatureManagerImpl
 import com.intellij.stats.personalization.UserFactorDescriptions
 import com.intellij.stats.personalization.UserFactorStorage
 import com.intellij.completion.FeatureManagerImpl
 import com.intellij.stats.personalization.UserFactorDescriptions
 import com.intellij.stats.personalization.UserFactorStorage
+import com.jetbrains.completion.ranker.features.impl.FeatureUtils
 
 /**
  * @author Vitaliy.Bibaev
 
 /**
  * @author Vitaliy.Bibaev
@@ -49,26 +50,27 @@ class LookupCompletedTracker : LookupAdapter() {
         val relevanceObjects =
                 lookup.getRelevanceObjects(listOf(element), false)
         val relevanceMap = relevanceObjects[element]?.associate { it.first to it.second } ?: return
         val relevanceObjects =
                 lookup.getRelevanceObjects(listOf(element), false)
         val relevanceMap = relevanceObjects[element]?.associate { it.first to it.second } ?: return
+        val featuresValues = FeatureUtils.preparedMap(relevanceMap)
         val project = lookup.project
         val featureManager = FeatureManagerImpl.getInstance()
         featureManager.binaryFactors.filter { !featureManager.isUserFeature(it.name) }.forEach { feature ->
             UserFactorStorage.applyOnBoth(project, UserFactorDescriptions.binaryFeatureDescriptor(feature))
             { updater ->
         val project = lookup.project
         val featureManager = FeatureManagerImpl.getInstance()
         featureManager.binaryFactors.filter { !featureManager.isUserFeature(it.name) }.forEach { feature ->
             UserFactorStorage.applyOnBoth(project, UserFactorDescriptions.binaryFeatureDescriptor(feature))
             { updater ->
-                updater.update(relevanceMap[feature.name])
+                updater.update(featuresValues[feature.name])
             }
         }
 
         featureManager.doubleFactors.filter { !featureManager.isUserFeature(it.name) }.forEach { feature ->
             UserFactorStorage.applyOnBoth(project, UserFactorDescriptions.doubleFeatureDescriptor(feature))
             { updater ->
             }
         }
 
         featureManager.doubleFactors.filter { !featureManager.isUserFeature(it.name) }.forEach { feature ->
             UserFactorStorage.applyOnBoth(project, UserFactorDescriptions.doubleFeatureDescriptor(feature))
             { updater ->
-                updater.update(relevanceMap[feature.name])
+                updater.update(featuresValues[feature.name])
             }
         }
 
         featureManager.categorialFactors.filter { !featureManager.isUserFeature(it.name) }.forEach { feature ->
             UserFactorStorage.applyOnBoth(project, UserFactorDescriptions.categoriealFeatureDescriptor(feature))
             { updater ->
             }
         }
 
         featureManager.categorialFactors.filter { !featureManager.isUserFeature(it.name) }.forEach { feature ->
             UserFactorStorage.applyOnBoth(project, UserFactorDescriptions.categoriealFeatureDescriptor(feature))
             { updater ->
-                updater.update(relevanceMap[feature.name])
+                updater.update(featuresValues[feature.name])
             }
         }
     }
             }
         }
     }