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 exceptions #530

Merged
merged 3 commits into from
Jul 5, 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
22 changes: 3 additions & 19 deletions src/main/kotlin/org/arend/codeInsight/ArendLineMarkerProvider.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,15 @@ import com.intellij.codeInsight.daemon.LineMarkerInfo
import com.intellij.codeInsight.daemon.LineMarkerProviderDescriptor
import com.intellij.codeInsight.daemon.impl.LineMarkerNavigator
import com.intellij.codeInsight.daemon.impl.MarkerType
import com.intellij.codeInsight.daemon.impl.PsiElementListNavigator
import com.intellij.codeInsight.navigation.BackgroundUpdaterTask
import com.intellij.codeInsight.navigation.PsiTargetNavigator
import com.intellij.icons.AllIcons
import com.intellij.ide.util.PsiElementListCellRenderer
import com.intellij.openapi.components.service
import com.intellij.openapi.editor.markup.GutterIconRenderer
import com.intellij.openapi.progress.ProgressManager
import com.intellij.psi.PsiElement
import org.arend.psi.ext.ArendDefClass
import org.arend.psi.ext.ArendDefIdentifier
import org.arend.psi.ext.ArendDefinition
import org.arend.search.ClassDescendantsSearch
import org.arend.util.FullName
import java.awt.event.MouseEvent

class ArendLineMarkerProvider: LineMarkerProviderDescriptor() {
Expand Down Expand Up @@ -45,20 +41,8 @@ class ArendLineMarkerProvider: LineMarkerProviderDescriptor() {
object : LineMarkerNavigator() {
override fun browse(e: MouseEvent, element: PsiElement) {
val clazz = element.parent.parent as? ArendDefClass ?: return
PsiElementListNavigator.openTargets(e, clazz.project.service<ClassDescendantsSearch>().getAllDescendants(clazz).toTypedArray(), "Subclasses of " + clazz.name,
CodeInsightBundle.message("goto.implementation.findUsages.title", clazz.refName), MyListCellRenderer, null as BackgroundUpdaterTask?)
PsiTargetNavigator(clazz.project.service<ClassDescendantsSearch>().getAllDescendants(clazz).toTypedArray()).navigate(e, "Subclasses of " + clazz.name, element.project)
}
})
}

private object MyListCellRenderer : PsiElementListCellRenderer<ArendDefinition<*>>() {
override fun getElementText(element: ArendDefinition<*>): String {
val fullName = FullName(element)
return fullName.longName.toString() + " in " + fullName.modulePath.toString()
}

override fun getContainerText(element: ArendDefinition<*>, name: String): String? = null

override fun getIconFlags() = 0
}
}
}
14 changes: 13 additions & 1 deletion src/main/kotlin/org/arend/highlight/BasePass.kt
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,19 @@ abstract class BasePass(protected open val file: IArendFile, editor: Editor, nam
return HighlightInfo.newHighlightInfo(type ?: levelToHighlightInfoType(error.level))
.range(range)
.severity(levelToSeverity(error.level))
.description(error.shortMessage)
.description(
run {
var message: String? = null
ApplicationManager.getApplication().run {
executeOnPooledThread {
runReadAction {
message = error.shortMessage
}
}.get()
}
message ?: ""
}
)
.escapedToolTip(XmlStringUtil.escapeString(DocStringBuilder.build(vHang(error.getShortHeaderDoc(ppConfig), error.getBodyDoc(ppConfig)))).replace("\n", "<br>"))
}

Expand Down
8 changes: 5 additions & 3 deletions src/main/kotlin/org/arend/typechecking/error/ErrorService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,11 @@ class ErrorService : ErrorReporter {
val arendErrors = typecheckingErrors[file] ?: return emptyList()

val list = ArrayList<Pair<GeneralError, PsiElement>>()
for (arendError in arendErrors) {
arendError.cause?.let {
list.add(Pair(arendError.error, it))
synchronized(arendErrors) {
for (arendError in arendErrors) {
arendError.cause?.let {
list.add(Pair(arendError.error, it))
}
}
}
return list
Expand Down
Loading