1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-24 09:25:31 +02:00

bug 525288 - resolve partial template specializations in

CSourceHover/OpenDeclaration

Change-Id: I61c06fc453499ddc2b1af73a8a69d4b648d473c3
Signed-off-by: Michael Woski <woskimi@yahoo.de>
This commit is contained in:
Michael Woski 2017-09-27 22:16:18 +02:00 committed by Nathan Ridge
parent 89ebafa72e
commit a7be934ba2
2 changed files with 30 additions and 3 deletions

View file

@ -512,7 +512,7 @@ public class HeuristicResolver {
*/
public static IBinding[] resolveUnknownBinding(ICPPUnknownBinding binding) {
if (binding instanceof ICPPDeferredClassInstance) {
return new IBinding[] { ((ICPPDeferredClassInstance) binding).getClassTemplate() };
return new IBinding[] { chooseTemplateForDeferredInstance((ICPPDeferredClassInstance) binding) };
} else if (binding instanceof ICPPUnknownMember) {
Set<HeuristicLookup> lookupSet = new HashSet<>();
return lookInside(((ICPPUnknownMember) binding).getOwnerType(), false,

View file

@ -45,6 +45,7 @@ import org.eclipse.cdt.core.testplugin.CProjectHelper;
import org.eclipse.cdt.core.testplugin.FileManager;
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTNameBase;
import org.eclipse.cdt.internal.ui.search.actions.OpenDeclarationsAction;
@ -1353,15 +1354,41 @@ public class CPPSelectionTestsNoIndexer extends BaseSelectionTests {
public void testDependentAutoType_520913() throws Exception {
String code = getAboveComment();
IFile file = importFile("testBug520913a.cpp", code);
int offset = code.indexOf("auto test = ") + 2;
IASTNode target = testF3(file, offset);
assertInstance(target, IASTName.class);
assertEquals("AA", ((IASTName) target).toString());
offset = code.indexOf("auto test()") + 2;
target = testF3(file, offset);
assertInstance(target, IASTName.class);
assertEquals("AA", ((IASTName) target).toString());
}
// template<char T>
// struct A {};
//
// template<>
// struct A<0> {};
//
// void test(){
// A<0> a0;
// A<1> a1;
// }
public void testPartialSpecializationResolution_525288() throws Exception {
CPPASTNameBase.sAllowNameComputation = true;
String code = getAboveComment();
IFile file = importFile("testBug525288.cpp", code);
int offset = code.indexOf("a0") - 5;
IASTNode target = testF3(file, offset);
assertInstance(target, IASTName.class);
assertEquals("A<0>", ((IASTName) target).toString());
offset = code.indexOf("a1") - 5;
target = testF3(file, offset);
assertInstance(target, IASTName.class);
assertEquals("A", ((IASTName) target).toString());
}
}