From 7a4d4fdb95b1a85f4edad65c56ac23de2de93b1e Mon Sep 17 00:00:00 2001 From: Nathan Ridge Date: Sat, 25 Jun 2016 03:17:55 -0400 Subject: [PATCH] Revert "Bug 486682 - Syntax coloring of macro arguments that occur in reverse order in the AST" This commit caused a regression in syntax coloring, as reported in bugs 490415 and 496696. Change-Id: Ibfa7004b11677be56eb5a18d8236af2300de56cb --- .../cdt/ui/tests/text/SemanticHighlightingTest.java | 9 --------- .../ui/editor/SemanticHighlightingReconciler.java | 13 ++++++++++--- 2 files changed, 10 insertions(+), 12 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 72fb6793747..abfa1ff2f0e 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 @@ -508,15 +508,6 @@ public class SemanticHighlightingTest extends TestCase { 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(); - } - // #define WALDO(name) const char* Name() override { return name; } //$macroDefinition // class S { //$class // WALDO("name") //$macroSubstitution 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 5dd9ff4a3a5..5d006d5caa5 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 @@ -67,8 +67,10 @@ 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; @@ -90,6 +92,7 @@ public class SemanticHighlightingReconciler implements ICReconcilingListener { visitNode(macroDef.getName()); } } + fMinLocation= -1; // Visit macro expansions. IASTPreprocessorMacroExpansion[] macroExps= tu.getMacroExpansions(); @@ -103,6 +106,7 @@ public class SemanticHighlightingReconciler implements ICReconcilingListener { } } } + fMinLocation= -1; // Visit ordinary code. return super.visit(tu); @@ -230,9 +234,12 @@ public class SemanticHighlightingReconciler implements ICReconcilingListener { */ private void highlightLocation(IASTNodeLocation nodeLocation, HighlightingStyle highlightingStyle) { int offset= nodeLocation.getNodeOffset(); - int length= nodeLocation.getNodeLength(); - if (offset > -1 && length > 0) { - addPosition(offset, length, highlightingStyle); + if (offset >= fMinLocation) { + int length= nodeLocation.getNodeLength(); + if (offset > -1 && length > 0) { + fMinLocation= offset + length; + addPosition(offset, length, highlightingStyle); + } } }