kotlinx / ast

Generic AST parsing library for kotlin multiplatform
Apache License 2.0
325 stars 23 forks source link

Object is always parsed empty #28

Closed mbolotov closed 3 years ago

mbolotov commented 3 years ago

object node is always parsed empty. Parsing this piece of code

object MyObject {
   fun myFun() {}
}
class MyClass {
    fun myFun() {}
}

produces the following AST:

PackageHeader(identifier=[])
DefaultAstNode(description=importList, children=[])
KlassDeclaration(keyword=object, identifier=KlassIdentifier(identifier=MyObject, parameter=[], nullable=false, raw=null), type=null, annotations=[], modifiers=[], parameter=[], typeParameters=[], inheritance=[], expressions=[], raw=null)
KlassDeclaration(keyword=class, identifier=KlassIdentifier(identifier=MyClass, parameter=[], nullable=false, raw=null), type=null, annotations=[], modifiers=[], parameter=[], typeParameters=[], inheritance=[], expressions=[DefaultAstNode(description=classBody, children=[KlassDeclaration(keyword=fun, identifier=KlassIdentifier(identifier=myFun, parameter=[], nullable=false, raw=null), type=null, annotations=[], modifiers=[], parameter=[], typeParameters=[], inheritance=[], expressions=[], raw=null)])], raw=null)

MyClass shows myFun node while MyObject does not.

Lib version is 'com.github.kotlinx.ast:grammar-kotlin-parser-antlr-kotlin:c7dd6bbd54'

drieks commented 3 years ago

Hi @mbolotov,

thank you for reporting! It is fixed now, see https://github.com/kotlinx/ast/commit/5a03ad31d5be60982370d9bfeafb2cff026a54f2

Please try com.github.kotlinx.ast:grammar-kotlin-parser-antlr-kotlin:5a03ad31d5 and let me know, if it is also working for you.

mbolotov commented 3 years ago

it works for me, thanks! closing this issue