diff --git a/idea-plugin/src/main/kotlin/org/jetbrains/compose/intentions/remove_composable/RemoveComposableIntention.kt b/idea-plugin/src/main/kotlin/org/jetbrains/compose/intentions/remove_composable/RemoveComposableIntention.kt index 137613c87e..83db63ef06 100644 --- a/idea-plugin/src/main/kotlin/org/jetbrains/compose/intentions/remove_composable/RemoveComposableIntention.kt +++ b/idea-plugin/src/main/kotlin/org/jetbrains/compose/intentions/remove_composable/RemoveComposableIntention.kt @@ -6,12 +6,12 @@ import com.intellij.openapi.editor.Editor import com.intellij.openapi.project.Project import com.intellij.openapi.util.Iconable import com.intellij.psi.PsiElement -import javax.swing.Icon import org.jetbrains.compose.desktop.ide.preview.PreviewIcons -import org.jetbrains.compose.intentions.utils.is_intention_available.IsIntentionAvailable import org.jetbrains.compose.intentions.utils.composable_finder.ComposableFunctionFinder import org.jetbrains.compose.intentions.utils.composable_finder.DeepComposableFunctionFinder import org.jetbrains.compose.intentions.utils.get_root_element.GetRootElement +import org.jetbrains.compose.intentions.utils.is_intention_available.IsIntentionAvailable +import javax.swing.Icon class RemoveComposableIntention : PsiElementBaseIntentionAction(), Iconable, LowPriorityAction, IsIntentionAvailable { @@ -36,5 +36,4 @@ class RemoveComposableIntention : PsiElementBaseIntentionAction(), Iconable, Low } override fun getIcon(flags: Int): Icon = PreviewIcons.COMPOSE - } diff --git a/idea-plugin/src/main/kotlin/org/jetbrains/compose/intentions/remove_parent_composable/RemoveParentComposableIntention.kt b/idea-plugin/src/main/kotlin/org/jetbrains/compose/intentions/remove_parent_composable/RemoveParentComposableIntention.kt index eed5e7a926..64575e6a5b 100644 --- a/idea-plugin/src/main/kotlin/org/jetbrains/compose/intentions/remove_parent_composable/RemoveParentComposableIntention.kt +++ b/idea-plugin/src/main/kotlin/org/jetbrains/compose/intentions/remove_parent_composable/RemoveParentComposableIntention.kt @@ -7,16 +7,17 @@ import com.intellij.openapi.project.Project import com.intellij.openapi.util.Iconable import com.intellij.psi.PsiElement import com.intellij.psi.util.parentOfType -import javax.swing.Icon import org.jetbrains.compose.desktop.ide.preview.PreviewIcons -import org.jetbrains.compose.intentions.utils.is_intention_available.IsIntentionAvailable import org.jetbrains.compose.intentions.utils.composable_finder.ComposableFunctionFinder import org.jetbrains.compose.intentions.utils.composable_finder.NestedComposableFinder +import org.jetbrains.compose.intentions.utils.is_intention_available.IsIntentionAvailable import org.jetbrains.kotlin.psi.KtCallExpression import org.jetbrains.kotlin.psi.KtNameReferenceExpression import org.jetbrains.kotlin.psi.KtValueArgumentList +import javax.swing.Icon -class RemoveParentComposableIntention : PsiElementBaseIntentionAction(), +class RemoveParentComposableIntention : + PsiElementBaseIntentionAction(), Iconable, PriorityAction, IsIntentionAvailable { diff --git a/idea-plugin/src/main/kotlin/org/jetbrains/compose/intentions/utils/composable_finder/DeepComposableFunctionFinder.kt b/idea-plugin/src/main/kotlin/org/jetbrains/compose/intentions/utils/composable_finder/DeepComposableFunctionFinder.kt index f130acd35a..d953a893bc 100644 --- a/idea-plugin/src/main/kotlin/org/jetbrains/compose/intentions/utils/composable_finder/DeepComposableFunctionFinder.kt +++ b/idea-plugin/src/main/kotlin/org/jetbrains/compose/intentions/utils/composable_finder/DeepComposableFunctionFinder.kt @@ -24,7 +24,6 @@ class DeepComposableFunctionFinder : ComposableFunctionFinder, IsPsiElementCompo } } - /** * To handle both property and property delegates */ diff --git a/idea-plugin/src/main/kotlin/org/jetbrains/compose/intentions/utils/composable_finder/NestedComposableFinder.kt b/idea-plugin/src/main/kotlin/org/jetbrains/compose/intentions/utils/composable_finder/NestedComposableFinder.kt index 7b50cd79ec..f83044c9b1 100644 --- a/idea-plugin/src/main/kotlin/org/jetbrains/compose/intentions/utils/composable_finder/NestedComposableFinder.kt +++ b/idea-plugin/src/main/kotlin/org/jetbrains/compose/intentions/utils/composable_finder/NestedComposableFinder.kt @@ -6,7 +6,6 @@ import org.jetbrains.kotlin.psi.KtCallExpression import org.jetbrains.kotlin.psi.KtLambdaArgument import org.jetbrains.kotlin.psi.psiUtil.getChildOfType - class NestedComposableFinder : ComposableFunctionFinder, IsPsiElementComposable { override fun isFunctionComposable(psiElement: PsiElement): Boolean { diff --git a/idea-plugin/src/main/kotlin/org/jetbrains/compose/intentions/utils/get_root_element/GetRootElement.kt b/idea-plugin/src/main/kotlin/org/jetbrains/compose/intentions/utils/get_root_element/GetRootElement.kt index a4d5087c76..7cab9a14bc 100644 --- a/idea-plugin/src/main/kotlin/org/jetbrains/compose/intentions/utils/get_root_element/GetRootElement.kt +++ b/idea-plugin/src/main/kotlin/org/jetbrains/compose/intentions/utils/get_root_element/GetRootElement.kt @@ -1,7 +1,12 @@ package org.jetbrains.compose.intentions.utils.get_root_element import com.intellij.psi.PsiElement -import org.jetbrains.kotlin.psi.* +import org.jetbrains.kotlin.psi.KtCallExpression +import org.jetbrains.kotlin.psi.KtDotQualifiedExpression +import org.jetbrains.kotlin.psi.KtNameReferenceExpression +import org.jetbrains.kotlin.psi.KtProperty +import org.jetbrains.kotlin.psi.KtPropertyDelegate +import org.jetbrains.kotlin.psi.KtValueArgumentList /** * KtValueArgumentList -> Parent -> KtNameReferenceExpression -> Parent -> KtCallExpression -> Parent -> KtPropertyDelegate -> Parent -> Property @@ -28,8 +33,8 @@ class GetRootElement { is KtCallExpression -> { when (element.parent) { is KtProperty, - is KtDotQualifiedExpression -> invoke(element.parent, iteration + 1) //composable dot expression - is KtPropertyDelegate -> invoke(element.parent.parent, iteration + 1) //composable dot expression + is KtDotQualifiedExpression -> invoke(element.parent, iteration + 1) // composable dot expression + is KtPropertyDelegate -> invoke(element.parent.parent, iteration + 1) // composable dot expression else -> element } } diff --git a/idea-plugin/src/main/kotlin/org/jetbrains/compose/intentions/utils/is_intention_available/IsIntentionAvailable.kt b/idea-plugin/src/main/kotlin/org/jetbrains/compose/intentions/utils/is_intention_available/IsIntentionAvailable.kt index ac3dca4005..30d1d8a9b9 100644 --- a/idea-plugin/src/main/kotlin/org/jetbrains/compose/intentions/utils/is_intention_available/IsIntentionAvailable.kt +++ b/idea-plugin/src/main/kotlin/org/jetbrains/compose/intentions/utils/is_intention_available/IsIntentionAvailable.kt @@ -21,5 +21,4 @@ interface IsIntentionAvailable { composableFunctionFinder.isFunctionComposable(parentPsiElement) } ?: false } - -} \ No newline at end of file +} diff --git a/idea-plugin/src/main/kotlin/org/jetbrains/compose/intentions/utils/is_psi_element_composable/IsPsiElementComposable.kt b/idea-plugin/src/main/kotlin/org/jetbrains/compose/intentions/utils/is_psi_element_composable/IsPsiElementComposable.kt index f5334eb9ee..701be8cde3 100644 --- a/idea-plugin/src/main/kotlin/org/jetbrains/compose/intentions/utils/is_psi_element_composable/IsPsiElementComposable.kt +++ b/idea-plugin/src/main/kotlin/org/jetbrains/compose/intentions/utils/is_psi_element_composable/IsPsiElementComposable.kt @@ -17,5 +17,4 @@ interface IsPsiElementComposable { val ktNamedFunction = resolve() as? KtNamedFunction ?: return false return ktNamedFunction.isComposableFunction() } - -} \ No newline at end of file +} diff --git a/idea-plugin/src/main/kotlin/org/jetbrains/compose/intentions/wrap_with_composable/WrapWithComposableIntentionGroup.kt b/idea-plugin/src/main/kotlin/org/jetbrains/compose/intentions/wrap_with_composable/WrapWithComposableIntentionGroup.kt index 9f852974cb..7629b27e58 100644 --- a/idea-plugin/src/main/kotlin/org/jetbrains/compose/intentions/wrap_with_composable/WrapWithComposableIntentionGroup.kt +++ b/idea-plugin/src/main/kotlin/org/jetbrains/compose/intentions/wrap_with_composable/WrapWithComposableIntentionGroup.kt @@ -9,7 +9,6 @@ import com.intellij.openapi.ui.popup.util.BaseListPopupStep import com.intellij.openapi.util.Iconable import com.intellij.psi.PsiFile import com.intellij.ui.popup.list.ListPopupImpl -import javax.swing.Icon import org.jetbrains.compose.desktop.ide.preview.PreviewIcons import org.jetbrains.compose.intentions.wrap_with_composable.wrap_with_actions.BaseWrapWithComposableAction import org.jetbrains.compose.intentions.wrap_with_composable.wrap_with_actions.WrapWithBoxIntention @@ -18,6 +17,7 @@ import org.jetbrains.compose.intentions.wrap_with_composable.wrap_with_actions.W import org.jetbrains.compose.intentions.wrap_with_composable.wrap_with_actions.WrapWithLzyColumnIntention import org.jetbrains.compose.intentions.wrap_with_composable.wrap_with_actions.WrapWithLzyRowIntention import org.jetbrains.compose.intentions.wrap_with_composable.wrap_with_actions.WrapWithRowIntention +import javax.swing.Icon class WrapWithComposableIntentionGroup : IntentionActionGroup( @@ -29,7 +29,8 @@ class WrapWithComposableIntentionGroup : WrapWithLzyColumnIntention(), WrapWithLzyRowIntention() ) - ), Iconable { + ), + Iconable { private fun createPopup( project: Project, diff --git a/idea-plugin/src/main/kotlin/org/jetbrains/compose/intentions/wrap_with_composable/wrap_with_actions/BaseWrapWithComposableAction.kt b/idea-plugin/src/main/kotlin/org/jetbrains/compose/intentions/wrap_with_composable/wrap_with_actions/BaseWrapWithComposableAction.kt index 5f1f57e551..32cb662134 100644 --- a/idea-plugin/src/main/kotlin/org/jetbrains/compose/intentions/wrap_with_composable/wrap_with_actions/BaseWrapWithComposableAction.kt +++ b/idea-plugin/src/main/kotlin/org/jetbrains/compose/intentions/wrap_with_composable/wrap_with_actions/BaseWrapWithComposableAction.kt @@ -7,12 +7,13 @@ import com.intellij.codeInsight.template.impl.TemplateImpl import com.intellij.openapi.editor.Editor import com.intellij.openapi.project.Project import com.intellij.psi.PsiElement -import org.jetbrains.compose.intentions.utils.is_intention_available.IsIntentionAvailable import org.jetbrains.compose.intentions.utils.composable_finder.ComposableFunctionFinder import org.jetbrains.compose.intentions.utils.composable_finder.DeepComposableFunctionFinder import org.jetbrains.compose.intentions.utils.get_root_element.GetRootElement +import org.jetbrains.compose.intentions.utils.is_intention_available.IsIntentionAvailable -abstract class BaseWrapWithComposableAction : PsiElementBaseIntentionAction(), +abstract class BaseWrapWithComposableAction : + PsiElementBaseIntentionAction(), HighPriorityAction, IsIntentionAvailable { @@ -50,5 +51,4 @@ abstract class BaseWrapWithComposableAction : PsiElementBaseIntentionAction(), } protected abstract fun getTemplate(): TemplateImpl? - } diff --git a/idea-plugin/src/test/kotlin/org/jetbrains/compose/intentions/utils/get_root_element/GetRootElementTest.kt b/idea-plugin/src/test/kotlin/org/jetbrains/compose/intentions/utils/get_root_element/GetRootElementTest.kt index 3ef4d9fab8..ed06054cc0 100644 --- a/idea-plugin/src/test/kotlin/org/jetbrains/compose/intentions/utils/get_root_element/GetRootElementTest.kt +++ b/idea-plugin/src/test/kotlin/org/jetbrains/compose/intentions/utils/get_root_element/GetRootElementTest.kt @@ -14,7 +14,6 @@ import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.JUnit4 - @RunWith(JUnit4::class) class GetRootElementTest : LightJavaCodeInsightFixtureTestCase() { @@ -27,7 +26,7 @@ class GetRootElementTest : LightJavaCodeInsightFixtureTestCase() { @Language("Kotlin") val template = """ val systemUiController = rememberSystemUiController() - """.trimIndent() + """.trimIndent() .trim() val file = ktPsiFactory.createFile(template) @@ -39,7 +38,6 @@ class GetRootElementTest : LightJavaCodeInsightFixtureTestCase() { TestCase.assertEquals(property, getRootElement(ktNameReferenceExpression)) } - @Test fun `when a name reference expression is selected, with a call expression as root, call expression should be returned`() { val ktPsiFactory = KtPsiFactory(project) @@ -59,7 +57,7 @@ class GetRootElementTest : LightJavaCodeInsightFixtureTestCase() { } } - """.trimIndent().trim() + """.trimIndent().trim() val file = ktPsiFactory.createFile(template) @@ -73,7 +71,6 @@ class GetRootElementTest : LightJavaCodeInsightFixtureTestCase() { ) } - @Test fun `when an argument list element is selected, with a call expression as root, call expression should be returned`() { val ktPsiFactory = KtPsiFactory(project) @@ -93,7 +90,7 @@ class GetRootElementTest : LightJavaCodeInsightFixtureTestCase() { } // Name Reference Expression } - """.trimIndent().trim() + """.trimIndent().trim() val file = ktPsiFactory.createFile(template) @@ -109,7 +106,6 @@ class GetRootElementTest : LightJavaCodeInsightFixtureTestCase() { ) } - @Test fun `when a name reference expression is selected, with a delegated property as root, property should be returned`() { val ktPsiFactory = KtPsiFactory(project) @@ -122,7 +118,7 @@ class GetRootElementTest : LightJavaCodeInsightFixtureTestCase() { var isComposable by remember { true } - """.trimIndent().trim() + """.trimIndent().trim() val file = ktPsiFactory.createFile(template) @@ -158,7 +154,7 @@ class GetRootElementTest : LightJavaCodeInsightFixtureTestCase() { ) ) ) - """.trimIndent().trim() + """.trimIndent().trim() val file = ktPsiFactory.createFile(template) @@ -174,7 +170,6 @@ class GetRootElementTest : LightJavaCodeInsightFixtureTestCase() { ) } - @Test fun `when a name reference expression is selected, with a property and dot qualified expression as root, property should be returned`() { val ktPsiFactory = KtPsiFactory(project) @@ -197,7 +192,7 @@ class GetRootElementTest : LightJavaCodeInsightFixtureTestCase() { ) ) ) - """.trimIndent().trim() + """.trimIndent().trim() val file = ktPsiFactory.createFile(template) @@ -212,5 +207,4 @@ class GetRootElementTest : LightJavaCodeInsightFixtureTestCase() { getRootElement(referenceExpression) ) } - }