Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import com.intellij.openapi.actionSystem.impl.ActionButton
import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.application.ModalityState
import com.intellij.openapi.application.ReadAction
import com.intellij.openapi.application.runReadAction
import com.intellij.openapi.project.Project
import com.intellij.openapi.ui.SimpleToolWindowPanel
import com.intellij.psi.PsiElement
Expand Down Expand Up @@ -149,7 +148,11 @@ class EndpointsToolWindow(private val project: Project) :

private fun navigation(closestPathForLocation: TreePath?) {
val lastUserObject = TreeUtil.getLastUserObject(closestPathForLocation)
runReadAction { (lastUserObject as? EndpointNavigable)?.navigate() }
val navigable = (lastUserObject as? EndpointNavigable) ?: return
// Schedule navigation on the EDT: invokeLater runs the action under a
// write-intent read action, which is required since 253 to open a file
// editor and at the same time covers PSI read access inside navigate().
ApplicationManager.getApplication().invokeLater { navigable.navigate() }
}

private fun createRefreshButton(): JComponent {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,15 @@
package com.explyt.spring.web.view.nodes

interface EndpointNavigable {
/**
* Performs navigation to the underlying PSI element.
*
* Implementations access PSI and open a file editor, both of which require
* the EDT under a write-intent read action. Callers must invoke this from
* the EDT (e.g. via [com.intellij.openapi.application.Application.invokeLater]),
* not from a plain read action — opening an editor cannot be performed
* from inside a `ReadAction` ("WriteIntentReadAction can not be called
* from ReadAction", since 253).
*/
fun navigate()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,4 @@ class HttpMethodNode(
override fun navigate() {
(httpElement.psiPointer.element?.navigationElement as? Navigatable)?.navigate(true)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ class SpringBootClassNode(
override fun navigate() {
(viewData?.psiPointer?.element?.navigationElement as? Navigatable)?.navigate(true)
}
}
}
Loading