From abcedff7d76d6850969728520ae17a5c8e02ff36 Mon Sep 17 00:00:00 2001 From: Nathan Ridge Date: Mon, 13 Jun 2016 13:30:41 -0400 Subject: [PATCH] Bug 486672 - Syntax coloring of variable template instances Change-Id: I32a2fd3bc64f88e368924acafca1d1e596c90877 --- .../ui/tests/text/SemanticHighlightingTest.java | 15 +++++++++++++++ .../internal/ui/editor/SemanticHighlightings.java | 12 ++++++++++++ 2 files changed, 27 insertions(+) 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 abfa1ff2f0e..136e20a3d3c 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 @@ -554,4 +554,19 @@ public class SemanticHighlightingTest extends TestCase { public void testRecursion_491834() throws Exception { makeAssertions(); } + + // template //$templateParameter + // bool templ = true; //$globalVariable + // struct A {}; //$class + // bool x = templ; //$globalVariable,globalVariable,class + // struct S { //$class + // template //$templateParameter + // static bool templ = true; //$staticField + // void bar() { //$methodDeclaration + // bool y = templ; //$localVariableDeclaration,staticField,class + // } + // }; + public void testVariableTemplates_486672() throws Exception { + makeAssertions(); + } } 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 576079b9107..30162ba6222 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 @@ -252,6 +252,10 @@ public class SemanticHighlightings { if (name instanceof ICPPASTQualifiedName && name.isReference()) { return false; } + if (name instanceof ICPPASTTemplateId) { + // Variable template instance - do not color the entire template-id. + return false; + } IBinding binding= token.getBinding(); if (binding instanceof IField && !(binding instanceof IProblemBinding)) { return ((IField)binding).isStatic(); @@ -303,6 +307,10 @@ public class SemanticHighlightings { if (name instanceof ICPPASTQualifiedName && name.isReference()) { return false; } + if (name instanceof ICPPASTTemplateId) { + // Variable template instance - do not color the entire template-id. + return false; + } IBinding binding= token.getBinding(); if (binding instanceof IField) { if (binding instanceof ICPPUnknownBinding) { @@ -847,6 +855,10 @@ public class SemanticHighlightings { if (name instanceof ICPPASTQualifiedName) { return false; } + if (name instanceof ICPPASTTemplateId) { + // Variable template instance - do not color the entire template-id. + return false; + } IBinding binding= token.getBinding(); if (binding instanceof IVariable && !(binding instanceof IField)