summaryrefslogtreecommitdiff
path: root/src/plugins/texteditor/snippets/snippet.cpp
diff options
context:
space:
mode:
authorTobias Hunger <tobias.hunger@digia.com>2013-08-22 11:52:01 +0200
committerNikolai Kosjar <nikolai.kosjar@digia.com>2013-08-22 12:30:12 +0200
commit799bd4607c6a7c5d99ba5ec7a2d5fc120d220a67 (patch)
treee7d200ab613c2b4bb878be8886cdeaaca4ed4bec /src/plugins/texteditor/snippets/snippet.cpp
parente829b97371e1dfdf4ce688222ffaf84f54d4a1e0 (diff)
downloadqt-creator-799bd4607c6a7c5d99ba5ec7a2d5fc120d220a67.tar.gz
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>
Diffstat (limited to 'src/plugins/texteditor/snippets/snippet.cpp')
-rw-r--r--src/plugins/texteditor/snippets/snippet.cpp46
1 files changed, 30 insertions, 16 deletions
diff --git a/src/plugins/texteditor/snippets/snippet.cpp b/src/plugins/texteditor/snippets/snippet.cpp
index 31482eab3e..23c94fa6f1 100644
--- a/src/plugins/texteditor/snippets/snippet.cpp
+++ b/src/plugins/texteditor/snippets/snippet.cpp
@@ -225,22 +225,20 @@ Snippet::ParsedSnippet Snippet::parse(const QString &snippet)
break;
}
- if (current == QLatin1Char(':')) {
- if (start >= 0) {
- if (mangler != 0) {
- success = false;
- break;
- }
- if (next == QLatin1Char('l')) {
- mangler = &lcMangler;
- } else if (next == QLatin1Char('u')) {
- mangler = &ucMangler;
- } else if (next == QLatin1Char('c')) {
- mangler = &tcMangler;
- } else {
- success = false;
- break;
- }
+ if (current == QLatin1Char(':') && start >= 0) {
+ if (mangler != 0) {
+ success = false;
+ break;
+ }
+ if (next == QLatin1Char('l')) {
+ mangler = &lcMangler;
+ } else if (next == QLatin1Char('u')) {
+ mangler = &ucMangler;
+ } else if (next == QLatin1Char('c')) {
+ mangler = &tcMangler;
+ } else {
+ success = false;
+ break;
}
++i;
continue;
@@ -338,6 +336,22 @@ void Internal::TextEditorPlugin::testSnippetParsing_data()
<< QString::fromLatin1("$test:X$") << QString::fromLatin1("$test:X$") << false
<< (QList<int>()) << (QList<int>())
<< (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()