mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[CodeComplete] Avoid let/var completions in a few cases
Don't suggest `let` or `var` in e.g the sequence expression of a `for` loop, or after a `return`. We ought to do a better job of checking whether we're in expression position before suggesting these (as opposed to a pattern), but I'm leaving that as future work for now.
This commit is contained in:
@@ -1016,13 +1016,19 @@ void CodeCompletionCallbacksImpl::addKeywords(CodeCompletionResultSink &Sink,
|
||||
addStmtKeywords(Sink, CurDeclContext, MaybeFuncBody);
|
||||
addClosureSignatureKeywordsIfApplicable(Sink, CurDeclContext);
|
||||
|
||||
LLVM_FALLTHROUGH;
|
||||
case CompletionKind::PostfixExprBeginning:
|
||||
// We need to add 'let' and 'var' keywords in expression position here as
|
||||
// we initially parse patterns as expressions.
|
||||
// FIXME: We ought to be able to determine if we're in a pattern context and
|
||||
// only enable 'let' and 'var' in that case.
|
||||
addLetVarKeywords(Sink);
|
||||
|
||||
LLVM_FALLTHROUGH;
|
||||
case CompletionKind::ReturnStmtExpr:
|
||||
case CompletionKind::YieldStmtExpr:
|
||||
case CompletionKind::PostfixExprBeginning:
|
||||
case CompletionKind::ForEachSequence:
|
||||
addSuperKeyword(Sink, CurDeclContext);
|
||||
addLetVarKeywords(Sink);
|
||||
addExprKeywords(Sink, CurDeclContext);
|
||||
addAnyTypeKeyword(Sink, CurDeclContext->getASTContext().TheAnyType);
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user