diff options
author | Andreas Kling <kling@serenityos.org> | 2021-02-07 14:40:36 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-02-07 14:40:36 +0100 |
commit | ff2438e0ceac3b99248748f6a5caf49c223e041d (patch) | |
tree | 803d42d45e7bd3f635c44d18e7628045434f95c8 | |
parent | b1f1f5afcf8f3b8a3ca10bcb6aefa05fbb2b35be (diff) | |
download | serenity-ff2438e0ceac3b99248748f6a5caf49c223e041d.zip |
LibGUI+LibCpp: Move C++ syntax highlighter to LibCpp
This makes LibGUI not depend on LibCpp.
-rw-r--r-- | Userland/Applications/TextEditor/CMakeLists.txt | 2 | ||||
-rw-r--r-- | Userland/Applications/TextEditor/TextEditorWidget.cpp | 4 | ||||
-rw-r--r-- | Userland/DevTools/HackStudio/CMakeLists.txt | 2 | ||||
-rw-r--r-- | Userland/DevTools/HackStudio/Editor.cpp | 4 | ||||
-rw-r--r-- | Userland/Libraries/LibCpp/CMakeLists.txt | 1 | ||||
-rw-r--r-- | Userland/Libraries/LibCpp/SyntaxHighlighter.cpp (renamed from Userland/Libraries/LibGUI/CppSyntaxHighlighter.cpp) | 18 | ||||
-rw-r--r-- | Userland/Libraries/LibCpp/SyntaxHighlighter.h (renamed from Userland/Libraries/LibGUI/CppSyntaxHighlighter.h) | 10 | ||||
-rw-r--r-- | Userland/Libraries/LibGUI/CMakeLists.txt | 3 | ||||
-rw-r--r-- | Userland/Utilities/CMakeLists.txt | 2 |
9 files changed, 23 insertions, 23 deletions
diff --git a/Userland/Applications/TextEditor/CMakeLists.txt b/Userland/Applications/TextEditor/CMakeLists.txt index 07eccd212e..bbc7b92e84 100644 --- a/Userland/Applications/TextEditor/CMakeLists.txt +++ b/Userland/Applications/TextEditor/CMakeLists.txt @@ -7,4 +7,4 @@ set(SOURCES ) serenity_app(TextEditor ICON app-text-editor) -target_link_libraries(TextEditor LibWeb LibMarkdown LibGUI LibShell LibRegex LibDesktop) +target_link_libraries(TextEditor LibWeb LibMarkdown LibGUI LibShell LibRegex LibDesktop LibCpp) diff --git a/Userland/Applications/TextEditor/TextEditorWidget.cpp b/Userland/Applications/TextEditor/TextEditorWidget.cpp index 6deb939c2f..280d7fca08 100644 --- a/Userland/Applications/TextEditor/TextEditorWidget.cpp +++ b/Userland/Applications/TextEditor/TextEditorWidget.cpp @@ -33,12 +33,12 @@ #include <Applications/TextEditor/TextEditorWindowGML.h> #include <LibCore/File.h> #include <LibCore/MimeData.h> +#include <LibCpp/SyntaxHighlighter.h> #include <LibDesktop/Launcher.h> #include <LibGUI/Action.h> #include <LibGUI/ActionGroup.h> #include <LibGUI/BoxLayout.h> #include <LibGUI/Button.h> -#include <LibGUI/CppSyntaxHighlighter.h> #include <LibGUI/FilePicker.h> #include <LibGUI/FontPicker.h> #include <LibGUI/GMLSyntaxHighlighter.h> @@ -469,7 +469,7 @@ TextEditorWidget::TextEditorWidget() syntax_menu.add_action(*m_plain_text_highlight); m_cpp_highlight = GUI::Action::create_checkable("C++", [&](auto&) { - m_editor->set_syntax_highlighter(make<GUI::CppSyntaxHighlighter>()); + m_editor->set_syntax_highlighter(make<Cpp::SyntaxHighlighter>()); m_editor->update(); }); syntax_actions.add_action(*m_cpp_highlight); diff --git a/Userland/DevTools/HackStudio/CMakeLists.txt b/Userland/DevTools/HackStudio/CMakeLists.txt index 59406cbcbc..e31a214a62 100644 --- a/Userland/DevTools/HackStudio/CMakeLists.txt +++ b/Userland/DevTools/HackStudio/CMakeLists.txt @@ -33,5 +33,5 @@ set(SOURCES ) serenity_app(HackStudio ICON app-hack-studio) -target_link_libraries(HackStudio LibWeb LibMarkdown LibGUI LibGfx LibCore LibVT LibDebug LibX86 LibDiff LibShell) +target_link_libraries(HackStudio LibWeb LibMarkdown LibGUI LibCpp LibGfx LibCore LibVT LibDebug LibX86 LibDiff LibShell) add_dependencies(HackStudio CppLanguageServer) diff --git a/Userland/DevTools/HackStudio/Editor.cpp b/Userland/DevTools/HackStudio/Editor.cpp index eb11d3dcaf..df4b30c515 100644 --- a/Userland/DevTools/HackStudio/Editor.cpp +++ b/Userland/DevTools/HackStudio/Editor.cpp @@ -34,8 +34,8 @@ #include <AK/LexicalPath.h> #include <LibCore/DirIterator.h> #include <LibCore/File.h> +#include <LibCpp/SyntaxHighlighter.h> #include <LibGUI/Application.h> -#include <LibGUI/CppSyntaxHighlighter.h> #include <LibGUI/GMLSyntaxHighlighter.h> #include <LibGUI/INISyntaxHighlighter.h> #include <LibGUI/JSSyntaxHighlighter.h> @@ -418,7 +418,7 @@ void Editor::set_document(GUI::TextDocument& doc) CodeDocument& code_document = static_cast<CodeDocument&>(doc); switch (code_document.language()) { case Language::Cpp: - set_syntax_highlighter(make<GUI::CppSyntaxHighlighter>()); + set_syntax_highlighter(make<Cpp::SyntaxHighlighter>()); m_language_client = get_language_client<LanguageClients::Cpp::ServerConnection>(project().root_path()); break; case Language::GML: diff --git a/Userland/Libraries/LibCpp/CMakeLists.txt b/Userland/Libraries/LibCpp/CMakeLists.txt index 73eaf2bb4d..87ee85b916 100644 --- a/Userland/Libraries/LibCpp/CMakeLists.txt +++ b/Userland/Libraries/LibCpp/CMakeLists.txt @@ -2,6 +2,7 @@ set(SOURCES AST.cpp Lexer.cpp Parser.cpp + SyntaxHighlighter.cpp ) serenity_lib(LibCpp cpp) diff --git a/Userland/Libraries/LibGUI/CppSyntaxHighlighter.cpp b/Userland/Libraries/LibCpp/SyntaxHighlighter.cpp index f0e0171f2e..71e0597135 100644 --- a/Userland/Libraries/LibGUI/CppSyntaxHighlighter.cpp +++ b/Userland/Libraries/LibCpp/SyntaxHighlighter.cpp @@ -26,14 +26,14 @@ #include <AK/Debug.h> #include <LibCpp/Lexer.h> -#include <LibGUI/CppSyntaxHighlighter.h> +#include <LibCpp/SyntaxHighlighter.h> #include <LibGUI/TextEditor.h> #include <LibGfx/Font.h> #include <LibGfx/Palette.h> -namespace GUI { +namespace Cpp { -static TextStyle style_for_token_type(Gfx::Palette palette, Cpp::Token::Type type) +static GUI::TextStyle style_for_token_type(const Gfx::Palette& palette, Cpp::Token::Type type) { switch (type) { case Cpp::Token::Type::Keyword: @@ -63,19 +63,19 @@ static TextStyle style_for_token_type(Gfx::Palette palette, Cpp::Token::Type typ } } -bool CppSyntaxHighlighter::is_identifier(void* token) const +bool SyntaxHighlighter::is_identifier(void* token) const { auto cpp_token = static_cast<Cpp::Token::Type>(reinterpret_cast<size_t>(token)); return cpp_token == Cpp::Token::Type::Identifier; } -bool CppSyntaxHighlighter::is_navigatable(void* token) const +bool SyntaxHighlighter::is_navigatable(void* token) const { auto cpp_token = static_cast<Cpp::Token::Type>(reinterpret_cast<size_t>(token)); return cpp_token == Cpp::Token::Type::IncludePath; } -void CppSyntaxHighlighter::rehighlight(Gfx::Palette palette) +void SyntaxHighlighter::rehighlight(Gfx::Palette palette) { ASSERT(m_editor); auto text = m_editor->text(); @@ -103,7 +103,7 @@ void CppSyntaxHighlighter::rehighlight(Gfx::Palette palette) m_editor->update(); } -Vector<SyntaxHighlighter::MatchingTokenPair> CppSyntaxHighlighter::matching_token_pairs() const +Vector<SyntaxHighlighter::MatchingTokenPair> SyntaxHighlighter::matching_token_pairs() const { static Vector<SyntaxHighlighter::MatchingTokenPair> pairs; if (pairs.is_empty()) { @@ -114,12 +114,12 @@ Vector<SyntaxHighlighter::MatchingTokenPair> CppSyntaxHighlighter::matching_toke return pairs; } -bool CppSyntaxHighlighter::token_types_equal(void* token1, void* token2) const +bool SyntaxHighlighter::token_types_equal(void* token1, void* token2) const { return static_cast<Cpp::Token::Type>(reinterpret_cast<size_t>(token1)) == static_cast<Cpp::Token::Type>(reinterpret_cast<size_t>(token2)); } -CppSyntaxHighlighter::~CppSyntaxHighlighter() +SyntaxHighlighter::~SyntaxHighlighter() { } diff --git a/Userland/Libraries/LibGUI/CppSyntaxHighlighter.h b/Userland/Libraries/LibCpp/SyntaxHighlighter.h index a67ca78cf2..7a6351ffd2 100644 --- a/Userland/Libraries/LibGUI/CppSyntaxHighlighter.h +++ b/Userland/Libraries/LibCpp/SyntaxHighlighter.h @@ -28,17 +28,17 @@ #include <LibGUI/SyntaxHighlighter.h> -namespace GUI { +namespace Cpp { -class CppSyntaxHighlighter final : public SyntaxHighlighter { +class SyntaxHighlighter final : public GUI::SyntaxHighlighter { public: - CppSyntaxHighlighter() { } - virtual ~CppSyntaxHighlighter() override; + SyntaxHighlighter() { } + virtual ~SyntaxHighlighter() override; virtual bool is_identifier(void*) const override; virtual bool is_navigatable(void*) const override; - virtual SyntaxLanguage language() const override { return SyntaxLanguage::Cpp; } + virtual GUI::SyntaxLanguage language() const override { return GUI::SyntaxLanguage::Cpp; } virtual void rehighlight(Gfx::Palette) override; protected: diff --git a/Userland/Libraries/LibGUI/CMakeLists.txt b/Userland/Libraries/LibGUI/CMakeLists.txt index f5b8bc2f66..9d1e57d5b8 100644 --- a/Userland/Libraries/LibGUI/CMakeLists.txt +++ b/Userland/Libraries/LibGUI/CMakeLists.txt @@ -22,7 +22,6 @@ set(SOURCES ComboBox.cpp Command.cpp ControlBoxButton.cpp - CppSyntaxHighlighter.cpp Desktop.cpp Dialog.cpp DisplayLink.cpp @@ -111,4 +110,4 @@ set(GENERATED_SOURCES ) serenity_lib(LibGUI gui) -target_link_libraries(LibGUI LibCore LibGfx LibIPC LibThread LibCpp LibShell LibRegex LibJS) +target_link_libraries(LibGUI LibCore LibGfx LibIPC LibThread LibShell LibRegex LibJS) diff --git a/Userland/Utilities/CMakeLists.txt b/Userland/Utilities/CMakeLists.txt index fb8c07c932..64f35b1be7 100644 --- a/Userland/Utilities/CMakeLists.txt +++ b/Userland/Utilities/CMakeLists.txt @@ -48,4 +48,4 @@ target_link_libraries(test-web LibWeb) target_link_libraries(tt LibPthread) target_link_libraries(grep LibRegex) target_link_libraries(gunzip LibCompress) -target_link_libraries(CppParserTest LibCpp) +target_link_libraries(CppParserTest LibCpp LibGUI) |