forked from qt-creator/qt-creator
Snippet: Fix snippets with : in them
* Fix the parser * Add a unit test for this Change-Id: I202f845e12c9b6203444f3bb12d7a9229c8a2887 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
This commit is contained in:
committed by
Nikolai Kosjar
parent
e829b97371
commit
799bd4607c
@@ -225,8 +225,7 @@ Snippet::ParsedSnippet Snippet::parse(const QString &snippet)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (current == QLatin1Char(':')) {
|
if (current == QLatin1Char(':') && start >= 0) {
|
||||||
if (start >= 0) {
|
|
||||||
if (mangler != 0) {
|
if (mangler != 0) {
|
||||||
success = false;
|
success = false;
|
||||||
break;
|
break;
|
||||||
@@ -241,7 +240,6 @@ Snippet::ParsedSnippet Snippet::parse(const QString &snippet)
|
|||||||
success = false;
|
success = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
++i;
|
++i;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -338,6 +336,22 @@ void Internal::TextEditorPlugin::testSnippetParsing_data()
|
|||||||
<< QString::fromLatin1("$test:X$") << QString::fromLatin1("$test:X$") << false
|
<< QString::fromLatin1("$test:X$") << QString::fromLatin1("$test:X$") << false
|
||||||
<< (QList<int>()) << (QList<int>())
|
<< (QList<int>()) << (QList<int>())
|
||||||
<< (QList<Core::Id>());
|
<< (QList<Core::Id>());
|
||||||
|
|
||||||
|
QTest::newRow("multiline with :")
|
||||||
|
<< QString::fromLatin1("class $name$\n"
|
||||||
|
"{\n"
|
||||||
|
"public:\n"
|
||||||
|
" $name$() {}\n"
|
||||||
|
"};")
|
||||||
|
<< QString::fromLatin1("class name\n"
|
||||||
|
"{\n"
|
||||||
|
"public:\n"
|
||||||
|
" name() {}\n"
|
||||||
|
"};")
|
||||||
|
<< true
|
||||||
|
<< (QList<int>() << 6 << 25)
|
||||||
|
<< (QList<int>() << 4 << 4)
|
||||||
|
<< (QList<Core::Id>() << NOMANGLER_ID << NOMANGLER_ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Internal::TextEditorPlugin::testSnippetParsing()
|
void Internal::TextEditorPlugin::testSnippetParsing()
|
||||||
|
|||||||
Reference in New Issue
Block a user