File tree Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -1079,6 +1079,9 @@ class ResultBuilderTransform
1079
1079
// to rank code completion items that match the type expected by
1080
1080
// buildBlock higher.
1081
1081
buildBlockArguments.push_back (expr);
1082
+ } else if (ctx.CompletionCallback && expr->getSourceRange ().isValid () && !ctx.SourceMgr .rangeContainsIDEInspectionTarget (expr->getSourceRange ())) {
1083
+ auto *resultVar = buildPlaceholderVar (expr->getStartLoc (), newBody);
1084
+ buildBlockArguments.push_back (builder.buildVarRef (resultVar, expr->getStartLoc ()));
1082
1085
} else {
1083
1086
auto *capture = captureExpr (expr, newBody);
1084
1087
// A reference to the synthesized variable is passed as an argument
Original file line number Diff line number Diff line change @@ -1030,6 +1030,19 @@ class SyntacticElementConstraintGenerator
1030
1030
1031
1031
SmallVector<ElementInfo, 4 > elements;
1032
1032
for (auto element : braceStmt->getElements ()) {
1033
+ if (cs.isForCodeCompletion () && !cs.containsIDEInspectionTarget (element)) {
1034
+ // Statements and expressions can't influence the expresion that
1035
+ // contains the code completion token. To improve performance, skip
1036
+ // type checking them entirely.
1037
+ if (element.is <Expr *>()) {
1038
+ continue ;
1039
+ } else if (element.is <Stmt *>() && !element.isStmt (StmtKind::Guard)) {
1040
+ // Guard statements might define variables that are used in the code
1041
+ // completion expression. Don't skip them.
1042
+ continue ;
1043
+ }
1044
+ }
1045
+
1033
1046
if (auto *decl = element.dyn_cast <Decl *>()) {
1034
1047
if (auto *PDB = dyn_cast<PatternBindingDecl>(decl)) {
1035
1048
visitPatternBinding (PDB, elements);
You can’t perform that action at this time.
0 commit comments