1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 20:17:44 +00:00

LibSyntax+Userland: Make LibSyntax not depend on LibGUI

This moves some stuff around to make LibGUI depend on LibSyntax instead
of the other way around, as not every application that wishes to do
syntax highlighting is necessarily a LibGUI (or even a GUI) application.
This commit is contained in:
Ali Mohammad Pur 2023-08-29 12:43:41 +03:30 committed by Tim Flynn
parent 2495302991
commit ba4db899d4
26 changed files with 773 additions and 683 deletions

View file

@ -45,11 +45,11 @@ void IniSyntaxHighlighter::rehighlight(Palette const& palette)
Optional<IniToken> previous_section_token;
IniToken previous_token;
Vector<TextDocumentFoldingRegion> folding_regions;
Vector<Syntax::TextDocumentFoldingRegion> folding_regions;
Vector<GUI::TextDocumentSpan> spans;
Vector<Syntax::TextDocumentSpan> spans;
for (auto& token : tokens) {
GUI::TextDocumentSpan span;
Syntax::TextDocumentSpan span;
span.range.set_start({ token.m_start.line, token.m_start.column });
span.range.set_end({ token.m_end.line, token.m_end.column });
span.attributes = style_for_token_type(palette, token.m_type);
@ -61,7 +61,7 @@ void IniSyntaxHighlighter::rehighlight(Palette const& palette)
previous_section_token = token;
} else if (token.m_type == IniToken::Type::LeftBracket) {
if (previous_section_token.has_value()) {
TextDocumentFoldingRegion region;
Syntax::TextDocumentFoldingRegion region;
region.range.set_start({ previous_section_token->m_end.line, previous_section_token->m_end.column });
// If possible, leave a blank line between sections.
// `end_line - start_line > 1` means the whitespace contains at least 1 blank line,
@ -80,7 +80,7 @@ void IniSyntaxHighlighter::rehighlight(Palette const& palette)
previous_token = token;
}
if (previous_section_token.has_value()) {
TextDocumentFoldingRegion region;
Syntax::TextDocumentFoldingRegion region;
auto& end_token = tokens.last();
region.range.set_start({ previous_section_token->m_end.line, previous_section_token->m_end.column });
region.range.set_end({ end_token.m_end.line, end_token.m_end.column });