mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
LAB-29: don't report history position for new files
GitOrigin-RevId: 7f563a9fbda277ea65d2b13e9ac4c3a460479391
This commit is contained in:
committed by
intellij-monorepo-bot
parent
6ec86876e8
commit
d7fef2f225
+2
-2
@@ -1,6 +1,6 @@
|
||||
package com.intellij.filePrediction.history
|
||||
|
||||
data class FileHistoryFeatures(val position: Int, val uniGram: NextFileProbability, val biGram: NextFileProbability)
|
||||
data class FileHistoryFeatures(val position: Int?, val uniGram: NextFileProbability, val biGram: NextFileProbability)
|
||||
|
||||
data class NextFileProbability(
|
||||
val mle: Double, val minMle: Double, val maxMle: Double, val mleToMin: Double, val mleToMax: Double
|
||||
@@ -67,7 +67,7 @@ class FileHistoryManager(private var state: FilePredictionHistoryState, private
|
||||
|
||||
val fileWasPreviouslyOpened = index in 0 until size
|
||||
val entry = if (fileWasPreviouslyOpened) state.recentFiles[index] else null
|
||||
val position = if (fileWasPreviouslyOpened) size - index - 1 else -1
|
||||
val position = if (fileWasPreviouslyOpened) size - index - 1 else null
|
||||
val uniGram = helper.calculateUniGramProb(state.root, entry?.code)
|
||||
val biGram = helper.calculateBiGramProb(state.root, entry?.code, state.prevFile)
|
||||
return FileHistoryFeatures(position, uniGram, biGram)
|
||||
|
||||
+3
-1
@@ -16,7 +16,9 @@ internal class FilePredictionHistoryFeatures: FilePredictionFeatureProvider {
|
||||
result["size"] = numerical(history.size())
|
||||
|
||||
val (position, uniGram, biGram) = history.calcHistoryFeatures(newFile.url)
|
||||
result["position"] = numerical(position)
|
||||
if (position != null) {
|
||||
result["position"] = numerical(position)
|
||||
}
|
||||
addNGramFeatures(uniGram, "uni", result)
|
||||
addNGramFeatures(biGram, "bi", result)
|
||||
return result
|
||||
|
||||
-1
@@ -40,7 +40,6 @@ class FilePredictionFeaturesTest : CodeInsightFixtureTestCase<ModuleFixtureBuild
|
||||
"path_prefix",
|
||||
"relative_path_prefix",
|
||||
"history_size",
|
||||
"history_position",
|
||||
"history_uni_mle",
|
||||
"history_bi_mle"
|
||||
)
|
||||
|
||||
+3
-3
@@ -5,7 +5,7 @@ import com.intellij.filePrediction.history.FilePredictionHistoryState
|
||||
|
||||
class FilePredictionHistoryFeaturesTest : FilePredictionHistoryBaseTest() {
|
||||
|
||||
private fun doTest(openedFiles: List<String>, size: Int, vararg expected: Pair<String, Int>) {
|
||||
private fun doTest(openedFiles: List<String>, size: Int, vararg expected: Pair<String, Int?>) {
|
||||
doTestInternal(openedFiles, size, 5) { manager ->
|
||||
expected.forEach { assertEquals(it.second, manager.calcHistoryFeatures(it.first).position) }
|
||||
}
|
||||
@@ -25,11 +25,11 @@ class FilePredictionHistoryFeaturesTest : FilePredictionHistoryBaseTest() {
|
||||
}
|
||||
|
||||
fun `test position of the file without history`() {
|
||||
doTest(listOf(), 0, "file://a" to -1)
|
||||
doTest(listOf(), 0, "file://a" to null)
|
||||
}
|
||||
|
||||
fun `test position of the new file`() {
|
||||
doTest(listOf("file://a"), 1, "file://b" to -1)
|
||||
doTest(listOf("file://a"), 1, "file://b" to null)
|
||||
}
|
||||
|
||||
fun `test position of the prev file`() {
|
||||
|
||||
Reference in New Issue
Block a user