Annotations "Jump to Source"

Answered

Hi,

in my Pycharm plugin, I have text editor annotations - errors and warnings. If I use the the editor shortcut F2 - Next Highlighted Error, the caret properly jumps to the problem. However, in the Tool Window Problems, where all the annotations are listed, if I double-click on the problem or use the context-menu Jump to Source (F4), the caret is not affected.

My annotation creation code:

annotationHolder.newAnnotation(HighlightSeverity.ERROR, "Invalid command header delimiter").
range(psiElement).
gutterIconRenderer(iconSyntaxError).
enforcedTextAttributes(errorWave).
tooltip("Invalid command header delimiter").
create();

My question is - how do I make the caret jump to the source from the Problems Tool Window?

 

Thanks,

Milo

0
9 comments

What exactly is psiElement here? Does it work if you comment out the range(psiElement) call?

0

Hi Yann,

 

the PSI Element:

 

Removing the call range(psiElement) does not change anything...

 

And as I wrote, it works correctly in the editor if I press Next Highlighted Error (F2):

The Problems also show the correct line number, but double-clicking does nothing... :-(

Milo

0

Sorry for delay, waiting for answer..

0
Avatar
Alexey Kudravtsev

Hello. So this is some sort of your own PSI? Because It can't find ScpiTokenType anywhere.

Please make sure that the implementation of this PSI node correctly handles navigation, meaning `yourCustomPsiElement.navigate()` works.

0

Hi Alexey,

 

I am using the *.bnf and *.flex definitions to generate my SCPI parser and the lexer.

In  my PsiElement extention interfaces, I added default method getNavigationElement(), for example:

public interface ScpiSingleCmd extends PsiElement
{
    @Override
    default PsiElement getNavigationElement()
    {
        return this;
    }
}
 
This did not help... Then, in the structure that the JFlex generated, I added the following implementations:
public class ScpiSingleCmdImpl extends ASTWrapperPsiElement implements ScpiSingleCmd {

...

@Override
  public void navigate(boolean requestFocus)
  {
    super.navigate(requestFocus);
  }

  @Override
  public boolean canNavigate()
  {
    return true;
  }

  @Override
  public boolean canNavigateToSource()
  {
    return true;
  }
}
This did not help either. Do I need to do some special implementation of navigate()? Can you maybe give some example?
 
Thanks
0
Avatar
Alexey Kudravtsev

Hi. By "it didn't help" you meant `scpiElement.navigate()` method didn't navigate correctly, or this method was never called?

0

The method navigate() is not called at all. But as I wrote, the navigation works correctly in the editor if I press Next Highlighted Error (F2). Even then, the navigate() is not called. In other words, my breakpoint in the navigate() was never hit.

0
Avatar
Alexey Kudravtsev

I can't seem to reproduce this problem. Is there any plugin I can download or something to try to reproduce?

0

Please sign in to leave a comment.