Snippet: Use Template engine to pre-process snippets

This enables macros in snippets as well as if/else to select/deselect
lines to have in the snippet.

Change-Id: Ic88fb3277a0f5ac803bcab486b245c688c00822a
Reviewed-by: David Schulz <david.schulz@theqtcompany.com>
This commit is contained in:
Tobias Hunger
2015-09-25 10:31:28 +02:00
parent ec2e01faec
commit 08ca3eb480
3 changed files with 27 additions and 10 deletions

View File

@@ -2464,6 +2464,14 @@ void TextEditorWidget::insertCodeSnippet(const QTextCursor &cursor_arg, const QS
{
Snippet::ParsedSnippet data = Snippet::parse(snippet);
if (!data.success) {
QString message = QString::fromLatin1("Cannot parse snippet \"%1\".").arg(snippet);
if (!data.errorMessage.isEmpty())
message += QLatin1String("\nParse error: ") + data.errorMessage;
QMessageBox::warning(this, QLatin1String("Snippet Parse Error"), message);
return;
}
QTextCursor cursor = cursor_arg;
cursor.beginEditBlock();
cursor.removeSelectedText();