Search Everywhere | File search gotoFileContributor not work from 2022.01
Answered
I implemented ChooseByNameContributorEx2 for next behavior:
When I click ctrl+n (File search) and enter MY-FILE-NAME, I want to found MY_FILE_NAME.groovy too.
<gotoFileContributor implementation="com.icthh.xm.extensions.LepChooseByNameContributor" />
open class LepChooseByNameContributor2: ChooseByNameContributorEx2 {
val delegate: ChooseByNameContributorEx = DefaultFileNavigationContributor()
override fun processNames(processor: Processor<in String>, parameters: FindSymbolParameters) {
processNames(processor, parameters.searchScope, parameters.idFilter)
}
override fun processNames(processor: Processor<in String>, scope: GlobalSearchScope, filter: IdFilter?) {
delegate.processNames({ name ->
if (name.endsWith(".groovy")) {
processor.process(name)
processor.process(replaceFromUnderscores(name))
}
true
}, scope, filter)
}
override fun processElementsWithName(
name: String,
processor: Processor<in NavigationItem>,
parameters: FindSymbolParameters
) {
val completePattern = parameters.completePattern
val transliteratedPattern = replaceToUnderscores(completePattern)
if (transliteratedPattern != completePattern) {
val transliteratedName = replaceToUnderscores(name.substringBeforeLast(".groovy")) + ".groovy"
delegate.processElementsWithName(
transliteratedName, processor,
FindSymbolParameters(transliteratedPattern, transliteratedName, parameters.searchScope)
)
}
}
private fun replaceFromUnderscores(symbol: String) = symbol.replace("_".toRegex(), "-")
private fun replaceToUnderscores(symbol: String) = symbol.replace("-".toRegex(), "_")
}
It works fine in previous version of intellij idea. But on 2022.01 it does not work.
Please sign in to leave a comment.
This should be fixed in upcoming 2022.1.1 bugfix release.