forked from qt-creator/qt-creator
Fix C++ Macro Usages definition line in Search Results.
Add the complete line to the Search Results window,
including '#', "define", macro and macro value and
all possible white spaces between them.
Also covers the case of line continuation in macro
definitions from commit 3dec48557a
.
Task-number: QTCREATORBUG-7217
Change-Id: I8b9d0c23d31ef76244833a9b9d67469c5c4a5635
Reviewed-by: Roberto Raggi <roberto.raggi@nokia.com>
This commit is contained in:
committed by
Roberto Raggi
parent
4f0170e5c4
commit
998e4ae139
@@ -646,14 +646,13 @@ void CppFindReferences::findMacroUses(const Macro ¯o)
|
||||
{
|
||||
// ### FIXME: Encoding?
|
||||
const QByteArray &source = getSource(macro.fileName(), workingCopy).toLatin1();
|
||||
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
|
||||
int lineBegin = source.lastIndexOf('\n', macro.offset()) + 1;
|
||||
int lineEnd = source.indexOf('\n', macro.offset());
|
||||
if (lineEnd == -1)
|
||||
lineEnd = source.length();
|
||||
const QByteArray line = source.mid(lineBegin, lineEnd - lineBegin);
|
||||
search->addResult(macro.fileName(), macro.line(), line,
|
||||
macroNameOffset, macroNameLength);
|
||||
line.indexOf(macro.name()), macro.name().length());
|
||||
}
|
||||
|
||||
QFuture<Usage> result;
|
||||
|
Reference in New Issue
Block a user