Is it possible to understand which phase right now in LineMarkerProviders?

Answered

Hello,

This documentation  

https://plugins.jetbrains.com/docs/intellij/line-marker-provider.html#best-practices-for-implementing-line-marker-providers

says

LineMarkersPass queries all LineMarkerProviders in two phases:

  • The first pass is for all elements visible in the Editor window,
  • The second pass is for the rest of the elements in the file.

Is it possible to understand is it first phase or second in LineMarkerProviders?

 

0
3 comments

Hi Alexandr,

What is the use case? Why do you need this?

0

Hi Karol,

 

Thank you for your response! I implemented LineMarkerProviderDescriptor. And I need to show gutter icons for provided lines. But for different languages, I have different results. For example, if it's Language.ANY (plain text) will display a gutter icon only once. But if I install the Python plugin (for example) and open some test.py file it will show a gutter icon twice. 

To find PsiElement for line I use next code

val document: Document = PsiDocumentManager.getInstance(project).getDocument(psiFile) ?: return null

val targetOffset = document.getLineStartOffset(calculateLineNumber(lineNumber))

val element: PsiElement = psiFile.findElementAt(targetOffset) ?: return null

return LineMarkerInfo(
element,
getTextRange(element, targetOffset),
MyIcons.DocumentGutterIcon,
{ documentsTooltipText },
DocumentGutterIconNavigationHandler(docs),
GutterIconRenderer.Alignment.LEFT,
{ documentsTooltipText }
)


And getTextRange(element, targetOffset) method could return TextRange(targetOffset, targetOffset) for Language.ANY and psiElement.textRange for some specific icon

0

I'm sorry, but I still don't get why you need to know in which phase your marker is added. Do I understand correctly that you get duplicate gutter icons in Python files, and you want to know which phase you are in for debugging purposes?

This part can be your entry point for debugging the issue: https://github.com/JetBrains/intellij-community/blob/master/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/LineMarkersPassFactory.java#L44

0

Please sign in to leave a comment.