fbsamples / fbsamples/kotlin_ast_tools

Cannot match multiline template

Đang mở
#2 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Kotlin
Star
212
Fork
10
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

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
```

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.