Commit 33ae7645 authored by Orgad Shaneh's avatar Orgad Shaneh Committed by Orgad Shaneh
Browse files

C++: Fix completion for enum inside member functions



Take 2

Task-number: QTCREATORBUG-13757
Change-Id: I9c2558bf01121e53710db984a99d37c2c6cafaf4
Reviewed-by: default avatarNikolai Kosjar <nikolai.kosjar@theqtcompany.com>
parent 1f2b5954
......@@ -820,22 +820,38 @@ ClassOrNamespace *ClassOrNamespace::findType(const Name *name)
return lookupType_helper(name, &processed, /*searchInEnclosingScope =*/ false, this);
}
ClassOrNamespace *ClassOrNamespace::findBlock(Block *block)
ClassOrNamespace *ClassOrNamespace::findBlock_helper(Block *block,
QSet<ClassOrNamespace *> *processed,
bool searchInEnclosingScope)
{
flush();
QHash<Block *, ClassOrNamespace *>::const_iterator citBlock = _blocks.find(block);
if (citBlock != _blocks.end())
return citBlock.value();
for (citBlock = _blocks.begin(); citBlock != _blocks.end(); ++citBlock) {
if (ClassOrNamespace *foundNestedBlock = citBlock.value()->findBlock(block))
return foundNestedBlock;
for (ClassOrNamespace *binding = this; binding; binding = binding->_parent) {
if (processed->contains(binding))
break;
processed->insert(binding);
binding->flush();
auto end = binding->_blocks.end();
auto citBlock = binding->_blocks.find(block);
if (citBlock != end)
return citBlock.value();
for (citBlock = binding->_blocks.begin(); citBlock != end; ++citBlock) {
if (ClassOrNamespace *foundNestedBlock =
citBlock.value()->findBlock_helper(block, processed, false)) {
return foundNestedBlock;
}
}
if (!searchInEnclosingScope)
break;
}
return 0;
}
ClassOrNamespace *ClassOrNamespace::findBlock(Block *block)
{
QSet<ClassOrNamespace *> processed;
return findBlock_helper(block, &processed, true);
}
Symbol *ClassOrNamespace::lookupInScope(const QList<const Name *> &fullName)
{
if (!_scopeLookupCache) {
......
......@@ -124,6 +124,9 @@ private:
ClassOrNamespace *lookupType_helper(const Name *name, QSet<ClassOrNamespace *> *processed,
bool searchInEnclosingScope, ClassOrNamespace *origin);
ClassOrNamespace *findBlock_helper(Block *block, QSet<ClassOrNamespace *> *processed,
bool searchInEnclosingScope);
ClassOrNamespace *nestedType(const Name *name, ClassOrNamespace *origin);
void instantiateNestedClasses(ClassOrNamespace *enclosingTemplateClass,
......
......@@ -313,9 +313,6 @@ void CppToolsPlugin::test_completion()
QEXPECT_FAIL("enum_in_function_in_struct_in_function", "QTCREATORBUG-13757", Abort);
QEXPECT_FAIL("enum_in_function_in_struct_in_function_cxx11", "QTCREATORBUG-13757", Abort);
QEXPECT_FAIL("enum_in_function_in_struct_in_function_anon", "QTCREATORBUG-13757", Abort);
QEXPECT_FAIL("enum_inside_member_function", "QTCREATORBUG-13757", Abort);
QEXPECT_FAIL("enum_inside_member_function_cxx11", "QTCREATORBUG-13757", Abort);
QEXPECT_FAIL("enum_inside_member_function_anon", "QTCREATORBUG-13757", Abort);
QEXPECT_FAIL("enum_in_class_accessed_in_member_func_cxx11", "QTCREATORBUG-13757", Abort);
QEXPECT_FAIL("enum_in_class_accessed_in_member_func_inline_cxx11", "QTCREATORBUG-13757", Abort);
QCOMPARE(actualCompletions, expectedCompletions);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment