mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-01 06:05:24 +02:00
Bug 484898 - Highlighting of inherited constructor name
Change-Id: I314dcf08b0d882a60aa02f248131d02281f8ff16
This commit is contained in:
parent
36f16ba1b9
commit
eb54f64445
2 changed files with 47 additions and 2 deletions
|
@ -472,7 +472,15 @@ public class SemanticHighlightingTest extends TestCase {
|
||||||
// }
|
// }
|
||||||
// N::C::E1 e1; //$namespace,class,enum,globalVariable
|
// N::C::E1 e1; //$namespace,class,enum,globalVariable
|
||||||
// N::E2 e2; //$namespace,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();
|
makeAssertions();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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.ICPPAliasTemplateInstance;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBlockScope;
|
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.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.ICPPDeferredFunction;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionScope;
|
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.ICPPNamespace;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateNonTypeParameter;
|
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.ICPPTemplateParameter;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPUsingDeclaration;
|
||||||
import org.eclipse.cdt.core.index.IIndex;
|
import org.eclipse.cdt.core.index.IIndex;
|
||||||
import org.eclipse.cdt.core.index.IIndexBinding;
|
import org.eclipse.cdt.core.index.IIndexBinding;
|
||||||
import org.eclipse.cdt.core.index.IIndexFile;
|
import org.eclipse.cdt.core.index.IIndexFile;
|
||||||
|
@ -481,7 +483,8 @@ public class SemanticHighlightings {
|
||||||
return false;
|
return false;
|
||||||
if (node instanceof IASTName) {
|
if (node instanceof IASTName) {
|
||||||
IASTName name= (IASTName) node;
|
IASTName name= (IASTName) node;
|
||||||
if (name instanceof ICPPASTQualifiedName && name.isReference()) {
|
boolean qualified = name instanceof ICPPASTQualifiedName;
|
||||||
|
if (qualified && name.isReference()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
IBinding binding= token.getBinding();
|
IBinding binding= token.getBinding();
|
||||||
|
@ -496,10 +499,44 @@ public class SemanticHighlightings {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else if (!qualified && isInheritingConstructorDeclaration(binding)) {
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Reference in a new issue