mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-04 23:05:47 +02:00
Bug 486682 - Syntax coloring of macro arguments that occur in reverse order in the AST
Change-Id: Ib038a39ada52d44356c4207bef72a681dd3aa790
This commit is contained in:
parent
f1e935c1ad
commit
a201468432
2 changed files with 15 additions and 16 deletions
|
@ -507,4 +507,13 @@ public class SemanticHighlightingTest extends TestCase {
|
||||||
public void testDependentEnum_486688() throws Exception {
|
public void testDependentEnum_486688() throws Exception {
|
||||||
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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,10 +66,8 @@ 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;
|
||||||
|
@ -91,7 +89,6 @@ 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();
|
||||||
|
@ -105,7 +102,6 @@ public class SemanticHighlightingReconciler implements ICReconcilingListener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fMinLocation= -1;
|
|
||||||
|
|
||||||
// Visit ordinary code.
|
// Visit ordinary code.
|
||||||
return super.visit(tu);
|
return super.visit(tu);
|
||||||
|
@ -207,12 +203,9 @@ public class SemanticHighlightingReconciler implements ICReconcilingListener {
|
||||||
if (imageLocation != null) {
|
if (imageLocation != null) {
|
||||||
if (imageLocation.getLocationKind() != IASTImageLocation.MACRO_DEFINITION) {
|
if (imageLocation.getLocationKind() != IASTImageLocation.MACRO_DEFINITION) {
|
||||||
int offset= imageLocation.getNodeOffset();
|
int offset= imageLocation.getNodeOffset();
|
||||||
if (offset >= fMinLocation) {
|
int length= imageLocation.getNodeLength();
|
||||||
int length= imageLocation.getNodeLength();
|
if (offset >= 0 && length > 0) {
|
||||||
if (offset >= 0 && length > 0) {
|
addPosition(offset, length, highlightingStyle);
|
||||||
fMinLocation= offset + length;
|
|
||||||
addPosition(offset, length, highlightingStyle);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -235,12 +228,9 @@ public class SemanticHighlightingReconciler implements ICReconcilingListener {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
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) {
|
addPosition(offset, length, highlightingStyle);
|
||||||
fMinLocation= offset + length;
|
|
||||||
addPosition(offset, length, highlightingStyle);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue