diff options
author | Itamar <itamar8910@gmail.com> | 2022-02-06 23:02:34 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-02-09 00:51:31 +0100 |
commit | 4646bf4b9221490f1eca39f894d84a34646f5421 (patch) | |
tree | a76200f8f105fb32978885759c45e37e525b05df /Userland/Libraries/LibSyntax | |
parent | 4737fc2485d6d5b311e5b3c6f7bac096fc30412b (diff) | |
download | serenity-4646bf4b9221490f1eca39f894d84a34646f5421.zip |
LibCpp: Add SemanticSyntaxHighlighter
The SemanticSyntaxHighlighter uses TokenInfo results from the
language server to provide 'semantic' syntax highlighting, which
provides more fin-grained text spans results.
For example, the SemanticSyntaxHighlighter can color function calls,
member fields references and user-defined types in different colors.
With the simple lexer-only syntax highlighter, all of these tokens were
given the same text highlighting span type.
Since we have to provide immediate highlighting feedback to the user
after each edit and before we get the result for the language server,
we use a heuristic which computes the diff between the current tokens
and the last known tokens with compete semantic information
(We use LibDiff for this).
This heuristic is not very performant, and starts feeling sluggish with
bigger (~200 LOC) files.
A possible future improvement would be only computing the diff for
tokens in text ranges that have changes since the last commit.
Diffstat (limited to 'Userland/Libraries/LibSyntax')
-rw-r--r-- | Userland/Libraries/LibSyntax/Highlighter.h | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/Userland/Libraries/LibSyntax/Highlighter.h b/Userland/Libraries/LibSyntax/Highlighter.h index bed19b3fbd..5351b462bc 100644 --- a/Userland/Libraries/LibSyntax/Highlighter.h +++ b/Userland/Libraries/LibSyntax/Highlighter.h @@ -56,6 +56,12 @@ public: }; Vector<MatchingTokenPair> matching_token_pairs() const; + template<typename T> + bool fast_is() const = delete; + + // FIXME: When other syntax highlighters start using a language server, we should add a common base class here. + virtual bool is_cpp_semantic_highlighter() const { return false; } + protected: Highlighter() { } |