forked from qt-creator/qt-creator
Fix C++ Macro Usages when Definition contains Newline.
Now truncates the displayed line at the first Newline character after the Macro name. Task-number: QTCREATORBUG-7113 Change-Id: Ifb13c01d10b97098b54ac4346a80f0dcff3a35f3 Reviewed-by: Orgad Shaneh <orgads@gmail.com> Reviewed-by: Erik Verbruggen <erik.verbruggen@nokia.com>
This commit is contained in:
committed by
Erik Verbruggen
parent
60db573660
commit
3dec48557a
@@ -646,9 +646,14 @@ void CppFindReferences::findMacroUses(const Macro ¯o)
|
|||||||
{
|
{
|
||||||
// ### FIXME: Encoding?
|
// ### FIXME: Encoding?
|
||||||
const QByteArray &source = getSource(macro.fileName(), workingCopy).toLatin1();
|
const QByteArray &source = getSource(macro.fileName(), workingCopy).toLatin1();
|
||||||
const QByteArray line = source.mid(macro.offset(), macro.length());
|
QByteArray line = source.mid(macro.offset(), macro.length());
|
||||||
|
const int macroNameOffset = line.indexOf(macro.name());
|
||||||
|
const int macroNameLength = macro.name().length();
|
||||||
|
const int possibleNewLine = line.indexOf('\n', macroNameOffset + macroNameLength);
|
||||||
|
if (possibleNewLine != -1)
|
||||||
|
line.truncate(possibleNewLine); // truncate line at first '\n' after macro name
|
||||||
search->addResult(macro.fileName(), macro.line(), line,
|
search->addResult(macro.fileName(), macro.line(), line,
|
||||||
line.indexOf(macro.name()), macro.name().length());
|
macroNameOffset, macroNameLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
QFuture<Usage> result;
|
QFuture<Usage> result;
|
||||||
|
Reference in New Issue
Block a user