forked from qt-creator/qt-creator
C++: Fix highlighting for lines with predefined macros
This adds definitions for the macros __FILE__, __LINE__, __DATE__ and __TIME__ on demand. As a side effect, this also introduces highlighting for the uses of these macros. Task-number: QTCREATORBUG-8036 Change-Id: Ib7546c7d45d2eecbc50c7883fc684e3497154405 Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com> Reviewed-by: Eike Ziller <eike.ziller@digia.com> Reviewed-by: hjk <hjk121@nokiamail.com>
This commit is contained in:
@@ -558,6 +558,8 @@ restart_search:
|
||||
usages.clear();
|
||||
foreach (const Document::MacroUse &use, doc->macroUses()) {
|
||||
const Macro &useMacro = use.macro();
|
||||
if (useMacro.isPredefined())
|
||||
continue;
|
||||
|
||||
if (useMacro.fileName() == macro.fileName()) { // Check if this is a match, but possibly against an outdated document.
|
||||
if (source.isEmpty())
|
||||
|
||||
@@ -58,6 +58,9 @@ QFuture<TextEditor::HighlightingResult> CppHighlightingSupportInternal::highligh
|
||||
|
||||
// Get macro definitions
|
||||
foreach (const CPlusPlus::Macro& macro, doc->definedMacros()) {
|
||||
if (macro.isPredefined())
|
||||
continue; // No "real" definition location
|
||||
|
||||
int line, column;
|
||||
editor()->convertPosition(macro.offset(), &line, &column);
|
||||
++column; //Highlighting starts at (column-1) --> compensate here
|
||||
|
||||
Reference in New Issue
Block a user