Skip to content

Commit f223050

Browse files
committed
[CodeCompletion] Compute semantic context based on where the called fucntion is defined
1 parent c6ef596 commit f223050

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

lib/IDE/ArgumentCompletion.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,15 @@ void ArgumentTypeCheckCompletionCallback::deliverResults(
231231
SemanticContext = SemanticContextKind::CurrentNominal;
232232
}
233233
}
234+
if (SemanticContext == SemanticContextKind::None && Result.FuncD) {
235+
if (Result.FuncD->getDeclContext()->isTypeContext()) {
236+
SemanticContext = SemanticContextKind::CurrentNominal;
237+
} else if (Result.FuncD->getDeclContext()->isLocalContext()) {
238+
SemanticContext = SemanticContextKind::Local;
239+
} else if (Result.FuncD->getModuleContext() == DC->getParentModule()) {
240+
SemanticContext = SemanticContextKind::CurrentModule;
241+
}
242+
}
234243
if (Result.IsSubscript) {
235244
assert(SemanticContext != SemanticContextKind::None);
236245
auto *SD = dyn_cast_or_null<SubscriptDecl>(Result.FuncD);

0 commit comments

Comments
 (0)