-
-
Notifications
You must be signed in to change notification settings - Fork 784
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Minimise usage of Kotlin reflection #1883
Conversation
b2321a5
to
771a4df
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really like this improvement.
Why did you close this @3flex ?
* Remove kotlin-reflect usage in detekt-rules * detekt-gradle-plugin doesn't use Kotlin reflection * detekt-rules needs kotlin-reflect for tests * Remove more class references * Function should remain internal
|
||
/** | ||
* Tests if this element is part of given PsiElement. | ||
*/ | ||
fun PsiElement.isPartOf(clazz: KClass<out PsiElement>): Boolean = getNonStrictParentOfType(clazz.java) != null | ||
inline fun <reified T : PsiElement> PsiElement.isPartOf() = getNonStrictParentOfType<T>() != null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting, I remember that I had to rewrite some psi helpers because the kotlin compiler throw errors because he could not resolve all types or something ...
Just out of curiosity, what was the reasoning for this changes? I see the code is now much more readable :). |
That was the only reason :) I hope it doesn't reintroduce any bugs. |
* Remove kotlin-reflect usage in detekt-rules * detekt-gradle-plugin doesn't use Kotlin reflection * detekt-rules needs kotlin-reflect for tests * Remove more class references * Function should remain internal
* Remove kotlin-reflect usage in detekt-rules * detekt-gradle-plugin doesn't use Kotlin reflection * detekt-rules needs kotlin-reflect for tests * Remove more class references * Function should remain internal
* Remove kotlin-reflect usage in detekt-rules * detekt-gradle-plugin doesn't use Kotlin reflection * detekt-rules needs kotlin-reflect for tests * Remove more class references * Function should remain internal
Remaining usage is in detekt-api (KClass is used in a public API, and there are some property delegates which require it).