Skip to content

Frontend/Intentions/FSI: fix threading and language warnings #520

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

Open
wants to merge 3 commits into
base: net232
Choose a base branch
from
Open
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 @@ -10,7 +10,6 @@ import com.intellij.openapi.util.Iconable
import com.intellij.openapi.util.SystemInfo
import com.intellij.psi.PsiElement
import com.jetbrains.rd.platform.util.getComponent
import com.jetbrains.rider.ideaInterop.fileTypes.fsharp.FSharpLanguageBase
import icons.ReSharperIcons
import javax.swing.Icon

Expand Down Expand Up @@ -41,6 +40,8 @@ open class SendToFsiActionBase(
private val sendSelectionText: String
) : AnAction(), DumbAware {

override fun getActionUpdateThread() = ActionUpdateThread.BGT

override fun actionPerformed(e: AnActionEvent) {
val editor = CommonDataKeys.EDITOR.getData(e.dataContext)!!
val file = CommonDataKeys.PSI_FILE.getData(e.dataContext)!!
Expand All @@ -55,9 +56,9 @@ open class SendToFsiActionBase(
e.presentation.isVisible = false
return
}
val file = CommonDataKeys.PSI_FILE.getData(e.dataContext)
CommonDataKeys.PSI_FILE.getData(e.dataContext)
val editor = CommonDataKeys.EDITOR.getData(e.dataContext)
if (file?.language !is FSharpLanguageBase || editor?.caretModel?.caretCount != 1) {
if (editor?.caretModel?.caretCount != 1) {
e.presentation.isEnabled = false
return
}
Expand Down Expand Up @@ -99,7 +100,7 @@ abstract class BaseSendToFsiIntentionAction(private val debug: Boolean, private
override fun startInWriteAction() = false

override fun isAvailable(project: Project, editor: Editor?, file: PsiElement) =
isAvailable && file.language is FSharpLanguageBase && editor?.caretModel?.caretCount == 1
isAvailable && editor?.caretModel?.caretCount == 1

override fun invoke(project: Project, editor: Editor, element: PsiElement) {
project.getComponent<FsiHost>().sendToFsi(editor, element.containingFile, debug)
Expand Down
4 changes: 4 additions & 0 deletions rider-fsharp/src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,24 +62,28 @@
<intentionAction>
<className>com.jetbrains.rider.plugins.fsharp.services.fsi.SendLineToFsiIntentionAction</className>
<category>F#</category>
<language>F#</language>
<descriptionDirectoryName>SendToFsi</descriptionDirectoryName>
</intentionAction>

<intentionAction>
<className>com.jetbrains.rider.plugins.fsharp.services.fsi.SendSelectionToFsiIntentionAction</className>
<category>F#</category>
<language>F#</language>
<descriptionDirectoryName>SendToFsi</descriptionDirectoryName>
</intentionAction>

<intentionAction>
<className>com.jetbrains.rider.plugins.fsharp.services.fsi.DebugLineInFsiIntentionAction</className>
<category>F#</category>
<language>F#</language>
<descriptionDirectoryName>SendToFsi</descriptionDirectoryName>
</intentionAction>

<intentionAction>
<className>com.jetbrains.rider.plugins.fsharp.services.fsi.DebugSelectionInFsiIntentionAction</className>
<category>F#</category>
<language>F#</language>
<descriptionDirectoryName>SendToFsi</descriptionDirectoryName>
</intentionAction>

Expand Down