Skip to content

Commit d0c91b7

Browse files
committed
feat(kotlin): add language-specific file name dictionary provider for Kotlin #358
- Implement KotlinLangDictProvider to collect Kotlin file names - Update plugin XML to register the new langDictProvider
1 parent ff77786 commit d0c91b7

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package cc.unitmesh.kotlin.indexer.provider
2+
3+
import cc.unitmesh.devti.indexer.provider.LangDictProvider
4+
import com.intellij.openapi.application.runReadAction
5+
import com.intellij.openapi.project.Project
6+
import com.intellij.psi.search.FileTypeIndex
7+
import com.intellij.psi.search.ProjectScope
8+
import org.jetbrains.kotlin.idea.KotlinFileType
9+
10+
class KotlinLangDictProvider : LangDictProvider {
11+
override suspend fun collectFileNames(project: Project): List<String> {
12+
val searchScope = ProjectScope.getProjectScope(project)
13+
val javaFiles = runReadAction {
14+
FileTypeIndex.getFiles(KotlinFileType.INSTANCE, searchScope)
15+
}
16+
17+
val filenames = javaFiles.mapNotNull {
18+
it.nameWithoutExtension
19+
}
20+
21+
return filenames
22+
}
23+
}

kotlin/src/main/resources/cc.unitmesh.kotlin.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,7 @@
4545
<customPromptProvider
4646
language="kotlin"
4747
implementationClass="cc.unitmesh.kotlin.provider.KotlinCustomPromptProvider" />
48+
49+
<langDictProvider implementation="cc.unitmesh.kotlin.indexer.provider.KotlinLangDictProvider"/>
4850
</extensions>
4951
</idea-plugin>

0 commit comments

Comments
 (0)