Skip to content

Commit

Permalink
fix styles
Browse files Browse the repository at this point in the history
  • Loading branch information
Valerii committed Jan 15, 2024
1 parent 9d27f4a commit b90b68e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@ import com.intellij.openapi.actionSystem.CommonDataKeys
import com.intellij.openapi.command.WriteCommandAction
import org.jetbrains.academy.plugin.course.dev.access.sortMethods
import org.jetbrains.kotlin.psi.KtClass
import org.jetbrains.kotlin.psi.KtFile

class SortMethodsAction : AnAction() {
override fun actionPerformed(e: AnActionEvent) {
val project = e.project ?: return
val editor = e.getData(CommonDataKeys.EDITOR) ?: return
val psiFile = e.getData(CommonDataKeys.PSI_FILE) ?: return
val project = e.project
val editor = e.getData(CommonDataKeys.EDITOR)
val psiFile = e.getData(CommonDataKeys.PSI_FILE) as? KtFile

val caret = editor.caretModel.currentCaret
val element = psiFile.findElementAt(caret.offset) ?: return
if (project == null || editor == null || psiFile == null) return

val ktClass = element.parent as? KtClass ?: return
val caret = editor.caretModel.currentCaret
val element = psiFile.findElementAt(caret.offset)

// Call your method sorting function here
// sortMethodsInClass(ktClass)
val ktClass = element?.parent as? KtClass ?: return

WriteCommandAction.runWriteCommandAction(project) {
// Execute your sorting logic here
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ class Test : BasePlatformTestCase() {
""".trimIndent()
val file = myFixture.configureByText("Person.kt", fileContent)
sortMethods(file)

val classes = PsiTreeUtil.findChildrenOfType(file, KtClass::class.java)
for (ktClass in classes) {
val methods = ktClass.declarations.filterIsInstance<KtNamedFunction>()
Expand Down

0 comments on commit b90b68e

Please sign in to comment.