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 <erik.verbruggen@digia.com>
This commit is contained in:
Nikolai Kosjar
2014-05-09 10:04:13 -04:00
parent bb7da966b8
commit c6358e5d38
24 changed files with 345 additions and 215 deletions

View File

@@ -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 &macro)
void FastPreprocessor::passedMacroDefinitionCheck(unsigned bytesOffset, unsigned utf16charsOffset,
unsigned line, const Macro &macro)
{
Q_ASSERT(_currentDoc);
_currentDoc->addMacroUse(revision(_snapshot, macro),
offset, macro.name().length(), line,
QVector<MacroArgumentReference>());
bytesOffset, macro.name().size(),
utf16charsOffset, macro.nameToQString().size(),
line, QVector<MacroArgumentReference>());
}
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 &macro)
void FastPreprocessor::notifyMacroReference(unsigned bytesOffset, unsigned utf16charsOffset,
unsigned line, const Macro &macro)
{
Q_ASSERT(_currentDoc);
_currentDoc->addMacroUse(revision(_snapshot, macro),
offset, macro.name().length(), line,
QVector<MacroArgumentReference>());
bytesOffset, macro.name().size(),
utf16charsOffset, macro.nameToQString().size(),
line, QVector<MacroArgumentReference>());
}
void FastPreprocessor::startExpandingMacro(unsigned offset, unsigned line,
const Macro &macro,
const QVector<MacroArgumentReference> &actuals)
void FastPreprocessor::startExpandingMacro(unsigned bytesOffset, unsigned utf16charsOffset,
unsigned line, const Macro &macro,
const QVector<MacroArgumentReference> &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);
}