prepareSample(sample)
actionTask("CollapseRegion") {
- "Sometimes you need to collapse a piece of code for better readability. Try collapsing code with ${action(it)}."
+ "Sometimes you need to collapse a piece of code for better readability. Try to collapse a code fragment with ${action(it)}."
}
actionTask("ExpandRegion") {
"To expand a code region, hit ${action(it)}."
actionTask("EditorDuplicate") { "Duplicate any line with ${action(it)}." }
task("EditorDuplicate") {
- text("You can do the same thing with multiple lines, too. Simply select two or more lines and duplicate them with ${action(it)}.")
+ text("You can do the same action with multiple lines, too. Simply select two or more lines and duplicate them with ${action(it)}.")
trigger(it, {
val selection = editor.selectionModel
val start = selection.selectionStartPosition?.line ?: 0
test { actions("EditorUp", "EditorLineStart", "EditorDownWithSelection", "EditorDownWithSelection", it) }
}
actionTask("EditorDeleteLine") {
- "To delete current line you can use action ${action(it)}."
+ "To delete the current line you can use action ${action(it)}."
}
}
}
\ No newline at end of file
"refer to <a href=\"$FIND_ACTION_WORKAROUND\">this article</a>." else ""
}
actionTask("About") {
- "Let's say you want to read about the IDE, type <strong>about</strong> and press ${action("EditorEnter")}."
+ "Let's say you want to learn about the IDE, type <strong>about</strong> and press ${action("EditorEnter")}."
}
task {
text("Hit ${action("EditorEscape")} to return to the editor.")
prepareSample(sample)
actionTask("MoveLineDown") {
- "Rearranging lines usually takes two actions: cut and paste. In this IDE, you can do it with just one: " +
- "pressing ${action(it)} will pull down the current line."
+ "Rearranging lines usually takes two actions: cut and paste. In this IDE, you can do it with just one. " +
+ "Press ${action(it)} to pull down the current line."
}
actionTask("MoveLineUp") {
"Similarly, to pull a line up, use ${action(it)}."
}
if (lang == JavaLangSupport.lang) caret(9, 5)
task("MoveStatementUp") {
- text("Now try moving the whole method up with ${action(it)}.")
+ text("Now try to move the whole method up with ${action(it)}.")
trigger(it, { editor.document.text }, { before, now ->
checkSwapMoreThan2Lines(before, now)
})
"Press ${action(it)} to extend the selection to the next code block."
}
task("EditorSelectWord") {
- text("Try increasing your selection with ${action(it)} until your whole file is selected.")
+ text("Try to increase your selection with ${action(it)} until your whole file is selected.")
trigger(it) {
editor.selectionModel.selectionStart == 0 && editor.document.textLength == editor.selectionModel.selectionEnd
}
editor.caretModel.currentCaret.selectionStart != previous.sample.selection?.first ||
editor.caretModel.currentCaret.selectionEnd != previous.sample.selection?.second
}
- text("Press ${action(it)} to surround selected code with some template code.")
+ text("Press ${action(it)} to surround the selected code fragment with some template code.")
triggerByListItemAndHighlight { item ->
surroundItems.all { need -> wordIsPresent(item.toString(), need) }
}
proposeIfModified {
editor.caretModel.currentCaret.logicalPosition.line != previous.position.line
}
- text("Lets return to the initial file with unwrapping action by ${action(it)}.")
+ text("Let's return to the initial file with unwrapping action by ${action(it)}.")
triggerByListItemAndHighlight { item ->
wordIsPresent(item.toString(), surroundItems[0])
}
}
}
task {
- text("Continue typing <code>$item1Completion</code> unless it become the first item.")
+ text("Continue typing <code>$item1Completion</code> unless it becomes the first item.")
stateCheck {
(previous.ui as? JList<*>)?.let {
isTheFirstVariant(it)
}
task("GotoDeclaration") {
- text("Now the caret is on the attribute accessor declaration. " +
+ text("Now the caret is at the attribute accessor declaration. " +
"Use the same shortcut ${action(it)} to see all of its usages, then select one of them.")
trigger(it, { state() }) l@{ before, now ->
if (before == null || now == null) {
}
}
task {
- text("Only the one item remains. Now press <strong>Enter</strong> to jump to the selected item.")
+ text("Only one item remains. Now press <strong>Enter</strong> to jump to the selected item.")
stateCheck { focusOwner is EditorComponentImpl }
test { GuiTestUtil.shortcut(Key.ENTER) }
}
}
task {
- text("Cocktail Sort has 2 swap places. The first fragment has just been extracted. Click <strong>Yes</strong> to extract both of them.")
+ text("Cocktail Sort has two swap places. The first fragment has just been extracted. Click <strong>Yes</strong> to extract both of them.")
// Wait until the third dialog
triggerByUiComponentAndHighlight(highlightBorder = false, highlightInside = false) { dialog : JDialog ->
}
}
task {
- text("Now you can confirm or reject replacement of the second fragment.")
+ text("Now you can confirm or reject the replacement of the second fragment.")
stateCheck {
previous.ui?.isShowing?.not() ?: true
task {
text("This code block contains 3 occurrences of the selected expression. " +
- "Choose the second item in the list to replace both of them.")
+ "Choose the second item on the list to replace all of them.")
stateCheck {
editor.document.text.split("i + 1").size == 2
return {
prepareSample(sample)
task("CodeCompletion") {
- text("Suppose you want to replace ${code("current")} by ${code("total")}. Invoke completion by pressing ${action(it)}.")
+ text("Suppose you want to replace ${code("current")} with ${code("total")}. Invoke completion by pressing ${action(it)}.")
triggerByListItemAndHighlight(checkList = { ui -> isTotalItem(ui) })
proposeRestoreMe()
test { actions(it) }
task {
val result = LessonUtil.insertIntoSample(template, "total")
text("If you press ${action("EditorEnter")} you will insert ${code("total")} before ${code("current")}. " +
- "Instead press ${action("EditorTab")} to replace ${code("current")} by ${code("total")}")
+ "Instead press ${action("EditorTab")} to replace ${code("current")} with ${code("total")}")
trigger("EditorChooseLookupItemReplace") {
editor.document.text == result
import javax.swing.JLabel
import javax.swing.JPanel
-class PythonInPlaceRefactoringLesson(module: Module) : KLesson("In place refactoring", module, "Python") {
+class PythonInPlaceRefactoringLesson(module: Module) : KLesson("refactoring.in.place", "In-place refactoring", module, "Python") {
private val template = """
def fibonacci(stop):
first = 0
override val lessonContent: LessonContext.() -> Unit = {
prepareSample(sample)
task {
- text("Let's consider an alternative approach to perform refactorings. Suppose we want to rename local variable ${code(variableName)} " +
+ text("Let's consider an alternative approach to performing refactorings. Suppose we want to rename local variable ${code(variableName)} " +
"to ${code("second")}. Just start typing the new name.")
stateCheck {
editor.document.text != sample.text
task("ShowIntentionActions") {
text("IDE is guessing that you are going to rename the variable. " +
- "You can notice it by the icon ${icon(AllIcons.Gutter.SuggestedRefactoringBulb)} at the left editor gutter. " +
+ "You can notice it by the icon ${icon(AllIcons.Gutter.SuggestedRefactoringBulb)} in the left editor gutter. " +
"Invoke intentions by ${action(it)} when you finish to type the new name.")
triggerByListItemAndHighlight(highlightBorder = true, highlightInside = false) { ui -> // no highlighting
ui.toString().contains("Rename usages")
task {
text("Let's add an argument to this method. We place the editor caret just after the first parameter. " +
- "Now type comma and parameter name: ${code(", start")} .")
+ "Now type comma and parameter's name: ${code(", start")} .")
stateCheck {
val text = editor.document.text
val parameter = text.substring(secondSample.startOffset, text.indexOf(')'))
task("ShowIntentionActions") {
text("IDE is guessing that you are going to change the method signature. " +
"You can notice it by the same icon ${icon(AllIcons.Gutter.SuggestedRefactoringBulb)} at the left editor gutter. " +
- "Invoke intentions by ${action(it)} when you finish to type the new parameter.")
+ "Invoke intentions by ${action(it)} when you finish typing the new parameter.")
triggerByListItemAndHighlight(highlightBorder = true, highlightInside = false) { item ->
item.toString().contains("Update usages to")
}
before {
beforeSecondRefactoring = editor.document.text
}
- text("Now you need to type the value which will be inserted as an argument to the each call. " +
+ text("Now you need to type the value which will be inserted as an argument into the each call. " +
"You can choose ${code("0")} for this sample. Then press ${action("EditorEnter")} to continue.")
stateCheck {
editor.document.text != beforeSecondRefactoring && Thread.currentThread().stackTrace.any {
}
task {
- text("Wait a little bit for completion list...")
+ text("Wait a little bit for the completion list...")
triggerByListItemAndHighlight(highlightBorder = false, highlightInside = false) { item ->
item.toString().contains("string=y")
}
}
task {
- text("But we do not need completion now. Close it (${action("EditorEscape")}).")
+ text("For now, we don't want to apply any completion. Close the list (${action("EditorEscape")}).")
stateCheck { previous.ui?.isShowing != true }
test { GuiTestUtil.shortcut(Key.ESCAPE) }
}
task("ShowIntentionActions") {
- text("As you may notice IDE is showing you a warning here. Let's invoke intentions by ${action(it)}.")
+ text("As you may notice, IDE is showing you a warning here. Let's invoke intentions by ${action(it)}.")
triggerByListItemAndHighlight(highlightBorder = true, highlightInside = false) { item ->
item.toString().contains("Change signature of")
}
}
task {
text("Let's set the default value for the new parameter. Click at the new parameter line. " +
- "Alternatively you can set focus to the parameter without mouse by ${action("EditorTab")} and then ${action("EditorEnter")}.")
+ "Alternatively, you can set focus to the parameter without mouse by ${action("EditorTab")} and then ${action("EditorEnter")}.")
triggerByUiComponentAndHighlight(highlightBorder = false, highlightInside = false) { label: JLabel ->
label.text == "Default value:"
before {
beforeRefactoring = editor.document.text
}
- text("You may navigate through the fields (and the checkbox) by ${action("EditorTab")}. " +
- "By the checkbox you can choose whether IDE will inline the default values to the other callers or set it as default value for the new parameter. " +
- "The Signature Preview will help to understand the difference. Now set the default value as 0 and press <raw_action>Ctrl + Enter</raw_action> " +
+ text("You may navigate through the fields (and the checkbox) by using ${action("EditorTab")}. " +
+ "With the checkbox you can let IDE inline the default value to the other callers or set it as the default value for the new parameter. " +
+ "The Signature Preview will help understand the difference. Now set the default value as 0 and press <raw_action>Ctrl + Enter</raw_action> " +
"(or click <strong>Do Refactor</strong>) to finish the refactoring.")
stateCheck {
"But for rare refactorings you can use ${action(it)} and see a partial list of them."
}
task("Introduce Parameter") {
- text("Suppose we want to replace this expression by parameter. So we need to choose <strong>$it...</strong>. " +
+ text("Suppose we want to replace this expression with a parameter. So we need to choose <strong>$it...</strong>. " +
"Now simply type ${code("pa")} (as prefix of Parameter) to reduce proposed list.")
triggerByUiComponentAndHighlight(highlightBorder = false, highlightInside = false) { ui: JList<*> ->
ui.model.size > 0 && ui.model.getElementAt(0).toString().contains(it)
}
task {
- text("To complete refactoring you need to choose some name or leave it as default and press ${action("EditorEnter")}.")
+ text("To complete refactoring, you need to choose some name or leave it as default and press ${action("EditorEnter")}.")
stateCheck {
!hasInplaceRename()
}
TreeUtil.collapseAll(tree, 1)
}
}
- text("In simple case PyCharm will just rename without confirmation. But in this sample PyCharm see two calls of " +
+ text("In simple cases PyCharm will just rename without confirmation. But in this sample PyCharm sees two calls of " +
"${code("teams")} method for objects with unknown type. Expand <strong>Dynamic references</strong> item.")
triggerByFoundPathAndHighlight { _: JTree, path: TreePath ->
task {
val result = replace?.let { template.replace("<name>", it).replace("<caret>", "") }
- text("Now just finish rename with <strong>Do Refactor</strong> button.")
+ text("Now just finish the rename with the <strong>Do Refactor</strong> button.")
stateCheck { editor.document.text == result }
test {
ideFrame {