[Completion] Addd constructors from the completion cache back

31dee1ce1c refactored the completion
filter, accidentally dropping initializers when found from the cache.
Add these back in and also modify the existing test to load from the
cache as well.

Resolves rdar://107807707.
This commit is contained in:
Ben Barham
2023-04-09 09:34:51 -07:00
parent 5e90d32cb0
commit 39c0afcff1
2 changed files with 74 additions and 69 deletions

View File

@@ -37,10 +37,19 @@ static MutableArrayRef<CodeCompletionResult *> copyCodeCompletionResults(
return false;
switch (R->getAssociatedDeclKind()) {
case CodeCompletionDeclKind::EnumElement:
case CodeCompletionDeclKind::Constructor:
case CodeCompletionDeclKind::Destructor:
case CodeCompletionDeclKind::Subscript:
case CodeCompletionDeclKind::StaticMethod:
case CodeCompletionDeclKind::InstanceMethod:
case CodeCompletionDeclKind::PrefixOperatorFunction:
case CodeCompletionDeclKind::PostfixOperatorFunction:
case CodeCompletionDeclKind::InfixOperatorFunction:
case CodeCompletionDeclKind::FreeFunction:
case CodeCompletionDeclKind::StaticVar:
case CodeCompletionDeclKind::InstanceVar:
case CodeCompletionDeclKind::LocalVar:
case CodeCompletionDeclKind::GlobalVar:
return filter.contains(CodeCompletionFilterFlag::Expr);
@@ -60,20 +69,9 @@ static MutableArrayRef<CodeCompletionResult *> copyCodeCompletionResults(
case CodeCompletionDeclKind::Macro:
return (bool)(R->getMacroRoles() & expectedMacroRoles);
case CodeCompletionDeclKind::EnumElement:
case CodeCompletionDeclKind::Constructor:
case CodeCompletionDeclKind::Destructor:
case CodeCompletionDeclKind::Subscript:
case CodeCompletionDeclKind::StaticMethod:
case CodeCompletionDeclKind::InstanceMethod:
case CodeCompletionDeclKind::StaticVar:
case CodeCompletionDeclKind::InstanceVar:
case CodeCompletionDeclKind::LocalVar:
break;
}
return false;
llvm_unreachable("Unhandled associated decl kind");
};
USRBasedTypeContext USRTypeContext(TypeContext, source.USRTypeArena);