mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Bug 330762: Content assist for deferred base classes.
This commit is contained in:
parent
40a4382b3e
commit
6cab1923dc
3 changed files with 24 additions and 1 deletions
|
@ -26,6 +26,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
|
||||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ClassTypeHelper;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPDeferredClassInstance;
|
||||
|
||||
/**
|
||||
* The context that determines access to private and protected class members.
|
||||
|
@ -128,6 +129,10 @@ public class AccessContext {
|
|||
if (bases != null) {
|
||||
for (ICPPBase base : bases) {
|
||||
IBinding baseBinding = base.getBaseClass();
|
||||
if (baseBinding instanceof ICPPDeferredClassInstance) {
|
||||
// Support content assist for members of deferred instances.
|
||||
baseBinding= ((ICPPDeferredClassInstance) baseBinding).getTemplateDefinition();
|
||||
}
|
||||
if (!(baseBinding instanceof ICPPClassType)) {
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@ import org.eclipse.cdt.core.index.IIndexFileSet;
|
|||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||
import org.eclipse.cdt.core.parser.util.CharArrayObjectMap;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPDeferredClassInstance;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalUnknownScope;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding;
|
||||
|
||||
|
@ -203,7 +204,11 @@ class BaseClassLookup {
|
|||
continue;
|
||||
}
|
||||
|
||||
final ICPPClassType grandBaseClass = (ICPPClassType) grandBaseBinding;
|
||||
ICPPClassType grandBaseClass = (ICPPClassType) grandBaseBinding;
|
||||
if (data.contentAssist && grandBaseClass instanceof ICPPDeferredClassInstance) {
|
||||
// Support content assist for members of deferred instances.
|
||||
grandBaseClass= ((ICPPDeferredClassInstance) grandBaseClass).getClassTemplate();
|
||||
}
|
||||
if (grandBaseBindings != null && !grandBaseBindings.add(grandBaseClass))
|
||||
continue;
|
||||
|
||||
|
|
|
@ -1340,4 +1340,17 @@ public class CompletionTests extends AbstractContentAssistTest {
|
|||
final String[] expected= { "Reference" };
|
||||
assertCompletionResults(fCursorOffset, expected, COMPARE_ID_STRINGS);
|
||||
}
|
||||
|
||||
// template<class T> struct BaseClass {
|
||||
// void BaseMethod();
|
||||
// };
|
||||
// template<class T> struct DerivedClass : BaseClass<T> {
|
||||
// void DerivedMethod() {
|
||||
// this->BaseM/*cursor*/
|
||||
// }
|
||||
// };
|
||||
public void testDeferredBaseClass_Bug330762() throws Exception {
|
||||
final String[] expected= { "BaseMethod(void)" };
|
||||
assertCompletionResults(fCursorOffset, expected, COMPARE_ID_STRINGS);
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue