Editor: Allow defining custom snippet parser function

Task-number: QTCREATORBUG-22406
Change-Id: I21ae9740d348d4e0869029343d51b70f9df9cdac
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
David Schulz
2021-05-11 10:49:14 +02:00
parent 770d87709e
commit 44e7047450
14 changed files with 152 additions and 67 deletions

View File

@@ -2720,9 +2720,11 @@ public:
QTextCursor cursor;
};
void TextEditorWidget::insertCodeSnippet(const QTextCursor &cursor_arg, const QString &snippet)
void TextEditorWidget::insertCodeSnippet(const QTextCursor &cursor_arg,
const QString &snippet,
const SnippetParser &parse)
{
SnippetParseResult result = Snippet::parse(snippet);
SnippetParseResult result = parse(snippet);
if (Utils::holds_alternative<SnippetParseError>(result)) {
const auto &error = Utils::get<SnippetParseError>(result);
QMessageBox::warning(this, tr("Snippet Parse Error"), error.htmlMessage());