generated from jetbrains-academy/kotlin-course-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Valerii
committed
Dec 27, 2023
1 parent
8f54dc1
commit fd56d76
Showing
24 changed files
with
100 additions
and
84 deletions.
There are no files selected for viewing
File renamed without changes.
1 change: 1 addition & 0 deletions
1
...psi/Accessing PSI Elements/task-info.yaml → ...n/psi/AccessingPsiElements/task-info.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
type: theory | ||
custom_name: Accessing PSI Elements | ||
files: | ||
- name: src/jetbrains/plugindev/course/access/Main.kt | ||
visible: true |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
type: edu | ||
custom_name: Psi Manipulation Advanced | ||
files: | ||
- name: src/org/jetbrains/academy/ij/plugin/course/annotations/Task.kt | ||
visible: true | ||
placeholders: | ||
- offset: 871 | ||
length: 247 | ||
placeholder_text: TODO() | ||
- name: test/org/jetbrains/academy/ij/plugin/course/annotations/Tests.kt | ||
visible: false |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
5 changes: 3 additions & 2 deletions
5
...seSection/psi/classCounter/task-info.yaml → ...seSection/psi/ClassCounter/task-info.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
type: edu | ||
custom_name: Count number of classes | ||
files: | ||
- name: src/jetbrains/plugindev/course/classcounter/Task.kt | ||
visible: true | ||
placeholders: | ||
- offset: 160 | ||
length: 85 | ||
- offset: 211 | ||
length: 81 | ||
placeholder_text: TODO() | ||
- name: test/jetbrains/plugindev/course/classcounter/Tests.kt | ||
visible: false |
1 change: 1 addition & 0 deletions
1
...ction/psi/Count number of classes/task.md → courseSection/psi/ClassCounter/task.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
|
||
You need to implement a function `countKtClasses` which will count number of kotlin classes declared in the given kotlin PSI file. | ||
<div class="hint"> | ||
|
||
Try to use `KtClass::class.java` value for aClass parameter for `findChildrenOfType` | ||
</div> | ||
|
File renamed without changes.
13 changes: 13 additions & 0 deletions
13
courseSection/psi/EditPSI/src/jetbrains/plugindev/course/editpsi/Task.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package jetbrains.plugindev.course.editpsi | ||
|
||
import com.intellij.openapi.command.WriteCommandAction | ||
import org.jetbrains.kotlin.psi.KtNamedFunction | ||
|
||
|
||
fun editFunctionName(function: KtNamedFunction, newName: String) { | ||
val project = function.project | ||
|
||
WriteCommandAction.runWriteCommandAction(project) { | ||
function.setName(newName) | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
courseSection/psi/editPSI/task-info.yaml → courseSection/psi/EditPSI/task-info.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,11 @@ | ||
type: edu | ||
custom_name: Rename function using PSI | ||
files: | ||
- name: src/jetbrains/plugindev/course/editpsi/Task.kt | ||
visible: true | ||
placeholders: | ||
- offset: 220 | ||
length: 127 | ||
placeholder_text: TODO() | ||
- name: test/jetbrains/plugindev/course/editpsi/Tests.kt | ||
visible: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
1 change: 1 addition & 0 deletions
1
courseSection/psi/What is PSI/task-info.yaml → courseSection/psi/IntroToPsi/task-info.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
type: theory | ||
custom_name: What is PSI? | ||
files: | ||
- name: src/Person.kt | ||
visible: true |
File renamed without changes.
5 changes: 5 additions & 0 deletions
5
courseSection/psi/addPSI/task-info.yaml → courseSection/psi/SortMethods/task-info.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,11 @@ | ||
type: edu | ||
custom_name: Psi Manipulation Basics | ||
files: | ||
- name: src/jetbrains/plugindev/course/addpsi/Task.kt | ||
visible: true | ||
placeholders: | ||
- offset: 228 | ||
length: 387 | ||
placeholder_text: TODO() | ||
- name: test/jetbrains/plugindev/course/addpsi/Tests.kt | ||
visible: false |
42 changes: 42 additions & 0 deletions
42
courseSection/psi/SortMethods/test/jetbrains/plugindev/course/addpsi/Tests.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package jetbrains.plugindev.course.addpsi | ||
|
||
import com.intellij.ide.highlighter.JavaFileType | ||
import com.intellij.psi.PsiClass | ||
import com.intellij.psi.PsiMethod | ||
import com.intellij.psi.util.PsiTreeUtil | ||
import com.intellij.testFramework.fixtures.BasePlatformTestCase | ||
import org.jetbrains.kotlin.psi.KtClass | ||
import org.jetbrains.kotlin.psi.KtNamedFunction | ||
|
||
class Test : BasePlatformTestCase() { | ||
|
||
fun testSolution() { | ||
var file = myFixture.configureByText("Person.kt", """ | ||
class Person { | ||
fun name() { | ||
println("My name is John") | ||
} | ||
fun surname() { | ||
println("My surname is Johnson") | ||
} | ||
fun age() { | ||
println("I am 18 years old") | ||
} | ||
} | ||
""".trimIndent()) | ||
|
||
val classes = PsiTreeUtil.findChildrenOfType(file, KtClass::class.java) | ||
for (ktClass in classes){ | ||
sortMethods(ktClass) | ||
|
||
val methods = ktClass.declarations.filterIsInstance<KtNamedFunction>() | ||
val sorted = methods.sortedBy { it.name } | ||
assertEquals(sorted, methods) | ||
} | ||
} | ||
|
||
|
||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
20 changes: 0 additions & 20 deletions
20
courseSection/psi/editPSI/src/jetbrains/plugindev/course/editpsi/Task.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
custom_name: PSI | ||
content: | ||
- What is PSI | ||
- Try PSI Viewer | ||
- Accessing PSI Elements | ||
- classCounter | ||
- editPSI | ||
- addPSI | ||
- IntroToPsi | ||
- TryPsiViewer | ||
- AccessingPsiElements | ||
- ClassCounter | ||
- EditPSI | ||
- SortMethods | ||
- AddAnnotations |