galex
05/05/2022, 9:59 AMAnalysisHandlerExtension
is the right place for things like returning errors if the class name is not valid (as a simple use case).
To do so I've implemented something like this:
class CGAnalysisHandlerExtension : AnalysisHandlerExtension {
override fun doAnalysis(
project: Project,
module: ModuleDescriptor,
projectContext: ProjectContext,
files: Collection<KtFile>,
bindingTrace: BindingTrace,
componentProvider: ComponentProvider
): AnalysisResult? {
files.forEach { file ->
val fileName = file.name.replace(".kt", "")
file.children.forEach {
when (it) {
is KtClass -> {
if (it.name != fileName) {
bindingTrace.report(UNDERSCORE_IS_RESERVED.on(it))
return AnalysisResult.compilationError(bindingTrace.bindingContext)
}
}
}
}
}
return super.doAnalysis(project, module, projectContext, files, bindingTrace, componentProvider)
}
}
Doing so I thought I'd see the IDE underline the className in red with its error but the IDE doesn't react to this report, only when compiling and in the Build Output (see screenshot).
So my question is the following: What is the missing piece here to have the IDE show the report/error as any other errors, and can't I have this check actually happen when the class is in the "Analyzing..." phase of the IDE?
Thanks in advance!galex
05/05/2022, 11:37 AMgalex
05/05/2022, 11:46 AMraulraja
05/05/2022, 11:53 AMorg.jetbrains.kotlin.fir.analysis.extensions.FirAdditionalCheckersExtension
raulraja
05/05/2022, 11:54 AMraulraja
05/05/2022, 11:54 AMgalex
05/05/2022, 12:11 PMgalex
05/06/2022, 6:27 AMraulraja
05/06/2022, 8:15 AMraulraja
05/06/2022, 8:15 AMJavier
05/06/2022, 8:18 AMgalex
05/06/2022, 8:19 AMJavier
05/06/2022, 8:19 AMgalex
05/06/2022, 8:30 AMraulraja
05/06/2022, 8:41 AM