-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[CodeCompletion] Add flairs to cached items #37834
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[CodeCompletion] Add flairs to cached items #37834
Conversation
lib/IDE/CodeCompletion.cpp
Outdated
switch (result->getKeywordKind()) { | ||
#define POUND_DIRECTIVE_KEYWORD(kw) | ||
#define POUND_CONFIG(kw) | ||
#define POUND_KEYWORD(kw) case CodeCompletionKeywordKind::pound_##kw: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about other expression-context things like try
, await
, true
, false
or statement-context like for
, while
, etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved the logic to addExprKeywords()
, addValueLiteralCompletions()
, etc.
'ExpressionAtNonScriptOrMainFileScope' is not exactly a correct word, but I applied it to statement keyword too.
lib/IDE/CodeCompletion.cpp
Outdated
// Use the current SourceFile as the DeclContext so that we can use it to | ||
// perform qualified lookup, and to get the correct visibility for | ||
// @testable imports. | ||
DeclContext *DCForModules = DC->getParentSourceFile(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment should clarify we cannot use DC since it would apply DC-specific changes to cached results.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, we used to do that in lookupCodeCompletionResultsFromModule()
too. So I made lookupCodeCompletionResultsFromModule
only accept SourceFile
.
* Starting a statement with a protocol name is rare * Starting a statemnet at top-level of non-script file is invalid rdar://77934897
fac9596
to
4617bbb
Compare
…cept SourceFile as the decl context.
3d555f3
to
5d5b93d
Compare
@swift-ci Please smoke test |
…d results Instead, allocate new `CodeCompletionResult` in the current sink.
@swift-ci Please smoke test |
Based on #37725
Introduced
postProcessResults()
to add flairs to cached items.rdar://77934897