Caret on wrong position for renaming

I have a problem with the position of the caret when I try to rename an element. My language looks like this:
Unbenanntes Bild.png

The SOL_PROPERTY_DEFINITION is the complete block and implements PSINamedElement:

  public static PsiElement getNameIdentifier(SOLPropertyDefinition element) {         ASTNode keyNode = element.getNode();         ASTNode childByType = keyNode.findChildByType(SOLTypes.PROPERTY_NAME);         if (childByType != null) {             PsiElement psi = childByType.getPsi();             return psi;         } else {             return null;         }     }

However, when I want to rename the entity, The caret has to be over the SOL_PROPERTY_TYPE (BOOLEAN).
Thanks in advance, Sebastian

Comment actions Permalink

I forgot to mention that I want the caret to be over the PROPERTY_NAME

Comment actions Permalink

Have to bump this as I've got exactly the same issue.

I have a RecordTypeDef which is a PsiNameIdentifierOwner, looks like this:

record SomeName { .. more stuff here .. }

And then there are references to it. References get highlighted when caret is on "record" keyword, not when it's on "SomeName" (which is what getNameIdentifier returns). What's the right way to fix this?



Comment actions Permalink

found it after a bit of debugging (see TargetElementUtil::getNamedElement, currently line 367).

RecordTypeDef should override getTextOffset to return identifier offset. In Sebastian's case that would be:

int getTextOffset() { return getNameIdentifier().getTextOffset(); }


Please sign in to leave a comment.