1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-17 22:15:23 +02:00

Bug 510788 - Syntax coloring for template arguments in function template specialization

Previously, the arguments shared the color of the template-name.
Now, the arguments get their own colors.

Change-Id: I27af4146717a19095f1ac22188eedb8a71d9466c
This commit is contained in:
Nathan Ridge 2017-01-21 16:10:01 -05:00
parent aeb39d6352
commit 01ead0227a
2 changed files with 32 additions and 1 deletions

View file

@ -634,4 +634,13 @@ public class SemanticHighlightingTest extends TestCase {
public void testReferenceToConstPointer_509619() throws Exception {
makeAssertions();
}
// struct S {}; //$class
// template <typename>
// void waldo() {} //$functionDeclaration
// template <>
// void waldo<S>() {} //$functionDeclaration,class
public void testArgumentsOfFunctionTemplateSpecialization_510788() throws Exception {
makeAssertions();
}
}

View file

@ -606,6 +606,20 @@ public class SemanticHighlightings {
return CEditorMessages.SemanticHighlighting_functionDeclaration;
}
private boolean isDeclaration(IASTName name) {
if (name.isDeclaration()) {
return true;
}
// The template-name in a template-id is never a declaration, it's a reference
// to the template. However, if the template-id itself is a declaration, we want
// to color the template-name part of it as a declaration.
if (name.getParent() instanceof ICPPASTTemplateId &&
name.getPropertyInParent() == ICPPASTTemplateId.TEMPLATE_NAME) {
return ((IASTName) name.getParent()).isDeclaration();
}
return false;
}
@Override
public boolean consumes(ISemanticToken token) {
IASTNode node= token.getNode();
@ -613,8 +627,12 @@ public class SemanticHighlightings {
return false;
if (node instanceof IASTName) {
// Do not color an entire template-id; color its constituent parts separately.
if (node instanceof ICPPASTTemplateId) {
return false;
}
IASTName name= (IASTName) node;
if (name.isDeclaration()) {
if (isDeclaration(name)) {
IBinding binding= token.getBinding();
if (binding instanceof IFunction && !(binding instanceof ICPPMethod)) {
return true;
@ -687,6 +705,10 @@ public class SemanticHighlightings {
if (name instanceof ICPPASTQualifiedName && name.isReference()) {
return false;
}
// Do not color an entire template-id; color its constituent parts separately.
if (name instanceof ICPPASTTemplateId) {
return false;
}
IBinding binding= token.getBinding();
if (binding instanceof IFunction && !(binding instanceof ICPPMethod)) {
return true;