Skip to content

Commit 4924322

Browse files
committed
[CodeCompletion] Reject all UserInaccessible decl attributes
Generalize a fix that removes __consuming from Code Completion to all inaccessible decl attributes.
1 parent 02bad38 commit 4924322

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

lib/IDE/CodeCompletion.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4849,15 +4849,15 @@ static bool isClangSubModule(ModuleDecl *TheModule) {
48494849
}
48504850

48514851
static void addDeclKeywords(CodeCompletionResultSink &Sink) {
4852-
auto AddKeyword = [&](StringRef Name, CodeCompletionKeywordKind Kind) {
4852+
auto AddKeyword = [&](StringRef Name, CodeCompletionKeywordKind Kind,
4853+
Optional<DeclAttrKind> DAK) {
48534854
if (Name == "let" || Name == "var") {
48544855
// Treat keywords that could be the start of a pattern specially.
48554856
return;
48564857
}
4857-
// FIXME: __consuming should not appear in CodeCompletion until it is
4858-
// finalized in a language proposal.
4859-
if (Name == "__consuming")
4860-
return;
4858+
4859+
// Remove user inaccessible keywords.
4860+
if (DAK.hasValue() && DeclAttribute::isUserInaccessible(*DAK)) return;
48614861

48624862
CodeCompletionResultBuilder Builder(
48634863
Sink, CodeCompletionResult::ResultKind::Keyword,
@@ -4866,18 +4866,18 @@ static void addDeclKeywords(CodeCompletionResultSink &Sink) {
48664866
Builder.addTextChunk(Name);
48674867
};
48684868

4869-
#define DECL_KEYWORD(kw) AddKeyword(#kw, CodeCompletionKeywordKind::kw_##kw);
4869+
#define DECL_KEYWORD(kw) AddKeyword(#kw, CodeCompletionKeywordKind::kw_##kw, None);
48704870
#include "swift/Syntax/TokenKinds.def"
48714871

48724872
// Context-sensitive keywords.
4873-
auto AddCSKeyword = [&](StringRef Name) {
4874-
AddKeyword(Name, CodeCompletionKeywordKind::None);
4873+
auto AddCSKeyword = [&](StringRef Name, DeclAttrKind Kind) {
4874+
AddKeyword(Name, CodeCompletionKeywordKind::None, Kind);
48754875
};
48764876

4877-
#define CONTEXTUAL_CASE(KW) AddCSKeyword(#KW);
4878-
#define CONTEXTUAL_DECL_ATTR(KW, ...) CONTEXTUAL_CASE(KW)
4879-
#define CONTEXTUAL_DECL_ATTR_ALIAS(KW, ...) CONTEXTUAL_CASE(KW)
4880-
#define CONTEXTUAL_SIMPLE_DECL_ATTR(KW, ...) CONTEXTUAL_CASE(KW)
4877+
#define CONTEXTUAL_CASE(KW, CLASS) AddCSKeyword(#KW, DAK_##CLASS);
4878+
#define CONTEXTUAL_DECL_ATTR(KW, CLASS, ...) CONTEXTUAL_CASE(KW, CLASS)
4879+
#define CONTEXTUAL_DECL_ATTR_ALIAS(KW, CLASS) CONTEXTUAL_CASE(KW, CLASS)
4880+
#define CONTEXTUAL_SIMPLE_DECL_ATTR(KW, CLASS, ...) CONTEXTUAL_CASE(KW, CLASS)
48814881
#include <swift/AST/Attr.def>
48824882
#undef CONTEXTUAL_CASE
48834883

0 commit comments

Comments
 (0)