forked from qt-creator/qt-creator
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:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user