Skip to content

Commit b87bbb4

Browse files
authored
fix handlebars read action error (#312)
1 parent 3902b06 commit b87bbb4

File tree

3 files changed

+23
-10
lines changed

3 files changed

+23
-10
lines changed

src/main/kotlin/com/emberjs/gts/GtsSupport.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1116,7 +1116,10 @@ class RootBlockWrapper(val block: DataLanguageBlockWrapper, val policy: HtmlPoli
11161116
val htmlFile = viewProvider.getPsi(HTMLLanguage.INSTANCE)
11171117
val jsFile = viewProvider.getPsi(JavaScriptSupportLoader.TYPESCRIPT) ?: viewProvider.getPsi(JavaScriptSupportLoader.ECMA_SCRIPT_6)
11181118
val project = this.node!!.psi.project
1119-
val document = PsiDocumentManager.getInstance(project).getDocument(htmlFile)!!
1119+
val document = PsiDocumentManager.getInstance(project).getDocument(htmlFile)
1120+
if (document === null) {
1121+
return null
1122+
}
11201123
val INDENT_SIZE = this.policy.settings.getIndentSize(htmlFile.language.associatedFileType)
11211124
val JS_INDENT_SIZE = this.policy.settings.getIndentSize(jsFile.language.associatedFileType)
11221125
if (this.parent != null) {

src/main/kotlin/com/emberjs/hbs/linter/ember-template-lint/TemplateLintExternalAnnotator.kt

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@ import com.emberjs.icons.EmberIcons
77
import com.intellij.lang.annotation.AnnotationHolder
88
import com.intellij.lang.javascript.linter.*
99
import com.intellij.lang.javascript.psi.JSFile
10+
import com.intellij.openapi.application.ApplicationManager
1011
import com.intellij.openapi.editor.Editor
1112
import com.intellij.openapi.project.Project
1213
import com.intellij.openapi.util.text.StringUtil
1314
import com.intellij.openapi.vfs.VirtualFile
1415
import com.intellij.psi.PsiDocumentManager
1516
import com.intellij.psi.PsiFile
17+
import java.util.concurrent.Future
1618

1719
class TemplateLintExternalAnnotator(onTheFly: Boolean = true) : JSLinterExternalAnnotator<TemplateLintState>(onTheFly) {
1820
companion object {
@@ -46,16 +48,20 @@ class TemplateLintExternalAnnotator(onTheFly: Boolean = true) : JSLinterExternal
4648

4749
override fun annotate(input: JSLinterInput<TemplateLintState>): JSLinterAnnotationResult? {
4850
var res: JSLinterAnnotationResult? = null
49-
try {
50-
res = TemplateLintExternalRunner(this.isOnTheFly).highlight(input)
51-
} catch (ex: Exception) {
52-
res = null
53-
println(ex)
54-
}
51+
var p = ApplicationManager.getApplication().executeOnPooledThread {
52+
try {
53+
res = TemplateLintExternalRunner(this.isOnTheFly).highlight(input)
54+
} catch (ex: Exception) {
55+
res = null
56+
println(ex)
57+
}
5558

56-
val errors: MutableList<JSLinterError> = mutableListOf()
57-
errors.addAll(res?.errors ?: listOf())
58-
return JSLinterAnnotationResult.createLinterResult(input, errors.toList(), null as VirtualFile?)
59+
val errors: MutableList<JSLinterError> = mutableListOf()
60+
errors.addAll(res?.errors ?: listOf())
61+
res = JSLinterAnnotationResult.createLinterResult(input, errors.toList(), null as VirtualFile?)
62+
}
63+
p.get()
64+
return res
5965
}
6066

6167
override fun apply(file: PsiFile, annotationResult: JSLinterAnnotationResult?, holder: AnnotationHolder) {

src/main/kotlin/com/emberjs/hbs/linter/ember-template-lint/TemplateLintInspection.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ class TemplateLintInspection : JSLinterInspection() {
88
return TemplateLintExternalAnnotator.INSTANCE_FOR_BATCH_INSPECTION
99
}
1010

11+
override fun getStaticDescription(): String {
12+
return TemplateLintBundle.message("hbs.lint.inspection")
13+
}
14+
1115
override fun getSettingsPath(): List<String?> {
1216
return ContainerUtil.newArrayList(
1317
OptionsBundle.message("configurable.group.language.settings.display.name", *arrayOfNulls(0)),

0 commit comments

Comments
 (0)