mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-18 14:35: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:
parent
aeb39d6352
commit
01ead0227a
2 changed files with 32 additions and 1 deletions
|
@ -634,4 +634,13 @@ public class SemanticHighlightingTest extends TestCase {
|
||||||
public void testReferenceToConstPointer_509619() throws Exception {
|
public void testReferenceToConstPointer_509619() throws Exception {
|
||||||
makeAssertions();
|
makeAssertions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// struct S {}; //$class
|
||||||
|
// template <typename>
|
||||||
|
// void waldo() {} //$functionDeclaration
|
||||||
|
// template <>
|
||||||
|
// void waldo<S>() {} //$functionDeclaration,class
|
||||||
|
public void testArgumentsOfFunctionTemplateSpecialization_510788() throws Exception {
|
||||||
|
makeAssertions();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -606,6 +606,20 @@ public class SemanticHighlightings {
|
||||||
return CEditorMessages.SemanticHighlighting_functionDeclaration;
|
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
|
@Override
|
||||||
public boolean consumes(ISemanticToken token) {
|
public boolean consumes(ISemanticToken token) {
|
||||||
IASTNode node= token.getNode();
|
IASTNode node= token.getNode();
|
||||||
|
@ -613,8 +627,12 @@ public class SemanticHighlightings {
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (node instanceof IASTName) {
|
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;
|
IASTName name= (IASTName) node;
|
||||||
if (name.isDeclaration()) {
|
if (isDeclaration(name)) {
|
||||||
IBinding binding= token.getBinding();
|
IBinding binding= token.getBinding();
|
||||||
if (binding instanceof IFunction && !(binding instanceof ICPPMethod)) {
|
if (binding instanceof IFunction && !(binding instanceof ICPPMethod)) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -687,6 +705,10 @@ public class SemanticHighlightings {
|
||||||
if (name instanceof ICPPASTQualifiedName && name.isReference()) {
|
if (name instanceof ICPPASTQualifiedName && name.isReference()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
// Do not color an entire template-id; color its constituent parts separately.
|
||||||
|
if (name instanceof ICPPASTTemplateId) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
IBinding binding= token.getBinding();
|
IBinding binding= token.getBinding();
|
||||||
if (binding instanceof IFunction && !(binding instanceof ICPPMethod)) {
|
if (binding instanceof IFunction && !(binding instanceof ICPPMethod)) {
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Add table
Reference in a new issue