@@ -132,31 +132,6 @@ class CodeCompletionCallbacksImpl : public CodeCompletionCallbacks {
132
132
133
133
std::vector<std::pair<std::string, bool >> SubModuleNameVisibilityPairs;
134
134
135
- void addSuperKeyword (CodeCompletionResultSink &Sink) {
136
- auto *DC = CurDeclContext->getInnermostTypeContext ();
137
- if (!DC)
138
- return ;
139
- auto *CD = DC->getSelfClassDecl ();
140
- if (!CD)
141
- return ;
142
- Type ST = CD->getSuperclass ();
143
- if (ST.isNull () || ST->is <ErrorType>())
144
- return ;
145
-
146
- CodeCompletionResultBuilder Builder (Sink, CodeCompletionResultKind::Keyword,
147
- SemanticContextKind::CurrentNominal,
148
- {});
149
- if (auto *AFD = dyn_cast<AbstractFunctionDecl>(CurDeclContext)) {
150
- if (AFD->getOverriddenDecl () != nullptr ) {
151
- Builder.addFlair (CodeCompletionFlairBit::CommonKeywordAtCurrentPosition);
152
- }
153
- }
154
-
155
- Builder.setKeywordKind (CodeCompletionKeywordKind::kw_super);
156
- Builder.addKeyword (" super" );
157
- Builder.addTypeAnnotation (ST, PrintOptions ());
158
- }
159
-
160
135
Optional<std::pair<Type, ConcreteDeclRef>> typeCheckParsedExpr () {
161
136
assert (ParsedExpr && " should have an expression" );
162
137
@@ -879,6 +854,32 @@ static void addExprKeywords(CodeCompletionResultSink &Sink, DeclContext *DC) {
879
854
addKeyword (Sink, " await" , CodeCompletionKeywordKind::None, " " , flair);
880
855
}
881
856
857
+ static void addSuperKeyword (CodeCompletionResultSink &Sink, DeclContext *DC) {
858
+ if (!DC)
859
+ return ;
860
+ auto *TC = DC->getInnermostTypeContext ();
861
+ if (!TC)
862
+ return ;
863
+ auto *CD = TC->getSelfClassDecl ();
864
+ if (!CD)
865
+ return ;
866
+ Type ST = CD->getSuperclass ();
867
+ if (ST.isNull () || ST->is <ErrorType>())
868
+ return ;
869
+
870
+ CodeCompletionResultBuilder Builder (Sink, CodeCompletionResultKind::Keyword,
871
+ SemanticContextKind::CurrentNominal, {});
872
+ if (auto *AFD = dyn_cast<AbstractFunctionDecl>(DC)) {
873
+ if (AFD->getOverriddenDecl () != nullptr ) {
874
+ Builder.addFlair (CodeCompletionFlairBit::CommonKeywordAtCurrentPosition);
875
+ }
876
+ }
877
+
878
+ Builder.setKeywordKind (CodeCompletionKeywordKind::kw_super);
879
+ Builder.addKeyword (" super" );
880
+ Builder.addTypeAnnotation (ST, PrintOptions ());
881
+ }
882
+
882
883
static void addOpaqueTypeKeyword (CodeCompletionResultSink &Sink) {
883
884
addKeyword (Sink, " some" , CodeCompletionKeywordKind::None, " some" );
884
885
}
@@ -950,7 +951,7 @@ void CodeCompletionCallbacksImpl::addKeywords(CodeCompletionResultSink &Sink,
950
951
case CompletionKind::YieldStmtExpr:
951
952
case CompletionKind::PostfixExprBeginning:
952
953
case CompletionKind::ForEachSequence:
953
- addSuperKeyword (Sink);
954
+ addSuperKeyword (Sink, CurDeclContext );
954
955
addLetVarKeywords (Sink);
955
956
addExprKeywords (Sink, CurDeclContext);
956
957
addAnyTypeKeyword (Sink, CurDeclContext->getASTContext ().TheAnyType );
@@ -1565,7 +1566,7 @@ void CodeCompletionCallbacksImpl::doneParsing() {
1565
1566
Lookup.setHaveLParen (false );
1566
1567
1567
1568
// Add any keywords that can be used in an argument expr position.
1568
- addSuperKeyword (CompletionContext.getResultSink ());
1569
+ addSuperKeyword (CompletionContext.getResultSink (), CurDeclContext );
1569
1570
addExprKeywords (CompletionContext.getResultSink (), CurDeclContext);
1570
1571
1571
1572
DoPostfixExprBeginning ();
@@ -1711,7 +1712,7 @@ void CodeCompletionCallbacksImpl::doneParsing() {
1711
1712
ContextInfo.isImplicitSingleExpressionReturn ());
1712
1713
1713
1714
// Add any keywords that can be used in an argument expr position.
1714
- addSuperKeyword (CompletionContext.getResultSink ());
1715
+ addSuperKeyword (CompletionContext.getResultSink (), CurDeclContext );
1715
1716
addExprKeywords (CompletionContext.getResultSink (), CurDeclContext);
1716
1717
1717
1718
DoPostfixExprBeginning ();
@@ -1769,7 +1770,7 @@ void CodeCompletionCallbacksImpl::doneParsing() {
1769
1770
Context.LangOpts .EnableExperimentalConcurrency ,
1770
1771
Context.LangOpts .EnableExperimentalDistributed );
1771
1772
addStmtKeywords (Sink, CurDeclContext, MaybeFuncBody);
1772
- addSuperKeyword (Sink);
1773
+ addSuperKeyword (Sink, CurDeclContext );
1773
1774
addLetVarKeywords (Sink);
1774
1775
addExprKeywords (Sink, CurDeclContext);
1775
1776
addAnyTypeKeyword (Sink, Context.TheAnyType );
0 commit comments