forked from qt-creator/qt-creator
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>
This commit is contained in:
committed by
Christian Stenger
parent
8e62876f64
commit
5d15076ea1
@@ -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);
|
||||
|
||||
@@ -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()) {
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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 \
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -7,7 +7,7 @@ SOURCES += \
|
||||
tst_highlighterengine.cpp \
|
||||
highlightermock.cpp \
|
||||
formats.cpp \
|
||||
texteditor/syntaxhighlighter.cpp \
|
||||
syntaxhighlighter.cpp \
|
||||
$$GENERICHIGHLIGHTERDIR/highlighter.cpp \
|
||||
$$GENERICHIGHLIGHTERDIR/context.cpp \
|
||||
$$GENERICHIGHLIGHTERDIR/dynamicrule.cpp \
|
||||
@@ -21,9 +21,9 @@ SOURCES += \
|
||||
HEADERS += \
|
||||
highlightermock.h \
|
||||
formats.h \
|
||||
texteditor/basetextdocumentlayout.h \
|
||||
texteditor/syntaxhighlighter.h \
|
||||
texteditor/tabsettings.h \
|
||||
basetextdocumentlayout.h \
|
||||
syntaxhighlighter.h \
|
||||
tabsettings.h \
|
||||
$$GENERICHIGHLIGHTERDIR/highlighter.h \
|
||||
$$GENERICHIGHLIGHTERDIR/context.h \
|
||||
$$GENERICHIGHLIGHTERDIR/dynamicrule.h \
|
||||
@@ -34,4 +34,4 @@ HEADERS += \
|
||||
$$GENERICHIGHLIGHTERDIR/keywordlist.h \
|
||||
$$GENERICHIGHLIGHTERDIR/itemdata.h
|
||||
|
||||
INCLUDEPATH += $$PWD $$GENERICHIGHLIGHTERDIR
|
||||
INCLUDEPATH += $$PWD
|
||||
|
||||
@@ -30,7 +30,6 @@ Autotest {
|
||||
}
|
||||
Group {
|
||||
name: "Drop-in sources for the plugin"
|
||||
prefix: "texteditor/"
|
||||
files: [
|
||||
"basetextdocumentlayout.h",
|
||||
"syntaxhighlighter.h", "syntaxhighlighter.cpp",
|
||||
@@ -41,7 +40,6 @@ Autotest {
|
||||
cpp.defines: base.concat(["TEXTEDITOR_LIBRARY"]) // For Windows
|
||||
cpp.includePaths: base.concat([
|
||||
path,
|
||||
project.genericHighlighterDir,
|
||||
project.genericHighlighterDir + "/../..",
|
||||
path])
|
||||
])
|
||||
}
|
||||
|
||||
@@ -27,10 +27,11 @@
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "highlightermock.h"
|
||||
#include "context.h"
|
||||
#include "highlightdefinition.h"
|
||||
#include "formats.h"
|
||||
#include "highlightermock.h"
|
||||
|
||||
#include <texteditor/generichighlighter/context.h>
|
||||
#include <texteditor/generichighlighter/highlightdefinition.h>
|
||||
|
||||
#include <QDebug>
|
||||
#include <QtTest>
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
#ifndef HIGHLIGHTERMOCK_H
|
||||
#define HIGHLIGHTERMOCK_H
|
||||
|
||||
#include "highlighter.h"
|
||||
#include <texteditor/generichighlighter/highlighter.h>
|
||||
|
||||
#include <QList>
|
||||
|
||||
|
||||
@@ -28,9 +28,10 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include "syntaxhighlighter.h"
|
||||
#include "highlighter.h"
|
||||
#include "formats.h"
|
||||
|
||||
#include <texteditor/generichighlighter/highlighter.h>
|
||||
|
||||
using namespace TextEditor;
|
||||
using namespace Internal;
|
||||
|
||||
@@ -27,13 +27,14 @@
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "highlightdefinition.h"
|
||||
#include "keywordlist.h"
|
||||
#include "itemdata.h"
|
||||
#include "context.h"
|
||||
#include "specificrules.h"
|
||||
#include "highlightermock.h"
|
||||
#include "formats.h"
|
||||
#include "highlightermock.h"
|
||||
|
||||
#include <texteditor/generichighlighter/context.h>
|
||||
#include <texteditor/generichighlighter/highlightdefinition.h>
|
||||
#include <texteditor/generichighlighter/itemdata.h>
|
||||
#include <texteditor/generichighlighter/keywordlist.h>
|
||||
#include <texteditor/generichighlighter/specificrules.h>
|
||||
|
||||
#include <QSharedPointer>
|
||||
#include <QScopedPointer>
|
||||
|
||||
Reference in New Issue
Block a user