This plugin allows creating custom highlighting for commented lines and language keyword. Commented lines highlighting is supported for any language, highlighting of language keywords supports Java, Kotlin, PHP, Javascript/Typescript, C/C++/ObjectiveC and C# ( for example, highlight "public" keyword). Plugin has possibility to define custom user tokens for commented line highlighting.
- Open settings window
- Editor->Comment Highlighter
- Click on "+" sign, select type of highlight token/keyword and enter token/keyword itself in popup. (Third screenshot of plugin)
- Click "Apply"
- Reopen settings window. This is mandatory step due to bug in Intellij
- Open settings window
- Editor->Comment Highlighter
- Enable checkbox "Enable comment highlighting in Plain text files."
- Click "Apply"
In plain text files could be used "#" or "//" as a comment line.
General architecture is simple and has 2 main parts:
- Annotators:
- AbstractCommentHighlighterAnnotator
abstract Annotator
to highlight comments defined in Intellij AST.
- GenericCommentHighlighterAnnotator highlights PsiComment type. In such way plugin is able to handle any language, supported by Intellij IDEA.
- AbstractKeywordHighlighterAnnotator
abstract Annotator
to highlight keywords defined in Intellij AST.
- Each language requires specific implementation of isKeywordElement and isMethodAccessModifierKeyword.
- findClassByName is used instead of instanceof comparing to be able to compile plugin on any type of IDE( PyCharm,Rider etc).
- Language specific implementations:
- JavaKeywordHighlighterAnnotator
- KotlinKeywordHighlighterAnnotator
- CKeywordHighlighterAnnotator
- CSharpKeywordHighlighterAnnotator
- PHPKeywordHighlighterAnnotator
- JavaScriptKeywordHighlighterAnnotator
- AbstractLexerPostProcessingHighlighterAnnotator
abstract Annotator
to highlight both comments and keywords defined in Lexer segments. Used for files, which have only lexer highlighting, for example C++ files in Rider.
- CPPLexerPostProcessingHighlighterAnnotator highlights CppElementType comment and keyword tokens in CPPFile type.
- AbstractCommentHighlighterAnnotator
abstract Annotator
to highlight comments defined in Intellij AST.
- Highlighters:
- CommentHighlighter main class to define, what part of comment must be highlighted.
- KeywordHighlighter main class to define, what keywords must be highlighted.
- (Feature) Add possibility to highlight Javascript/Typescript keywords.
- (Feature) Add support of Lexer based highlighting, which is used in Rider to highlight C++ files.
- (Feature) Add support for java tokens highlighting (null, true, false).
- (Bug Fix) Fix comment highlighting for tokens, which contains other tokens.
- (Bug Fix) Fix comment highlighting for Twig and Blade templates.
- (Bug Fix) Add tab sign as valid start line char.
- (Feature) Add possibility to highlight PHP keywords.
- (Feature) Add possibility to highlight comments in plain txt files.
- (Feature) Add keyword highlighting for C/C++/ObjectiveC.
- (Feature) Add possibility to highlight Kotlin keywords.
- (Improvement) Migrate on newest gradle.
- (Improvement) Move settings into panel into "Editor" section.
- (Feature) Add keyword highlighting for C#.
- (Feature) Add possibility to remove/modify default tokens.
- (Feature) Add possibility to highlight any keyword type, not only method keywords.
- (Feature) Add possibility to create custom highlighting for java keyword.
- (Feature) Add default highlight for public keyword.
- (Improvement) Migrate on newest gradle.
- (Improvement) Migrate on java 11 toolchain.
- (Improvement) Migrate on non-deprecated api usage.
- (Improvement) Disable until version plugin definition.
- (Bug Fix) Fix StringIndexOutOfBoundsException on Rider IDE.
- (Bug Fix) Made compatible with EAP builds.
- (Documentation) Add how-to define custom user token.
- (Feature) Add possibility to create custom tokens.
- (Bug Fix) Define plugin compatibility starting from version 2019.1.
- (Feature) Improve performance.
- (Feature) Change default color scheme.
- (Bug Fix) Fix fail positive highlight of xml comments.
- (Feature) Add support for one line, multi line and doc comments highlighting.