Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,6 @@ modify the target file.
The script filename should end with `.transform.kts`.

```kts
import ktast.ast.Node
import ktcodeshift.*

transform { fileInfo ->
Ktcodeshift
.parse(fileInfo.source)
Expand All @@ -86,6 +83,16 @@ The following API documents will be helpful to write a transform file.
- [API document of ktcodeshift](https://orangain.github.io/ktcodeshift/latest/api/ktcodeshift-dsl/ktcodeshift/index.html)
- [API document of ktast](https://orangain.github.io/ktast/latest/api/ast/ktast.ast/index.html)

### Implicit imports

The following imports are implicitly available in the transform file:

```kts
import ktast.ast.*
import ktast.builder.*
import ktcodeshift.*
```

### Annotations

The following annotations can be used in the transform file:
Expand All @@ -111,9 +118,6 @@ their input and output.
You can dump the AST of a Kotlin file using the [ktast.ast.Dumper](https://orangain.github.io/ktast/latest/api/ast/ktast.ast/-dumper/index.html). This is useful to understand the structure of the AST. For example:

```kts
import ktast.ast.*
import ktcodeshift.*

transform { fileInfo ->
Ktcodeshift
.parse(fileInfo.source)
Expand Down
2 changes: 1 addition & 1 deletion ktcodeshift-cli/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ dependencies {
implementation("info.picocli:picocli:4.7.6")
implementation(project(":ktcodeshift-dsl")) // the script definition module
implementation("org.jetbrains.kotlin:kotlin-test")
testImplementation("com.github.orangain.ktast:ast-psi:0.9.4")
testImplementation("com.github.orangain.ktast:ast-psi:0.10.0")
}

tasks.withType<KotlinCompile> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
@file:Import("./common.transform.kts")

import ktast.ast.Node
import ktcodeshift.*

transform { fileInfo ->
"\"\"\"\n" + renderHtml() + "\"\"\"\n"
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import ktast.ast.Node
import ktcodeshift.*

transform { fileInfo ->
Ktcodeshift
.parse(fileInfo.source)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ ktcodeshift -t ktcodeshift-cli/src/test/resources/examples/GenerateBuilders.tran

*/

import ktast.ast.*
import ktcodeshift.*
import org.jetbrains.kotlin.util.capitalizeDecapitalize.decapitalizeSmart
import java.nio.charset.StandardCharsets

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import ktast.ast.Dumper
import ktcodeshift.*

transform { fileInfo ->
Ktcodeshift
.parse(fileInfo.source)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import ktast.ast.Node
import ktcodeshift.*

val annotationNameMap = mapOf(
"Before" to "BeforeEach",
"After" to "AfterEach",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import ktast.ast.Node
import ktcodeshift.*

transform { fileInfo ->
Ktcodeshift
.parse(fileInfo.source)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ ktcodeshift -t ktcodeshift-cli/src/test/resources/examples/SortWhenBranches.tran

*/

import ktast.ast.Node
import ktcodeshift.*
import java.nio.charset.StandardCharsets

transform { fileInfo ->
Expand Down
2 changes: 1 addition & 1 deletion ktcodeshift-dsl/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ dependencies {

// Use the Kotlin JDK 8 standard library.
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
implementation("com.github.orangain.ktast:ast-psi:0.9.4")
implementation("com.github.orangain.ktast:ast-psi:0.10.0")
implementation("org.jetbrains.kotlin:kotlin-scripting-common")
implementation("org.jetbrains.kotlin:kotlin-scripting-jvm")
implementation("org.jetbrains.kotlin:kotlin-scripting-dependencies")
Expand Down
Loading