Custom PSI error message when hovered on error

Answered

Hi all,

I am working on a plugin for some language and I want to customize the error message displayed when tokens are not matching. Below is the snapshot.

Here Instead of CDSToken.DOT or CDSTokenType.SEMICOLON expected I want to display " '.' or ';' expected, got ',' ".

Similarly, for other keywords that I have in my language, I don't want to display this type of message.

How can I achieve this?

I am a total noob here. Please elaborate or give a reference when answering. :-)

Thank you,

Ajit

 

0
2 comments

What do you pass in your TokenType CTOR as "debugName"?

1

I have defined keywords in uppercase and the same is passed. 

new CDSTokenType("ARRAYOF");

I just updated my TokenType toString() method to not add TokenType before any keyword. It was like "TokenType." + debugName;

Also, I figured that if I create a mapper in my toString() method to return the expected text, it'll work. But I am not sure if that's the recommended approach to achieve this objective.

Like I added a switch statement to match every debugName and return the actual keyword there.

For ex: 

case "ARRAYOF" : return "array of";
case "SEMICOLON" : return ";";

I am not sure if there is a better way of doing this task.

Please suggest me.

 

Thanks and regards,

Ajit

0

Please sign in to leave a comment.