forked from qt-creator/qt-creator
Generic highlighter: Small re-writings.
This commit is contained in:
@@ -205,7 +205,6 @@ void Highlighter::iterateThroughRules(const QString &text,
|
|||||||
if (progress->willContinueLine()) {
|
if (progress->willContinueLine()) {
|
||||||
createWillContinueBlock();
|
createWillContinueBlock();
|
||||||
progress->setWillContinueLine(false);
|
progress->setWillContinueLine(false);
|
||||||
progress->setOffset(length);
|
|
||||||
} else {
|
} else {
|
||||||
if (rule->hasChild())
|
if (rule->hasChild())
|
||||||
iterateThroughRules(text, length, progress, true, rule->childs());
|
iterateThroughRules(text, length, progress, true, rule->childs());
|
||||||
@@ -270,7 +269,7 @@ void Highlighter::changeContext(const QString &contextName,
|
|||||||
m_contexts.pop_back();
|
m_contexts.pop_back();
|
||||||
|
|
||||||
if (currentBlockState() >= PersistentsStart) {
|
if (currentBlockState() >= PersistentsStart) {
|
||||||
// One or more persistent contexts were popped.
|
// One or more contexts were popped during during a persistent state.
|
||||||
const QString ¤tSequence = currentContextSequence();
|
const QString ¤tSequence = currentContextSequence();
|
||||||
if (m_persistentStates.contains(currentSequence))
|
if (m_persistentStates.contains(currentSequence))
|
||||||
setCurrentBlockState(m_persistentStates.value(currentSequence));
|
setCurrentBlockState(m_persistentStates.value(currentSequence));
|
||||||
|
@@ -88,10 +88,10 @@ inline bool isHexDigit(const QChar &c)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void setStartCharacter(QChar &c, const QString &character)
|
inline void setStartCharacter(QChar *c, const QString &character)
|
||||||
{
|
{
|
||||||
if (!character.isEmpty())
|
if (!character.isEmpty())
|
||||||
c = character.at(0);
|
*c = character.at(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
@@ -45,7 +45,8 @@ void replaceByCaptures(QChar *c, const QStringList &captures)
|
|||||||
int index = c->digitValue();
|
int index = c->digitValue();
|
||||||
if (index > 0) {
|
if (index > 0) {
|
||||||
const QString &capture = captures.at(index);
|
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
|
// DetectChar
|
||||||
void DetectCharRule::setChar(const QString &character)
|
void DetectCharRule::setChar(const QString &character)
|
||||||
{ setStartCharacter(m_char, character); }
|
{ setStartCharacter(&m_char, character); }
|
||||||
|
|
||||||
void DetectCharRule::doReplaceExpressions(const QStringList &captures)
|
void DetectCharRule::doReplaceExpressions(const QStringList &captures)
|
||||||
{ replaceByCaptures(&m_char, captures); }
|
{ replaceByCaptures(&m_char, captures); }
|
||||||
@@ -90,10 +91,10 @@ bool DetectCharRule::doMatchSucceed(const QString &text,
|
|||||||
|
|
||||||
// Detect2Chars
|
// Detect2Chars
|
||||||
void Detect2CharsRule::setChar(const QString &character)
|
void Detect2CharsRule::setChar(const QString &character)
|
||||||
{ setStartCharacter(m_char, character); }
|
{ setStartCharacter(&m_char, character); }
|
||||||
|
|
||||||
void Detect2CharsRule::setChar1(const QString &character)
|
void Detect2CharsRule::setChar1(const QString &character)
|
||||||
{ setStartCharacter(m_char1, character); }
|
{ setStartCharacter(&m_char1, character); }
|
||||||
|
|
||||||
void Detect2CharsRule::doReplaceExpressions(const QStringList &captures)
|
void Detect2CharsRule::doReplaceExpressions(const QStringList &captures)
|
||||||
{
|
{
|
||||||
@@ -399,10 +400,10 @@ bool HlCCharRule::doMatchSucceed(const QString &text,
|
|||||||
|
|
||||||
// RangeDetect
|
// RangeDetect
|
||||||
void RangeDetectRule::setChar(const QString &character)
|
void RangeDetectRule::setChar(const QString &character)
|
||||||
{ setStartCharacter(m_char, character); }
|
{ setStartCharacter(&m_char, character); }
|
||||||
|
|
||||||
void RangeDetectRule::setChar1(const QString &character)
|
void RangeDetectRule::setChar1(const QString &character)
|
||||||
{ setStartCharacter(m_char1, character); }
|
{ setStartCharacter(&m_char1, character); }
|
||||||
|
|
||||||
bool RangeDetectRule::doMatchSucceed(const QString &text,
|
bool RangeDetectRule::doMatchSucceed(const QString &text,
|
||||||
const int length,
|
const int length,
|
||||||
@@ -429,6 +430,7 @@ bool LineContinueRule::doMatchSucceed(const QString &text,
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (text.at(progress->offset()) == kBackSlash) {
|
if (text.at(progress->offset()) == kBackSlash) {
|
||||||
|
progress->incrementOffset();
|
||||||
progress->setWillContinueLine(true);
|
progress->setWillContinueLine(true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@@ -725,7 +725,7 @@ void tst_SpecificRules::testLineContinue_data()
|
|||||||
{
|
{
|
||||||
addCommonColumns();
|
addCommonColumns();
|
||||||
|
|
||||||
QTest::newRow("\\") << "\\" << true << 0 << false << true;
|
QTest::newRow("\\") << "\\" << true << 1 << false << true;
|
||||||
QTest::newRow("\\\\") << "\\\\" << false << 0 << true << false;
|
QTest::newRow("\\\\") << "\\\\" << false << 0 << true << false;
|
||||||
QTest::newRow("\\x") << "\\x" << false << 0 << true << false;
|
QTest::newRow("\\x") << "\\x" << false << 0 << true << false;
|
||||||
QTest::newRow("x\\") << "x\\" << false << 0 << true << false;
|
QTest::newRow("x\\") << "x\\" << false << 0 << true << false;
|
||||||
|
Reference in New Issue
Block a user