dvdciri / daggraph

Dagger dependency graph generator for Android Developers
MIT License
1.15k stars 58 forks source link

Add support to Analyze Kotlin project #11

Closed ravidsrk closed 6 years ago

ravidsrk commented 6 years ago

Description

v3n3 commented 6 years ago

@ravidsrk i tried it and you need to update the injectRegex:

const injectRegex = /@Inject(?:\n|.)*?\s+(?:protected|public)*\s*(\w*)/g;

this regex match something like:

@Inject
public MyType field;

So it causes issues with kotlin code. You should replace it with:

const injectRegex = /@Inject(?:\n|.)*?\s+(?:protected|public|var|val|lateinit|.+?\:)*\s*(\w*)/g;

It will also cause issues with constructor instantiation.

class test @Inject constructor(var injection1:InjectionOne)

So we need to find a good Regex to support that scenario as well or add an extra step for kt files for constructor injection.

dvdciri commented 6 years ago

Thanks for the PR mate. Completely forgot about Kotlin, yeah let's think about a proper regex that works with both!

dvdciri commented 6 years ago

@ravidsrk Just finished to setup the default branches for the PRs, can i ask you to create PR that goes into develop and not master? So i can start having a look at the regex and on what @v3n3 provided! 😄