Commit Graph

16 Commits

Author SHA1 Message Date
Nathan Hawes
0d59bffd81 [SourceKit] Fix placeholder expansion not working inside #if
Update the PlaceholderFinder ASTWalker to walk into the clauses of
IfConfigDecls. It wasn't previously, resulting in any placeholders there not
being expanded.

Also update CallExprFinder (used to determine if expansions should use trailing
closure syntax) to walk into inactive if-config clauses. Previously it only
walked into active regions, so expansions never used trailing closure syntax in
inactive regions.

Resolves rdar://problem/51995648
2019-07-09 14:18:40 -07:00
Rintaro Ishizaki
1c2c5c5114 [placeholder-expansion] Function builder: add basic expansion test
rdar://problem/50074177
2019-06-11 17:34:45 -07:00
Ben Langmuir
6377199e2f [placeholder-expansion] Expand trailing closure in statements correctly
In addition to brace statements (previously handled), several other
statements allow a trailing closure (return, yield, throw). Also fix the
handling of statements nested within expressions for closures - both
single-expression bodies and brace statements.

This also fixes a particular regression caused by single-expression
function bodies where we would fail to expand to a trailing closure when
a function body only contained a single expression.

rdar://50227500
2019-04-26 11:58:52 -07:00
Ben Langmuir
27b12bfe89 Merge pull request #23978 from AnthonyLatsis/expand-closure-check-braces
SourceKit: Account for existing braces when expanding closure placeholders
2019-04-25 15:00:40 -07:00
Nate Chandler
3139d3e061 Tweaked remaining failing tests.
Modified so that single-expression implicit return does not throw off
tests.
2019-04-24 10:04:20 -07:00
fischertony
7344fdb0a4 SourceKit: Account for existing braces when expanding closure placeholders 2019-04-12 07:30:28 +03:00
Xi Ge
3160446a8c SourceKitd: fix a placeholder expanding issue. rdar://34230324
When expanding placeholders, we analyze the surrounding context of a
placeholder to decide whether to expand the placeholder to a trailing
closure. This analysis assumes CallExpr is the only AST node with argument;
however UnresolvedMemberExpr can have argument as well. This commit
teaches the analysis logic to handle both.
2017-11-16 16:31:50 -08:00
Xi Ge
5c9099b07e SourceKitd: Properly record enclosing statement to ensure expanding to trailing closures consistently. rdar://33477177 2017-08-28 13:43:13 -07:00
Xi Ge
9577d980b0 [SourceKit] Initialize pointer as nullptr to fix a crash. rdar://28959889 2016-10-27 13:01:50 -07:00
Dmitri Gribenko
d175b3b66d Migrate FileCheck to %FileCheck in tests 2016-08-10 23:52:02 -07:00
Argyrios Kyrtzidis
1e9bae34a3 [AST] Preserve parameter names in TypeReprs of function types.
Also fixup 'test/SourceKit/CodeExpand/code-expand.swift' and use the syntax
for adding parameter names with an underscore for first name.
2016-08-09 18:07:58 -07:00
Doug Gregor
5b67fe455c [SE-0111 HACK] Disable some IDE- and SourceKit-related changes.
I still need to investigate what happened here, but I don't want it to
delay landing the bulk of SE-0111.
2016-07-29 17:28:25 -07:00
Xi Ge
09a19bb230 [SourceKit] Avoid expanding the last argument as trailing closure if there are other closures in the tuple. rdar://23428366 (#3408)
SourceKit invariantly expands the last argument in a function call as trailing closure,
if it is of function type. However, there are situations when inline closures
are preferred; for example, when the last argument is not the only closure in the function
call. This patch modifies SourceKit so that when the argument contains multiple closures,
the last argument is expanded as inline closure.
2016-07-07 18:25:55 -07:00
ken0nek
3ac60b13f5 Add spaces before and after closure arrow in test 2015-12-23 04:38:46 +09:00
Xi Ge
ab969d14a4 [SourceKit][PlaceholderExpand] Avoid function signatures when expanding trailing closures of ()->(). rdar://21879249 2015-12-07 11:48:53 -08:00
Argyrios Kyrtzidis
8ff6a98a99 [sourcekit] Merge SourceKit into the Swift repo.
The code goes into its own sub-tree under 'tools' but tests go under 'test',
so that running 'check-swift' will also run all the SourceKit tests.

SourceKit is disabled on non-darwin platforms.
2015-11-05 01:09:08 -08:00