Skip to content

Commit 4479870

Browse files
authored
improve glint service detection (#321)
1 parent 12bcccf commit 4479870

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/main/kotlin/com/emberjs/glint/GlintLanguageService.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,14 @@ import java.util.concurrent.Future
5252
import java.util.stream.Stream
5353

5454
class GlintLanguageServiceProvider(val project: Project) : JSLanguageServiceProvider {
55+
val descriptor = getGlintDescriptor(project)
5556

5657
override fun isHighlightingCandidate(file: VirtualFile) = file.fileType is HbFileType || file.fileType is JavaScriptFileType || file.fileType is TypeScriptFileType || file.fileType is GtsFileType
5758

58-
override fun getService(file: VirtualFile) = allServices.firstOrNull()
59+
override fun getService(file: VirtualFile) = if (descriptor.isAvailable(file)) GlintTypeScriptService.getInstance(project) else null
5960

6061
override val allServices: List<GlintTypeScriptService>
61-
get() = if (EmberUtils.isEnabledEmberProject(project)) listOf(GlintTypeScriptService.getInstance(project)) else emptyList()
62+
get() = if (descriptor.isAvailable(null)) listOf(GlintTypeScriptService.getInstance(project)) else emptyList()
6263
}
6364

6465

src/main/kotlin/com/emberjs/glint/GlintLspSupportProvider.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ class GlintLspServerDescriptor(private val myProject: Project) : LspServerDescri
9898
return true
9999
}
100100

101-
fun isAvailable(vfile: VirtualFile): Boolean {
101+
fun isAvailable(vfile: VirtualFile?): Boolean {
102102
val config = GlintConfiguration.getInstance(myProject)
103103
val pkg = config.getPackage()
104104
val path = pkg.`package`.constantPackage?.systemIndependentPath

0 commit comments

Comments
 (0)