[IFT] Refactor: do not pass non-action ID string in task method that expects an action ID

GitOrigin-RevId: 9530411f521527cc78ded6d98b659e8b6522749e
This commit is contained in:
Konstantin Hudyakov
2025-01-13 17:07:25 +02:00
committed by intellij-monorepo-bot
parent 61701d5f62
commit c015b73c0d
7 changed files with 49 additions and 41 deletions

View File

@@ -75,8 +75,9 @@ class GotoActionLesson(private val sample: LessonSample,
}
val showLineNumbersName = ActionsBundle.message("action.EditorGutterToggleGlobalLineNumbers.text")
task(LearnBundle.message("show.line.number.prefix.to.show.first")) {
text(LessonsBundle.message("goto.action.show.line.numbers.request", strong(it), strong(showLineNumbersName)))
task {
val prefix = LearnBundle.message("show.line.number.prefix.to.show.first")
text(LessonsBundle.message("goto.action.show.line.numbers.request", strong(prefix), strong(showLineNumbersName)))
triggerAndBorderHighlight().listItem { item ->
val matchedValue = item as? GotoActionModel.MatchedValue
val actionWrapper = matchedValue?.value as? GotoActionModel.ActionWrapper
@@ -86,7 +87,7 @@ class GotoActionLesson(private val sample: LessonSample,
restoreState { !checkInsideSearchEverywhere() }
test {
waitComponent(SearchEverywhereUI::class.java)
type(it)
type(prefix)
}
}

View File

@@ -32,15 +32,15 @@ abstract class FileStructureLesson
actionTask("FileStructurePopup") {
LessonsBundle.message("file.structure.open.popup", action(it))
}
task(searchSubstring) {
task {
text(LessonsBundle.message("file.structure.request.prefixes", strong(firstWord), strong(secondWord), code(searchSubstring)))
stateCheck { checkWordInSearch(it) }
stateCheck { checkWordInSearch(searchSubstring) }
restoreAfterStateBecomeFalse { focusOwner is EditorComponentImpl }
test {
ideFrame {
waitComponent(DnDAwareTree::class.java, "FileStructurePopup")
}
type(it)
type(searchSubstring)
}
}
task {

View File

@@ -57,11 +57,12 @@ open class FindInFilesLesson(override val sampleFilePath: String,
}
}
task("apple") {
text(LessonsBundle.message("find.in.files.type.to.find", code(it)))
stateCheck { getFindPopup()?.stringToFind?.lowercase(Locale.getDefault()) == it }
task {
val appleText = "apple"
text(LessonsBundle.message("find.in.files.type.to.find", code(appleText)))
stateCheck { getFindPopup()?.stringToFind?.lowercase(Locale.getDefault()) == appleText }
restoreByUi()
test { type(it) }
test { type(appleText) }
}
task {
@@ -137,15 +138,16 @@ open class FindInFilesLesson(override val sampleFilePath: String,
test { actions(it) }
}
task("orange") {
task {
val orangeText = "orange"
text(LessonsBundle.message("find.in.files.type.to.replace",
code("apple"), code(it)))
code("apple"), code(orangeText)))
triggerAndBorderHighlight().component { ui: SearchTextArea ->
it.startsWith(ui.textArea.text) && UIUtil.getParentOfType(FindPopupPanel::class.java, ui) != null
orangeText.startsWith(ui.textArea.text) && UIUtil.getParentOfType(FindPopupPanel::class.java, ui) != null
}
stateCheck {
getFindPopup()?.helper?.model?.let { model ->
model.stringToReplace == it && model.stringToFind == "apple"
model.stringToReplace == orangeText && model.stringToFind == "apple"
} ?: false
}
restoreByUi()
@@ -153,7 +155,7 @@ open class FindInFilesLesson(override val sampleFilePath: String,
ideFrame {
val textArea = findComponentWithTimeout { textArea: JTextArea -> textArea.text == "" }
JTextComponentFixture(robot(), textArea).click()
type(it)
type(orangeText)
}
}
}

View File

@@ -83,18 +83,19 @@ abstract class RecentFilesLesson : KLesson("Recent Files and Locations", Lessons
test { actions(it) }
}
task("rfd") {
text(LessonsBundle.message("recent.files.search.typing", code(it)))
task {
val prefixes = "rfd"
text(LessonsBundle.message("recent.files.search.typing", code(prefixes)))
triggerUI().component { ui: ExtendableTextField ->
ui.javaClass.name.contains("SpeedSearchBase\$SearchField")
}
stateCheck { checkRecentFilesSearch(it) }
stateCheck { checkRecentFilesSearch(prefixes) }
restoreByUi()
test {
ideFrame {
waitComponent(Switcher.SwitcherPanel::class.java)
}
type(it)
type(prefixes)
}
}
@@ -151,16 +152,16 @@ abstract class RecentFilesLesson : KLesson("Recent Files and Locations", Lessons
test { actions(it) }
}
task(stringForRecentFilesSearch) {
text(LessonsBundle.message("recent.files.locations.search.typing", code(it)))
stateCheck { checkRecentLocationsSearch(it) }
task {
text(LessonsBundle.message("recent.files.locations.search.typing", code(stringForRecentFilesSearch)))
stateCheck { checkRecentLocationsSearch(stringForRecentFilesSearch) }
triggerUI().component { _: SearchTextField -> true } // needed in next task to restore if search field closed
restoreByUi()
test {
ideFrame {
waitComponent(JBList::class.java)
}
type(it)
type(stringForRecentFilesSearch)
}
}

View File

@@ -55,18 +55,19 @@ abstract class SearchEverywhereLesson : KLesson("Search everywhere", LessonsBund
test { actions(it) }
}
task("que") {
task {
before {
if (backupPopupLocation == null) {
backupPopupLocation = adjustPopupPosition(SearchEverywhereManagerImpl.LOCATION_SETTINGS_KEY)
}
}
text(LessonsBundle.message("search.everywhere.type.prefixes", strong("quadratic"), strong("equation"), code(it)))
stateCheck { checkWordInSearch(it) }
val prefix = "que"
text(LessonsBundle.message("search.everywhere.type.prefixes", strong("quadratic"), strong("equation"), code(prefix)))
stateCheck { checkWordInSearch(prefix) }
restoreByUi()
test {
Thread.sleep(500)
type(it)
type(prefix)
}
}
@@ -139,21 +140,22 @@ abstract class SearchEverywhereLesson : KLesson("Search everywhere", LessonsBund
LessonsBundle.message("search.everywhere.goto.class", action(it))
}
task(goToClassSearchQuery) {
text(LessonsBundle.message("search.everywhere.type.class.name", code(it)))
stateCheck { checkWordInSearch(it) }
task {
text(LessonsBundle.message("search.everywhere.type.class.name", code(goToClassSearchQuery)))
stateCheck { checkWordInSearch(goToClassSearchQuery) }
restoreAfterStateBecomeFalse { !checkInsideSearchEverywhere() }
test { type(it) }
test { type(goToClassSearchQuery) }
}
task(EverythingGlobalScope.getNameText()) {
task {
val globalScopeName = EverythingGlobalScope.getNameText()
text(LessonsBundle.message("search.everywhere.use.all.places",
strong(projectFilesScopeName), strong(it)))
strong(projectFilesScopeName), strong(globalScopeName)))
triggerAndFullHighlight().component { button: ActionButtonWithText ->
button.accessibleContext.accessibleName.isToStringContains(projectFilesScopeName)
}
triggerUI().component { button: ActionButtonWithText ->
button.accessibleContext.accessibleName == it
button.accessibleContext.accessibleName == globalScopeName
}
showWarning(LessonsBundle.message("search.everywhere.class.popup.closed.warning.message", action("GotoClass"))) {
!checkInsideSearchEverywhere() && focusOwner !is JList<*>

View File

@@ -43,10 +43,11 @@ abstract class RefactoringMenuLessonBase(lessonId: String) : KLesson(lessonId, L
}
if (!adaptToNotNativeLocalization) {
task(ActionsBundle.message("action.IntroduceParameter.text").dropMnemonic()) {
text(LessonsBundle.message("refactoring.menu.introduce.parameter.eng", strong(it)))
task {
val introduceParameterText = ActionsBundle.message("action.IntroduceParameter.text").dropMnemonic()
text(LessonsBundle.message("refactoring.menu.introduce.parameter.eng", strong(introduceParameterText)))
triggerUI().component { ui: JList<*> ->
ui.model.size > 0 && ui.model.getElementAt(0).isToStringContains(it)
ui.model.size > 0 && ui.model.getElementAt(0).isToStringContains(introduceParameterText)
}
restoreByUi(restoreId = showPopupTaskId, delayMillis = defaultRestoreDelay)
test {

View File

@@ -52,11 +52,12 @@ class FStringCompletionLesson
prepareSample(sample)
showWarningIfPython3NotFound()
task("{my") {
text(PythonLessonsBundle.message("python.f.string.completion.type.prefix", code(it)))
task {
val prefix = "{my"
text(PythonLessonsBundle.message("python.f.string.completion.type.prefix", code(prefix)))
runtimeText {
val prefixTyped = checkExpectedStateOfEditor(sample) { change ->
"{my_car".startsWith(change) && change.startsWith(it)
"{my_car".startsWith(change) && change.startsWith(prefix)
} == null
if (prefixTyped) PythonLessonsBundle.message("python.f.string.completion.invoke.manually", action("CodeCompletion")) else null
}
@@ -68,7 +69,7 @@ class FStringCompletionLesson
"{my_car".startsWith(change)
}
}
test { type(it) }
test { type(prefix) }
}
task {
text(PythonLessonsBundle.message("python.f.string.completion.complete.it", code(completionItem), action("EditorChooseLookupItem")))