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/texteditorsettings.h>
|
||||||
#include <texteditor/fontsettings.h>
|
#include <texteditor/fontsettings.h>
|
||||||
#include <texteditor/displaysettings.h>
|
#include <texteditor/displaysettings.h>
|
||||||
#include <texteditor/generichighlighter/highlighter.h>
|
#include <texteditor/highlighterutils.h>
|
||||||
#include <texteditor/generichighlighter/highlighterutils.h>
|
|
||||||
|
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
#include <coreplugin/minisplitter.h>
|
#include <coreplugin/minisplitter.h>
|
||||||
@@ -278,9 +277,7 @@ void MultiHighlighter::setDocuments(const QList<QPair<DiffEditorWidget::DiffFile
|
|||||||
highlighter->setDocument(document);
|
highlighter->setDocument(document);
|
||||||
}
|
}
|
||||||
if (!highlighter) {
|
if (!highlighter) {
|
||||||
TextEditor::Highlighter *h = new TextEditor::Highlighter();
|
highlighter = createGenericSyntaxHighlighter(mimeType);
|
||||||
highlighter = h;
|
|
||||||
setMimeTypeForHighlighter(h, mimeType);
|
|
||||||
highlighter->setDocument(document);
|
highlighter->setDocument(document);
|
||||||
}
|
}
|
||||||
m_documents.append(document);
|
m_documents.append(document);
|
||||||
|
|||||||
@@ -35,7 +35,7 @@
|
|||||||
#include "highlighterexception.h"
|
#include "highlighterexception.h"
|
||||||
#include "progressdata.h"
|
#include "progressdata.h"
|
||||||
#include "reuse.h"
|
#include "reuse.h"
|
||||||
#include <texteditor/tabsettings.h>
|
#include "tabsettings.h"
|
||||||
|
|
||||||
#include <QLatin1String>
|
#include <QLatin1String>
|
||||||
#include <QLatin1Char>
|
#include <QLatin1Char>
|
||||||
@@ -50,8 +50,6 @@ namespace {
|
|||||||
static const QLatin1Char kHash('#');
|
static const QLatin1Char kHash('#');
|
||||||
}
|
}
|
||||||
|
|
||||||
const Highlighter::KateFormatMap Highlighter::m_kateFormats;
|
|
||||||
|
|
||||||
Highlighter::Highlighter(QTextDocument *parent) :
|
Highlighter::Highlighter(QTextDocument *parent) :
|
||||||
TextEditor::SyntaxHighlighter(parent),
|
TextEditor::SyntaxHighlighter(parent),
|
||||||
m_regionDepth(0),
|
m_regionDepth(0),
|
||||||
@@ -92,7 +90,14 @@ Highlighter::BlockData::BlockData() : m_foldingIndentDelta(0), m_originalObserva
|
|||||||
Highlighter::BlockData::~BlockData()
|
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("dsNormal"), Highlighter::Normal);
|
||||||
m_ids.insert(QLatin1String("dsKeyword"), Highlighter::Keyword);
|
m_ids.insert(QLatin1String("dsKeyword"), Highlighter::Keyword);
|
||||||
@@ -110,6 +115,8 @@ Highlighter::KateFormatMap::KateFormatMap()
|
|||||||
m_ids.insert(QLatin1String("dsOthers"), Highlighter::Others);
|
m_ids.insert(QLatin1String("dsOthers"), Highlighter::Others);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Q_GLOBAL_STATIC(KateFormatMap, kateFormatMap)
|
||||||
|
|
||||||
void Highlighter::setDefaultContext(const QSharedPointer<Context> &defaultContext)
|
void Highlighter::setDefaultContext(const QSharedPointer<Context> &defaultContext)
|
||||||
{
|
{
|
||||||
m_defaultContext = defaultContext;
|
m_defaultContext = defaultContext;
|
||||||
@@ -404,7 +411,7 @@ void Highlighter::applyFormat(int offset,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
TextFormatId formatId = m_kateFormats.m_ids.value(itemData->style(), Normal);
|
TextFormatId formatId = kateFormatMap()->m_ids.value(itemData->style(), Normal);
|
||||||
if (formatId != Normal) {
|
if (formatId != Normal) {
|
||||||
QTextCharFormat format = formatForCategory(formatId);
|
QTextCharFormat format = formatForCategory(formatId);
|
||||||
if (itemData->isCustomized()) {
|
if (itemData->isCustomized()) {
|
||||||
|
|||||||
@@ -30,12 +30,12 @@
|
|||||||
#ifndef HIGHLIGHTER_H
|
#ifndef HIGHLIGHTER_H
|
||||||
#define HIGHLIGHTER_H
|
#define HIGHLIGHTER_H
|
||||||
|
|
||||||
#include <texteditor/basetextdocumentlayout.h>
|
|
||||||
#include <texteditor/syntaxhighlighter.h>
|
|
||||||
#include <texteditor/texteditor_global.h>
|
|
||||||
|
|
||||||
#include "context.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 <QString>
|
||||||
#include <QVector>
|
#include <QVector>
|
||||||
#include <QStack>
|
#include <QStack>
|
||||||
@@ -55,7 +55,12 @@ class ProgressData;
|
|||||||
|
|
||||||
} // namespace Internal
|
} // 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
|
Q_OBJECT
|
||||||
|
|
||||||
@@ -129,14 +134,6 @@ private:
|
|||||||
void applyIndentationBasedFolding(const QString &text) const;
|
void applyIndentationBasedFolding(const QString &text) const;
|
||||||
int neighbouringNonEmptyBlockIndent(QTextBlock block, const bool previous) 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
|
struct BlockData : TextBlockUserData
|
||||||
{
|
{
|
||||||
BlockData();
|
BlockData();
|
||||||
|
|||||||
@@ -28,9 +28,9 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include "highlighterutils.h"
|
#include "highlighterutils.h"
|
||||||
#include "highlighter.h"
|
#include "generichighlighter/highlighter.h"
|
||||||
#include "highlightdefinition.h"
|
#include "generichighlighter/highlightdefinition.h"
|
||||||
#include "manager.h"
|
#include "generichighlighter/manager.h"
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
|
|
||||||
using namespace TextEditor;
|
using namespace TextEditor;
|
||||||
@@ -66,5 +66,11 @@ void TextEditor::setMimeTypeForHighlighter(Highlighter *highlighter, const Core:
|
|||||||
highlighter->setDefaultContext(definition->initialContext());
|
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
|
#define HIGHLIGHTERUTILS_H
|
||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <texteditor/texteditor_global.h>
|
#include "texteditor_global.h"
|
||||||
|
|
||||||
/* These methods were originally a part of TextEditor::Highlighter,
|
/* These methods were originally a part of TextEditor::Highlighter,
|
||||||
* but due to a very hackish test of that generic highlighter,
|
* but due to a very hackish test of that generic highlighter,
|
||||||
@@ -44,9 +44,11 @@ class MimeType;
|
|||||||
namespace TextEditor {
|
namespace TextEditor {
|
||||||
|
|
||||||
class Highlighter;
|
class Highlighter;
|
||||||
|
class SyntaxHighlighter;
|
||||||
|
|
||||||
void TEXTEDITOR_EXPORT setMimeTypeForHighlighter(Highlighter *highlighter, const Core::MimeType &mimeType);
|
void setMimeTypeForHighlighter(Highlighter *highlighter, const Core::MimeType &mimeType);
|
||||||
QString TEXTEDITOR_EXPORT findDefinitionId(const Core::MimeType &mimeType, bool considerParents);
|
QString findDefinitionId(const Core::MimeType &mimeType, bool considerParents);
|
||||||
|
TEXTEDITOR_EXPORT SyntaxHighlighter *createGenericSyntaxHighlighter(const Core::MimeType &mimeType);
|
||||||
|
|
||||||
} // namespace TextEditor
|
} // namespace TextEditor
|
||||||
|
|
||||||
@@ -33,7 +33,7 @@
|
|||||||
#include "texteditorsettings.h"
|
#include "texteditorsettings.h"
|
||||||
#include "basetextdocument.h"
|
#include "basetextdocument.h"
|
||||||
#include "normalindenter.h"
|
#include "normalindenter.h"
|
||||||
#include "generichighlighter/highlighterutils.h"
|
#include "highlighterutils.h"
|
||||||
#include <texteditor/generichighlighter/context.h>
|
#include <texteditor/generichighlighter/context.h>
|
||||||
#include <texteditor/generichighlighter/highlightdefinition.h>
|
#include <texteditor/generichighlighter/highlightdefinition.h>
|
||||||
#include <texteditor/generichighlighter/highlighter.h>
|
#include <texteditor/generichighlighter/highlighter.h>
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ SOURCES += texteditorplugin.cpp \
|
|||||||
indenter.cpp \
|
indenter.cpp \
|
||||||
quickfix.cpp \
|
quickfix.cpp \
|
||||||
syntaxhighlighter.cpp \
|
syntaxhighlighter.cpp \
|
||||||
|
highlighterutils.cpp \
|
||||||
generichighlighter/itemdata.cpp \
|
generichighlighter/itemdata.cpp \
|
||||||
generichighlighter/specificrules.cpp \
|
generichighlighter/specificrules.cpp \
|
||||||
generichighlighter/rule.cpp \
|
generichighlighter/rule.cpp \
|
||||||
@@ -54,7 +55,6 @@ SOURCES += texteditorplugin.cpp \
|
|||||||
generichighlighter/highlightersettings.cpp \
|
generichighlighter/highlightersettings.cpp \
|
||||||
generichighlighter/managedefinitionsdialog.cpp \
|
generichighlighter/managedefinitionsdialog.cpp \
|
||||||
generichighlighter/definitiondownloader.cpp \
|
generichighlighter/definitiondownloader.cpp \
|
||||||
generichighlighter/highlighterutils.cpp \
|
|
||||||
refactoringchanges.cpp \
|
refactoringchanges.cpp \
|
||||||
refactoroverlay.cpp \
|
refactoroverlay.cpp \
|
||||||
outlinefactory.cpp \
|
outlinefactory.cpp \
|
||||||
@@ -146,6 +146,7 @@ HEADERS += texteditorplugin.h \
|
|||||||
quickfix.h \
|
quickfix.h \
|
||||||
ihighlighterfactory.h \
|
ihighlighterfactory.h \
|
||||||
syntaxhighlighter.h \
|
syntaxhighlighter.h \
|
||||||
|
highlighterutils.h \
|
||||||
generichighlighter/reuse.h \
|
generichighlighter/reuse.h \
|
||||||
generichighlighter/itemdata.h \
|
generichighlighter/itemdata.h \
|
||||||
generichighlighter/specificrules.h \
|
generichighlighter/specificrules.h \
|
||||||
@@ -166,7 +167,6 @@ HEADERS += texteditorplugin.h \
|
|||||||
generichighlighter/managedefinitionsdialog.h \
|
generichighlighter/managedefinitionsdialog.h \
|
||||||
generichighlighter/highlightdefinitionmetadata.h \
|
generichighlighter/highlightdefinitionmetadata.h \
|
||||||
generichighlighter/definitiondownloader.h \
|
generichighlighter/definitiondownloader.h \
|
||||||
generichighlighter/highlighterutils.h \
|
|
||||||
refactoringchanges.h \
|
refactoringchanges.h \
|
||||||
refactoroverlay.h \
|
refactoroverlay.h \
|
||||||
outlinefactory.h \
|
outlinefactory.h \
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ QtcPlugin {
|
|||||||
Depends { name: "Find" }
|
Depends { name: "Find" }
|
||||||
Depends { name: "Locator" }
|
Depends { name: "Locator" }
|
||||||
|
|
||||||
|
cpp.includePaths: base.concat([path]) // Needed for the highlighterengine autotest.
|
||||||
|
|
||||||
files: [
|
files: [
|
||||||
"autocompleter.cpp",
|
"autocompleter.cpp",
|
||||||
"autocompleter.h",
|
"autocompleter.h",
|
||||||
@@ -78,6 +80,8 @@ QtcPlugin {
|
|||||||
"fontsettingspage.ui",
|
"fontsettingspage.ui",
|
||||||
"helpitem.cpp",
|
"helpitem.cpp",
|
||||||
"helpitem.h",
|
"helpitem.h",
|
||||||
|
"highlighterutils.cpp",
|
||||||
|
"highlighterutils.h",
|
||||||
"icodestylepreferences.cpp",
|
"icodestylepreferences.cpp",
|
||||||
"icodestylepreferences.h",
|
"icodestylepreferences.h",
|
||||||
"icodestylepreferencesfactory.cpp",
|
"icodestylepreferencesfactory.cpp",
|
||||||
@@ -216,8 +220,6 @@ QtcPlugin {
|
|||||||
"highlightersettingspage.cpp",
|
"highlightersettingspage.cpp",
|
||||||
"highlightersettingspage.h",
|
"highlightersettingspage.h",
|
||||||
"highlightersettingspage.ui",
|
"highlightersettingspage.ui",
|
||||||
"highlighterutils.cpp",
|
|
||||||
"highlighterutils.h",
|
|
||||||
"includerulesinstruction.cpp",
|
"includerulesinstruction.cpp",
|
||||||
"includerulesinstruction.h",
|
"includerulesinstruction.h",
|
||||||
"itemdata.cpp",
|
"itemdata.cpp",
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ SOURCES += \
|
|||||||
tst_highlighterengine.cpp \
|
tst_highlighterengine.cpp \
|
||||||
highlightermock.cpp \
|
highlightermock.cpp \
|
||||||
formats.cpp \
|
formats.cpp \
|
||||||
texteditor/syntaxhighlighter.cpp \
|
syntaxhighlighter.cpp \
|
||||||
$$GENERICHIGHLIGHTERDIR/highlighter.cpp \
|
$$GENERICHIGHLIGHTERDIR/highlighter.cpp \
|
||||||
$$GENERICHIGHLIGHTERDIR/context.cpp \
|
$$GENERICHIGHLIGHTERDIR/context.cpp \
|
||||||
$$GENERICHIGHLIGHTERDIR/dynamicrule.cpp \
|
$$GENERICHIGHLIGHTERDIR/dynamicrule.cpp \
|
||||||
@@ -21,9 +21,9 @@ SOURCES += \
|
|||||||
HEADERS += \
|
HEADERS += \
|
||||||
highlightermock.h \
|
highlightermock.h \
|
||||||
formats.h \
|
formats.h \
|
||||||
texteditor/basetextdocumentlayout.h \
|
basetextdocumentlayout.h \
|
||||||
texteditor/syntaxhighlighter.h \
|
syntaxhighlighter.h \
|
||||||
texteditor/tabsettings.h \
|
tabsettings.h \
|
||||||
$$GENERICHIGHLIGHTERDIR/highlighter.h \
|
$$GENERICHIGHLIGHTERDIR/highlighter.h \
|
||||||
$$GENERICHIGHLIGHTERDIR/context.h \
|
$$GENERICHIGHLIGHTERDIR/context.h \
|
||||||
$$GENERICHIGHLIGHTERDIR/dynamicrule.h \
|
$$GENERICHIGHLIGHTERDIR/dynamicrule.h \
|
||||||
@@ -34,4 +34,4 @@ HEADERS += \
|
|||||||
$$GENERICHIGHLIGHTERDIR/keywordlist.h \
|
$$GENERICHIGHLIGHTERDIR/keywordlist.h \
|
||||||
$$GENERICHIGHLIGHTERDIR/itemdata.h
|
$$GENERICHIGHLIGHTERDIR/itemdata.h
|
||||||
|
|
||||||
INCLUDEPATH += $$PWD $$GENERICHIGHLIGHTERDIR
|
INCLUDEPATH += $$PWD
|
||||||
|
|||||||
@@ -30,7 +30,6 @@ Autotest {
|
|||||||
}
|
}
|
||||||
Group {
|
Group {
|
||||||
name: "Drop-in sources for the plugin"
|
name: "Drop-in sources for the plugin"
|
||||||
prefix: "texteditor/"
|
|
||||||
files: [
|
files: [
|
||||||
"basetextdocumentlayout.h",
|
"basetextdocumentlayout.h",
|
||||||
"syntaxhighlighter.h", "syntaxhighlighter.cpp",
|
"syntaxhighlighter.h", "syntaxhighlighter.cpp",
|
||||||
@@ -41,7 +40,6 @@ Autotest {
|
|||||||
cpp.defines: base.concat(["TEXTEDITOR_LIBRARY"]) // For Windows
|
cpp.defines: base.concat(["TEXTEDITOR_LIBRARY"]) // For Windows
|
||||||
cpp.includePaths: base.concat([
|
cpp.includePaths: base.concat([
|
||||||
path,
|
path,
|
||||||
project.genericHighlighterDir,
|
|
||||||
project.genericHighlighterDir + "/../..",
|
project.genericHighlighterDir + "/../..",
|
||||||
path])
|
])
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,10 +27,11 @@
|
|||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include "highlightermock.h"
|
|
||||||
#include "context.h"
|
|
||||||
#include "highlightdefinition.h"
|
|
||||||
#include "formats.h"
|
#include "formats.h"
|
||||||
|
#include "highlightermock.h"
|
||||||
|
|
||||||
|
#include <texteditor/generichighlighter/context.h>
|
||||||
|
#include <texteditor/generichighlighter/highlightdefinition.h>
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QtTest>
|
#include <QtTest>
|
||||||
|
|||||||
@@ -30,7 +30,7 @@
|
|||||||
#ifndef HIGHLIGHTERMOCK_H
|
#ifndef HIGHLIGHTERMOCK_H
|
||||||
#define HIGHLIGHTERMOCK_H
|
#define HIGHLIGHTERMOCK_H
|
||||||
|
|
||||||
#include "highlighter.h"
|
#include <texteditor/generichighlighter/highlighter.h>
|
||||||
|
|
||||||
#include <QList>
|
#include <QList>
|
||||||
|
|
||||||
|
|||||||
@@ -28,9 +28,10 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include "syntaxhighlighter.h"
|
#include "syntaxhighlighter.h"
|
||||||
#include "highlighter.h"
|
|
||||||
#include "formats.h"
|
#include "formats.h"
|
||||||
|
|
||||||
|
#include <texteditor/generichighlighter/highlighter.h>
|
||||||
|
|
||||||
using namespace TextEditor;
|
using namespace TextEditor;
|
||||||
using namespace Internal;
|
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 "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 <QSharedPointer>
|
||||||
#include <QScopedPointer>
|
#include <QScopedPointer>
|
||||||
|
|||||||
Reference in New Issue
Block a user