Add feature manager entity
authorVitaliy.Bibaev <vitaliy.bibaev@jetbrains.com>
Thu, 23 Nov 2017 10:15:30 +0000 (13:15 +0300)
committerVitaliy.Bibaev <vitaliy.bibaev@jetbrains.com>
Mon, 27 Nov 2017 16:05:23 +0000 (19:05 +0300)
plugins/stats-collector/src/com/intellij/completion/FeatureManager.kt [new file with mode: 0644]
plugins/stats-collector/src/com/intellij/completion/FeatureManagerImpl.kt [new file with mode: 0644]

diff --git a/plugins/stats-collector/src/com/intellij/completion/FeatureManager.kt b/plugins/stats-collector/src/com/intellij/completion/FeatureManager.kt
new file mode 100644 (file)
index 0000000..36c06fb
--- /dev/null
@@ -0,0 +1,26 @@
+package com.intellij.completion
+
+import com.intellij.openapi.application.ApplicationManager
+import com.jetbrains.completion.ranker.features.BinaryFeatureInfo
+import com.jetbrains.completion.ranker.features.CategoricalFeatureInfo
+import com.jetbrains.completion.ranker.features.CompletionFactors
+import com.jetbrains.completion.ranker.features.DoubleFeatureInfo
+
+/**
+ * @author Vitaliy.Bibaev
+ */
+interface FeatureManager {
+    val featuresOrder: Map<String, Int>
+    val binaryFactors: BinaryFeatureInfo
+    val doubleFactors: DoubleFeatureInfo
+    val categorialFactors: CategoricalFeatureInfo
+    val ignoredFactors: Set<String>
+
+    val allFeatures: CompletionFactors
+
+    fun isUserFeature(name: String): Boolean
+
+    companion object {
+        fun getInstance(): FeatureManager = ApplicationManager.getApplication().getComponent(FeatureManager::class.java)
+    }
+}
\ No newline at end of file
diff --git a/plugins/stats-collector/src/com/intellij/completion/FeatureManagerImpl.kt b/plugins/stats-collector/src/com/intellij/completion/FeatureManagerImpl.kt
new file mode 100644 (file)
index 0000000..c9036bd
--- /dev/null
@@ -0,0 +1,27 @@
+package com.intellij.completion
+
+import com.intellij.openapi.components.ApplicationComponent
+import com.jetbrains.completion.ranker.features.*
+
+/**
+ * @author Vitaliy.Bibaev
+ */
+class FeatureManagerImpl : FeatureManager, ApplicationComponent {
+    override lateinit var binaryFactors: BinaryFeatureInfo private set
+    override lateinit var doubleFactors: DoubleFeatureInfo private set
+    override lateinit var categorialFactors: CategoricalFeatureInfo private set
+    override lateinit var allFeatures: CompletionFactors private set
+    override lateinit var featuresOrder: Map<String, Int> private set
+    override lateinit var ignoredFactors: Set<String> private set
+
+    override fun isUserFeature(name: String): Boolean = false
+
+    override fun initComponent() {
+        binaryFactors = FeatureReader.binaryFactors()
+        doubleFactors = FeatureReader.doubleFactors()
+        allFeatures = FeatureReader.completionFactors()
+        categorialFactors = FeatureReader.categoricalFactors()
+        featuresOrder = FeatureReader.featuresOrder()
+        ignoredFactors = FeatureReader.ignoredFactors()
+    }
+}
\ No newline at end of file