Skip to content

[5.1][CodeCompletion] Grab bag of recent changes in code completion #23577

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 Mar 26, 2019

Cherry-pick of recent changes in code-completion for swift-5.1-branch

master PR title problem
#23332 [AST] Don't return decls from unsatisfied conformance rdar://problem/36594731
#23372 [CodeCompletion] Escape declaration base name if needed rdar://problem/16232627
#23397 [CodeCompletion] Add already fixed test case rdar://problem/36818556
#23408 [AST] Prefer available member in lookupVisibleDecls() rdar://problem/47408946
#23410 [CodeCompletion] 'case' keyword completion at the top of 'switch' stmt rdar://problem/35943849
#23498 [CodeCompletion] Look through implicit exprs to find the parsed expr N/A
#23490 [CodeCompletion] Provide empty call pattern after paren rdar://problem/46215262
#23502 [CodeCompletion] Don't provide 'init(nilLiteral:)' et al in optional context rdar://problem/47806831
#23542 [CodeCompletion] Infer keypath root type from the context type rdar://problem/46102807

rintaro added 10 commits March 26, 2019 14:04
When a type conditionally conforms to a protocol, it used to provide
symbols from extension to that protocol.
e.g.:

  protocol P {}
  extension P {
    func foo() {}
  }

  struct S<T> {}
  extension S: P where T == Int {}

  func test(val: S<String>) {
    val.#^COMPLETE^#
  }

This should not provide `foo()` method.

rdar://problem/36594731
(cherry picked from commit dcb1db2)
There should be escaped identifiers in code completion:
- As primary expression: Any keyword name except for `self` and `Self`.
- After dot: Something named `init`.

rdar://problem/16232627
(cherry picked from commit df473f6)
rdar://problem/36818556
(cherry picked from commit 3e4ab1f)
'init?()' and 'init()' are considerd conflicting. But user can declare
both if only one of them is available.

rdar://problem/47408946
(cherry picked from commit c01799c)
rdar://problem/35943849
(cherry picked from commit fd542e2)
The parsed expression may be wrapped with various implicit expressions.
For example, if the expression is only element in array literal, it's
wrapped with `(arrayLiteral: <expr>)`.

(cherry picked from commit bfaa6af)
This improves discoverability of no-parameter initializers.

rdar://problem/46215262
(cherry picked from commit 7ae18ff)
…context

For unresolved member completion, member decls in `Optional`
referenceable by implicit member expression are useless in most cases.
- `init(_: <#Wrapped#>)`
- `init(nilLiteral: ())`
- `.some(<#Wrapped#>)`
- `.none`

Instead, provide `nil` with erasing `.` instruction.

rdar://problem/47806831
(cherry picked from commit 7e3a5dc)
with "TODO: ignore them in expression context".
They are useful in pattern context, so we should provide them in
completion.

(cherry picked from commit b1efc21)
So that this works:

```
func foo(_: KeyPath<SomeObject, Int>) {}
foo(\.<HERE>)
```

rdar://problem/46102807
(cherry picked from commit 65d8d29)
@rintaro
Copy link
Member Author

rintaro commented Mar 26, 2019

@swift-ci Please test

@rintaro rintaro merged commit df39cd7 into swiftlang:swift-5.1-branch Mar 27, 2019
@rintaro rintaro deleted the 5.1-ide-completion-grabbag1 branch March 27, 2019 04:57
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.

1 participant