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>
This commit is contained in:
Nikolai Kosjar
2014-05-08 09:48:27 -04:00
parent dd61ed3345
commit bb7da966b8
10 changed files with 51 additions and 20 deletions

View File

@@ -176,11 +176,6 @@ struct CanonicalSymbol
return typeOfExpression.context();
}
static inline bool isIdentifierChar(const QChar &ch)
{
return ch.isLetterOrNumber() || ch == QLatin1Char('_');
}
Scope *getScopeAndExpression(const QTextCursor &cursor, QString *code)
{
return getScopeAndExpression(editor, info, cursor, code);
@@ -202,11 +197,11 @@ struct CanonicalSymbol
int pos = tc.position();
if (!isIdentifierChar(document->characterAt(pos)))
if (!(pos > 0 && isIdentifierChar(document->characterAt(pos - 1))))
if (!isValidIdentifierChar(document->characterAt(pos)))
if (!(pos > 0 && isValidIdentifierChar(document->characterAt(pos - 1))))
return 0;
while (isIdentifierChar(document->characterAt(pos)))
while (isValidIdentifierChar(document->characterAt(pos)))
++pos;
tc.setPosition(pos);