Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot match multiline template #2

Open
DjakaTechnology opened this issue Dec 30, 2022 · 0 comments
Open

Cannot match multiline template #2

DjakaTechnology opened this issue Dec 30, 2022 · 0 comments

Comments

@DjakaTechnology
Copy link

DjakaTechnology commented Dec 30, 2022

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<KtExpression>(
                matcher =
                template {
                    val a by match<KtExpression>()
                    val b by match<KtExpression>()
                    """
                        @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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant