mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-24 01:15:29 +02:00
Bug 484899 - Navigation to inherited constructor
Change-Id: I3ce24f3fb70e50b50757900c5ccb372abd855dfc Signed-off-by: Nathan Ridge <zeratul976@hotmail.com>
This commit is contained in:
parent
f82660f14c
commit
e667b2631c
4 changed files with 38 additions and 3 deletions
|
@ -455,8 +455,10 @@ public class CPPClassScope extends CPPScope implements ICPPClassScope {
|
|||
if (name == null)
|
||||
return false;
|
||||
|
||||
if (!isPrefixLookup)
|
||||
return CPPVisitor.isConstructorDeclaration(name);
|
||||
if (!isPrefixLookup) {
|
||||
return CPPVisitor.isConstructorDeclaration(name)
|
||||
|| CPPVisitor.isLastNameInUsingDeclaration(name);
|
||||
}
|
||||
|
||||
IASTNode node = name.getParent();
|
||||
if (node instanceof ICPPASTTemplateId)
|
||||
|
|
|
@ -1030,6 +1030,13 @@ public class CPPVisitor extends ASTQueries {
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isLastNameInUsingDeclaration(IASTName name) {
|
||||
IASTNode parent = name.getParent();
|
||||
return parent instanceof ICPPASTQualifiedName
|
||||
&& ((ICPPASTQualifiedName) parent).getLastName() == name
|
||||
&& parent.getParent() instanceof ICPPASTUsingDeclaration;
|
||||
}
|
||||
|
||||
public static IScope getContainingNonTemplateScope(final IASTNode inputNode) {
|
||||
IScope scope= getContainingScope(inputNode);
|
||||
|
|
|
@ -37,6 +37,8 @@ import org.eclipse.cdt.core.CCorePlugin;
|
|||
import org.eclipse.cdt.core.dom.IPDOMManager;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
|
||||
import org.eclipse.cdt.core.model.ICProject;
|
||||
import org.eclipse.cdt.core.testplugin.CProjectHelper;
|
||||
import org.eclipse.cdt.core.testplugin.FileManager;
|
||||
|
@ -1255,8 +1257,26 @@ public class CPPSelectionTestsNoIndexer extends BaseSelectionTests {
|
|||
public void testUserDefinedLiteralSuffix_484618() throws Exception {
|
||||
String code = getAboveComment();
|
||||
IFile file = importFile("testBug484618.cpp", code);
|
||||
|
||||
|
||||
int offset = code.indexOf("42_d") + 3;
|
||||
assertTrue(testF3(file, offset) instanceof IASTName);
|
||||
}
|
||||
|
||||
// struct Base {
|
||||
// Base(int, int);
|
||||
// };
|
||||
//
|
||||
// struct Derived : Base {
|
||||
// using Base::Base;
|
||||
// };
|
||||
public void testInheritedConstructor_484899() throws Exception {
|
||||
String code = getAboveComment();
|
||||
IFile file = importFile("testBug484899.cpp", code);
|
||||
|
||||
int offset = code.indexOf("Base::Base") + 7;
|
||||
IASTNode target = testF3(file, offset);
|
||||
assertInstance(target, IASTName.class);
|
||||
IBinding targetBinding = ((IASTName) target).resolveBinding();
|
||||
assertInstance(targetBinding, ICPPConstructor.class);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -215,6 +215,12 @@ class OpenDeclarationsJob extends Job implements ASTRunnable {
|
|||
continue;
|
||||
}
|
||||
}
|
||||
if (binding instanceof ICPPUsingDeclaration) {
|
||||
// For using-declarations, apply the logic below to each delegate
|
||||
// individually.
|
||||
bindings = ArrayUtil.addAll(bindings, ((ICPPUsingDeclaration) binding).getDelegates());
|
||||
continue;
|
||||
}
|
||||
if (binding != null && !(binding instanceof IProblemBinding)) {
|
||||
IName[] names = findDeclNames(ast, kind, binding);
|
||||
for (final IName name : names) {
|
||||
|
|
Loading…
Add table
Reference in a new issue