clutcher / bh

Issue tracker for Better Highlights Intellij IDEA plugin
7 stars 0 forks source link

Add support of Lexer based highlighting, which is used in Rider to highlight C++ files #32

Closed hwooo closed 2 years ago

hwooo commented 3 years ago

2021-02-01

There is no highlighting if I write comments in Rider for UE.

clutcher commented 3 years ago

Unfortunately I can't find Rider for Unreal Engine version for Linux to debug your issue.

clutcher commented 3 years ago

There is Win and Mac versions, but still waiting for Linux version to be released.

clutcher commented 2 years ago

Rider for Unreal Engine was released, but there is no Linux version( Can anyone revalidate if it is still an issue?

neelkoos commented 2 years ago

The Linux version was released! I hope you able to fix it now.

clutcher commented 2 years ago

@hwooo @neelkoos Looks good on my side. Can you share your example, which I can use for tests?

2021-12-17_11-03-48

neelkoos commented 2 years ago

@clutcher It works with .cs but .cpp and .h not.

image

clutcher commented 2 years ago

@neelkoos Thanks.

That highlighting is special one (it is basic lexer highlighting) and it doesn't support intellij annotators, which I use for additional highlighting. I'll work on it next but it will take some time to understand how to extend that highlighting and override it.

clutcher commented 2 years ago

Intermediate results of investigation:

EditorImpl has list of change listeners, which we execute one by one. One of the listener is LexerEditorHighlighter, which holds CppLexer inside. After execution of this listener and lexer we can get from LexerEditorHighlighter data about token types and text of token.

In theory we can write and add one more listener, which will check find that highlighter, extract token types and text, process with comment highlighter and override TextAttribute.

P.S. Get token type by segment index: ((LexerEditorHighlighter) listeners[20]).getSegments().unpackTokenFromData(((LexerEditorHighlighter) listeners[20]).getSegments().getSegmentData(0))

Get token text by segment index: this.getImmutableCharSequence().subSequence(((LexerEditorHighlighter) listeners[20]).getSegments().getSegmentStart(0),((LexerEditorHighlighter) listeners[20]).getSegments().getSegmentEnd(0))