Closed martinflorek closed 5 years ago
Thank you @martinflorek, it should be easy to fix. I will have a look at the issue this evening.
Hi @martinflorek, I added support for nullable types in Version ac934f1076
.
KlassIdentifer
contains now a Boolean flag nullable
(added in commit https://github.com/kotlinx/ast/commit/6055b752f13166ea33bf33fe8e5a568e5867fdad)
Structure after call to summary
:
PackageHeader(com.example.test)
importList
KlassDeclaration(class TestClass)
classBody
KlassDeclaration(fun function)
KlassDeclaration(parameter record Map<String?, String>)
Hi @martinflorek,
please try version 7fbbd71235
. I added a unit test that parses the source of kotlinx.ast
and arrow
. I fixed some small errors, all files are now parsed without AstFailure
.
There are two bugs left, I'm already working on it: #3 #4
I hope you can now use kotlinx.ast
to parse your code. If you have any suggestions please let me know :smiley:
Works perfectly now. Everything I have thrown at the parser looks OK. Just the speed is very slow. The Kastree parses my sources in a second or so and AST takes maybe 10-15 seconds. Hopefully the #3 will improve this.
Thanks for this great parser!
Ok, that's good that it's working fine now :smiley:
I know that it is slow, but currently there are no speed optimizations at all. I will look into this. What are you doing with the parsed data? Maybe running the AST transformation using Kotlin native can also speed up things. (Currently not supported but planned) I'm using kotlinpoet to create generated sources based on the parsed data.
Fits the Layout of the Klass
data classes your needs?
Klass
is OK for my use case, which is extracting annotations. It is even easier to use than Kastree.
I'm closing this issue because you wrote that it is working fine now.
Works perfectly now. Everything I have thrown at the parser looks OK. Just the speed is very slow. The Kastree parses my sources in a second or so and AST takes maybe 10-15 seconds. Hopefully the #3 will improve this.
Thanks for this great parser!
Example below will crash when calling
summary()
i.e.KotlinAstParser.parseKotlinFile(source).summary()
throwsjava.lang.UnsupportedOperationException: Empty collection can't be reduced.
.Parsing the code below, with the
String?
in a generic, leads to a new structure andsummary()
does not work anymore.