Adding Markers/Icons to Editor using Line Numbers in Plugin

I'm trying to add icons to the gutter of the editor using just the line number and the file name.

The plugin I'm building runs a service and returns the line numbers, tooltip text and the name of the files that have problems. I've seen approaches using the Line marker provider but that wouldn't work for me because I don't have the PSI elements that have problems. I only have the line number and the file name. How can I use this info to add a marker/icon to to the gutter of the editor?

 

1
3 comments
Avatar
Permanently deleted user

Well, you shouldn't worry about no PSI for your file. IDEA runs Line marker providers for already created PSI, even if it's a plain text file, in which case the PSI will be the only node containing the whole text.

So all you have to do is to implement `LineMarkerProvider.getLineMarkerInfo(PsiElement element)` and create the corresponding LineMarkerInfo. For example in case of plain text file you could create LineMarkerInfo(element = whole file, range = the range of the line you want to mark with the icon)

1

Thanks for your response Alexey.

The problem is that the output is that the file I'm using doesn't have the original text from the file. The format is changed. The only reliable information I get from the service is the name of the file and the line numbers. Can I use just this information to add icons to the editor?

0
Avatar
Permanently deleted user

the LineMarker API is following: new LineMarkeInfo() creates line marker for the line in the given PsiFile at given (startOffset, endOffset). If some of this information is not available, you are out of luck.

0

Please sign in to leave a comment.