Snippets: Move snippet parsing into the snippet class

* Move the code to parse snippets into the snippet class
* Allow to escape $ so that this character can be used in
  snippets
* Add unit tests for the snippet parsing

Change-Id: I134f3c0de8290e1d7fcaf808577b31f5ac8fbc63
Reviewed-by: David Schulz <david.schulz@digia.com>
This commit is contained in:
Tobias Hunger
2013-08-20 13:58:16 +02:00
parent 6ac341467d
commit b589336e54
4 changed files with 142 additions and 44 deletions

View File

@@ -33,6 +33,7 @@
#include <texteditor/texteditor_global.h>
#include <QChar>
#include <QList>
#include <QString>
namespace TextEditor {
@@ -67,6 +68,20 @@ public:
static const QChar kVariableDelimiter;
class ParsedSnippet {
public:
QString text;
bool success;
struct Range {
Range(int s, int l) : start(s), length(l) { }
int start;
int length;
};
QList<Range> ranges;
};
static ParsedSnippet parse(const QString &snippet);
private:
bool m_isRemoved;
bool m_isModified;