1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-21 07:55:24 +02:00

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
This commit is contained in:
Nathan Ridge 2016-06-25 03:17:55 -04:00 committed by Gerrit Code Review @ Eclipse.org
parent 492fc0a164
commit 7a4d4fdb95
2 changed files with 10 additions and 12 deletions

View file

@ -508,15 +508,6 @@ public class SemanticHighlightingTest extends TestCase {
makeAssertions(); 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 // #define WALDO(name) const char* Name() override { return name; } //$macroDefinition
// class S { //$class // class S { //$class
// WALDO("name") //$macroSubstitution // WALDO("name") //$macroSubstitution

View file

@ -67,8 +67,10 @@ public class SemanticHighlightingReconciler implements ICReconcilingListener {
private class PositionCollector extends ASTVisitor { private class PositionCollector extends ASTVisitor {
/** The semantic token */ /** The semantic token */
private SemanticToken fToken= new SemanticToken(); private SemanticToken fToken= new SemanticToken();
private int fMinLocation;
public PositionCollector(boolean visitImplicitNames) { public PositionCollector(boolean visitImplicitNames) {
fMinLocation= -1;
shouldVisitTranslationUnit= true; shouldVisitTranslationUnit= true;
shouldVisitNames= true; shouldVisitNames= true;
shouldVisitDeclarations= true; shouldVisitDeclarations= true;
@ -90,6 +92,7 @@ public class SemanticHighlightingReconciler implements ICReconcilingListener {
visitNode(macroDef.getName()); visitNode(macroDef.getName());
} }
} }
fMinLocation= -1;
// Visit macro expansions. // Visit macro expansions.
IASTPreprocessorMacroExpansion[] macroExps= tu.getMacroExpansions(); IASTPreprocessorMacroExpansion[] macroExps= tu.getMacroExpansions();
@ -103,6 +106,7 @@ public class SemanticHighlightingReconciler implements ICReconcilingListener {
} }
} }
} }
fMinLocation= -1;
// Visit ordinary code. // Visit ordinary code.
return super.visit(tu); return super.visit(tu);
@ -230,11 +234,14 @@ public class SemanticHighlightingReconciler implements ICReconcilingListener {
*/ */
private void highlightLocation(IASTNodeLocation nodeLocation, HighlightingStyle highlightingStyle) { private void highlightLocation(IASTNodeLocation nodeLocation, HighlightingStyle highlightingStyle) {
int offset= nodeLocation.getNodeOffset(); int offset= nodeLocation.getNodeOffset();
if (offset >= fMinLocation) {
int length= nodeLocation.getNodeLength(); int length= nodeLocation.getNodeLength();
if (offset > -1 && length > 0) { if (offset > -1 && length > 0) {
fMinLocation= offset + length;
addPosition(offset, length, highlightingStyle); addPosition(offset, length, highlightingStyle);
} }
} }
}
/** /**
* Adds a position with the given range and highlighting iff it does not exist already. * Adds a position with the given range and highlighting iff it does not exist already.