Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tracer #521

Merged
merged 2 commits into from
Jun 21, 2024
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
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 @@ -122,16 +122,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
Loading