You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
67 lines
2.5 KiB
67 lines
2.5 KiB
package org.jetbrains.compose.intentions |
|
|
|
import com.intellij.codeInsight.intention.impl.IntentionActionGroup |
|
import com.intellij.openapi.editor.Editor |
|
import com.intellij.openapi.project.Project |
|
import com.intellij.openapi.ui.popup.ListPopup |
|
import com.intellij.openapi.ui.popup.PopupStep |
|
import com.intellij.openapi.ui.popup.util.BaseListPopupStep |
|
import com.intellij.psi.PsiFile |
|
import com.intellij.ui.popup.list.ListPopupImpl |
|
import org.jetbrains.compose.intentions.wrapActions.BaseWrapWithComposableAction |
|
import org.jetbrains.compose.intentions.wrapActions.WrapWithBoxIntention |
|
import org.jetbrains.compose.intentions.wrapActions.WrapWithCardIntention |
|
import org.jetbrains.compose.intentions.wrapActions.WrapWithColumnIntention |
|
import org.jetbrains.compose.intentions.wrapActions.WrapWithLzyColumnIntention |
|
import org.jetbrains.compose.intentions.wrapActions.WrapWithLzyRowIntention |
|
import org.jetbrains.compose.intentions.wrapActions.WrapWithRowIntention |
|
|
|
class WrapWithComposableIntentionGroup : |
|
IntentionActionGroup<BaseWrapWithComposableAction>( |
|
listOf( |
|
WrapWithBoxIntention(), |
|
WrapWithCardIntention(), |
|
WrapWithColumnIntention(), |
|
WrapWithRowIntention(), |
|
WrapWithLzyColumnIntention(), |
|
WrapWithLzyRowIntention() |
|
) |
|
) { |
|
|
|
private fun createPopup( |
|
project: Project, |
|
actions: List<BaseWrapWithComposableAction>, |
|
invokeAction: (BaseWrapWithComposableAction) -> Unit |
|
): ListPopup { |
|
|
|
val step = object : BaseListPopupStep<BaseWrapWithComposableAction>(null, actions) { |
|
|
|
override fun getTextFor(action: BaseWrapWithComposableAction) = action.text |
|
|
|
override fun onChosen(selectedValue: BaseWrapWithComposableAction, finalChoice: Boolean): PopupStep<*>? { |
|
invokeAction(selectedValue) |
|
return FINAL_CHOICE |
|
} |
|
} |
|
|
|
return ListPopupImpl(project, step) |
|
} |
|
|
|
override fun getFamilyName(): String { |
|
return "Compose Multiplatform intentions" |
|
} |
|
|
|
override fun chooseAction( |
|
project: Project, |
|
editor: Editor, |
|
file: PsiFile, |
|
actions: List<BaseWrapWithComposableAction>, |
|
invokeAction: (BaseWrapWithComposableAction) -> Unit |
|
) { |
|
createPopup(project, actions, invokeAction).showInBestPositionFor(editor) |
|
} |
|
|
|
override fun getGroupText(actions: List<BaseWrapWithComposableAction>): String { |
|
return "Wrap with Composable" |
|
} |
|
}
|
|
|