Skip to content

[CodeCompletion] Call argument completion for implicit member expression #24805

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 May 15, 2019

Implement following completions for implicit member expression.

class MyType {
  static func foo(_: Int, name: String, file: String = "", line: Int? = nil) -> MyType
}
func foo() -> MyType {
  // Call signature completion after opening paren.
  return .foo(<HERE> // -> <#Int#>, name: <#String#>
                     //    <#Int#>, name: <#String#>, file: <#String#>, line: <#Int?#>
                     //    ... other global completions.

  // Argument label completion
  return .foo(1, <HERE> // -> name:

  // Collect call arguments if the parameter is defaulted.
  return .foo(1, name: "test", <HERE> // -> file:
                                      //    line:

rdar://problem/50696432

…ession

At argument part of implict member expression, we need context type
analysis to complete arguments.

rdar://problem/50696432
@rintaro
Copy link
Member Author

rintaro commented May 15, 2019

@swift-ci Please smoke test

@rintaro rintaro requested a review from benlangmuir May 15, 2019 19:48
if (shouldPerformGlobalCompletion) {
Lookup.setExpectedTypes(ContextInfo.getPossibleTypes(),
ContextInfo.isSingleExpressionBody());
Lookup.setHaveLParen(false);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we move this up into the if block so it's closer to where we setHaveLParen(true)?

Copy link
Contributor

@benlangmuir benlangmuir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for explaining. LGTM with my nitpick about the setHaveLParen

rintaro added 3 commits May 15, 2019 17:31
For example:
  let x: MyClass = .create(<#COMPLETE#>)

This expression ends up with:
  (call_expr
    (dot_syntax_self_apply_expr
      (decl_ref_expr decl='C.create(_:arg1)'
      (type_expr type=MyClass))))
So we need to look through 'DotSyntaxSelfApplyExpr' to get the decl.
@rintaro rintaro force-pushed the ide-completion-unresolvedarg-rdar50696432 branch from fc509c8 to e9e5134 Compare May 16, 2019 00:31
@rintaro
Copy link
Member Author

rintaro commented May 16, 2019

@swift-ci Please smoke test

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