forked from qt-creator/qt-creator
C++: Fix completion for enum inside member functions
Take 2 Task-number: QTCREATORBUG-13757 Change-Id: I9c2558bf01121e53710db984a99d37c2c6cafaf4 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
This commit is contained in:
committed by
Orgad Shaneh
parent
1f2b595433
commit
33ae764554
@@ -820,20 +820,36 @@ ClassOrNamespace *ClassOrNamespace::findType(const Name *name)
|
|||||||
return lookupType_helper(name, &processed, /*searchInEnclosingScope =*/ false, this);
|
return lookupType_helper(name, &processed, /*searchInEnclosingScope =*/ false, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ClassOrNamespace *ClassOrNamespace::findBlock_helper(Block *block,
|
||||||
|
QSet<ClassOrNamespace *> *processed,
|
||||||
|
bool searchInEnclosingScope)
|
||||||
|
{
|
||||||
|
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)
|
ClassOrNamespace *ClassOrNamespace::findBlock(Block *block)
|
||||||
{
|
{
|
||||||
flush();
|
QSet<ClassOrNamespace *> processed;
|
||||||
|
return findBlock_helper(block, &processed, true);
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Symbol *ClassOrNamespace::lookupInScope(const QList<const Name *> &fullName)
|
Symbol *ClassOrNamespace::lookupInScope(const QList<const Name *> &fullName)
|
||||||
|
@@ -124,6 +124,9 @@ private:
|
|||||||
ClassOrNamespace *lookupType_helper(const Name *name, QSet<ClassOrNamespace *> *processed,
|
ClassOrNamespace *lookupType_helper(const Name *name, QSet<ClassOrNamespace *> *processed,
|
||||||
bool searchInEnclosingScope, ClassOrNamespace *origin);
|
bool searchInEnclosingScope, ClassOrNamespace *origin);
|
||||||
|
|
||||||
|
ClassOrNamespace *findBlock_helper(Block *block, QSet<ClassOrNamespace *> *processed,
|
||||||
|
bool searchInEnclosingScope);
|
||||||
|
|
||||||
ClassOrNamespace *nestedType(const Name *name, ClassOrNamespace *origin);
|
ClassOrNamespace *nestedType(const Name *name, ClassOrNamespace *origin);
|
||||||
|
|
||||||
void instantiateNestedClasses(ClassOrNamespace *enclosingTemplateClass,
|
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", "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_cxx11", "QTCREATORBUG-13757", Abort);
|
||||||
QEXPECT_FAIL("enum_in_function_in_struct_in_function_anon", "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_cxx11", "QTCREATORBUG-13757", Abort);
|
||||||
QEXPECT_FAIL("enum_in_class_accessed_in_member_func_inline_cxx11", "QTCREATORBUG-13757", Abort);
|
QEXPECT_FAIL("enum_in_class_accessed_in_member_func_inline_cxx11", "QTCREATORBUG-13757", Abort);
|
||||||
QCOMPARE(actualCompletions, expectedCompletions);
|
QCOMPARE(actualCompletions, expectedCompletions);
|
||||||
|
Reference in New Issue
Block a user