Skip to content

Commit f326849

Browse files
authored
Merge pull request #23 from jetbrains-academy/stephen-hero-patch-1
Update task.md
2 parents ba98048 + 67f7749 commit f326849

File tree

20 files changed

+104
-104
lines changed
  • introductionSection
  • psiSection
    • accessingPsiElementsLesson
      • accessingPsiElementsProgrammingTask
      • accessingPsiElementsTheoryTask
    • addingPsiElementsLesson/addingAnnotationsProgrammingTask
    • editingPsiElementsLesson
    • introductionToPsiLesson
    • practicingPsiProject
      • createDataClassProgrammingTask
      • identifyFunctionArgumentsProgrammingTask
      • insertDataClassProgrammingTask
      • psiProjectIntroduction
      • replaceFunctionArgumentsProgrammingTask
      • replaceFunctionBodyVariablesProgrammingTask
      • replaceFunctionCallArgumentsProgrammingTask

20 files changed

+104
-104
lines changed

README.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
[![Gradle Build With Detekt](https://github.com/jetbrains-academy/kotlin-course-template/actions/workflows/gradle-build-with-detekt.yml/badge.svg)](https://github.com/jetbrains-academy/kotlin-course-template/actions/workflows/gradle-build-with-detekt.yml)
66
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
77

8-
This course is designed for novices in plugin development for JetBrains IDEs. It covers the basics of plugin development and provides a hands-on experience in working with PSI (Program Structure Interface) elements.
9-
The main goal of the course is not to rewrite the existing documentation, but rather to cover popular topics and provide links to the official documentation, so that the students can get used to reading the documentation and searching for the necessary information.
8+
This course is designed for novices in plugin development for JetBrains IDEs. It covers the basics of plugin development and provides hands-on experience in working with PSI (Program Structure Interface) elements.
9+
The main goal of the course is not to rewrite the existing documentation but rather to cover popular topics and provide links to the official documentation so that students can get used to reading the documentation and searching for necessary information.
1010

11-
Each lesson of the course consist of a theoretical task and a few programming tasks. The theoretical tasks are designed to help you understand the topic, while the programming tasks aim to apply the acquired knowledge.
12-
At the end of each chapter, an additional final project will be offered. It includes all the topics of the lesson but does not contain theory part. It is divided into multiple tasks, and by completing them step by step, you will get a finished small project in the end.
11+
Each lesson of the course consists of a theoretical task and a few programming tasks. The theoretical tasks are designed to help you understand the topic, while the programming tasks aim to apply the acquired knowledge.
12+
At the end of each chapter, an additional final project will be offered. It includes all the topics of the lesson but does not contain a theory part. It is divided into multiple tasks, and by completing them step by step, you will get a finished small project in the end.
1313

1414
Topics covered:
1515
* Accessing PSI elements
@@ -18,14 +18,14 @@ Topics covered:
1818

1919
## Technical requirements
2020

21-
Before starting this course, check the following requirements.
21+
Before starting this course, please check the following requirements:
2222

23-
1. Your computer needs to have a stable internet connection.
24-
2. Git version control system needs to be installed on your computer (link to the git site: https://git-scm.com/).
25-
3. Make sure that the path to the root folder of the course does not contain spaces, special characters, or non-Latin characters.
26-
4. Make sure that you use the [Intellij IDEA](https://www.jetbrains.com/idea/download/?_ga=2.189310830.494255415.1682514714-1823138827.1669894241&_gac=1.83806948.1682684894.Cj0KCQjw3a2iBhCFARIsAD4jQB3QkDU43KtbIx2HzEz02KvcN7Ma3QGzkIbyX4KS3H4x8b2bl9p4EfYaAvWsEALw_wcB&_gl=1*1h13lr8*_ga*MTgyMzEzODgyNy4xNjY5ODk0MjQx*_ga_9J976DJZ68*MTY4MjY5NDIyMy4xMjUuMS4xNjgyNjk0MjM4LjQ1LjAuMA..#section=windows) with version at least `2023.1.1`.
27-
5. Make sure that you use the [JetBrains Academy](https://plugins.jetbrains.com/plugin/10081-jetbrains-academy) plugin with version at least `2023.1`.
23+
1. Ensure that your computer has a stable internet connection.
24+
2. Install the Git version control system on your computer (link to the Git site: https://git-scm.com/).
25+
3. Ensure that the path to the root folder of the course does not contain spaces, special characters, or non-Latin characters.
26+
4. Make sure you are using [IntelliJ IDEA](https://www.jetbrains.com/idea/download/?_ga=2.189310830.494255415.1682514714-1823138827.1669894241&_gac=1.83806948.1682684894.Cj0KCQjw3a2iBhCFARIsAD4jQB3QkDU43KtbIx2HzEz02KvcN7Ma3QGzkIbyX4KS3H4x8b2bl9p4EfYaAvWsEALw_wcB&_gl=1*1h13lr8*_ga*MTgyMzEzODgyNy4xNjY5ODk0MjQx*_ga_9J976DJZ68*MTY4MjY5NDIyMy4xMjUuMS4xNjgyNjk0MjM4LjQ1LjAuMA..#section=windows) with a version of at least `2023.1.1`.
27+
5. Ensure that you are using the [JetBrains Academy](https://plugins.jetbrains.com/plugin/10081-jetbrains-academy) plugin with a version of at least `2023.1`.
2828

29-
The course is integrated into the [Intellij Idea IDE](https://www.jetbrains.com/idea/), which has a free Community license.
29+
The course is integrated into the [IntelliJ IDEA IDE](https://www.jetbrains.com/idea/), which has a free Community license.
3030
You can use this license to complete the course.
31-
If you have some troubles with the course installation, feel free to contact us by email at [email protected].
31+
If you encounter any issues with the course installation, feel free to contact us by email at [email protected].
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# Setup
22

3-
To have access to some internal actions you need to enable `Internal Mode`.
4-
Please, follow steps in internal mode instruction configuration [by this link](https://plugins.jetbrains.com/docs/intellij/enabling-internal.html) and enable it in your IDE.
3+
To access some internal actions, you need to enable `Internal Mode`.
4+
Please follow the steps in the internal mode instruction configuration [at this link](https://plugins.jetbrains.com/docs/intellij/enabling-internal.html) and enable it in your IDE.
55

6-
**Do not forget to restart you IDE after changing idea.properties file!!!**
6+
**Do not forget to restart you IDE after changing the idea.properties file!!!**
77

8-
Also, following gif will show you how Helena done this in her IDE.
8+
Also, the following GIF will show you how Helena did this in her IDE.
99

1010

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
Say hello to Helena! Add implementation to method `helloHelena` method which should return “Hello, Helena!” given number of times, separated by new line.
1+
Say hello to Helena! Add an implementation to the `helloHelena` method, which should return “Hello, Helena!” a given number of times. Each greeting should be separated by a newline.
22

3-
<div class="hint" title="How to get platform-specific new line symbol?">
3+
<div class="hint" title="How to get a platform-specific newline symbol?">
44

5-
Use `System.lineSeparator()` to get platform-specific new line symbol
6-
</div>
5+
Use `System.lineSeparator()` to get a platform-specific newline symbol.
6+
</div>
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
Hi! My name is Helena. I’m working in the Plugin Development Team. We have just hired a new young developer, Jonsi, so I’ve prepared lots of amazing projects for him to do.
1+
Hi! My name is Helena. I’m working in the Plugin Development Team. We have just hired a new young developer, Jonsi, so I’ve prepared lots of amazing projects for him to tackle.
22

3-
But wait, he has never worked with IntelliJ Platform before?! So well, I’ll try to teach him all important things during one week of his probation.
3+
But wait, he has never worked with the IntelliJ Platform before?! Well, I’ll try to teach him all the important things during the one week of his probation.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
Hi! My name is Jonsi! It’s my first day at JetBrains, and I’m ready to start! But I’m really nervous of my probation week as I have no idea, how IDE works behind and what is more, how to write plugins for it.
1+
Hi! My name is Jonsi! It’s my first day at JetBrains, and I’m ready to get started! But I’m really nervous about my probation week, since I have no idea how an IDE works behind the scenes, and what's more, I don't know how to write plugins for it.
22

3-
So I really need someone's help!!!
3+
So, I really need someone's help!!!
44

55
Maybe you can help me?

psiSection/accessingPsiElementsLesson/accessingPsiElementsProgrammingTask/task.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
Using your newly gained knowledge about `PsiTreeUtil.findChildrenOfType` method, implement functions `countKtClasses` and `countKtFunctions` which will
2-
count number of kotlin classes of functions relatively declared in the given kotlin PSI file.
1+
Using your newly gained knowledge about the `PsiTreeUtil.findChildrenOfType` method, implement the functions `countKtClasses` and `countKtFunctions`. These functions will
2+
count the number of Kotlin classes and functions, respectively, declared in the given Kotlin PSI file.
33

4-
<div class="hint" title="Which class should I use as aClass parameter?">
4+
<div class="hint" title="Which class should I use as the aClass parameter?">
55

6-
Try to use `KtClass::class.java` for classes and `KtNamedFunction::class.java` for functions value for aClass parameter for `findChildrenOfType`
6+
Try using `KtClass::class.java` for classes and `KtNamedFunction::class.java` for functions as the aClass parameter values for `findChildrenOfType`.
77
</div>
88

99
**Run Plugin**
1010

11-
To see your implemented methods in action within a UI, run the following command in your project's root directory:
11+
To see your implemented methods in action within the UI, run the following command in your project's root directory:
1212

1313
* ` ./gradlew :psiSection-accessingPsiElementsLesson-task:runIde
1414
` on Linux or MacOS

psiSection/accessingPsiElementsLesson/accessingPsiElementsTheoryTask/task.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
is a utility class in the IntelliJ Platform SDK that provides methods for navigating and querying the PSI tree of a project.
33

44
The [com.intellij.psi.util.PsiTreeUtil.findChildrenOfType](https://github.com/JetBrains/intellij-community/blob/30cfa651ac2b9c50163368b56ee87ce1944543ec/platform/core-api/src/com/intellij/psi/util/PsiTreeUtil.java#L197C64-L197C64) method is used to find all children of a specified type within a given PSI element.
5-
It's particularly useful when you need to locate all instances of a particular element type, such as classes, methods, or variables, within a file or a code block.
5+
It's particularly useful when you need to locate all instances of a specified element type, such as classes, methods, or variables, within a file or a code block.
66

77
**Syntax:**
88
```java
@@ -11,4 +11,4 @@ public static @Unmodifiable @NotNull <T extends PsiElement> Collection<T> findCh
1111

1212
**Parameters:**
1313
* **element**: The PSI element within which to search for children. This could be a PsiFile, a PsiClass, or any other PSI element.
14-
* **aClass**: The class type of the elements you are searching for. For example, PsiClass.class to find all classes.
14+
* **aClass**: The class type of the elements you are searching for. For example, if you're looking for all classes, you would use PsiClass.class.

psiSection/addingPsiElementsLesson/addingAnnotationsProgrammingTask/task.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ They are a form of syntactic metadata that can be added to the code but do not d
33

44
The `@Deprecated` annotation marks a program element as deprecated, indicating that the element should no longer be used.
55

6-
**Task**
6+
**Task**:
77
Implement the function
88
```kotlin
99
fun addDeprecatedAnnotations(psiFile: PsiFile)
1010
```
1111

1212
This function should iterate over all Kotlin functions (`KtFunction`) in the given PSI file.
13-
For each function that does not already have a `@Deprecated` annotation, you will add one with a message indicating that the method is deprecated.
13+
For each function that lacks a `@Deprecated` annotation, one should be added, accompanied by a message that signifies the method's deprecation.
1414

1515
<div class="hint" title="How to find all function declarations">
1616

@@ -19,11 +19,11 @@ Use `PsiTreeUtil.findChildrenOfType` to find all Kotlin function declarations (`
1919

2020
<div class="hint" title="Creating annotations">
2121

22-
Use `KtPsiFactory` to create a new annotation entry. Look into how to instantiate KtPsiFactory and use it to create annotations.
22+
Use `KtPsiFactory` to create a new annotation entry. Learn how to instantiate `KtPsiFactory` and use it to create annotations.
2323
</div>
2424

2525
<div class="hint" title="Checking for existing annotations">
2626

2727
Implement a helper method to check if a `KtFunction` already has a `@Deprecated` annotation.
28-
You might find KtFunction’s `annotationEntries` property useful for this.
29-
</div>
28+
The `annotationEntries` property of `KtFunction` might be useful for this.
29+
</div>
Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
1-
All operations with code like adding, deleting or moving methods, renaming variable, you name it, are implemented as PSI editions.
2-
Please skim the [Modify the PSI](https://plugins.jetbrains.com/docs/intellij/modifying-psi.html) documentation.
1+
All operations involving code modifications, such as adding, deleting, or moving methods, renaming variables, etc., are implemented as PSI edits.
2+
Please review the [Modify the PSI](https://plugins.jetbrains.com/docs/intellij/modifying-psi.html) documentation.
33

4-
Common methods to edit PSI Element:
5-
* [`PsiElement.copy()`](https://github.com/JetBrains/intellij-community/blob/19d9a1cc2d9c14df9c3bdee391e9e4795ac25cb9/platform/core-api/src/com/intellij/psi/PsiElement.java#L293) - to copy PSI Element subtree
6-
* [`PsiElement.replace()`](https://github.com/JetBrains/intellij-community/blob/19d9a1cc2d9c14df9c3bdee391e9e4795ac25cb9/platform/core-api/src/com/intellij/psi/PsiElement.java#L402) - to replace PSI Element in tree
7-
* [`PsiElement.delete()`](https://github.com/JetBrains/intellij-community/blob/19d9a1cc2d9c14df9c3bdee391e9e4795ac25cb9/platform/core-api/src/com/intellij/psi/PsiElement.java#L373) - to delete PSI Element from tree
8-
* [`PsiElement:add`](https://github.com/JetBrains/intellij-community/blob/19d9a1cc2d9c14df9c3bdee391e9e4795ac25cb9/platform/core-api/src/com/intellij/psi/PsiElement.java#L302) - to add a child into the PSI Element subtree
9-
* [`PsiElement:addBefore`](https://github.com/JetBrains/intellij-community/blob/19d9a1cc2d9c14df9c3bdee391e9e4795ac25cb9/platform/core-api/src/com/intellij/psi/PsiElement.java#L312C14-L312C23) / [`PsiElement:addAfter`](https://github.com/JetBrains/intellij-community/blob/19d9a1cc2d9c14df9c3bdee391e9e4795ac25cb9/platform/core-api/src/com/intellij/psi/PsiElement.java#L322) - to add a child into the PSI Element subtree before / after the specified anchor element
10-
* [`PsiElement:addRange`](https://github.com/JetBrains/intellij-community/blob/19d9a1cc2d9c14df9c3bdee391e9e4795ac25cb9/platform/core-api/src/com/intellij/psi/PsiElement.java#L343) - to add a list of children into the PSI Element subtree
11-
* [`PsiElement:addRangeBefore`](https://github.com/JetBrains/intellij-community/blob/19d9a1cc2d9c14df9c3bdee391e9e4795ac25cb9/platform/core-api/src/com/intellij/psi/PsiElement.java#L354) / [`PsiElement:addRangeAfter`](https://github.com/JetBrains/intellij-community/blob/19d9a1cc2d9c14df9c3bdee391e9e4795ac25cb9/platform/core-api/src/com/intellij/psi/PsiElement.java#L365)- to add a list of children into the PSI Element subtree before / after the specified anchor element
4+
Common methods to edit PSI elements include:
5+
* [`PsiElement.copy()`](https://github.com/JetBrains/intellij-community/blob/19d9a1cc2d9c14df9c3bdee391e9e4795ac25cb9/platform/core-api/src/com/intellij/psi/PsiElement.java#L293) - Copies the PSI element subtree.
6+
* [`PsiElement.replace()`](https://github.com/JetBrains/intellij-community/blob/19d9a1cc2d9c14df9c3bdee391e9e4795ac25cb9/platform/core-api/src/com/intellij/psi/PsiElement.java#L402) - Replaces the PSI element in the tree.
7+
* [`PsiElement.delete()`](https://github.com/JetBrains/intellij-community/blob/19d9a1cc2d9c14df9c3bdee391e9e4795ac25cb9/platform/core-api/src/com/intellij/psi/PsiElement.java#L373) - Deletes the PSI element from the tree.
8+
* [`PsiElement:add`](https://github.com/JetBrains/intellij-community/blob/19d9a1cc2d9c14df9c3bdee391e9e4795ac25cb9/platform/core-api/src/com/intellij/psi/PsiElement.java#L302) - Adds a child to the PSI element subtree.
9+
* [`PsiElement:addBefore`](https://github.com/JetBrains/intellij-community/blob/19d9a1cc2d9c14df9c3bdee391e9e4795ac25cb9/platform/core-api/src/com/intellij/psi/PsiElement.java#L312C14-L312C23) / [`PsiElement:addAfter`](https://github.com/JetBrains/intellij-community/blob/19d9a1cc2d9c14df9c3bdee391e9e4795ac25cb9/platform/core-api/src/com/intellij/psi/PsiElement.java#L322) - Adds a child to the PSI element subtree before/after the specified anchor element.
10+
* [`PsiElement:addRange`](https://github.com/JetBrains/intellij-community/blob/19d9a1cc2d9c14df9c3bdee391e9e4795ac25cb9/platform/core-api/src/com/intellij/psi/PsiElement.java#L343) - Adds a list of children to the PSI element subtree.
11+
* [`PsiElement:addRangeBefore`](https://github.com/JetBrains/intellij-community/blob/19d9a1cc2d9c14df9c3bdee391e9e4795ac25cb9/platform/core-api/src/com/intellij/psi/PsiElement.java#L354) / [`PsiElement:addRangeAfter`](https://github.com/JetBrains/intellij-community/blob/19d9a1cc2d9c14df9c3bdee391e9e4795ac25cb9/platform/core-api/src/com/intellij/psi/PsiElement.java#L365)- Adds a list of children to the PSI element subtree before/after the specified anchor element.
1212

1313

14-
Moreover, there are some PisElement-specific methods like [`KtNamedFunction:setName`](https://github.com/JetBrains/intellij-community/blob/bf3083ca66771e038eb1c64128b4e508f52acfad/platform/core-api/src/com/intellij/psi/PsiNamedElement.java#L39) or as well as all `PsiNamedElement` inheritors.
14+
Moreover, there are some PsiElement-specific methods like [`KtNamedFunction:setName`](https://github.com/JetBrains/intellij-community/blob/bf3083ca66771e038eb1c64128b4e508f52acfad/platform/core-api/src/com/intellij/psi/PsiNamedElement.java#L39) and methods available to all `PsiNamedElement` inheritors.
1515

1616
**IMPORTANT!**
1717

18-
Every PSI modifications need to be wrapped in a [write action and in command](https://github.com/JetBrains/intellij-community/blob/master/platform/core-api/src/com/intellij/openapi/command/WriteCommandAction.java)
18+
Every PSI modification needs to be wrapped in a [write action and command](https://github.com/JetBrains/intellij-community/blob/master/platform/core-api/src/com/intellij/openapi/command/WriteCommandAction.java)
1919

2020
```kotlin
2121
WriteCommandAction.runWriteCommandAction(project) {
22-
// Here you can modify PSI Elements
22+
// Here you can modify PSI elements
2323
}
2424
```
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
1-
Sometimes, switching between Python and Kotlin leeds to following code style mistake:
1+
Sometimes, switching between Python and Kotlin leads to the following code style mistake:
22

3-
Python developers usually use `snake_case` for methods naming like
3+
Python developers usually use `snake_case` for method naming, like:
44
```python
55
def sort_values(values):
66
```
7-
While in Kotlin or Java `camelCase` is commonly used
7+
In contrast, Kotlin and Java commonly use `camelCase`:
88
```Kotlin
99
fun sortValues(values: List<Int>) {...}
1010
```
1111

12-
**Your task will be** to help such multi-language programmers and
13-
implement method which renames `snake_case` named method to `camelCase`.
12+
**Your task will be** to assist multi-language programmers by
13+
implementing a method that renames `snake_case` methods to `camelCase`.
1414

15-
So before your method invocation method looked like:
15+
Before your method invocation, the method might look like:
1616
```Kotlin
1717
fun sort_values(values: List<Int>) {...}
1818
```
19-
but after
19+
After:
2020
```Kotlin
2121
fun sortValues(values: List<Int>) {...}
2222
```
2323

24-
<div class="hint" title="How to get project for WriteActionCommand?">
24+
<div class="hint" title="How to get the project for WriteActionCommand?">
2525

26-
Every PSI element has link to project, just try `psiElement.project`
26+
Every PSI element has a link to the project; just try `psiElement.project`.
2727
</div>

0 commit comments

Comments
 (0)