[IFT] Rework Python and Java run lessons and adjust them for the new UI

IJ-CR-103403

GitOrigin-RevId: 88218a3ef100af6592eea13a2ea3ee4c3a8070c6
This commit is contained in:
Alexey Merkulov
2023-02-22 14:23:27 +01:00
committed by intellij-monorepo-bot
parent bc6abbde05
commit 0291a4ce92
11 changed files with 247 additions and 66 deletions

View File

@@ -22,5 +22,6 @@
<orderEntry type="library" name="kotlinx-serialization-core" level="project" />
<orderEntry type="library" name="kotlinx-serialization-json" level="project" />
<orderEntry type="module" module-name="intellij.platform.testFramework" scope="TEST" />
<orderEntry type="module" module-name="intellij.java.execution.impl" />
</component>
</module>

View File

@@ -80,8 +80,9 @@ java.basic.completion.deeper.level=Sometimes, you need to see suggestions for st
Press {0} twice to get them in the lookup.
java.basic.completion.module.promotion=You will find more about refactorings in the {0} module.
java.run.configuration.lets.run=Any code marked with {0} can be run. Let''s run our simple example with {1}. \
Alternatively, you can click {0} and select the {2} item.
java.run.configuration.lets.run=There are more than one way to run your code. \
Let''s try to run it from gutter this time by clicking {0} and selecting the {1} item. \
Alternatively, you can press {2}.
java.postfix.completion.type=Type {0} after the parenthesis to see the list of postfix completion suggestions.
java.postfix.completion.complete=Select {0} from the list or type the same value in the editor. Press {1} to complete the statement.

View File

@@ -3,6 +3,7 @@ package com.intellij.java.ift.lesson.run
import com.intellij.codeInsight.daemon.LineMarkerInfo
import com.intellij.execution.ExecutionBundle
import com.intellij.execution.application.ApplicationConfiguration
import com.intellij.icons.AllIcons
import com.intellij.java.ift.JavaLessonsBundle
import com.intellij.openapi.actionSystem.CommonDataKeys
@@ -35,8 +36,10 @@ class JavaRunConfigurationLesson : CommonRunConfigurationLesson("java.run.config
}
task("RunClass") {
text(JavaLessonsBundle.message("java.run.configuration.lets.run", icon(AllIcons.Actions.Execute), action(it),
strong(ExecutionBundle.message("default.runner.start.action.text").dropMnemonic())))
text(JavaLessonsBundle.message("java.run.configuration.lets.run",
icon(AllIcons.RunConfigurations.TestState.Run),
strong(ExecutionBundle.message("default.runner.start.action.text").dropMnemonic()),
action(it)))
timerCheck { configurations().isNotEmpty() }
//Wait toolwindow
checkToolWindowState("Run", true)
@@ -46,7 +49,16 @@ class JavaRunConfigurationLesson : CommonRunConfigurationLesson("java.run.config
}
}
override val sampleFilePath: String = "src/${JavaRunLessonsUtils.demoClassName}.java"
override fun LessonContext.addAnotherRunConfiguration() {
prepareRuntimeTask {
addNewRunConfigurationFromContext { runConfiguration ->
runConfiguration.name = demoWithParametersName
(runConfiguration as ApplicationConfiguration).programParameters = "hello world"
}
}
}
override val sampleFilePath: String = "src/${demoClassName}.java"
}
internal fun TaskContext.highlightRunGutters(highlightInside: Boolean = false, usePulsation: Boolean = false) {
@@ -56,10 +68,8 @@ internal fun TaskContext.highlightRunGutters(highlightInside: Boolean = false, u
}.componentPart l@{ ui: EditorGutterComponentEx ->
if (CommonDataKeys.EDITOR.getData(ui as DataProvider) != editor) return@l null
val runGutterLines = (0 until editor.document.lineCount).mapNotNull { lineInd ->
val gutter = ui.getGutterRenderers(lineInd).singleOrNull() ?: return@mapNotNull null
if ((gutter as? LineMarkerInfo.LineMarkerGutterIconRenderer<*>)?.featureId == "run") {
if (ui.getGutterRenderers(lineInd).any { (it as? LineMarkerInfo.LineMarkerGutterIconRenderer<*>)?.featureId == "run" })
lineInd
}
else null
}
if (runGutterLines.size < 2) return@l null