Generic highlighter: Small re-writings.

This commit is contained in:
Leandro Melo
2010-06-14 14:33:28 +02:00
parent 24be4b878f
commit b57a161101
4 changed files with 12 additions and 11 deletions

View File

@@ -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));

View File

@@ -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

View File

@@ -45,6 +45,7 @@ void replaceByCaptures(QChar *c, const QStringList &captures)
int index = c->digitValue();
if (index > 0) {
const QString &capture = captures.at(index);
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;
}

View File

@@ -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;