How to update the text of LeafPsiElement inside HighlightVisitor?

Answered

It seems that the LeafPsiElement does not have a set method of the text field.

11 comments
Comment actions Permalink

What do you want to achieve? Highlighting should not modify anything in general

0
Comment actions Permalink

To achieve this: https://twitter.com/sanisimov/status/1141919852929658881/photo/1

Is that possible to update the text of a LeafPsiElement? maybe reflection?

0
Comment actions Permalink

Use extension point com.intellij.openapi.editor.EditorLinePainter

0
Comment actions Permalink

Any docs or examples?

0
Comment actions Permalink

com.intellij.xdebugger.impl.evaluate.XDebuggerEditorLinePainter

0
Comment actions Permalink

Thanks, And I need to find a way to pass some information from the HighlightVisitor to EditorLinePainter, because the HighlightVisitor knows some state, so that I could choose how to display according to the state. How can I achieve this?

0
Comment actions Permalink

You can store information in User Data, e.g. on com.intellij.openapi.vfs.VirtualFile and access it later in EditorLinePainter.

0
Comment actions Permalink

And as I see, the EditorLinePainter is run before the HighlightVisitor, so is that works?

0
Comment actions Permalink

What is responsibilty of HighlightVisitor in your use-case? Can't you calculate this data in ELP instead?

0
Comment actions Permalink

So what is "ELP"?

And as I see, the EditorLinePainter does not support emoji at all, at least in version 2017.2

My code looks like:

class EmojiEditorLinePainter : EditorLinePainter() {
override fun getLineExtensions(project: Project, file: VirtualFile, line: Int): MutableCollection<LineExtensionInfo> {
val attributes = TextAttributes()
return Collections.singletonList(LineExtensionInfo("😁222222", attributes))
}
}

But actually display as:

0
Comment actions Permalink

Please note that emojis are not supported when you launch your IDE with Oracle JDK, please use JetBrains Runtime instead.

0

Please sign in to leave a comment.