Skip to content

[5.2][CodeCompletion] Don't discard parsed expression in incomplete ternary #29358

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

Conversation

rintaro
Copy link
Member

@rintaro rintaro commented Jan 22, 2020

Cherry-pick of #29343 into swift-5.2-branch

  • Explanation: This patch enables dot-member completion in incomplete ternary operator expression (e.g. receiveEnum(cond ? <HERE>)) . Previously, if : is missing, the whole expression was discarded and not in the AST. Because of that, we couldn't check the context type of the expression. This patch keeps it in the AST, and teach the context type analysis to how to analyze them.
  • Scope: Code completion
  • Risk: Low. The changes affect only code completion.
  • Issue: rdar://problem/54132682
  • Testing: Added regression test cases
  • Reviewer: Nathan Hawes (@nathawes )

If we are code-completion, we need to keep the parsed expression in the
AST. Don't discard the parsed expression if the middle expression in a
ternary expression has code-completion token. This improves the
completions for:

    let _: MyEnum = condition ? .<HERE>
    let _: MyEnum = condition ? .<HERE> :

rdar://problem/54132682
This improves code-completion for non-type-checked ternary expressions.
@rintaro rintaro requested a review from a team as a code owner January 22, 2020 19:21
@rintaro
Copy link
Member Author

rintaro commented Jan 22, 2020

@swift-ci Please test

@rintaro
Copy link
Member Author

rintaro commented Jan 22, 2020

@swift-ci Please nominate

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 32a3529

@rintaro
Copy link
Member Author

rintaro commented Jan 22, 2020

@swift-ci Please test Linux

@rintaro rintaro merged commit 185c235 into swiftlang:swift-5.2-branch Jan 22, 2020
@rintaro rintaro deleted the 5.2-ide-completion-ternary-rdar54132682 branch January 23, 2020 19:27
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.

3 participants