diff options
author | jkobus <jaroslaw.kobus@digia.com> | 2013-09-13 12:13:10 +0200 |
---|---|---|
committer | Christian Stenger <christian.stenger@digia.com> | 2013-09-18 17:25:41 +0200 |
commit | 5d15076ea14262b474dd60768e6d80ef498cfdd1 (patch) | |
tree | acb14dbe24ed5de2f08baa021ea566571aa7a58f /src | |
parent | 8e62876f642901ba12121e6699b35986ff9595b5 (diff) | |
download | qt-creator-5d15076ea14262b474dd60768e6d80ef498cfdd1.tar.gz |
Fix compilation of generichighlighter test on Windows
Change-Id: I25c2f68528ede12fa900ea86973c6df39667c421
Reviewed-by: Jarek Kobus <jaroslaw.kobus@digia.com>
Reviewed-by: Christian Stenger <christian.stenger@digia.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/diffeditor/diffeditorwidget.cpp | 7 | ||||
-rw-r--r-- | src/plugins/texteditor/generichighlighter/highlighter.cpp | 17 | ||||
-rw-r--r-- | src/plugins/texteditor/generichighlighter/highlighter.h | 23 | ||||
-rw-r--r-- | src/plugins/texteditor/highlighterutils.cpp (renamed from src/plugins/texteditor/generichighlighter/highlighterutils.cpp) | 12 | ||||
-rw-r--r-- | src/plugins/texteditor/highlighterutils.h (renamed from src/plugins/texteditor/generichighlighter/highlighterutils.h) | 8 | ||||
-rw-r--r-- | src/plugins/texteditor/plaintexteditor.cpp | 2 | ||||
-rw-r--r-- | src/plugins/texteditor/texteditor.pro | 4 | ||||
-rw-r--r-- | src/plugins/texteditor/texteditor.qbs | 6 |
8 files changed, 45 insertions, 34 deletions
diff --git a/src/plugins/diffeditor/diffeditorwidget.cpp b/src/plugins/diffeditor/diffeditorwidget.cpp index 8c0c43b570..4960b19263 100644 --- a/src/plugins/diffeditor/diffeditorwidget.cpp +++ b/src/plugins/diffeditor/diffeditorwidget.cpp @@ -45,8 +45,7 @@ #include <texteditor/texteditorsettings.h> #include <texteditor/fontsettings.h> #include <texteditor/displaysettings.h> -#include <texteditor/generichighlighter/highlighter.h> -#include <texteditor/generichighlighter/highlighterutils.h> +#include <texteditor/highlighterutils.h> #include <coreplugin/icore.h> #include <coreplugin/minisplitter.h> @@ -278,9 +277,7 @@ void MultiHighlighter::setDocuments(const QList<QPair<DiffEditorWidget::DiffFile highlighter->setDocument(document); } if (!highlighter) { - TextEditor::Highlighter *h = new TextEditor::Highlighter(); - highlighter = h; - setMimeTypeForHighlighter(h, mimeType); + highlighter = createGenericSyntaxHighlighter(mimeType); highlighter->setDocument(document); } m_documents.append(document); diff --git a/src/plugins/texteditor/generichighlighter/highlighter.cpp b/src/plugins/texteditor/generichighlighter/highlighter.cpp index 7cd1bfca37..06106e9703 100644 --- a/src/plugins/texteditor/generichighlighter/highlighter.cpp +++ b/src/plugins/texteditor/generichighlighter/highlighter.cpp @@ -35,7 +35,7 @@ #include "highlighterexception.h" #include "progressdata.h" #include "reuse.h" -#include <texteditor/tabsettings.h> +#include "tabsettings.h" #include <QLatin1String> #include <QLatin1Char> @@ -50,8 +50,6 @@ namespace { static const QLatin1Char kHash('#'); } -const Highlighter::KateFormatMap Highlighter::m_kateFormats; - Highlighter::Highlighter(QTextDocument *parent) : TextEditor::SyntaxHighlighter(parent), m_regionDepth(0), @@ -92,7 +90,14 @@ Highlighter::BlockData::BlockData() : m_foldingIndentDelta(0), m_originalObserva Highlighter::BlockData::~BlockData() {} -Highlighter::KateFormatMap::KateFormatMap() +// Mapping from Kate format strings to format ids. +struct KateFormatMap +{ + KateFormatMap(); + QHash<QString, Highlighter::TextFormatId> m_ids; +}; + +KateFormatMap::KateFormatMap() { m_ids.insert(QLatin1String("dsNormal"), Highlighter::Normal); m_ids.insert(QLatin1String("dsKeyword"), Highlighter::Keyword); @@ -110,6 +115,8 @@ Highlighter::KateFormatMap::KateFormatMap() m_ids.insert(QLatin1String("dsOthers"), Highlighter::Others); } +Q_GLOBAL_STATIC(KateFormatMap, kateFormatMap) + void Highlighter::setDefaultContext(const QSharedPointer<Context> &defaultContext) { m_defaultContext = defaultContext; @@ -404,7 +411,7 @@ void Highlighter::applyFormat(int offset, return; } - TextFormatId formatId = m_kateFormats.m_ids.value(itemData->style(), Normal); + TextFormatId formatId = kateFormatMap()->m_ids.value(itemData->style(), Normal); if (formatId != Normal) { QTextCharFormat format = formatForCategory(formatId); if (itemData->isCustomized()) { diff --git a/src/plugins/texteditor/generichighlighter/highlighter.h b/src/plugins/texteditor/generichighlighter/highlighter.h index 470506fdf4..968a48a6c1 100644 --- a/src/plugins/texteditor/generichighlighter/highlighter.h +++ b/src/plugins/texteditor/generichighlighter/highlighter.h @@ -30,12 +30,12 @@ #ifndef HIGHLIGHTER_H #define HIGHLIGHTER_H -#include <texteditor/basetextdocumentlayout.h> -#include <texteditor/syntaxhighlighter.h> -#include <texteditor/texteditor_global.h> - #include "context.h" +// Yes, this is correct. These are found somewhere else when building the autotest. +#include <basetextdocumentlayout.h> +#include <syntaxhighlighter.h> + #include <QString> #include <QVector> #include <QStack> @@ -55,7 +55,12 @@ class ProgressData; } // namespace Internal -class TEXTEDITOR_EXPORT Highlighter : public TextEditor::SyntaxHighlighter +/* + Warning: Due to a very ugly hack with generichighlighter test + you can't export this class, so that it would be used from + other plugins. That's why highlighterutils.h was introduced. +*/ +class Highlighter : public TextEditor::SyntaxHighlighter { Q_OBJECT @@ -129,14 +134,6 @@ private: void applyIndentationBasedFolding(const QString &text) const; int neighbouringNonEmptyBlockIndent(QTextBlock block, const bool previous) const; - // Mapping from Kate format strings to format ids. - struct KateFormatMap - { - KateFormatMap(); - QHash<QString, TextFormatId> m_ids; - }; - static const KateFormatMap m_kateFormats; - struct BlockData : TextBlockUserData { BlockData(); diff --git a/src/plugins/texteditor/generichighlighter/highlighterutils.cpp b/src/plugins/texteditor/highlighterutils.cpp index 4ecd5b675c..360bb7bb91 100644 --- a/src/plugins/texteditor/generichighlighter/highlighterutils.cpp +++ b/src/plugins/texteditor/highlighterutils.cpp @@ -28,9 +28,9 @@ ****************************************************************************/ #include "highlighterutils.h" -#include "highlighter.h" -#include "highlightdefinition.h" -#include "manager.h" +#include "generichighlighter/highlighter.h" +#include "generichighlighter/highlightdefinition.h" +#include "generichighlighter/manager.h" #include <coreplugin/icore.h> using namespace TextEditor; @@ -66,5 +66,11 @@ void TextEditor::setMimeTypeForHighlighter(Highlighter *highlighter, const Core: highlighter->setDefaultContext(definition->initialContext()); } } +} +SyntaxHighlighter *TextEditor::createGenericSyntaxHighlighter(const Core::MimeType &mimeType) +{ + TextEditor::Highlighter *highlighter = new TextEditor::Highlighter(); + setMimeTypeForHighlighter(highlighter, mimeType); + return highlighter; } diff --git a/src/plugins/texteditor/generichighlighter/highlighterutils.h b/src/plugins/texteditor/highlighterutils.h index a781ac7e17..dd6bc5343d 100644 --- a/src/plugins/texteditor/generichighlighter/highlighterutils.h +++ b/src/plugins/texteditor/highlighterutils.h @@ -31,7 +31,7 @@ #define HIGHLIGHTERUTILS_H #include <QString> -#include <texteditor/texteditor_global.h> +#include "texteditor_global.h" /* These methods were originally a part of TextEditor::Highlighter, * but due to a very hackish test of that generic highlighter, @@ -44,9 +44,11 @@ class MimeType; namespace TextEditor { class Highlighter; +class SyntaxHighlighter; -void TEXTEDITOR_EXPORT setMimeTypeForHighlighter(Highlighter *highlighter, const Core::MimeType &mimeType); -QString TEXTEDITOR_EXPORT findDefinitionId(const Core::MimeType &mimeType, bool considerParents); +void setMimeTypeForHighlighter(Highlighter *highlighter, const Core::MimeType &mimeType); +QString findDefinitionId(const Core::MimeType &mimeType, bool considerParents); +TEXTEDITOR_EXPORT SyntaxHighlighter *createGenericSyntaxHighlighter(const Core::MimeType &mimeType); } // namespace TextEditor diff --git a/src/plugins/texteditor/plaintexteditor.cpp b/src/plugins/texteditor/plaintexteditor.cpp index 410032a6ac..573961cc23 100644 --- a/src/plugins/texteditor/plaintexteditor.cpp +++ b/src/plugins/texteditor/plaintexteditor.cpp @@ -33,7 +33,7 @@ #include "texteditorsettings.h" #include "basetextdocument.h" #include "normalindenter.h" -#include "generichighlighter/highlighterutils.h" +#include "highlighterutils.h" #include <texteditor/generichighlighter/context.h> #include <texteditor/generichighlighter/highlightdefinition.h> #include <texteditor/generichighlighter/highlighter.h> diff --git a/src/plugins/texteditor/texteditor.pro b/src/plugins/texteditor/texteditor.pro index 723dbda613..2a449986b6 100644 --- a/src/plugins/texteditor/texteditor.pro +++ b/src/plugins/texteditor/texteditor.pro @@ -38,6 +38,7 @@ SOURCES += texteditorplugin.cpp \ indenter.cpp \ quickfix.cpp \ syntaxhighlighter.cpp \ + highlighterutils.cpp \ generichighlighter/itemdata.cpp \ generichighlighter/specificrules.cpp \ generichighlighter/rule.cpp \ @@ -54,7 +55,6 @@ SOURCES += texteditorplugin.cpp \ generichighlighter/highlightersettings.cpp \ generichighlighter/managedefinitionsdialog.cpp \ generichighlighter/definitiondownloader.cpp \ - generichighlighter/highlighterutils.cpp \ refactoringchanges.cpp \ refactoroverlay.cpp \ outlinefactory.cpp \ @@ -146,6 +146,7 @@ HEADERS += texteditorplugin.h \ quickfix.h \ ihighlighterfactory.h \ syntaxhighlighter.h \ + highlighterutils.h \ generichighlighter/reuse.h \ generichighlighter/itemdata.h \ generichighlighter/specificrules.h \ @@ -166,7 +167,6 @@ HEADERS += texteditorplugin.h \ generichighlighter/managedefinitionsdialog.h \ generichighlighter/highlightdefinitionmetadata.h \ generichighlighter/definitiondownloader.h \ - generichighlighter/highlighterutils.h \ refactoringchanges.h \ refactoroverlay.h \ outlinefactory.h \ diff --git a/src/plugins/texteditor/texteditor.qbs b/src/plugins/texteditor/texteditor.qbs index 637b756fbc..cf5e4b68e6 100644 --- a/src/plugins/texteditor/texteditor.qbs +++ b/src/plugins/texteditor/texteditor.qbs @@ -10,6 +10,8 @@ QtcPlugin { Depends { name: "Find" } Depends { name: "Locator" } + cpp.includePaths: base.concat([path]) // Needed for the highlighterengine autotest. + files: [ "autocompleter.cpp", "autocompleter.h", @@ -78,6 +80,8 @@ QtcPlugin { "fontsettingspage.ui", "helpitem.cpp", "helpitem.h", + "highlighterutils.cpp", + "highlighterutils.h", "icodestylepreferences.cpp", "icodestylepreferences.h", "icodestylepreferencesfactory.cpp", @@ -216,8 +220,6 @@ QtcPlugin { "highlightersettingspage.cpp", "highlightersettingspage.h", "highlightersettingspage.ui", - "highlighterutils.cpp", - "highlighterutils.h", "includerulesinstruction.cpp", "includerulesinstruction.h", "itemdata.cpp", |