Skip to content

Commit

Permalink
Fix SlowOperations related to ArendProofSearch
Browse files Browse the repository at this point in the history
  • Loading branch information
alex999990009 committed Jun 19, 2024
1 parent 7229594 commit 3a64f02
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
13 changes: 12 additions & 1 deletion src/main/kotlin/org/arend/navigation/Utils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ package org.arend.navigation

import com.intellij.ide.projectView.PresentationData
import com.intellij.navigation.ItemPresentation
import com.intellij.openapi.application.ApplicationManager
import com.intellij.psi.PsiElement
import org.arend.psi.ArendFile
import org.arend.psi.ext.ArendCompositeElement
import org.arend.psi.ext.PsiReferable
import javax.swing.Icon

fun getPresentation(psi: ArendCompositeElement): ItemPresentation {
val location = run {
Expand All @@ -14,7 +16,16 @@ fun getPresentation(psi: ArendCompositeElement): ItemPresentation {
}

val name = presentableName(psi)
return PresentationData(name, location, psi.getIcon(0), null)
var icon: Icon? = null
ApplicationManager.getApplication().run {
executeOnPooledThread {
runReadAction {
icon = psi.getIcon(0)
}
}.get()
}

return PresentationData(name, location, icon, null)
}

fun getPresentationForStructure(psi: ArendCompositeElement): ItemPresentation =
Expand Down
14 changes: 13 additions & 1 deletion src/main/kotlin/org/arend/search/proof/ProofSearchUtils.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.arend.search.proof

import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.application.runReadAction
import com.intellij.openapi.components.service
import com.intellij.openapi.project.DumbService
Expand Down Expand Up @@ -258,7 +259,18 @@ class ProofSearchUISettings(private val project: Project) {
}

fun getCompleteModuleLocation(def: ReferableBase<*>): String? {
val file = def.location?.toString() ?: return null
var file: String? = null
ApplicationManager.getApplication().run {
executeOnPooledThread {
runReadAction {
file = def.location?.toString()
}
}.get()
}
if (file == null) {
return null
}

val module = def.parentsOfType<ArendGroup>(false).toList().reversed().drop(1).map { it.name }
return (listOf(file) + module).joinToString(".")
}

0 comments on commit 3a64f02

Please sign in to comment.