mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[IFT] IJOB-576 Demonstrate other quick-fix in the Kotlin onboarding lesson
`Replace loop with for each` quick-fix is not available in the K2 now, so let's showcase another quick-fix: `Safe Delete`. GitOrigin-RevId: 1946a68de91af70be5ba7c524e24c61906c18588
This commit is contained in:
committed by
intellij-monorepo-bot
parent
04d1a1e177
commit
3bc136de5a
@@ -7,7 +7,7 @@ kotlin.onboarding.invoke.intention.for.warning.1=You have just fixed a bug, but
|
||||
IntelliJ IDEA highlights and adds a yellow bulb to the code lines that can be improved.
|
||||
kotlin.onboarding.invoke.intention.for.warning.2=Press {0} to preview the warnings and apply a quick-fix.
|
||||
kotlin.onboarding.invoke.intention.for.warning.balloon=Press {0} to show available quick-fixes
|
||||
kotlin.onboarding.select.fix=Apply the first item: {0}. In this case, the <strong>for-each</strong> loop will make code easier to understand.
|
||||
kotlin.onboarding.select.fix=Apply the {0} quick-fix. It will remove the unused local variable.
|
||||
kotlin.onboarding.invoke.intention.for.code=Intentions also save your time and make coding easier. Let''s use an intention to reformat string concatenation. \
|
||||
Press {0} to show possible options.
|
||||
kotlin.onboarding.invoke.intention.for.code.balloon=Press {0} to show available intentions
|
||||
|
||||
+6
-5
@@ -6,6 +6,7 @@ import com.intellij.java.ift.lesson.essential.OnboardingTourLessonBase
|
||||
import com.intellij.java.ift.lesson.essential.ideaOnboardingLessonId
|
||||
import com.intellij.openapi.ui.popup.Balloon
|
||||
import org.jetbrains.annotations.Nls
|
||||
import org.jetbrains.kotlin.idea.base.highlighting.KotlinBaseHighlightingBundle
|
||||
import org.jetbrains.kotlin.idea.base.resources.KotlinBundle
|
||||
import org.jetbrains.kotlin.training.ift.KotlinLessonsBundle
|
||||
import training.dsl.*
|
||||
@@ -18,8 +19,9 @@ class KotlinOnboardingTourLesson : OnboardingTourLessonBase(ideaOnboardingLesson
|
||||
private val samplePrintln = "println(\"AVERAGE of array \" + array.joinToString() + \" is \" + findAverage(array))"
|
||||
override val sample: LessonSample = parseLessonSample("""
|
||||
fun findAverage(values: IntArray): Double {
|
||||
val si<caret id=3/>ze = values.size
|
||||
var result = 0.0
|
||||
for (i in 0 un<caret id=3/>til values.size) {
|
||||
for (i in 0 until values.size) {
|
||||
result += values[i]
|
||||
}
|
||||
<caret>return result<caret id=2/>
|
||||
@@ -34,11 +36,11 @@ class KotlinOnboardingTourLesson : OnboardingTourLessonBase(ideaOnboardingLesson
|
||||
override val completionStepExpectedCompletion: String = "size"
|
||||
|
||||
override fun LessonContext.contextActions() {
|
||||
val quickFixMessage = KotlinBundle.message("replace.index.loop.with.collection.loop.quick.fix.text")
|
||||
val quickFixMessage = KotlinBaseHighlightingBundle.message("safe.delete.text.0", "size")
|
||||
caret(sample.getPosition(3))
|
||||
|
||||
task {
|
||||
triggerOnEditorText("until", highlightBorder = true)
|
||||
triggerOnEditorText("size", highlightBorder = true)
|
||||
}
|
||||
|
||||
task("ShowIntentionActions") {
|
||||
@@ -55,9 +57,8 @@ class KotlinOnboardingTourLesson : OnboardingTourLessonBase(ideaOnboardingLesson
|
||||
task {
|
||||
text(KotlinLessonsBundle.message("kotlin.onboarding.select.fix", strong(quickFixMessage)))
|
||||
stateCheck {
|
||||
editor.document.text.contains("for (element in values)")
|
||||
!editor.document.text.contains("size = values")
|
||||
}
|
||||
restoreByUi(delayMillis = defaultRestoreDelay)
|
||||
}
|
||||
|
||||
fun getIntentionMessage(): @Nls String {
|
||||
|
||||
Reference in New Issue
Block a user