Skip to content

Commit

Permalink
Merge pull request #521 from alex999990009/alex99999/fixes
Browse files Browse the repository at this point in the history
Fix tracer
  • Loading branch information
sxhya authored Jun 21, 2024
2 parents 6ff0213 + e0b7c1e commit 09f2b9e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
4 changes: 3 additions & 1 deletion src/main/kotlin/org/arend/tracer/ArendSuspendContext.kt
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ class ArendSuspendContext(traceEntry: ArendTraceEntry, contextView: ArendTraceCo
}
}
val psiElement = getSourcePositionElement(traceEntry)
val psiText = psiElement?.text?.let(::shorten) ?: ArendBundle.message("arend.tracer.unknown.expression")
val psiText = runReadAction {
psiElement?.text?.let(::shorten) ?: ArendBundle.message("arend.tracer.unknown.expression")
}
component.append(psiText, SimpleTextAttributes.REGULAR_ATTRIBUTES)
setPositionText(component, positionComponents())
}
Expand Down
24 changes: 16 additions & 8 deletions src/main/kotlin/org/arend/tracer/ArendTraceAction.kt
Original file line number Diff line number Diff line change
Expand Up @@ -123,16 +123,24 @@ class ArendTraceAction : ArendPopupAction() {
is ArendDefData -> {
val body = def.dataBody ?: return null
val constructors = body.constructorList
val constructor = constructors.firstOrNull()
?: body.constructorClauseList.find { it.constructors.isNotEmpty() }?.constructors?.firstOrNull()
constructor?.parameters?.firstOrNull()?.typedExpr?.type
val constructor = constructors.find {
it.parameters.isNotEmpty()
} ?: body.constructorClauseList.find {
it.constructors.any { constructor -> constructor.parameters.isNotEmpty() }
}?.constructors?.find {
it.parameters.isNotEmpty()
}
constructor?.parameters?.firstOrNull()?.type
}
is ArendDefClass -> {
val classStat = def.classStatList.firstOrNull() ?: return null
classStat.classField?.returnExpr?.type
?: classStat.classImplement?.expr
?: classStat.coClause?.expr
?: classStat.overriddenField?.returnExpr?.type
val classStat = def.classStatList.firstOrNull()
classStat?.classField?.returnExpr?.type
?: classStat?.classImplement?.expr?.type
?: classStat?.coClause?.expr?.type
?: classStat?.overriddenField?.returnExpr?.type
?: def.classFieldList.firstOrNull()?.returnExpr?.type
?: def.classImplementList.firstOrNull()?.expr?.type
?: def.fieldTeleList.firstOrNull()?.type
}
else -> return null
} ?: return null
Expand Down

0 comments on commit 09f2b9e

Please sign in to comment.