@@ -9,15 +9,23 @@ import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer
99import com.intellij.execution.configurations.GeneralCommandLine
1010import com.intellij.execution.process.OSProcessHandler
1111import com.intellij.execution.process.OSProcessUtil
12+ import com.intellij.javascript.nodejs.NodePackageVersionUtil
13+ import com.intellij.javascript.nodejs.PackageJsonData
1214import com.intellij.javascript.nodejs.interpreter.NodeCommandLineConfigurator
1315import com.intellij.javascript.nodejs.interpreter.NodeJsInterpreterRef
16+ import com.intellij.javascript.nodejs.packages.NodePackageInfo
17+ import com.intellij.javascript.nodejs.packages.NodePackageUtil
1418import com.intellij.javascript.nodejs.reference.NodeModuleManager
19+ import com.intellij.javascript.nodejs.settings.NodePackageInfoManager
20+ import com.intellij.javascript.nodejs.util.NodePackage
21+ import com.intellij.javascript.nodejs.util.NodePackageDescriptor
1522import com.intellij.lang.javascript.JavaScriptFileType
1623import com.intellij.lang.javascript.TypeScriptFileType
1724import com.intellij.openapi.Disposable
1825import com.intellij.openapi.application.ApplicationManager
1926import com.intellij.openapi.components.Service
2027import com.intellij.openapi.project.Project
28+ import com.intellij.openapi.util.NlsSafe
2129import com.intellij.openapi.vfs.VfsUtilCore
2230import com.intellij.openapi.vfs.VirtualFile
2331import com.intellij.openapi.vfs.isFile
@@ -26,6 +34,7 @@ import com.intellij.platform.lsp.api.LspServerManager
2634import com.intellij.platform.lsp.api.LspServerSupportProvider
2735import com.intellij.psi.PsiManager
2836import com.intellij.util.FileContentUtil
37+ import org.eclipse.lsp4j.ServerInfo
2938import java.io.File
3039import java.net.URLEncoder
3140import java.nio.charset.StandardCharsets
@@ -36,7 +45,7 @@ class GlintLspSupportProvider : LspServerSupportProvider {
3645 var willStart = false
3746 override fun fileOpened (project : Project , file : VirtualFile , serverStarter : LspServerSupportProvider .LspServerStarter ) {
3847 if (! getGlintDescriptor(project).isAvailable(file)) return
39- serverStarter.ensureServerStarted( getGlintDescriptor(project))
48+ getGlintDescriptor(project).ensureStarted(file )
4049 }
4150}
4251
@@ -46,7 +55,7 @@ fun getGlintDescriptor(project: Project): GlintLspServerDescriptor {
4655}
4756
4857
49- @Service
58+ @Service( Service . Level . PROJECT )
5059class GlintLspServerDescriptor (private val myProject : Project ) : LspServerDescriptor(myProject, " Glint" ), Disposable {
5160 val psiManager = PsiManager .getInstance(myProject)
5261 val lspServerManager = LspServerManager .getInstance(project)
@@ -103,7 +112,21 @@ class GlintLspServerDescriptor(private val myProject: Project) : LspServerDescri
103112
104113 fun ensureStarted (vfile : VirtualFile ) {
105114 if (! isAvailable(vfile)) return
106- lspServerManager.startServersIfNeeded(GlintLspSupportProvider ::class .java)
115+ lspServerManager.ensureServerStarted(GlintLspSupportProvider ::class .java, getGlintDescriptor(project))
116+ server?.let {
117+ if (it.initializeResult?.serverInfo == null ) {
118+ it.initializeResult?.serverInfo = ServerInfo ()
119+ }
120+ it.initializeResult?.serverInfo?.name = " Glint"
121+ it.initializeResult?.serverInfo?.version = getGlintVersion()
122+ }
123+ }
124+
125+ fun getGlintVersion (): String? {
126+ val workingDir = lastDir!!
127+ val workDirectory = VfsUtilCore .virtualToIoFile(workingDir)
128+ var path = workingDir.findFileByRelativePath(" node_modules/@glint/core/package.json" ) ? : return null
129+ return PackageJsonData .getOrCreate(path).version?.rawVersion
107130 }
108131
109132 override fun createCommandLine (): GeneralCommandLine {
0 commit comments