From c6358e5d380c18f3ebff148a095ddf3a9d6b266c Mon Sep 17 00:00:00 2001 From: Nikolai Kosjar Date: Fri, 9 May 2014 10:04:13 -0400 Subject: C++: Add utf16 indices to Macro and Document::MacroUse In most cases we need to work with the utf16 indices. Only in cppfindreferences the byte interface is still needed since there we read in files and work on a QByteArray to save memory. Change-Id: I6ef6a93fc1875a8c9a305c075d51a9ca034c41bb Reviewed-by: Erik Verbruggen --- src/libs/cplusplus/FastPreprocessor.cpp | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) (limited to 'src/libs/cplusplus/FastPreprocessor.cpp') diff --git a/src/libs/cplusplus/FastPreprocessor.cpp b/src/libs/cplusplus/FastPreprocessor.cpp index 5c52764cf5..c49695fc8c 100644 --- a/src/libs/cplusplus/FastPreprocessor.cpp +++ b/src/libs/cplusplus/FastPreprocessor.cpp @@ -108,37 +108,45 @@ static const Macro revision(const Snapshot &s, const Macro &m) return m; } -void FastPreprocessor::passedMacroDefinitionCheck(unsigned offset, unsigned line, const Macro ¯o) +void FastPreprocessor::passedMacroDefinitionCheck(unsigned bytesOffset, unsigned utf16charsOffset, + unsigned line, const Macro ¯o) { Q_ASSERT(_currentDoc); _currentDoc->addMacroUse(revision(_snapshot, macro), - offset, macro.name().length(), line, - QVector()); + bytesOffset, macro.name().size(), + utf16charsOffset, macro.nameToQString().size(), + line, QVector()); } -void FastPreprocessor::failedMacroDefinitionCheck(unsigned offset, const ByteArrayRef &name) +void FastPreprocessor::failedMacroDefinitionCheck(unsigned bytesOffset, unsigned utf16charsOffset, + const ByteArrayRef &name) { Q_ASSERT(_currentDoc); - _currentDoc->addUndefinedMacroUse(QByteArray(name.start(), name.size()), offset); + _currentDoc->addUndefinedMacroUse(QByteArray(name.start(), name.size()), + bytesOffset, utf16charsOffset); } -void FastPreprocessor::notifyMacroReference(unsigned offset, unsigned line, const Macro ¯o) +void FastPreprocessor::notifyMacroReference(unsigned bytesOffset, unsigned utf16charsOffset, + unsigned line, const Macro ¯o) { Q_ASSERT(_currentDoc); _currentDoc->addMacroUse(revision(_snapshot, macro), - offset, macro.name().length(), line, - QVector()); + bytesOffset, macro.name().size(), + utf16charsOffset, macro.nameToQString().size(), + line, QVector()); } -void FastPreprocessor::startExpandingMacro(unsigned offset, unsigned line, - const Macro ¯o, - const QVector &actuals) +void FastPreprocessor::startExpandingMacro(unsigned bytesOffset, unsigned utf16charsOffset, + unsigned line, const Macro ¯o, + const QVector &actuals) { Q_ASSERT(_currentDoc); _currentDoc->addMacroUse(revision(_snapshot, macro), - offset, macro.name().length(), line, actuals); + bytesOffset, macro.name().size(), + utf16charsOffset, macro.nameToQString().size(), + line, actuals); } -- cgit v1.2.1