2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2009-09-17 15:44:54 +02:00
|
|
|
**
|
2016-01-15 14:58:39 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2009-09-17 15:44:54 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2009-09-17 15:44:54 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
2016-01-15 14:58:39 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
2009-09-17 15:44:54 +02:00
|
|
|
**
|
2016-01-15 14:58:39 +01:00
|
|
|
** GNU General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
2010-12-17 16:01:08 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2013-03-27 18:54:03 +01:00
|
|
|
|
2009-09-17 15:44:54 +02:00
|
|
|
#include "MatchingText.h"
|
2013-03-27 18:54:03 +01:00
|
|
|
|
2009-09-17 15:44:54 +02:00
|
|
|
#include "BackwardsScanner.h"
|
|
|
|
|
|
2013-03-27 18:54:03 +01:00
|
|
|
#include <cplusplus/Token.h>
|
2009-09-18 10:59:31 +02:00
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QTextDocument>
|
|
|
|
|
#include <QTextCursor>
|
|
|
|
|
#include <QChar>
|
2012-08-06 13:42:46 +02:00
|
|
|
#include <QDebug>
|
2009-09-17 15:44:54 +02:00
|
|
|
|
|
|
|
|
using namespace CPlusPlus;
|
|
|
|
|
|
2009-09-18 10:59:31 +02:00
|
|
|
enum { MAX_NUM_LINES = 20 };
|
2009-09-17 17:57:17 +02:00
|
|
|
|
2010-06-14 16:06:42 +02:00
|
|
|
static bool shouldOverrideChar(QChar ch)
|
2009-09-17 17:57:17 +02:00
|
|
|
{
|
2009-09-18 11:07:05 +02:00
|
|
|
switch (ch.unicode()) {
|
|
|
|
|
case ')': case ']': case ';': case '"': case '\'':
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2009-09-17 17:57:17 +02:00
|
|
|
}
|
|
|
|
|
|
2009-09-21 16:09:01 +02:00
|
|
|
static bool isCompleteStringLiteral(const BackwardsScanner &tk, int index)
|
2009-09-17 17:57:17 +02:00
|
|
|
{
|
2009-09-21 16:09:01 +02:00
|
|
|
const QStringRef text = tk.textRef(index);
|
2009-09-17 17:57:17 +02:00
|
|
|
|
|
|
|
|
if (text.length() < 2)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
else if (text.at(text.length() - 1) == QLatin1Char('"'))
|
|
|
|
|
return text.at(text.length() - 2) != QLatin1Char('\\'); // ### not exactly.
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2009-09-21 16:09:01 +02:00
|
|
|
static bool isCompleteCharLiteral(const BackwardsScanner &tk, int index)
|
2009-09-17 17:57:17 +02:00
|
|
|
{
|
2009-09-21 16:09:01 +02:00
|
|
|
const QStringRef text = tk.textRef(index);
|
2009-09-17 17:57:17 +02:00
|
|
|
|
|
|
|
|
if (text.length() < 2)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
else if (text.at(text.length() - 1) == QLatin1Char('\''))
|
|
|
|
|
return text.at(text.length() - 2) != QLatin1Char('\\'); // ### not exactly.
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2016-04-14 10:09:31 +02:00
|
|
|
static bool isEscaped(const QTextCursor &tc)
|
|
|
|
|
{
|
|
|
|
|
const QTextDocument *doc = tc.document();
|
|
|
|
|
|
|
|
|
|
int escapeCount = 0;
|
|
|
|
|
int index = tc.selectionEnd() - 1;
|
|
|
|
|
while (doc->characterAt(index) == '\\') {
|
|
|
|
|
++escapeCount;
|
|
|
|
|
--index;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (escapeCount % 2) != 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static bool isQuote(const QChar c)
|
|
|
|
|
{
|
|
|
|
|
return c == '\'' || c == '"';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static bool insertQuote(const QChar ch, const BackwardsScanner &tk)
|
|
|
|
|
{
|
|
|
|
|
// Always insert matching quote on an empty line
|
|
|
|
|
if (tk.size() == 0)
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
const int index = tk.startToken() - 1;
|
|
|
|
|
const Token &token = tk[index];
|
|
|
|
|
// Do not insert a matching quote when we are closing an open string/char literal.
|
|
|
|
|
return (ch == '"' && token.isStringLiteral() == isCompleteStringLiteral(tk, index))
|
|
|
|
|
|| (ch == '\'' && token.isCharLiteral() == isCompleteCharLiteral(tk, index));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int countSkippedChars(const QString blockText, const QString &textToProcess)
|
|
|
|
|
{
|
|
|
|
|
int skippedChars = 0;
|
|
|
|
|
const int length = qMin(blockText.length(), textToProcess.length());
|
|
|
|
|
for (int i = 0; i < length; ++i) {
|
|
|
|
|
const QChar ch1 = blockText.at(i);
|
|
|
|
|
const QChar ch2 = textToProcess.at(i);
|
|
|
|
|
|
|
|
|
|
if (ch1 != ch2)
|
|
|
|
|
break;
|
|
|
|
|
else if (! shouldOverrideChar(ch1))
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
++skippedChars;
|
|
|
|
|
}
|
|
|
|
|
return skippedChars;
|
|
|
|
|
}
|
|
|
|
|
|
2016-04-15 09:35:20 +02:00
|
|
|
static const Token tokenAtPosition(const Tokens &tokens, const unsigned pos)
|
2009-09-21 18:19:09 +02:00
|
|
|
{
|
2016-04-15 09:35:20 +02:00
|
|
|
for (int i = tokens.size() - 1; i >= 0; --i) {
|
|
|
|
|
const Token tk = tokens.at(i);
|
|
|
|
|
if (pos >= tk.utf16charsBegin() && pos < tk.utf16charsEnd())
|
|
|
|
|
return tk;
|
|
|
|
|
}
|
|
|
|
|
return Token();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool MatchingText::contextAllowsAutoParentheses(const QTextCursor &cursor,
|
|
|
|
|
const QString &textToInsert)
|
|
|
|
|
{
|
|
|
|
|
QChar ch;
|
|
|
|
|
|
|
|
|
|
if (!textToInsert.isEmpty())
|
|
|
|
|
ch = textToInsert.at(0);
|
|
|
|
|
|
|
|
|
|
if (!shouldInsertMatchingText(cursor) && ch != QLatin1Char('\'') && ch != QLatin1Char('"'))
|
|
|
|
|
return false;
|
|
|
|
|
else if (isInCommentHelper(cursor))
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool MatchingText::contextAllowsElectricCharacters(const QTextCursor &cursor)
|
|
|
|
|
{
|
|
|
|
|
Token token;
|
|
|
|
|
|
|
|
|
|
if (isInCommentHelper(cursor, &token))
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
if (token.isStringLiteral() || token.isCharLiteral()) {
|
|
|
|
|
const unsigned pos = cursor.selectionEnd() - cursor.block().position();
|
|
|
|
|
if (pos <= token.utf16charsEnd())
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool MatchingText::shouldInsertMatchingText(const QTextCursor &cursor)
|
|
|
|
|
{
|
|
|
|
|
QTextDocument *doc = cursor.document();
|
|
|
|
|
return shouldInsertMatchingText(doc->characterAt(cursor.selectionEnd()));
|
2009-09-21 18:19:09 +02:00
|
|
|
}
|
|
|
|
|
|
2010-06-14 16:06:42 +02:00
|
|
|
bool MatchingText::shouldInsertMatchingText(QChar lookAhead)
|
2009-09-17 18:39:10 +02:00
|
|
|
{
|
2009-09-18 11:07:05 +02:00
|
|
|
switch (lookAhead.unicode()) {
|
|
|
|
|
case '{': case '}':
|
|
|
|
|
case ']': case ')':
|
|
|
|
|
case ';': case ',':
|
2009-09-17 18:39:10 +02:00
|
|
|
return true;
|
|
|
|
|
|
2009-09-18 11:07:05 +02:00
|
|
|
default:
|
|
|
|
|
if (lookAhead.isSpace())
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
} // switch
|
2009-09-17 18:39:10 +02:00
|
|
|
}
|
|
|
|
|
|
2016-04-15 09:35:20 +02:00
|
|
|
static Tokens getTokens(const QTextCursor &cursor, int &prevState)
|
|
|
|
|
{
|
|
|
|
|
LanguageFeatures features;
|
|
|
|
|
features.qtEnabled = false;
|
|
|
|
|
features.qtKeywordsEnabled = false;
|
|
|
|
|
features.qtMocRunEnabled = false;
|
|
|
|
|
features.cxx11Enabled = true;
|
|
|
|
|
features.c99Enabled = true;
|
|
|
|
|
|
|
|
|
|
SimpleLexer tokenize;
|
|
|
|
|
tokenize.setLanguageFeatures(features);
|
|
|
|
|
|
|
|
|
|
prevState = BackwardsScanner::previousBlockState(cursor.block()) & 0xFF;
|
|
|
|
|
return tokenize(cursor.block().text(), prevState);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool MatchingText::isInCommentHelper(const QTextCursor &cursor, Token *retToken)
|
|
|
|
|
{
|
|
|
|
|
int prevState = 0;
|
|
|
|
|
const Tokens tokens = getTokens(cursor, prevState);
|
|
|
|
|
|
|
|
|
|
const unsigned pos = cursor.selectionEnd() - cursor.block().position();
|
|
|
|
|
|
|
|
|
|
if (tokens.isEmpty() || pos < tokens.first().utf16charsBegin())
|
|
|
|
|
return prevState > 0;
|
|
|
|
|
|
|
|
|
|
if (pos >= tokens.last().utf16charsEnd()) {
|
|
|
|
|
const Token tk = tokens.last();
|
|
|
|
|
if (retToken)
|
|
|
|
|
*retToken = tk;
|
|
|
|
|
if (tk.is(T_CPP_COMMENT) || tk.is(T_CPP_DOXY_COMMENT))
|
|
|
|
|
return true;
|
|
|
|
|
return tk.isComment() && (cursor.block().userState() & 0xFF);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Token tk = tokenAtPosition(tokens, pos);
|
|
|
|
|
if (retToken)
|
|
|
|
|
*retToken = tk;
|
|
|
|
|
return tk.isComment();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool MatchingText::isInStringHelper(const QTextCursor &cursor)
|
|
|
|
|
{
|
|
|
|
|
int prevState = 0;
|
|
|
|
|
const Tokens tokens = getTokens(cursor, prevState);
|
|
|
|
|
|
|
|
|
|
const unsigned pos = cursor.selectionEnd() - cursor.block().position();
|
|
|
|
|
|
|
|
|
|
if (tokens.isEmpty() || pos <= tokens.first().utf16charsBegin())
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
if (pos >= tokens.last().utf16charsEnd()) {
|
|
|
|
|
const Token tk = tokens.last();
|
|
|
|
|
return tk.isStringLiteral() && prevState > 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Token tk = tokenAtPosition(tokens, pos);
|
|
|
|
|
return tk.isStringLiteral() && pos > tk.utf16charsBegin();
|
|
|
|
|
}
|
|
|
|
|
|
2009-09-17 18:39:10 +02:00
|
|
|
QString MatchingText::insertMatchingBrace(const QTextCursor &cursor, const QString &textToProcess,
|
2014-09-13 00:48:47 +02:00
|
|
|
QChar la, int *skippedChars)
|
2009-09-17 17:57:17 +02:00
|
|
|
{
|
|
|
|
|
QTextCursor tc = cursor;
|
|
|
|
|
QString text = textToProcess;
|
|
|
|
|
|
2010-06-15 10:44:07 +02:00
|
|
|
const QString blockText = tc.block().text().mid(tc.positionInBlock());
|
2012-02-19 14:35:41 +04:00
|
|
|
const QString trimmedBlockText = blockText.trimmed();
|
2009-10-05 16:20:06 +02:00
|
|
|
|
2016-04-14 10:09:31 +02:00
|
|
|
if (!textToProcess.isEmpty()) {
|
|
|
|
|
if (!isQuote(textToProcess.at(0)) || !isEscaped(tc)) {
|
|
|
|
|
*skippedChars = countSkippedChars(blockText, textToProcess);
|
|
|
|
|
if (*skippedChars != 0) {
|
|
|
|
|
tc.movePosition(QTextCursor::NextCharacter, QTextCursor::MoveAnchor, *skippedChars);
|
|
|
|
|
text = textToProcess.mid(*skippedChars);
|
|
|
|
|
}
|
2009-10-05 16:20:06 +02:00
|
|
|
}
|
2009-09-17 17:57:17 +02:00
|
|
|
}
|
|
|
|
|
|
2009-09-17 18:39:10 +02:00
|
|
|
if (text.isEmpty() || !shouldInsertMatchingText(la))
|
2009-09-17 17:57:17 +02:00
|
|
|
return QString();
|
|
|
|
|
|
2015-02-26 09:14:38 +02:00
|
|
|
BackwardsScanner tk(tc, LanguageFeatures::defaultFeatures(), MAX_NUM_LINES,
|
|
|
|
|
textToProcess.left(*skippedChars));
|
2016-04-14 10:09:31 +02:00
|
|
|
const QChar ch0 = text.at(0);
|
|
|
|
|
if (isQuote(ch0)) {
|
2009-09-17 17:57:17 +02:00
|
|
|
if (text.length() != 1)
|
|
|
|
|
qWarning() << Q_FUNC_INFO << "handle event compression";
|
2016-04-14 10:09:31 +02:00
|
|
|
if (insertQuote(ch0, tk))
|
|
|
|
|
return ch0;
|
2009-09-17 17:57:17 +02:00
|
|
|
return QString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString result;
|
|
|
|
|
foreach (const QChar &ch, text) {
|
2012-02-19 14:35:41 +04:00
|
|
|
if (ch == QLatin1Char('(')) result += QLatin1Char(')');
|
|
|
|
|
else if (ch == QLatin1Char('[')) result += QLatin1Char(']');
|
|
|
|
|
// Handle '{' appearance within functinon call context
|
|
|
|
|
else if (ch == QLatin1Char('{') && !trimmedBlockText.isEmpty() && trimmedBlockText.at(0) == QLatin1Char(')'))
|
|
|
|
|
result += QLatin1Char('}');
|
2009-09-17 17:57:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2014-09-13 00:48:47 +02:00
|
|
|
static bool shouldInsertNewline(const QTextCursor &tc)
|
2009-09-18 10:59:31 +02:00
|
|
|
{
|
|
|
|
|
QTextDocument *doc = tc.document();
|
|
|
|
|
int pos = tc.selectionEnd();
|
|
|
|
|
|
|
|
|
|
// count the number of empty lines.
|
|
|
|
|
int newlines = 0;
|
|
|
|
|
for (int e = doc->characterCount(); pos != e; ++pos) {
|
|
|
|
|
const QChar ch = doc->characterAt(pos);
|
|
|
|
|
|
|
|
|
|
if (! ch.isSpace())
|
|
|
|
|
break;
|
2014-09-13 00:48:47 +02:00
|
|
|
if (ch == QChar::ParagraphSeparator)
|
2009-09-18 10:59:31 +02:00
|
|
|
++newlines;
|
|
|
|
|
}
|
|
|
|
|
|
2014-09-13 00:48:47 +02:00
|
|
|
return newlines <= 1 && doc->characterAt(pos) != QLatin1Char('}');
|
2009-09-18 10:59:31 +02:00
|
|
|
}
|
|
|
|
|
|
2016-04-15 09:35:20 +02:00
|
|
|
QString MatchingText::insertParagraphSeparator(const QTextCursor &cursor)
|
2009-09-17 15:44:54 +02:00
|
|
|
{
|
2016-04-15 09:35:20 +02:00
|
|
|
BackwardsScanner tk(cursor, LanguageFeatures::defaultFeatures(), MAX_NUM_LINES);
|
2009-09-17 15:44:54 +02:00
|
|
|
int index = tk.startToken();
|
|
|
|
|
|
|
|
|
|
if (tk[index - 1].isNot(T_LBRACE))
|
|
|
|
|
return QString(); // nothing to do.
|
|
|
|
|
|
2016-04-15 09:35:20 +02:00
|
|
|
const QString textBlock = cursor.block().text().mid(cursor.positionInBlock()).trimmed();
|
2009-09-17 17:57:17 +02:00
|
|
|
if (! textBlock.isEmpty())
|
|
|
|
|
return QString();
|
|
|
|
|
|
2009-09-17 15:44:54 +02:00
|
|
|
--index; // consume the `{'
|
|
|
|
|
|
2010-06-29 17:57:15 +02:00
|
|
|
const Token &token = tk[index - 1];
|
2009-09-17 15:44:54 +02:00
|
|
|
|
2016-04-18 15:57:09 +02:00
|
|
|
if (token.is(T_IDENTIFIER)) {
|
2009-09-17 15:44:54 +02:00
|
|
|
int i = index - 1;
|
|
|
|
|
|
|
|
|
|
forever {
|
2010-06-29 17:57:15 +02:00
|
|
|
const Token ¤t = tk[i - 1];
|
2009-09-17 15:44:54 +02:00
|
|
|
|
|
|
|
|
if (current.is(T_EOF_SYMBOL))
|
|
|
|
|
break;
|
|
|
|
|
|
2013-07-17 00:01:45 +03:00
|
|
|
if (current.is(T_CLASS) || current.is(T_STRUCT) || current.is(T_UNION) || current.is(T_ENUM)) {
|
2009-09-18 10:59:31 +02:00
|
|
|
// found a class key.
|
|
|
|
|
QString str = QLatin1String("};");
|
|
|
|
|
|
2016-04-15 09:35:20 +02:00
|
|
|
if (shouldInsertNewline(cursor))
|
2009-09-18 10:59:31 +02:00
|
|
|
str += QLatin1Char('\n');
|
|
|
|
|
|
|
|
|
|
return str;
|
|
|
|
|
}
|
2009-09-17 15:44:54 +02:00
|
|
|
|
|
|
|
|
else if (current.is(T_NAMESPACE))
|
|
|
|
|
return QLatin1String("}"); // found a namespace declaration
|
|
|
|
|
|
|
|
|
|
else if (current.is(T_SEMICOLON))
|
|
|
|
|
break; // found the `;' sync token
|
|
|
|
|
|
|
|
|
|
else if (current.is(T_LBRACE) || current.is(T_RBRACE))
|
|
|
|
|
break; // braces are considered sync tokens
|
|
|
|
|
|
|
|
|
|
else if (current.is(T_LPAREN) || current.is(T_RPAREN))
|
|
|
|
|
break; // sync token
|
|
|
|
|
|
|
|
|
|
else if (current.is(T_LBRACKET) || current.is(T_RBRACKET))
|
|
|
|
|
break; // sync token
|
|
|
|
|
|
|
|
|
|
--i;
|
|
|
|
|
}
|
2010-02-01 11:56:52 +01:00
|
|
|
} else if (token.is(T_CLASS) || token.is(T_STRUCT) || token.is(T_UNION) || token.is(T_ENUM)) {
|
2009-09-17 15:44:54 +02:00
|
|
|
if (tk[index - 2].is(T_TYPEDEF)) {
|
|
|
|
|
// recognized:
|
|
|
|
|
// typedef struct {
|
|
|
|
|
//
|
|
|
|
|
// in this case we don't want to insert the extra semicolon+newline.
|
|
|
|
|
return QLatin1String("}");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// anonymous class
|
|
|
|
|
return QLatin1String("};");
|
|
|
|
|
|
|
|
|
|
} else if (token.is(T_RPAREN)) {
|
|
|
|
|
// search the matching brace.
|
|
|
|
|
const int lparenIndex = tk.startOfMatchingBrace(index);
|
|
|
|
|
|
|
|
|
|
if (lparenIndex == index) {
|
2016-04-18 15:57:09 +02:00
|
|
|
// found an unmatched brace. We don't really know what to do in this case.
|
2009-09-17 15:44:54 +02:00
|
|
|
return QString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// look at the token before the matched brace
|
2010-06-29 17:57:15 +02:00
|
|
|
const Token &tokenBeforeBrace = tk[lparenIndex - 1];
|
2009-09-17 15:44:54 +02:00
|
|
|
|
|
|
|
|
if (tokenBeforeBrace.is(T_IF)) {
|
|
|
|
|
// recognized an if statement
|
|
|
|
|
return QLatin1String("}");
|
|
|
|
|
|
|
|
|
|
} else if (tokenBeforeBrace.is(T_FOR) || tokenBeforeBrace.is(T_WHILE)) {
|
|
|
|
|
// recognized a for-like statement
|
|
|
|
|
return QLatin1String("}");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// if we reached this point there is a good chance that we are parsing a function definition
|
2009-09-18 10:59:31 +02:00
|
|
|
QString str = QLatin1String("}");
|
|
|
|
|
|
2016-04-15 09:35:20 +02:00
|
|
|
if (shouldInsertNewline(cursor))
|
2009-09-18 10:59:31 +02:00
|
|
|
str += QLatin1Char('\n');
|
|
|
|
|
|
|
|
|
|
return str;
|
2009-09-17 15:44:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// match the block
|
|
|
|
|
return QLatin1String("}");
|
|
|
|
|
}
|