Commit b57a1611 authored by Leandro Melo's avatar Leandro Melo
Browse files

Generic highlighter: Small re-writings.

parent 24be4b87
......@@ -205,7 +205,6 @@ void Highlighter::iterateThroughRules(const QString &text,
if (progress->willContinueLine()) {
createWillContinueBlock();
progress->setWillContinueLine(false);
progress->setOffset(length);
} else {
if (rule->hasChild())
iterateThroughRules(text, length, progress, true, rule->childs());
......@@ -270,7 +269,7 @@ void Highlighter::changeContext(const QString &contextName,
m_contexts.pop_back();
if (currentBlockState() >= PersistentsStart) {
// One or more persistent contexts were popped.
// One or more contexts were popped during during a persistent state.
const QString &currentSequence = currentContextSequence();
if (m_persistentStates.contains(currentSequence))
setCurrentBlockState(m_persistentStates.value(currentSequence));
......
......@@ -88,10 +88,10 @@ inline bool isHexDigit(const QChar &c)
return false;
}
inline void setStartCharacter(QChar &c, const QString &character)
inline void setStartCharacter(QChar *c, const QString &character)
{
if (!character.isEmpty())
c = character.at(0);
*c = character.at(0);
}
} // namespace Internal
......
......@@ -45,7 +45,8 @@ void replaceByCaptures(QChar *c, const QStringList &captures)
int index = c->digitValue();
if (index > 0) {
const QString &capture = captures.at(index);
*c = capture.at(0);
if (!capture.isEmpty())
*c = capture.at(0);
}
}
......@@ -76,7 +77,7 @@ void replaceByCaptures(QString *s, const QStringList &captures)
// DetectChar
void DetectCharRule::setChar(const QString &character)
{ setStartCharacter(m_char, character); }
{ setStartCharacter(&m_char, character); }
void DetectCharRule::doReplaceExpressions(const QStringList &captures)
{ replaceByCaptures(&m_char, captures); }
......@@ -90,10 +91,10 @@ bool DetectCharRule::doMatchSucceed(const QString &text,
// Detect2Chars
void Detect2CharsRule::setChar(const QString &character)
{ setStartCharacter(m_char, character); }
{ setStartCharacter(&m_char, character); }
void Detect2CharsRule::setChar1(const QString &character)
{ setStartCharacter(m_char1, character); }
{ setStartCharacter(&m_char1, character); }
void Detect2CharsRule::doReplaceExpressions(const QStringList &captures)
{
......@@ -399,10 +400,10 @@ bool HlCCharRule::doMatchSucceed(const QString &text,
// RangeDetect
void RangeDetectRule::setChar(const QString &character)
{ setStartCharacter(m_char, character); }
{ setStartCharacter(&m_char, character); }
void RangeDetectRule::setChar1(const QString &character)
{ setStartCharacter(m_char1, character); }
{ setStartCharacter(&m_char1, character); }
bool RangeDetectRule::doMatchSucceed(const QString &text,
const int length,
......@@ -429,6 +430,7 @@ bool LineContinueRule::doMatchSucceed(const QString &text,
return false;
if (text.at(progress->offset()) == kBackSlash) {
progress->incrementOffset();
progress->setWillContinueLine(true);
return true;
}
......
......@@ -725,7 +725,7 @@ void tst_SpecificRules::testLineContinue_data()
{
addCommonColumns();
QTest::newRow("\\") << "\\" << true << 0 << false << true;
QTest::newRow("\\") << "\\" << true << 1 << false << true;
QTest::newRow("\\\\") << "\\\\" << false << 0 << true << false;
QTest::newRow("\\x") << "\\x" << false << 0 << true << false;
QTest::newRow("x\\") << "x\\" << false << 0 << true << false;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment