I need to analyse kotlin files code, to detect the keyword "data" and "?".
The issue is I don't find any libs like JavaParser. I don't need powerfull tools, just something who return me the number of the lines.
Any idea?
This example demonstrates how to parse HTML in Android using Kotlin. Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project. Step 2 − Add the following code to res/layout/activity_main.xml. Step 3 − Add the given dependency in the build.gradle (Module: app)
Create a UsingGson.kt file under the serialize folder and copy-paste the following code into the file. We are sure you have understood that the first step creates a JSON representation of our object, and the second step creates a class that will be used to create a Kotlin object from the string.
You can try Kastree -- simple library to manipulate Kotlin source code as a set of AST objects. Show activity on this post. Besides the tools mentioned in other answers, here is another one someone may find useful:
And kotlin language is very easy to write and idiomatic. Not only evaluate expressions with +,-,*,/ but also can parse and evaluate functions like sin, cos ,log etc.
I use antlr4 to do it. And I create an open source lib: https://github.com/sarahBuisson/kotlin-parser
<dependency
<groupId>com.github.sarahbuisson</groupId>
<artifactId>kotlin-parser</artifactId>
</dependency>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With