VariableInplaceRenameHandler - endless loop

trying to extend it.

took the code from here:

https://github.com/joewalnes/idea-community/blob/master/platform/lang-impl/src/com/intellij/refactoring/rename/inplace/VariableInplaceRenameHandler.java

when press F2 (inline rename)
1) a prompt pops up to choose RenameHandler "What would you like to do?" <...> or VariableInplaceRenameHandler ?

so I choose mine (specified in plugin.xml under <renameHandler implementation="...")

then in doRename:

RenameHandler handler = RenameHandlerRegistry.getInstance().getRenameHandler(dataContext);
  
handler is an instance of this superclass of VariableInplaceRenameHandler
 
 (the same popup comes up again)
  
handler.invoke(..)
 
 takes us to 
 
public void invoke(@NotNull final Project project, final Editor editor, final PsiFile file, final DataContext dataContext)

in this same superclass of VariableInplaceRenameHandler

which calls the same doRename.

so we get this endless loop and also another error:

ERROR - ellij.ide.impl.DataManagerImpl - cannot share data context between Swing events; initial event count = 1983; current event count = 3553
java.lang.Throwable
 at com.intellij.openapi.diagnostic.Logger.error(Logger.java:115)
 at com.intellij.ide.impl.DataManagerImpl$MyDataContext.getData(DataManagerImpl.java:346)
 at com.intellij.openapi.actionSystem.DataContextWrapper.getData(DataContextWrapper.java:38)
 at com.intellij.openapi.actionSystem.AnActionEvent$1.getData(AnActionEvent.java:145)
 at com.intellij.openapi.actionSystem.DataKey.getData(DataKey.java:75)
 at com.intellij.refactoring.rename.RenameHandlerRegistry.getRenameHandler(RenameHandlerRegistry.java:98)


any thoughts?

1 comment
Comment actions Permalink

this could be an answer:

renamer.performInplaceRename(); 
  
returned false because 
 
InplaceRefactoring.checkLocalScope()
 
returned null
  
overriding checkLocalScope fixed it.
 

I did not realize that in-place renaming checks scopes.

век живи - век учись ;)

0

Please sign in to leave a comment.