From c78d2fe82398f8dd5571d943a8732edddfd9f9a4 Mon Sep 17 00:00:00 2001 From: Nathan Ridge Date: Sun, 23 Nov 2014 03:15:13 -0500 Subject: [PATCH] Bug 451772 - Syntax-color names of structures in C files Change-Id: I193648ffd15f581af75f71d62261068543a5769d Signed-off-by: Nathan Ridge Reviewed-on: https://git.eclipse.org/r/36887 Reviewed-by: Sergey Prigogin Tested-by: Sergey Prigogin --- .../eclipse/cdt/ui/tests/text/SemanticHighlightingTest.java | 6 ++++++ .../cdt/internal/ui/editor/SemanticHighlightings.java | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) 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 751032afffc..482d09ebb11 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 @@ -420,4 +420,10 @@ public class SemanticHighlightingTest extends TestCase { public void testDependentMethodCall_379626() throws Exception { makeAssertions(); } + + // struct S {}; //$class + // struct S waldo; //$class,globalVariable + public void testCStructureName_451772() throws Exception { + makeAssertions(false /* parse as C file */); + } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticHighlightings.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticHighlightings.java index c7cdc84d96b..f99ca12ef61 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticHighlightings.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticHighlightings.java @@ -30,6 +30,7 @@ import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IASTProblem; import org.eclipse.cdt.core.dom.ast.IBinding; +import org.eclipse.cdt.core.dom.ast.ICompositeType; import org.eclipse.cdt.core.dom.ast.IEnumeration; import org.eclipse.cdt.core.dom.ast.IEnumerator; import org.eclipse.cdt.core.dom.ast.IField; @@ -946,7 +947,7 @@ public class SemanticHighlightings { } if (node instanceof IASTName) { IBinding binding= token.getBinding(); - if (binding instanceof ICPPClassType && !(binding instanceof ICPPTemplateParameter)) { + if (binding instanceof ICompositeType && !(binding instanceof ICPPTemplateParameter)) { return true; } }