From a201468432b1c358e234df067f305f73d926d569 Mon Sep 17 00:00:00 2001 From: Nathan Ridge Date: Thu, 28 Jan 2016 22:48:50 -0500 Subject: [PATCH] Bug 486682 - Syntax coloring of macro arguments that occur in reverse order in the AST Change-Id: Ib038a39ada52d44356c4207bef72a681dd3aa790 --- .../tests/text/SemanticHighlightingTest.java | 9 ++++++++ .../SemanticHighlightingReconciler.java | 22 +++++-------------- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/SemanticHighlightingTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/SemanticHighlightingTest.java index c9e24f07377..a505d91f0af 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/SemanticHighlightingTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/SemanticHighlightingTest.java @@ -507,4 +507,13 @@ public class SemanticHighlightingTest extends TestCase { public void testDependentEnum_486688() throws Exception { makeAssertions(); } + + // #define MACRO(Name, Type) Type Name(); //$macroDefinition + // typedef int Int; //$typedef + // class S { //$class + // MACRO(foo, Int) //$macroSubstitution,methodDeclaration,typedef + // }; + public void testMethodNameInsideMacro_486682() throws Exception { + makeAssertions(); + } } 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 ce927ccb000..8f943861a8d 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 @@ -66,10 +66,8 @@ public class SemanticHighlightingReconciler implements ICReconcilingListener { private class PositionCollector extends ASTVisitor { /** The semantic token */ private SemanticToken fToken= new SemanticToken(); - private int fMinLocation; public PositionCollector(boolean visitImplicitNames) { - fMinLocation= -1; shouldVisitTranslationUnit= true; shouldVisitNames= true; shouldVisitDeclarations= true; @@ -91,7 +89,6 @@ public class SemanticHighlightingReconciler implements ICReconcilingListener { visitNode(macroDef.getName()); } } - fMinLocation= -1; // Visit macro expansions. IASTPreprocessorMacroExpansion[] macroExps= tu.getMacroExpansions(); @@ -105,7 +102,6 @@ public class SemanticHighlightingReconciler implements ICReconcilingListener { } } } - fMinLocation= -1; // Visit ordinary code. return super.visit(tu); @@ -207,12 +203,9 @@ public class SemanticHighlightingReconciler implements ICReconcilingListener { if (imageLocation != null) { if (imageLocation.getLocationKind() != IASTImageLocation.MACRO_DEFINITION) { int offset= imageLocation.getNodeOffset(); - if (offset >= fMinLocation) { - int length= imageLocation.getNodeLength(); - if (offset >= 0 && length > 0) { - fMinLocation= offset + length; - addPosition(offset, length, highlightingStyle); - } + int length= imageLocation.getNodeLength(); + if (offset >= 0 && length > 0) { + addPosition(offset, length, highlightingStyle); } } } else { @@ -235,12 +228,9 @@ public class SemanticHighlightingReconciler implements ICReconcilingListener { return; } int offset= nodeLocation.getNodeOffset(); - if (offset >= fMinLocation) { - int length= nodeLocation.getNodeLength(); - if (offset > -1 && length > 0) { - fMinLocation= offset + length; - addPosition(offset, length, highlightingStyle); - } + int length= nodeLocation.getNodeLength(); + if (offset > -1 && length > 0) { + addPosition(offset, length, highlightingStyle); } }