You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: jetbrains-core/src/software/aws/toolkits/jetbrains/services/codewhisperer/util/CodeWhispererFileCrawler.kt
+25Lines changed: 25 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -91,5 +91,30 @@ abstract class CodeWhispererFileCrawler : FileCrawler {
91
91
acc
92
92
}
93
93
}
94
+
95
+
/**
96
+
* For [LocalFileSystem](implementation of virtual file system), the path will be an absolute file path with file separator characters replaced
97
+
* by forward slash "/"
98
+
* @see [VirtualFile.getPath]
99
+
*/
100
+
fungetFileDistance(targetFile:VirtualFile, candidateFile:VirtualFile): Int {
101
+
val targetFilePaths = targetFile.path.split("/").dropLast(1)
102
+
val candidateFilePaths = candidateFile.path.split("/").dropLast(1)
103
+
104
+
var i =0
105
+
while (i < minOf(targetFilePaths.size, candidateFilePaths.size)) {
106
+
val dir1 = targetFilePaths[i]
107
+
val dir2 = candidateFilePaths[i]
108
+
109
+
if (dir1 != dir2) {
110
+
break
111
+
}
112
+
113
+
i++
114
+
}
115
+
116
+
return targetFilePaths.subList(fromIndex = i, toIndex = targetFilePaths.size).size +
117
+
candidateFilePaths.subList(fromIndex = i, toIndex = candidateFilePaths.size).size
Copy file name to clipboardExpand all lines: jetbrains-core/src/software/aws/toolkits/jetbrains/services/codewhisperer/util/JavaCodeWhispererFileCrawler.kt
0 commit comments