-
-
Notifications
You must be signed in to change notification settings - Fork 794
Support for BindingContext in FileProcessListener #2872
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
Comments
Yep, noticed the same. |
I took a quick look at this. I think that the breaking change here is unavoidable with detekt/detekt-api/src/main/kotlin/io/gitlab/arturbosch/detekt/api/FileProcessListener.kt Lines 18 to 22 in 2de31f1
What we could do, is use @JvmDefault
fun onProcess(file: KtFile, bindingContext: BindingContext) {
onProcess(file)
} But we would need to add a compiler flag. Is this something we want to do? |
Is there a benefit in using |
Yes but I think I overlooked the API change here. According to eclipse.org adding a API method should always be considered a breaking change (as our clients might already have a method with the same signature). In this specific case, If we don't use However, I expect the majority of our users to use Kotlin to code their custom rules/processors. Therefore, we should be fine with just: fun onProcess(file: KtFile, bindingContext: BindingContext) {
onProcess(file)
} and we should probably not be worried about our Java users (as we probably don't have any). |
Current Behavior
Implementations of
Rule
have access to theBindingContext
, granting them the ability to perform complex analysis within the scope of the entire compilation unit. On the other hand, theFileProcessListener
(andAbstractProcessor
, etc) APIs do not provide any way to access theBindingContext
, limiting their ability to resolve types, functions, and so forth.Expected Behavior
In order to enable the same level of analysis for implementations of
FileProcessListener
, the API should provide them aBindingContext
against which references can be resolved.Context
I am in the process of implementing "occurrences counting" metrics for our codebase such as "number of invocations of function A" and "number of constructor calls to classes which implement interface X". Complex queries such as this require a
BindingContext
, but the provided mechanism for making such queries,AbstractProjectMetricProcessor
, does not provide it.The text was updated successfully, but these errors were encountered: