diff options
author | Nikolai Kosjar <nikolai.kosjar@digia.com> | 2014-05-08 09:48:27 -0400 |
---|---|---|
committer | Nikolai Kosjar <nikolai.kosjar@digia.com> | 2014-05-23 14:33:34 +0200 |
commit | bb7da966b801a2884cd7cf47f640bf7ac7d775df (patch) | |
tree | a4a74a15edb1603e7a20a306bd0246665c45e88b /src/plugins/cpptools/cppcompletionassist.cpp | |
parent | dd61ed3345a70ef46fb38a17de36ac2bb1627081 (diff) | |
download | qt-creator-bb7da966b801a2884cd7cf47f640bf7ac7d775df.tar.gz |
Cpp{Tools,Editor}: Respect multi-QChar code points when handling identifiers
* Consolidate code dealing with C++ identifiers into cpptoolsreuse.h
* Handle code points that are represented with two QChars
Change-Id: I4fb4435aa539f65d88598cac0b50629f33f32440
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
Diffstat (limited to 'src/plugins/cpptools/cppcompletionassist.cpp')
-rw-r--r-- | src/plugins/cpptools/cppcompletionassist.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/plugins/cpptools/cppcompletionassist.cpp b/src/plugins/cpptools/cppcompletionassist.cpp index 70c190b9ef..77a25b1d5c 100644 --- a/src/plugins/cpptools/cppcompletionassist.cpp +++ b/src/plugins/cpptools/cppcompletionassist.cpp @@ -35,6 +35,7 @@ #include "cppsnapshotupdater.h" #include "cpptoolsconstants.h" #include "cpptoolseditorsupport.h" +#include "cpptoolsreuse.h" #include <coreplugin/icore.h> #include <cppeditor/cppeditorconstants.h> @@ -314,8 +315,7 @@ void CppAssistProposalItem::applyContextualContent(TextEditor::BaseTextEditor *e while (preserveLength > 0) { if (inEditor.startsWith(toInsert.right(preserveLength)) && (inEditorLength == preserveLength - || (!inEditor.at(preserveLength).isLetterOrNumber() - && inEditor.at(preserveLength) != QLatin1Char('_')))) { + || !CppTools::isValidIdentifierChar(inEditor.at(preserveLength)))) { break; } --preserveLength; @@ -671,11 +671,12 @@ bool CppCompletionAssistProcessor::accepts() const } else { // Trigger completion after three characters of a name have been typed, when not editing an existing name QChar characterUnderCursor = m_interface->characterAt(pos); - if (!characterUnderCursor.isLetterOrNumber() && characterUnderCursor != QLatin1Char('_')) { + + if (!isValidIdentifierChar(characterUnderCursor)) { const int startOfName = findStartOfName(pos); if (pos - startOfName >= 3) { const QChar firstCharacter = m_interface->characterAt(startOfName); - if (firstCharacter.isLetter() || firstCharacter == QLatin1Char('_')) { + if (isValidFirstIdentifierChar(firstCharacter)) { // Finally check that we're not inside a comment or string (code copied from startOfOperator) QTextCursor tc(m_interface->textDocument()); tc.setPosition(pos); @@ -875,7 +876,7 @@ int CppCompletionAssistProcessor::findStartOfName(int pos) const // Skip to the start of a name do { chr = m_interface->characterAt(--pos); - } while (chr.isLetterOrNumber() || chr == QLatin1Char('_')); + } while (CppTools::isValidIdentifierChar(chr)); return pos + 1; } |