Skip to content

Commit

Permalink
syntax_highlighting_and_error_highlighting.md: minor
Browse files Browse the repository at this point in the history
  • Loading branch information
YannCebron committed Oct 16, 2023
1 parent 35eaa0c commit add1b41
Showing 1 changed file with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,17 @@ The syntax and error highlighting are performed on multiple levels: [](#lexer),

## TextAttributesKey

The class used to specify how a particular range of text should be highlighted is called [`TextAttributesKey`](%gh-ic%/platform/core-api/src/com/intellij/openapi/editor/colors/TextAttributesKey.java).
An instance of this class is created for every distinct type of item that should be highlighted (keyword, number, string, etc.).
How a particular range of text should be highlighted is defined via [`TextAttributesKey`](%gh-ic%/platform/core-api/src/com/intellij/openapi/editor/colors/TextAttributesKey.java).
An instance of this class is created for every distinct type of item that should be highlighted (keyword, number, string literal, etc.).

The `TextAttributesKey` defines the default attributes applied to items of the corresponding type (for example, keywords are bold, numbers are blue, strings are bold and green).
The `TextAttributesKey` defines the default attributes applied to items of the corresponding type (for example, keywords are bold, numbers are blue, string literals are bold and green).
Highlighting from multiple `TextAttributesKey` items can be layered — for example, one key may define an item's boldness and another one its color.

> To inspect applied `TextAttributesKey`(s) for the element at the caret, use <ui-path>Jump to Colors and Fonts</ui-path> action.
> To inspect applied `TextAttributesKey`(s) in the editor for the element at the caret, use <ui-path>Jump to Colors and Fonts</ui-path> action.
>
> The underlying `TextAttributeKey`'s external name for items in <ui-path>Settings | Editor | Color Scheme</ui-path> can be inspected using [UI Inspector](internal_ui_inspector.md#inspecting-settings).
>
{title="Looking up existing TextAttributeKey"}

## Color Settings

Expand All @@ -48,7 +50,7 @@ Thus, it will work automatically for custom languages that provide a syntax high

The first syntax highlighting level is based on the lexer output and is provided through the [`SyntaxHighlighter`](%gh-ic%/platform/editor-ui-api/src/com/intellij/openapi/fileTypes/SyntaxHighlighter.java) interface.
The syntax highlighter returns the `TextAttributesKey` instances for each token type, which needs special highlighting.
For highlighting lexer errors, the standard `TextAttributesKey` for bad characters [`HighlighterColors.BAD_CHARACTER`](%gh-ic%/platform/editor-ui-api/src/com/intellij/openapi/editor/HighlighterColors.java) can be used.
For highlighting lexer errors [`HighlighterColors.BAD_CHARACTER`](%gh-ic%/platform/editor-ui-api/src/com/intellij/openapi/editor/HighlighterColors.java) should be used.

**Examples:**

Expand All @@ -57,6 +59,7 @@ For highlighting lexer errors, the standard `TextAttributesKey` for bad characte

> Use [`HtmlSyntaxInfoUtil`](%gh-ic%/platform/lang-impl/src/com/intellij/openapi/editor/richcopy/HtmlSyntaxInfoUtil.java) to create Lexer-based highlighted code samples, e.g. for usage in documentation.
>
{title="Creating highlighted code sample"}

### Semantic Highlighting

Expand Down Expand Up @@ -160,5 +163,5 @@ To enable running `ExternalAnnotator` during indexing in [](indexing_and_psi_stu

Existing highlighting can be suppressed programmatically in certain contexts, see [](controlling_highlighting.md).

To force re-highlighting (e.g., after changing plugin specific settings), use
To force re-highlighting all open or specific file(s) (e.g., after changing plugin specific settings), use
[`DaemonCodeAnalyzer.restart()`](%gh-ic%/platform/analysis-api/src/com/intellij/codeInsight/daemon/DaemonCodeAnalyzer.java).

0 comments on commit add1b41

Please sign in to comment.