Skip to content

Commit a6c98c2

Browse files
committed
报错 java.lang.Throwable: Don't call commitAndRunReadAction inside ReadAction, it will cause a deadlock.
1 parent 421b231 commit a6c98c2

1 file changed

Lines changed: 20 additions & 22 deletions

File tree

src/main/java/com/tang/intellij/lua/debugger/LuaDebuggerEvaluator.kt

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -34,33 +34,31 @@ import com.tang.intellij.lua.psi.*
3434
abstract class LuaDebuggerEvaluator : XDebuggerEvaluator() {
3535
override fun getExpressionRangeAtOffset(project: Project, document: Document, offset: Int, sideEffectsAllowed: Boolean): TextRange? {
3636
var currentRange: TextRange? = null
37-
PsiDocumentManager.getInstance(project).commitAndRunReadAction {
38-
try {
39-
val file = PsiDocumentManager.getInstance(project).getPsiFile(document) ?: return@commitAndRunReadAction
40-
if (currentRange == null) {
41-
val ele = file.findElementAt(offset)
42-
if (ele != null && ele.node.elementType == LuaTypes.ID) {
43-
val parent = ele.parent
44-
when (parent) {
45-
is LuaFuncDef,
46-
is LuaLocalFuncDef -> currentRange = ele.textRange
47-
is LuaClassMethodName,
48-
is PsiNameIdentifierOwner -> currentRange = parent.textRange
49-
}
37+
try {
38+
val file = PsiDocumentManager.getInstance(project).getPsiFile(document) ?: return null
39+
if (currentRange == null) {
40+
val ele = file.findElementAt(offset)
41+
if (ele != null && ele.node.elementType == LuaTypes.ID) {
42+
val parent = ele.parent
43+
when (parent) {
44+
is LuaFuncDef,
45+
is LuaLocalFuncDef -> currentRange = ele.textRange
46+
is LuaClassMethodName,
47+
is PsiNameIdentifierOwner -> currentRange = parent.textRange
5048
}
5149
}
50+
}
5251

53-
if (currentRange == null) {
54-
val expr = PsiTreeUtil.findElementOfClassAtOffset(file, offset, LuaExpr::class.java, false)
55-
currentRange = when (expr) {
56-
is LuaCallExpr,
57-
is LuaClosureExpr,
58-
is LuaLiteralExpr -> null
59-
else -> expr?.textRange
60-
}
52+
if (currentRange == null) {
53+
val expr = PsiTreeUtil.findElementOfClassAtOffset(file, offset, LuaExpr::class.java, false)
54+
currentRange = when (expr) {
55+
is LuaCallExpr,
56+
is LuaClosureExpr,
57+
is LuaLiteralExpr -> null
58+
else -> expr?.textRange
6159
}
62-
} catch (ignored: IndexNotReadyException) {
6360
}
61+
} catch (ignored: IndexNotReadyException) {
6462
}
6563
return currentRange
6664
}

0 commit comments

Comments
 (0)