refactor: use SlintFileType for type-safe file detection
Co-Authored-By: Claude (auto) <noreply@anthropic.com>
This commit is contained in:
@@ -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())
|
||||
|
||||
|
||||
Reference in New Issue
Block a user