aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/texteditor/generichighlighter
diff options
context:
space:
mode:
authorDavid Schulz <david.schulz@qt.io>2016-09-02 12:33:05 +0200
committerDavid Schulz <david.schulz@qt.io>2016-09-12 07:22:37 +0000
commitf1ee907bf429c1f6afb1b621b4a1e923b801c3aa (patch)
tree28cd7896033be6d8a244500e8b20f08a8047f20e /src/plugins/texteditor/generichighlighter
parentb554829fd8daee50a0de6cb132d40d0c9abd6e94 (diff)
Highlighter: Handle lineEmptyContext in generic highlighter
Task-number: QTCREATORBUG-16304 Change-Id: I8202bcb9cbebac5913d49e39011eb00f909aa4ad Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Diffstat (limited to 'src/plugins/texteditor/generichighlighter')
-rw-r--r--src/plugins/texteditor/generichighlighter/context.cpp10
-rw-r--r--src/plugins/texteditor/generichighlighter/context.h4
-rw-r--r--src/plugins/texteditor/generichighlighter/highlightdefinitionhandler.cpp2
-rw-r--r--src/plugins/texteditor/generichighlighter/highlighter.cpp5
4 files changed, 20 insertions, 1 deletions
diff --git a/src/plugins/texteditor/generichighlighter/context.cpp b/src/plugins/texteditor/generichighlighter/context.cpp
index e3bcb91071..10875c8e8c 100644
--- a/src/plugins/texteditor/generichighlighter/context.cpp
+++ b/src/plugins/texteditor/generichighlighter/context.cpp
@@ -37,7 +37,8 @@ Context::Context() : m_fallthrough(false), m_dynamic(false)
Context::Context(const Context &context) :
m_id(context.m_id), m_name(context.m_name), m_lineBeginContext(context.m_lineBeginContext),
- m_lineEndContext(context.m_lineEndContext), m_fallthroughContext(context.m_fallthroughContext),
+ m_lineEndContext(context.m_lineEndContext), m_lineEmptyContext(context.m_lineEmptyContext),
+ m_fallthroughContext(context.m_fallthroughContext),
m_itemData(context.m_itemData), m_fallthrough(context.m_fallthrough),
m_dynamic(context.m_dynamic), m_instructions(context.m_instructions),
m_definition(context.m_definition)
@@ -62,6 +63,7 @@ void Context::swap(Context &context)
qSwap(m_name, context.m_name);
qSwap(m_lineBeginContext, context.m_lineBeginContext);
qSwap(m_lineEndContext, context.m_lineEndContext);
+ qSwap(m_lineEmptyContext, context.m_lineEmptyContext);
qSwap(m_fallthroughContext, context.m_fallthroughContext);
qSwap(m_itemData, context.m_itemData);
qSwap(m_fallthrough, context.m_fallthrough);
@@ -98,6 +100,12 @@ void Context::setLineEndContext(const QString &context)
const QString &Context::lineEndContext() const
{ return m_lineEndContext; }
+void Context::setLineEmptyContext(const QString &context)
+{ m_lineEmptyContext = context; }
+
+const QString &Context::lineEmptyContext() const
+{ return m_lineEmptyContext; }
+
void Context::setFallthroughContext(const QString &context)
{ m_fallthroughContext = context; }
diff --git a/src/plugins/texteditor/generichighlighter/context.h b/src/plugins/texteditor/generichighlighter/context.h
index 79b0b280cb..c2358f2d04 100644
--- a/src/plugins/texteditor/generichighlighter/context.h
+++ b/src/plugins/texteditor/generichighlighter/context.h
@@ -57,6 +57,9 @@ public:
void setLineEndContext(const QString &context);
const QString &lineEndContext() const;
+ void setLineEmptyContext(const QString &context);
+ const QString &lineEmptyContext() const;
+
void setFallthroughContext(const QString &context);
const QString &fallthroughContext() const;
@@ -88,6 +91,7 @@ private:
QString m_name;
QString m_lineBeginContext;
QString m_lineEndContext;
+ QString m_lineEmptyContext;
QString m_fallthroughContext;
QString m_itemData;
bool m_fallthrough;
diff --git a/src/plugins/texteditor/generichighlighter/highlightdefinitionhandler.cpp b/src/plugins/texteditor/generichighlighter/highlightdefinitionhandler.cpp
index 2d0f556a11..be0db685c1 100644
--- a/src/plugins/texteditor/generichighlighter/highlightdefinitionhandler.cpp
+++ b/src/plugins/texteditor/generichighlighter/highlightdefinitionhandler.cpp
@@ -45,6 +45,7 @@ namespace {
static const QLatin1String kDynamic("dynamic");
static const QLatin1String kFallthrough("fallthrough");
static const QLatin1String kLineEndContext("lineEndContext");
+ static const QLatin1String kLineEmptyContext("lineEmptyContext");
static const QLatin1String kLineBeginContext("lineBeginContext");
static const QLatin1String kFallthroughContext("fallthroughContext");
static const QLatin1String kBeginRegion("beginRegion");
@@ -224,6 +225,7 @@ void HighlightDefinitionHandler::contextElementStarted(const QXmlAttributes &att
m_currentContext->setFallthroughContext(atts.value(kFallthroughContext));
m_currentContext->setLineBeginContext(atts.value(kLineBeginContext));
m_currentContext->setLineEndContext(atts.value(kLineEndContext));
+ m_currentContext->setLineEmptyContext(atts.value(kLineEmptyContext));
m_initialContext = false;
}
diff --git a/src/plugins/texteditor/generichighlighter/highlighter.cpp b/src/plugins/texteditor/generichighlighter/highlighter.cpp
index a7196602ca..1cefcfc2a5 100644
--- a/src/plugins/texteditor/generichighlighter/highlighter.cpp
+++ b/src/plugins/texteditor/generichighlighter/highlighter.cpp
@@ -204,6 +204,11 @@ void Highlighter::highlightBlock(const QString &text)
m_currentContext->definition(),
false);
}
+ if (length == 0) {
+ handleContextChange(m_currentContext->lineEmptyContext(),
+ m_currentContext->definition(),
+ false);
+ }
delete progress;
m_contexts.clear();