kotlinx / ast

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

Add support for @JvmSuppressWildcards/ Annotations for types. #95

Closed birajpatel closed 1 week ago

birajpatel commented 1 year ago

Input:

interface Something

class MyClass(
    list: List<@JvmSuppressWildcards Something>
)

Outputs: found unsupported ast node 'KlassAnnotation(identifier=[KlassIdentifier(identifier=JvmSuppressWildcards ...

Need: When using Kotlin & Java together, we need to often mark Generic types using @JvmSuppressWildcards to strip out ? extend Somthing when kotlin code is compiled and used from Java. This is especially needed when using Dagger with Kotlin.

Could you please add support for this? Thanks in advance :)

birajpatel commented 1 year ago

@drieks I can work on the potential fix & send you a PR, but just wanted to make sure you are still supporting the project before making the efforts.

drieks commented 1 year ago

Hi, this would be great! I'm currently working on #89. Unfortunately I don't have much time for this at the moment, but feed free to ask any question!

I already created a unit test in the branch issue95.

birajpatel commented 1 year ago

@drieks Great I will propose a fix in coming days. I don't see the tests yet in branch issue95, may be you forgot to push the changes? Screenshot 2023-02-08 at 10 39 45

I am thinking the fix would be similar to this fix. Basically I plan to add List<KlassAnnotations> in KlassIdentifier, similar to your fix for modifiers let me know if that sounds ok?

Also I couldn't import the project, I keep getting :

Could not GET 'https://mvnrepository.com/artifact/com.github.gundy/semver4j/com/github/drieks/antlr-kotlin/antlr-kotlin-gradle-plugin/ce9944fa0c/antlr-kotlin-gradle-plugin-ce9944fa0c.pom'. Received status code 403 from server: Forbidden
drieks commented 1 year ago

Hi @birajpatel, I pushed master to the feature branch.. now the correct commit should be visible :) Yes, this download problem is the reason for #89, I will try to publish both antlr-kotlin ant kotlinx.ast to maven central. you can fix this by cloning antlr-kotlin locally, then publish to local maven:

./gradlew clean publishToMavenLocal -x test

after this, you can change the local reference in build.gradle.kts in kotlinx.ast to you local dependency

drieks commented 1 week ago

Hi @birajpatel, thank you, I merged your changes!