fbsamples / fbsamples/kotlin_ast_tools

Cannot match multiline template

Ouverte
#2 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub
Langage dominant
Kotlin
Étoiles
212
Forks
10
Métriques de merge des PR
Aucune PR mergée en 30 j

Description

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

Guide de contribution

Ouvrir le guide de contribution

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.