How to update the text of LeafPsiElement inside HighlightVisitor?

已回答

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

0

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

0
Avatar
Permanently deleted user

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

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

0

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

0
Avatar
Permanently deleted user

Any docs or examples?

0

com.intellij.xdebugger.impl.evaluate.XDebuggerEditorLinePainter

0
Avatar
Permanently deleted user

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

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

0
Avatar
Permanently deleted user

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

0

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

0
Avatar
Permanently deleted user

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

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

0

请先登录再写评论。