Making NameSuggestionProvider work


I was trying custom implementation of Name suggestion provider, but it doesn't seem to get even initialized. 


class CustomNameSuggestionProvider : NameSuggestionProvider {
  init {
    println("Name Suggestion Provider initialized")

  override fun getSuggestedNames(
    element: PsiElement, p1: PsiElement?, result: MutableSet<String>)
    : SuggestedNameInfo? {
    result.addAll(listOf("suggestion1", "suggestion2",))
    return null


 I registered it like this within extensions like rest of providers that work:

<nameSuggestionProvider implementation="jarek.plugin.CustomNameSuggestionProvider">

The code however doesn't trigger, I tried to test this on test Kotlin file within ide on ‘introduce variable’ refactoring and nothing happens, not that I expected it to work as init block of plugin does't run after all.

Is there any extra step to make this Provider load? For instance associating it with particular language?



It's hard to help without more details. I suggest finding usages of com.intellij.refactoring.rename.NameSuggestionProvider#EP_NAME and adding breakpoints on its usages and debug why your provider is skipped. Maybe it should be ordered with order="first"?


Thank you for helping me get a bit further with this issue,

the real issue is that that it actually works with rename refactoring but fails to work with Introduce  Variable refactoring.

Is there chance that you may know what could cause one name related refactoring work with NameSuggestionProvider, while the other one doesn't work?


Hi Jarek,

It depends on the implementation for a specific language. For Kotlin, it seems to be done here (for K2):

It uses its own KotlinNameSuggester, which doesn't use NameSuggestionProvider, as far as I can see.


Please sign in to leave a comment.