Skip to content

[CodeCompletion] Fix call arguments completion in overloaded case #20721

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 Nov 26, 2018

In <expr> '(' <code-completion-token> case, we usually complete call arguments. However, if <expr> isn't typechecked, for example because of overloading, we used to give up arguments completions.

Now, use possible callee informations from CodeCompletionTypeContextAnalyzer. This increases the chance to provide arguments completions.

rdar://problem/43703157

(#20703 is a groundwork for this PR)

@rintaro rintaro force-pushed the ide-completion-postfixparen-rdar43703157 branch from bd723da to 5fdf8ee Compare November 26, 2018 14:09
@rintaro
Copy link
Member Author

rintaro commented Nov 26, 2018

@swift-ci Please smoke test

@rintaro rintaro requested a review from benlangmuir November 26, 2018 15:24
@benlangmuir
Copy link
Contributor

Will this work for individual label completions (i.e. what you get in overload(x: 1, <complete>)?

@rintaro
Copy link
Member Author

rintaro commented Nov 26, 2018

That's still FIXME. (OVERLOAD1 and OVERLOAD2).

For example, given:

func foo(arg1: Int, bar: Double) {}
func foo(arg1: Int, baz: Int){}
func foo(arg1: String, qux: Int) {}

func _test() {
  foo(arg1: 1, #^COMPLETE^#
}

results:

Begin completions, 3 items
Keyword/ExprSpecific:               bar: [#Argument name#]; name=bar: 
Keyword/ExprSpecific:               baz: [#Argument name#]; name=baz: 
Keyword/ExprSpecific:               qux: [#Argument name#]; name=qux: 

But qux: is not relevant here because arg1 is Int.

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.

LGTM other than some nitpicks about wording.


void collectPossibleParamListByQualifiedLookup(
/// Collect function (or subscript) member with specified \p name on \p baseTy.
void collectPossibleCalleeByQualifiedLookup(
Copy link
Contributor

Choose a reason for hiding this comment

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

Callee -> Callees

void collectPossibleParamListByQualifiedLookup(
/// Collect function (or subscript) member with specified \p name on
/// \p baseExpr expression.
void collectPossibleCalleeByQualifiedLookup(
Copy link
Contributor

Choose a reason for hiding this comment

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

Same comments about function name and comment as above.


void collectPossibleParamListByQualifiedLookup(
/// Collect function (or subscript) member with specified \p name on \p baseTy.
Copy link
Contributor

Choose a reason for hiding this comment

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

... members with the given \p name ...

}

bool collectPossibleParamListsApply(
/// For given \c callExpr, collect possible callee types and declarations.
bool collectPossibleCalleeForApply(
Copy link
Contributor

Choose a reason for hiding this comment

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

Callee -> Callees

DC, baseTy, DeclBaseName::createConstructor(), candidates);
}
}

return !candidates.empty();
}

bool collectPossibleParamListsSubscript(
/// For given \c subscriptExpr, collect possible callee types and declarations.
bool collectPossibleCalleeForSubscript(
Copy link
Contributor

Choose a reason for hiding this comment

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

Callee -> Callees

DeclBaseName::createSubscript(),
candidates);
}
return !candidates.empty();
}

/// Get index of \p CCExpr in \p Args. \p Args is usually a \c TupleExpr,
/// \c ParenExpr, or a \c TupleShuffleExpr.
/// Returns \c true if sucess, \c false if \p CCExpr is not a part of \p Args.
Copy link
Contributor

Choose a reason for hiding this comment

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

\returns

in context type analysis.
Still NFC, but this is needed by later commits.
In `<expr> '(' <code-completion-token>` case, we usually complete call
arguments. If '<expr>' isn't typechecked, for example, because of
overloading, we used to give up arguments completions.

Now, use possible callee informations from the context type analyzer. This
increases the chance to provide accurate completions.

rdar://problem/43703157
@rintaro rintaro force-pushed the ide-completion-postfixparen-rdar43703157 branch from 5fdf8ee to 0e4ce12 Compare November 26, 2018 23:00
@rintaro rintaro force-pushed the ide-completion-postfixparen-rdar43703157 branch from 0e4ce12 to 56c531d Compare November 26, 2018 23:03
@rintaro
Copy link
Member Author

rintaro commented Nov 26, 2018

@swift-ci Please smoke test

@rintaro rintaro merged commit 20f29c6 into swiftlang:master Nov 27, 2018
@rintaro rintaro deleted the ide-completion-postfixparen-rdar43703157 branch November 27, 2018 01:07
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