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 a54d8d3ae1d..8a52ba58184 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 @@ -472,7 +472,15 @@ public class SemanticHighlightingTest extends TestCase { // } // N::C::E1 e1; //$namespace,class,enum,globalVariable // N::E2 e2; //$namespace,enum,globalVariable - public void testQualifiedEnum_XXXXXX() throws Exception { + public void testQualifiedEnum_485709() throws Exception { + makeAssertions(); + } + + // class Base {}; //$class + // class Derived : Base { //$class,class + // using Base::Base; //$class,method + // }; + public void testInheritingConstructor_484898() 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 09797cce369..8a2c6869bcb 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 @@ -55,6 +55,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPAliasTemplate; import org.eclipse.cdt.core.dom.ast.cpp.ICPPAliasTemplateInstance; import org.eclipse.cdt.core.dom.ast.cpp.ICPPBlockScope; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor; import org.eclipse.cdt.core.dom.ast.cpp.ICPPDeferredFunction; import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction; import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionScope; @@ -62,6 +63,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod; import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateNonTypeParameter; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPUsingDeclaration; import org.eclipse.cdt.core.index.IIndex; import org.eclipse.cdt.core.index.IIndexBinding; import org.eclipse.cdt.core.index.IIndexFile; @@ -481,7 +483,8 @@ public class SemanticHighlightings { return false; if (node instanceof IASTName) { IASTName name= (IASTName) node; - if (name instanceof ICPPASTQualifiedName && name.isReference()) { + boolean qualified = name instanceof ICPPASTQualifiedName; + if (qualified && name.isReference()) { return false; } IBinding binding= token.getBinding(); @@ -496,10 +499,44 @@ public class SemanticHighlightings { } } } + } else if (!qualified && isInheritingConstructorDeclaration(binding)) { + return true; } } return false; } + + private boolean isInheritingConstructorDeclaration(IBinding binding) { + if (!(binding instanceof ICPPUsingDeclaration)) { + return false; + } + IBinding[] delegates = ((ICPPUsingDeclaration) binding).getDelegates(); + // The delegates of an inheriting constructor declaration + // include the class type and the constructors. + ICPPClassType classType = null; + boolean foundConstructors = false; + for (IBinding delegate : delegates) { + if (delegate instanceof ICPPClassType) { + if (classType != null) { + // Multiple classes among delegates. + return false; + } + classType = (ICPPClassType) delegate; + } else if (delegate instanceof ICPPConstructor) { + foundConstructors = true; + if (classType != null) { + if (!delegate.getOwner().equals(classType)) { + // Constructor does not belong to class. + return false; + } + } + } else { + // Delegate other than class or constructor. + return false; + } + } + return foundConstructors; + } } /**