Giter Site home page Giter Site logo

kotlin_ast_tools's People

Contributors

cgrushko avatar facebook-github-bot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

kotlin_ast_tools's Issues

Update documentation for running project

./gradlew run <kotlin file> command is failing.

The correct command is
./gradlew run --args <kotlin file path>
or

./gradlew run --args="<kotlin_file_path>"

or for multiple files

./gradlew run --args="<kotlin_file_path_1> <kotlin_file_path_2>"

Is it possible to resolve types from other files using Kotlin Compiler APIs?

By just using Kotlin Compiler APIs to parse the AST, we can only resolve AST for one particular file. But is it possible to resolve types from other files?

To resolve types and other class information of the class that is in some other file, we would need bindingContext. I assume when we are developing a compiler plugin we would get the binding context. But if we are solely relying on Kotlin compiler APIs and parsing on one file at a time, is it possible to resolve the types of classes in other files?

Relevant questions:
https://discuss.kotlinlang.org/t/how-to-get-declaring-ktfile-ktclass-using-ktcallexpression/26271/1
https://stackoverflow.com/questions/44986763/psitreevisitor-how-to-find-out-type-of-ktcallexpression-receiver

Cannot match multiline template

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.