kotlinx / ast

Generic AST parsing library for kotlin multiplatform
Apache License 2.0
317 stars 22 forks source link

Properties from companion object are not parsed as KlassDeclaration instances #38

Open mbolotov opened 3 years ago

mbolotov commented 3 years ago

Given the following code:


class MyClass {
    val myClassProp = "myClassProp"
    companion object {
        const val myCompanionConst = "myCompanionConst"
        val myCompanionProp = "myCompanionProp"
    }
}

the parser returns myConst and myClassProp as a KlassDeclaration instances, but the myCompanionProp is parsed as a tree of DefaultAstNode/DefaultAstTerminal which are hard to analyze: image

Is this the expected behavior?

drieks commented 3 years ago

Hi @mbolotov,

thank you for reporting! The recursive tree parsing call for companion objects was missing, it should be working now.

Please try version 6e557bc3ba