Skip to content

Commit 7e64abb

Browse files
committed
[CodeCompletion] Skip conjuction elements that are unrelated to the code completion token
1 parent 6999e35 commit 7e64abb

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

lib/Sema/CSSyntacticElement.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1030,6 +1030,19 @@ class SyntacticElementConstraintGenerator
10301030

10311031
SmallVector<ElementInfo, 4> elements;
10321032
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+
10331046
if (auto *decl = element.dyn_cast<Decl *>()) {
10341047
if (auto *PDB = dyn_cast<PatternBindingDecl>(decl)) {
10351048
visitPatternBinding(PDB, elements);

0 commit comments

Comments
 (0)