Commit 7104998d authored by hjk's avatar hjk

CPlusPlus: Simplify MatchingText interface

Change-Id: I46878d9ca048d0c79032445f5adc27c12d27f30c
Reviewed-by: default avatarNikolai Kosjar <nikolai.kosjar@digia.com>
parent 3be2c9df
......@@ -102,7 +102,7 @@ bool MatchingText::shouldInsertMatchingText(QChar lookAhead)
}
QString MatchingText::insertMatchingBrace(const QTextCursor &cursor, const QString &textToProcess,
QChar la, int *skippedChars) const
QChar la, int *skippedChars)
{
QTextCursor tc = cursor;
QTextDocument *doc = tc.document();
......@@ -193,7 +193,7 @@ QString MatchingText::insertMatchingBrace(const QTextCursor &cursor, const QStri
return result;
}
bool MatchingText::shouldInsertNewline(const QTextCursor &tc) const
static bool shouldInsertNewline(const QTextCursor &tc)
{
QTextDocument *doc = tc.document();
int pos = tc.selectionEnd();
......@@ -205,17 +205,14 @@ bool MatchingText::shouldInsertNewline(const QTextCursor &tc) const
if (! ch.isSpace())
break;
else if (ch == QChar::ParagraphSeparator)
if (ch == QChar::ParagraphSeparator)
++newlines;
}
if (newlines <= 1 && doc->characterAt(pos) != QLatin1Char('}'))
return true;
return false;
return newlines <= 1 && doc->characterAt(pos) != QLatin1Char('}');
}
QString MatchingText::insertParagraphSeparator(const QTextCursor &tc) const
QString MatchingText::insertParagraphSeparator(const QTextCursor &tc)
{
BackwardsScanner tk(tc, MAX_NUM_LINES);
int index = tk.startToken();
......
......@@ -26,6 +26,7 @@
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#ifndef CPLUSPLUS_MATCHINGTEXT_H
#define CPLUSPLUS_MATCHINGTEXT_H
......@@ -42,12 +43,9 @@ public:
static bool shouldInsertMatchingText(const QTextCursor &tc);
static bool shouldInsertMatchingText(QChar lookAhead);
QString insertMatchingBrace(const QTextCursor &tc, const QString &text,
QChar la, int *skippedChars) const;
QString insertParagraphSeparator(const QTextCursor &tc) const;
private:
bool shouldInsertNewline(const QTextCursor &tc) const;
static QString insertMatchingBrace(const QTextCursor &tc, const QString &text,
QChar la, int *skippedChars);
static QString insertParagraphSeparator(const QTextCursor &tc);
};
} // namespace CPlusPlus
......
......@@ -128,13 +128,11 @@ QString CppAutoCompleter::insertMatchingBrace(const QTextCursor &cursor,
QChar la,
int *skippedChars) const
{
MatchingText m;
return m.insertMatchingBrace(cursor, text, la, skippedChars);
return MatchingText::insertMatchingBrace(cursor, text, la, skippedChars);
}
QString CppAutoCompleter::insertParagraphSeparator(const QTextCursor &cursor) const
{
MatchingText m;
return m.insertParagraphSeparator(cursor);
return MatchingText::insertParagraphSeparator(cursor);
}
......@@ -124,14 +124,12 @@ QString GlslCompleter::insertMatchingBrace(const QTextCursor &cursor,
QChar la,
int *skippedChars) const
{
MatchingText m;
return m.insertMatchingBrace(cursor, text, la, skippedChars);
return MatchingText::insertMatchingBrace(cursor, text, la, skippedChars);
}
QString GlslCompleter::insertParagraphSeparator(const QTextCursor &cursor) const
{
MatchingText m;
return m.insertParagraphSeparator(cursor);
return MatchingText::insertParagraphSeparator(cursor);
}
} // namespace Internal
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment