Skip to content

Commit 0f37301

Browse files
committed
fix(ContextVariableResolver): handle potential exception when accessing containing file #379
1 parent 4d06fe5 commit 0f37301

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

exts/devins-lang/src/main/kotlin/cc/unitmesh/devti/language/ast/variable/resolver/ContextVariableResolver.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,12 @@ class ContextVariableResolver(
1515
fun all(): List<ContextVariable> = entries
1616

1717
override suspend fun resolve(initVariables: Map<String, Any>): Map<String, String> = ReadAction.compute<Map<String, String>, Throwable> {
18-
val file = context.element?.containingFile
18+
val file = try {
19+
context.element?.containingFile
20+
} catch (e: Exception) {
21+
null
22+
}
23+
1924
val caretModel = context.editor.caretModel
2025

2126
all().associate { variable ->

0 commit comments

Comments
 (0)