From 83c9961a1816b9569ceefe86bd2af64000022763 Mon Sep 17 00:00:00 2001 From: Anton Leherbauer Date: Tue, 27 Mar 2007 09:06:30 +0000 Subject: [PATCH] Improve macro reference detection --- .../ui/editor/SemanticHighlightingReconciler.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticHighlightingReconciler.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticHighlightingReconciler.java index 7eae4908346..13aa005e55c 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticHighlightingReconciler.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticHighlightingReconciler.java @@ -193,12 +193,16 @@ public class SemanticHighlightingReconciler implements ICReconcilingListener { fMinLocation= useOffset; // TLETODO This does not work correctly for nested macro substitutions IASTPreprocessorMacroDefinition macroDef= ((IASTMacroExpansion)nodeLocations[0]).getMacroDefinition(); + final int macroLength; IASTNodeLocation defLocation= macroDef.getName().getFileLocation(); if (defLocation != null) { - IASTNode macroNode= node.getTranslationUnit().selectNodeForLocation(fFilePath, useOffset, defLocation.getNodeLength()); - if (macroNode != null && visitMacro(macroNode, defLocation.getNodeLength())) { - return true; - } + macroLength= defLocation.getNodeLength(); + } else { + macroLength= macroDef.getName().toCharArray().length; + } + IASTNode macroNode= node.getTranslationUnit().selectNodeForLocation(fFilePath, useOffset, macroLength); + if (macroNode != null && visitMacro(macroNode, macroLength)) { + return true; } } }