Find usages dialog freezes/deadlocks upon rename

Hi, simple question: what would cause rename to show the find uses dialogue, complete the progress bar and then freeze, spinning the ball? pausing the debugger shows nothing interesting except everybody's parked. All I did was make identifier nodes implement PsiNamedElement. could not be simpler:

 
public class IdentifierPSIElement extends LeafPsiElement implements PsiNamedElement {
   protected String name = null; // an override to input text ID if we rename via intellij

   public
IdentifierPSIElement(IElementType type, CharSequence text) {
      super(type, text);
   }

   @Override
   public
String getName() {
      if ( name!=null ) return name;
      return getText();
   }

   @Override
   public
PsiElement setName(@NonNls @NotNull String name) throws IncorrectOperationException {
      this.name = name;
      return this;

       }
...
}

any ideas why the ide freezes?

thanks!
Ter

0
6 comments
Avatar
Permanently deleted user

More data:  when I implement a simple find usages provider, find usages operations complete with no problem. subsequent rename attempts fail and lock the GUI thread.
Ter

0
Avatar
Permanently deleted user

Ugh. I have no idea why but solving another problem, setting text range of my named element, prevented the freeze:

 
public class SampleElementRef extends PsiReferenceBase<IdentifierRefNode> {
   protected String id;
   public SampleElementRef(@NotNull IdentifierRefNode element, String id) {
      /** WARNING: You must send the text range or you get this error:
       * "Cannot find manipulator for PsiElement(ID) in org.antlr.jetbrains.sample.SampleElementRef"...
       *  when you click on an identifier.
       *
       *  Wow. This also solved the rename issue that was causing GUI thread
       *  to deadlock after the rename.
       */
      super
(element, element.getTextRange());
      this.id = id;
   }
0

This is a strange implementation of setName(). setName() is supposed to update the actual text of the file according to the new name passed to the method as a parameter. Simply storing the name in a field without updating the text is going to lead to all sorts of inconsistencies.

0
Avatar
Permanently deleted user

Thanks Dimtry! I was just trying to get something braindead working but apparently I made it TOO braindead. hahaha.  I also got the spinning ball of death when I did a PSI replace. I'll try again now with the range sent up to super.
Ter

0
Avatar
Permanently deleted user

even with proper node replacement, unless I set the text range, it freezes. odd but ok, works now.
Ter

0
Avatar
Permanently deleted user

For the record, I finally traced the spinning ball of death to the use of Dragon voice recognition for Mac. Dragon has to integrate with the GUI to figure out what your changes to a document are for recognition purposes, but it does not interact well with intellij.

0

Please sign in to leave a comment.