Skip to content

[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

Merged

Conversation

rintaro
Copy link
Member

@rintaro rintaro commented Jun 8, 2021

Based on #37725

Introduced postProcessResults() to add flairs to cached items.

  • Starting a statement with a protocol name is rare
  • Starting a statemnet at top-level of non-script file is invalid

rdar://77934897

@rintaro rintaro requested a review from benlangmuir June 8, 2021 20:35
switch (result->getKeywordKind()) {
#define POUND_DIRECTIVE_KEYWORD(kw)
#define POUND_CONFIG(kw)
#define POUND_KEYWORD(kw) case CodeCompletionKeywordKind::pound_##kw:
Copy link
Contributor

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.

Copy link
Member Author

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.

// 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();
Copy link
Contributor

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.

Copy link
Member Author

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.

rintaro added 2 commits June 8, 2021 14:09
* Starting a statement with a protocol name is rare
* Starting a statemnet at top-level of non-script file is invalid

rdar://77934897
@rintaro rintaro force-pushed the ide-completion-protocol-at-expr-rdar77934897 branch from fac9596 to 4617bbb Compare June 8, 2021 22:56
@rintaro rintaro force-pushed the ide-completion-protocol-at-expr-rdar77934897 branch from 3d555f3 to 5d5b93d Compare June 8, 2021 23:06
@rintaro
Copy link
Member Author

rintaro commented Jun 9, 2021

@swift-ci Please smoke test

…d results

Instead, allocate new `CodeCompletionResult` in the current sink.
@rintaro
Copy link
Member Author

rintaro commented Jun 9, 2021

@swift-ci Please smoke test

@rintaro rintaro merged commit e3ba609 into swiftlang:main Jun 10, 2021
@rintaro rintaro deleted the ide-completion-protocol-at-expr-rdar77934897 branch June 10, 2021 04:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants