Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions src/main/kotlin/com/emberjs/gts/GlintExternalAnnotator.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import com.intellij.lang.annotation.AnnotationHolder
import com.intellij.lang.javascript.integration.JSAnnotationError
import com.intellij.lang.javascript.linter.*
import com.intellij.lang.javascript.psi.JSFile
import com.intellij.openapi.components.Service
import com.intellij.openapi.components.State
import com.intellij.openapi.components.Storage
import com.intellij.openapi.options.OptionsBundle
Expand Down Expand Up @@ -66,8 +67,7 @@ data class GlintState(
private val myPackageRef: NodePackageRef = NodePackageRef.create(myTemplateLintPackage)

override fun withLinterPackage(packageRef: NodePackageRef): GlintState {
val constantPackage = packageRef.constantPackage
?: throw AssertionError(this.javaClass.simpleName + " does not support non-constant package refs")
val constantPackage = packageRef.constantPackage ?: return DEFAULT

return copy(myTemplateLintPackage = constantPackage)
}
Expand All @@ -93,6 +93,7 @@ data class GlintState(
}


@Service(Service.Level.PROJECT)
@State(name = "GlintConfiguration", storages = [Storage("emberLinters/glint.xml")])
class GlintConfiguration(project: Project) : JSLinterConfiguration<GlintState>(project) {
private val myPackage: JSLinterPackage = JSLinterPackage(project, "@glint/core")
Expand All @@ -103,7 +104,10 @@ class GlintConfiguration(project: Project) : JSLinterConfiguration<GlintState>(p
override fun loadPrivateSettings(state: GlintState): GlintState {
this.myPackage.readOrDetect()
val constantPackage = myPackage.getPackage().constantPackage
?: throw AssertionError("glint does not support non-constant node package refs")

if (constantPackage == null) {
return defaultState
}

return state.copy(
myInterpreterRef = this.myPackage.interpreter,
Expand Down Expand Up @@ -245,4 +249,4 @@ class GlintExternalAnnotator : JSLinterExternalAnnotator<GlintState>(true) {
override fun getInspectionClass(): Class<out JSLinterInspection> {
return GlintInspection::class.java
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,15 @@ class TemplateLintConfiguration(project: Project) : JSLinterConfiguration<Templa
override fun loadPrivateSettings(state: TemplateLintState): TemplateLintState {
this.myPackage.readOrDetect()

val constantPackage = this.myPackage.getPackage().constantPackage

if (constantPackage == null) {
return defaultState
}

return state.copy(
myInterpreterRef = this.myPackage.interpreter,
myTemplateLintPackage = this.myPackage.getPackage().constantPackage
myTemplateLintPackage = constantPackage
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@ import com.intellij.lang.javascript.linter.JSNpmLinterState

data class TemplateLintState(
private val myInterpreterRef: NodeJsInterpreterRef,
private val myTemplateLintPackage: NodePackage?,
private val myTemplateLintPackage: NodePackage,
val isRunOnSave: Boolean,
) : JSNpmLinterState<TemplateLintState> {

private val myPackageRef: NodePackageRef? = myTemplateLintPackage?.let { NodePackageRef.create(it) }
private val myPackageRef: NodePackageRef = myTemplateLintPackage.let { NodePackageRef.create(it) }

override fun withLinterPackage(packageRef: NodePackageRef): TemplateLintState {
val constantPackage = packageRef.constantPackage
?: throw AssertionError(this.javaClass.simpleName + " does not support non-constant package refs")
val constantPackage = packageRef.constantPackage ?: return DEFAULT

return copy(myTemplateLintPackage = constantPackage)
}
Expand All @@ -24,12 +23,12 @@ data class TemplateLintState(
}

override fun getNodePackageRef(): NodePackageRef {
return this.myPackageRef!!
return this.myPackageRef
}

val templateLintPackage: NodePackage
get() {
return this.myTemplateLintPackage!!
return this.myTemplateLintPackage
}

companion object {
Expand Down
1 change: 0 additions & 1 deletion src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,6 @@
<annotator language="Handlebars" implementationClass="com.emberjs.gts.HbLintAnnotator"/>
<annotator language="HTML" implementationClass="com.emberjs.gts.HbLintAnnotator"/>
<projectService serviceImplementation="TemplateLintConfiguration"/>
<projectService serviceImplementation="com.emberjs.gts.GlintConfiguration"/>
<projectService serviceImplementation="TemplateLintConfigFileChangeTracker"/>
<projectService serviceImplementation="TemplateLintUnsavedConfigFileManager"/>
<projectService serviceImplementation="com.emberjs.glint.GlintTypeScriptService"/>
Expand Down
Loading