From fdeff13ca336b5288a441ad3d7cab358eee4112b Mon Sep 17 00:00:00 2001 From: Marcus Tillmanns Date: Tue, 17 Oct 2023 15:13:45 +0200 Subject: [PATCH] TextEditor: Don't export KSyntaxHighlighting Change-Id: I84fa8c758af412d8847391a628deac60279b9448 Reviewed-by: David Schulz --- src/plugins/compilerexplorer/compilerexplorereditor.cpp | 5 +++-- src/plugins/texteditor/highlighter.h | 3 +-- src/plugins/texteditor/texteditor.cpp | 7 ++++++- src/plugins/texteditor/texteditor.h | 3 +-- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/plugins/compilerexplorer/compilerexplorereditor.cpp b/src/plugins/compilerexplorer/compilerexplorereditor.cpp index 2fcb4f8f073..c6040d65a42 100644 --- a/src/plugins/compilerexplorer/compilerexplorereditor.cpp +++ b/src/plugins/compilerexplorer/compilerexplorereditor.cpp @@ -285,8 +285,9 @@ CompilerWidget::CompilerWidget(const std::shared_ptr &sourceSett m_asmEditor = new AsmEditorWidget(undoStack); m_asmDocument = QSharedPointer(new TextDocument); m_asmEditor->setTextDocument(m_asmDocument); - m_asmEditor->configureGenericHighlighter( - TextEditor::Highlighter::definitionForName("Intel x86 (NASM)")); + QTC_ASSERT_EXPECTED(m_asmEditor->configureGenericHighlighter("Intel x86 (NASM)"), + m_asmEditor->configureGenericHighlighter( + Utils::mimeTypeForName("text/x-asm"))); m_asmEditor->setReadOnly(true); connect(m_asmEditor, &AsmEditorWidget::gotFocus, this, &CompilerWidget::gotFocus); diff --git a/src/plugins/texteditor/highlighter.h b/src/plugins/texteditor/highlighter.h index b3f10d0671d..0183c9c171e 100644 --- a/src/plugins/texteditor/highlighter.h +++ b/src/plugins/texteditor/highlighter.h @@ -13,8 +13,7 @@ namespace TextEditor { class TextDocument; -class TEXTEDITOR_EXPORT Highlighter : public SyntaxHighlighter, - public KSyntaxHighlighting::AbstractHighlighter +class Highlighter : public SyntaxHighlighter, public KSyntaxHighlighting::AbstractHighlighter { Q_OBJECT Q_INTERFACES(KSyntaxHighlighting::AbstractHighlighter) diff --git a/src/plugins/texteditor/texteditor.cpp b/src/plugins/texteditor/texteditor.cpp index 70265e14a47..ab1ab4cbc42 100644 --- a/src/plugins/texteditor/texteditor.cpp +++ b/src/plugins/texteditor/texteditor.cpp @@ -9068,10 +9068,15 @@ void TextEditorWidget::configureGenericHighlighter(const Utils::MimeType &mimeTy d->removeSyntaxInfoBar(); } -void TextEditorWidget::configureGenericHighlighter(const Highlighter::Definition &definition) +expected_str TextEditorWidget::configureGenericHighlighter(const QString &definitionName) { + Highlighter::Definition definition = TextEditor::Highlighter::definitionForName(definitionName); + if (!definition.isValid()) + return make_unexpected(Tr::tr("Could not find definition")); + d->configureGenericHighlighter(definition); d->removeSyntaxInfoBar(); + return {}; } int TextEditorWidget::blockNumberForVisibleRow(int row) const diff --git a/src/plugins/texteditor/texteditor.h b/src/plugins/texteditor/texteditor.h index 2af45826368..0abe3305639 100644 --- a/src/plugins/texteditor/texteditor.h +++ b/src/plugins/texteditor/texteditor.h @@ -6,7 +6,6 @@ #include "texteditor_global.h" #include "codeassist/assistenums.h" -#include "highlighter.h" #include "indenter.h" #include "refactoroverlay.h" #include "snippets/snippetparser.h" @@ -455,7 +454,7 @@ public: void configureGenericHighlighter(const Utils::MimeType &mimeType); /// Overwrite the current highlighter with a new generic highlighter based on the given definition - void configureGenericHighlighter(const Highlighter::Definition &definition); + Utils::expected_str configureGenericHighlighter(const QString &definitionName); Q_INVOKABLE void inSnippetMode(bool *active); // Used by FakeVim.