From 198af79707fae153c11fa2871f982a79ae4e1607 Mon Sep 17 00:00:00 2001 From: me Date: Thu, 29 Jan 2026 13:16:35 +0800 Subject: [PATCH] refactor: use SlintFileType for type-safe file detection Co-Authored-By: Claude (auto) --- .../me/zhouxi/slint/lsp/SlintLspServerSupportProvider.kt | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/kotlin/me/zhouxi/slint/lsp/SlintLspServerSupportProvider.kt b/src/main/kotlin/me/zhouxi/slint/lsp/SlintLspServerSupportProvider.kt index 2a762fd..f1ccb7b 100644 --- a/src/main/kotlin/me/zhouxi/slint/lsp/SlintLspServerSupportProvider.kt +++ b/src/main/kotlin/me/zhouxi/slint/lsp/SlintLspServerSupportProvider.kt @@ -9,6 +9,7 @@ import com.intellij.platform.lsp.api.ProjectWideLspServerDescriptor import com.intellij.platform.lsp.api.lsWidget.LspServerWidgetItem import me.zhouxi.slint.SlintRuntime import me.zhouxi.slint.icons.SlintIcons +import me.zhouxi.slint.lang.SlintFileType class SlintLspServerSupportProvider : LspServerSupportProvider { override fun fileOpened( @@ -16,8 +17,8 @@ class SlintLspServerSupportProvider : LspServerSupportProvider { file: VirtualFile, serverStarter: LspServerSupportProvider.LspServerStarter ) { - if (file.extension == "slint") { - serverStarter.ensureServerStarted(FooLspServerDescriptor(project)) + if (file.fileType == SlintFileType) { + serverStarter.ensureServerStarted(SlintLspServerDescriptor(project)) } } @@ -31,8 +32,8 @@ class SlintLspServerSupportProvider : LspServerSupportProvider { SlintIcons.Primary, ) - private class FooLspServerDescriptor(project: Project) : ProjectWideLspServerDescriptor(project, "Slint") { - override fun isSupportedFile(file: VirtualFile) = file.extension == "slint" + private class SlintLspServerDescriptor(project: Project) : ProjectWideLspServerDescriptor(project, "Slint") { + override fun isSupportedFile(file: VirtualFile) = file.fileType == SlintFileType override fun createCommandLine(): GeneralCommandLine { val line = GeneralCommandLine(SlintRuntime.LspExecutable.toAbsolutePath().toString())