fbsamples / fbsamples/kotlin_ast_tools

Cannot match multiline template

オープン
#2 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
Kotlin
スター
212
フォーク
10
PR マージ指標
30日以内にマージされた PR はありません

説明

Hello, thank you for sharing this tool. I found a problem when trying to match multiline:

given:
```
private var otherField: String? = null

@JvmField
@Inject
var fileDownloader: FileDownloader? = null
```

Matcher:

```
.replaceAllWithVariables(
matcher =
template {
val a by match()
val b by match()
"""
@JvmField
@Inject
var $a: $b? = null
""".trimIndent()
},
replaceWith = { (result, variables) ->
val a by variables
val b by variables
"""
@Inject
lateinit var $a: $b
""".trimIndent()
}
```

this tool will throw exception
```
Exception in thread "main" java.lang.IllegalStateException: Template references variable $a as a matcher of KtProperty, but variable was defined as a matcher of KtExpression
```

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。