[IFT] Update Extract Method lesson for Java

(cherry picked from commit f70f2f6e758d6faec898b1e72e137ad9217d5edc)

IDEA-CR-70585

GitOrigin-RevId: 5b7421e78f4439033d642990cc400622b22f3c58
This commit is contained in:
Konstantin Hudyakov
2021-02-19 21:02:10 +03:00
committed by intellij-monorepo-bot
parent ee061b376c
commit 5ec67dd859
2 changed files with 13 additions and 18 deletions

View File

@@ -43,6 +43,8 @@ java.refactoring.menu.introduce.constant=Finally, let''s extract an extension fr
java.refactoring.menu.confirm.constant=In this dialog, you can choose the new constant\u2019s type, name, parent class and visibility. \
You can leave the defaults and press {0} or click {1}.
java.extract.method.edit.method.name=Edit the name of the new method or leave the one that IDE proposed. Then press {0}.
java.inheritance.hierarchy.lesson.name=Inheritance hierarchy
java.inheritance.hierarchy.goto.implementation=Press {0} to look for implementations of {1}.
java.inheritance.hierarchy.choose.any.implementation=Choose any implementation and press {0} or click it.

View File

@@ -1,12 +1,14 @@
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.java.ift.lesson.refactorings
import com.intellij.codeInsight.template.impl.TemplateManagerImpl
import com.intellij.java.ift.JavaLessonsBundle
import com.intellij.java.refactoring.JavaRefactoringBundle
import com.intellij.refactoring.RefactoringBundle
import com.intellij.refactoring.extractMethod.ExtractMethodHandler
import com.intellij.ui.UIBundle
import training.dsl.LessonContext
import training.dsl.LessonUtil.rawEnter
import training.dsl.LessonUtil.restoreIfModifiedOrMoved
import training.dsl.defaultRestoreDelay
import training.dsl.dropMnemonic
import training.dsl.parseLessonSample
import training.learn.LessonsBundle
@@ -23,30 +25,21 @@ class JavaExtractMethodCocktailSortLesson
restoreIfModifiedOrMoved()
LessonsBundle.message("extract.method.invoke.action", action(it))
}
// Now will be open the first dialog
val processDuplicatesTitle = JavaRefactoringBundle.message("process.duplicates.title")
task {
val refactorButtonText = RefactoringBundle.message("refactor.button").dropMnemonic()
text(LessonsBundle.message("extract.method.start.refactoring", strong(refactorButtonText)))
text(JavaLessonsBundle.message("java.extract.method.edit.method.name", rawEnter()))
// Wait until the second dialog
triggerByUiComponentAndHighlight(highlightBorder = false, highlightInside = false) { dialog : JDialog ->
triggerByUiComponentAndHighlight(highlightBorder = false, highlightInside = false) { dialog: JDialog ->
dialog.title == processDuplicatesTitle
}
var needRestore = false
restoreState {
val insideDialog = Thread.currentThread().stackTrace.any {
it.className.contains(ExtractMethodHandler::class.simpleName!!)
}
(needRestore && !insideDialog).also { needRestore = insideDialog }
restoreState(delayMillis = defaultRestoreDelay) {
TemplateManagerImpl.getTemplateState(editor) == null
}
test {
dialog(RefactoringBundle.message("extract.method.title")) {
button(refactorButtonText).click()
}
test(waitEditorToBeReady = false) {
invokeActionViaShortcut("ENTER")
}
}
@@ -58,7 +51,7 @@ class JavaExtractMethodCocktailSortLesson
previous.ui?.isShowing?.not() ?: true
}
test {
test(waitEditorToBeReady = false) {
dialog(processDuplicatesTitle) {
button(replaceButtonText).click()
}