-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[CodeCompletion] Migrate labeled trailing closure completions to solver-based #68075
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
[CodeCompletion] Migrate labeled trailing closure completions to solver-based #68075
Conversation
4733bc1
to
b48ee42
Compare
@swift-ci Please smoke test |
@swift-ci Please SourceKit stress test |
lib/IDE/ArgumentCompletion.cpp
Outdated
->lookThroughAllOptionalTypes() | ||
->is<AnyFunctionType>()) { | ||
// We are completing an argument after the first trailing closure, i.e. | ||
// a mulitple trailing closure label but the parameter is not a function |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
multiple
Note to self: The stress tester hit 4 new timeouts, which we are accepting because of the improvements this brings and because it unblocks #68080, which deletes a huge amount of code. |
b48ee42
to
2b4c3bc
Compare
if (IdealType.isNull() != Other.IdealType.isNull()) { | ||
IdealType = Type(); | ||
} else if (IdealType && Other.IdealType && | ||
!IdealType->isEqual(Other.IdealType)) { | ||
IdealType = Type(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Seems like this could be reduced to !IdealType || !Other.IdealType || !IdealType->isEqual(Other.IdealType)
…onsumer phase This will allow us to run two different completion kinds and deliver results from both of them. Also: Compute a unified type context for global lookup. Previously, we always used the expected type context of the last lookup. But really, we should be considering all possible types from all constraint system solutions when computing code completion results from the cache.
…er-based rdar://113472967
2b4c3bc
to
48ce1b3
Compare
@swift-ci Please smoke test |
@swift-ci Please test Windows |
In a first commit, I split
deliverResults
into acollectResults
call that gathers all the code completion results and thentrySolverCompletion
is responsible for delivering the results to the code completion consumer.When we are performing code completion after a call that already has a trailing closure, we first perform the normal postfix completion, which will give us results for operators and member access. We then rewrite the call slightly to include the code completion token as an additional argument, and run argument completion on it. This gives us the completion for the trailing closure label. Once we have collected the results from both completion kinds, we deliver them to the consumer
As a little side-quest, I realized that when computing the code completion results from the cached modules, we were always using the type context of the last lookup that we performed. I changed that slightly to compute a unified type context that contains all possible types from all constraint system solutions. We then use that unified type context to compute the type relations of the global results – this didn’t change any tests.
Oh, and one more thing: When completing after
Void
, we were providing==
,<=
etc operators that are defined on tuples. These also showed up when completing trailing closure labels of a call that returnsVoid
. Since they are never useful, I now hide operators from code completion if the left-hand-side isVoid
.rdar://113472967