diff options
author | Roberto Raggi <roberto.raggi@nokia.com> | 2009-09-17 18:39:10 +0200 |
---|---|---|
committer | Roberto Raggi <roberto.raggi@nokia.com> | 2009-09-17 18:39:10 +0200 |
commit | da4fcd22ef4f15234a97f05d6fb5ae7a9e7ba56f (patch) | |
tree | 179c2ef747c05a89241d8db080cdb68bd02a1173 /src/libs/cplusplus/MatchingText.cpp | |
parent | 82b80b9e3946083ec0a9f2cb8415b32503790136 (diff) | |
download | qt-creator-da4fcd22ef4f15234a97f05d6fb5ae7a9e7ba56f.tar.gz |
Pass the lookahead character to matching text.
Diffstat (limited to 'src/libs/cplusplus/MatchingText.cpp')
-rw-r--r-- | src/libs/cplusplus/MatchingText.cpp | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/src/libs/cplusplus/MatchingText.cpp b/src/libs/cplusplus/MatchingText.cpp index 86a31fc9ec..76a6fe1ca7 100644 --- a/src/libs/cplusplus/MatchingText.cpp +++ b/src/libs/cplusplus/MatchingText.cpp @@ -71,10 +71,31 @@ static bool isCompleteCharLiteral(const BackwardsScanner &tk, int index, int sta return false; } +static bool shouldInsertMatchingText(const QChar &lookAhead) +{ + if (lookAhead.isSpace()) + return true; + else if (lookAhead == QLatin1Char('{')) + return true; + else if (lookAhead == QLatin1Char('}')) + return true; + else if (lookAhead == QLatin1Char(']')) + return true; + else if (lookAhead == QLatin1Char(')')) + return true; + else if (lookAhead == QLatin1Char(';')) + return true; + else if (lookAhead == QLatin1Char(',')) + return true; + + return false; +} + MatchingText::MatchingText() { } -QString MatchingText::insertMatchingBrace(const QTextCursor &cursor, const QString &textToProcess, int *skippedChars) const +QString MatchingText::insertMatchingBrace(const QTextCursor &cursor, const QString &textToProcess, + const QChar &la, int *skippedChars) const { *skippedChars = 0; @@ -101,7 +122,7 @@ QString MatchingText::insertMatchingBrace(const QTextCursor &cursor, const QStri text = textToProcess.mid(*skippedChars); } - if (text.isEmpty()) + if (text.isEmpty() || !shouldInsertMatchingText(la)) return QString(); BackwardsScanner tk(tc, textToProcess.left(*skippedChars), MAX_NUM_LINES); |