Commit Graph

53 Commits

Author SHA1 Message Date
Alexander Cyon
a80b8ae06f [test/IDE] Fix typos 2024-08-08 19:35:00 +02:00
Karoy Lorentey
4b1477cc2c [test] Update tests for new stdlib 2024-03-18 11:08:32 -07:00
Alex Hoppen
a5a17aa955 [tests] Add a %batch-code-completion lit substitution
I could never remember the command to run batch code completion tests. Add a lit substitution for it.
2023-09-18 13:57:49 -07:00
Pavel Yaskevich
c453f2d89d [Tests] NFC: Adjust new code completion tests to account for any 2023-07-07 19:51:01 +02:00
Alex Hoppen
4f5743c8c6 [IDE] Adjust more test cases 2023-07-07 19:51:01 +02:00
Alex Hoppen
c00428a1f4 [IDE] New test cases that were failing at some point during solver-based migration 2023-07-07 19:51:01 +02:00
Alex Hoppen
f2017b82ac [IDE] Don't fallback type check if the completion expression is inside a closure 2023-07-07 19:51:01 +02:00
Alex Hoppen
00eaed3af9 [CodeCompletion] Migrate postfix expr completion to solver-based 2023-07-07 19:51:01 +02:00
Alex Hoppen
48dd99b12d [IDE] Don't rank based on overload choices of function calls that contain the code completion token 2023-07-07 19:50:46 +02:00
Anthony Latsis
7f6d3bcd41 ASTPrinter: Turn on explicit any printing for everything and remove the option to disable it 2023-05-13 02:55:49 +03:00
Alex Hoppen
32eff21977 [IDE] Remove "Begin completions" and "End completions" from test cases
These test lines weren't actually providing any value and were annoying to write. Let's jut remove them.
2023-03-22 09:07:17 -07:00
Alex Hoppen
614679f73d [IDE] Set solution-specific variable types as interface types
Setting the interface type of a variable, just to reset it to a null type is actually really gross. But quite a few methods further down in the generation of code completion results (such as USR generation) need to get a variable’s type and passing them along in a separate map would be really invasive. So this seems like the least bad solution to me.
2023-03-07 17:48:41 -08:00
Alex Hoppen
754e9d7d54 [CodeCompletion] Fix issue when completing inside a switch in a closure 2023-02-14 09:40:56 +01:00
Alex Hoppen
20985eaecd [CodeCompletion] Don’t pass LeaveClosureBodiesUnchecked for solver-based code completion 2023-02-14 09:40:55 +01:00
Anthony Latsis
4cb63c8a0f [NFC] Migrate remnant Jira issue references to GitHub issues 2022-12-04 08:20:34 +03:00
Alex Hoppen
f5c0c9cb35 [CodeCompletion] Maintain LeaveClosureBodiesUnchecked when checking pattern binding
Before, we were dropping `LeaveClosureBodiesUnchecked` when checking a pattern binding request which caused missing completions inside variables initialized by closures.

rdar://92603748 [#58610]
2022-05-04 16:08:48 +02:00
Alex Hoppen
5d01a097e1 [CodeCompletion] Don't distinguish convertible and idenical type relation
I think that preferring identical over convertible makes sense in e.g. C++ where we have implicit user-defined type conversions but since we don’t have them in Swift, I think the distinction doesn’t make too much sense, because if we have a `func foo(x: Int?)`, want don’t really want to  prioritize variables of type `Int?` over `Int` Similarly if we have `func foo(x: View)`, we don’t want to prioritize a variable of type `View` over e.g. `Text`.

rdar://91349364
2022-04-13 08:28:17 +02:00
Alex Hoppen
e2a62f1a60 [CodeCompletion] Migrate expression completions to solver-based 2022-03-21 13:00:33 +01:00
Rintaro Ishizaki
18dc9c1c27 [CodeCompletion] Remove CodeComletionString::getName()
`CodeCompletioString::getName()` was used only as the sorting keys in
`CodeCompletionContext::sortCompletionResults()` which is effectively
deprecated. There's no reason to check them in `swift-ide-test`. Instead,
check `printCodeCompletionResultFilterName()` that is actually used for
filtering.
2021-07-16 13:24:19 -07:00
Rintaro Ishizaki
4e8d98de49 [CodeCompletion] Completion inside closure capture list 2021-06-10 14:44:39 -07:00
Rintaro Ishizaki
5cf87d30f5 [CodeCompletion] Don't offer completion names for closure argument names
Parse a completion token as an empty parameter name (just like `_`) to
prevent the parser to parse it as an expression and offer completions
for it.

rdar://78798718
2021-06-10 13:45:09 -07:00
Rintaro Ishizaki
6dd5d9482f [CodeCompletion] Introduce "Flair" in code completion
To describe fine grained priorities.

Introduce 'CodeCompletionFlair' that is a set of more descriptive flags for
prioritizing completion items. This aims to replace '
SemanticContextKind::ExpressionSpecific' which was a "catch all"
prioritization flag.
2021-06-07 17:25:01 -07:00
Rintaro Ishizaki
defb593f8d [CodeCompletion] Migrate some tests to batch completion test 2021-04-01 22:33:12 -07:00
Rintaro Ishizaki
75a0c9f819 [CodeCompletion] Add 'IsSystem' flag to code completion result item
'key.is_system: 1' is added if the associated declaration is from a
system module.

rdar://problem/62617558
2020-05-11 12:24:36 -07:00
Rintaro Ishizaki
71aeffdf17 [CodeCompletion] Calculate type relation for EnumElementDecl 2020-02-03 17:20:50 -08:00
Nathan Hawes
feb48a61b9 [code-completion] Fix correctness regressions from disabling diagnostics in code completion
There were some changes to completion results because AST mutations that were
made while diagnosing are no longer happening.

This patch 1) changes expression type checking to allow unresolved types when
solving constraint systems, so we get a solution and apply its types in more
cases, and 2) fixes a parsing issue where we would drop a ternary expression
completely if the code completion point was in its true branch.
2019-08-30 15:26:27 -07:00
Nathan Hawes
746340f9d9 [code-completion] Don't delay parsing a decl within a closure - delay the decl containing that closure instead
We were losing the CurLocalContext state (set when entering the closure's
BraceStmt) through the delaying process, sometimes causing errors when we
got back to parsing a delayed decl.

Resolves rdar://problem/54219186
2019-08-28 14:44:25 -07:00
Ben Langmuir
f5a216fc04 Merge pull request #23411 from benlangmuir/cc-1-close
[code-completion] Add type context for single-expression closures
2019-03-20 06:56:49 -07:00
Ben Langmuir
b817cbb9bc [code-completion] Add type context for single-expression closures
When completing in the only expression of closure, use the return type
of the closure as the type context for the code-completion. However,
since code-completion may be on an incomplete input, we only use the
return type to improve the quality of the result, not to mark it
invalid, since (a) we may add another statement afterwards, or (b) if
the context type is Void it doesn't need to match the value.
2019-03-18 17:04:33 -07:00
Rintaro Ishizaki
3e4ab1fd31 [CodeCompletion] Add already fixed test case
rdar://problem/36818556
2019-03-18 12:31:54 -07:00
Rintaro Ishizaki
797761adae [CodeCompletion] Try to parse complete expression after CC token
Type may depend on its suffix. Parsing complete expression including its
suffix improves context type info around the CC token.

rdar://problem/44143964
2018-10-16 06:08:29 +09:00
fischertony
7b41a41fb6 updated tests & added completions for postfixExpr 2018-05-12 09:05:57 +03:00
Pavel Yaskevich
1ee03bc9c4 [TypeChecker] Miscellaneous changes to switch to FunctionType::getParams() 2018-04-26 17:33:08 -07:00
practicalswift
ef8e43b519 [gardening] Increase consistency with regards to spacing after colons 2016-09-22 16:28:57 +02:00
Dmitri Gribenko
d175b3b66d Migrate FileCheck to %FileCheck in tests 2016-08-10 23:52:02 -07:00
Manav Gabhawala
7928140f79 [SE-0046] Implements consistent function parameter labels by discarding extraneous parameter names and adding _ where necessary 2016-04-06 20:21:58 -04:00
ken0nek
3ac60b13f5 Add spaces before and after closure arrow in test 2015-12-23 04:38:46 +09:00
Xi Ge
c8ab2b6999 Re-apply "[CodeComplete] Make sure the lookup API can find closure parameters. rdar://17968255"
This also fixes an ASAN issue when TuplePattern tries to retrieve its associated element buffer whose
size is 0.

Swift SVN r32303
2015-09-29 19:14:06 +00:00
Xi Ge
586ccaefbd Revert "Re-apply "[CodeComplete] Make sure the lookup API can find closure parameters. rdar://17968255""
for unhappy bot.

Swift SVN r32258
2015-09-26 06:33:45 +00:00
Xi Ge
c22ab44013 Re-apply "[CodeComplete] Make sure the lookup API can find closure parameters. rdar://17968255"
Swift SVN r32257
2015-09-26 05:54:43 +00:00
Xi Ge
82fd4009c2 Revert "[CodeComplete] Make sure the lookup API can find closure parameters. rdar://17968255"
for breaking build bot.

Swift SVN r32255
2015-09-26 00:58:46 +00:00
Xi Ge
3e925ca930 [CodeComplete] Make sure the lookup API can find closure parameters. rdar://17968255
Swift SVN r32252
2015-09-25 23:48:50 +00:00
Ben Langmuir
6df189b6f4 [CodeCompletion] Restore scope depth in delayed parsing
When the scope depth is wrong and we add a name to the hash table we
will skip the redefinition checks and end up hitting an assertion
failure.

rdar://problem/22344218

Swift SVN r31690
2015-09-04 18:29:45 +00:00
Ben Langmuir
a33ac57234 [CodeCompletion] Loosen an assert that's firing in closure bodies
Taking an ErrorType should be fine if we can't do any better.

rdar://problem/20923711

Swift SVN r29013
2015-05-25 20:30:59 +00:00
Denis Vnukov
152df92966 [CodeCompletion] Code Completion String getName should always return non-empty string value for
valid code completions. Code completion tests call and validate getName’s result. 

A minor fix for code completion fro subscripts.



Swift SVN r25101
2015-02-09 22:32:05 +00:00
Dmitri Hrybenko
3b04d1b013 tests: reorganize tests so that they actually use the target platform
Most tests were using %swift or similar substitutions, which did not
include the target triple and SDK.  The driver was defaulting to the
host OS.  Thus, we could not run the tests when the standard library was
not built for OS X.

Swift SVN r24504
2015-01-19 06:52:49 +00:00
Chris Lattner
440e38f66f fix <rdar://problem/19135222> swift reserves 'new' keyword and doesn't use it
by removing the old fixit code for migrating code away from the obsolete 'new' syntax
for allocating arrays.



Swift SVN r23664
2014-12-03 23:16:45 +00:00
Argyrios Kyrtzidis
d37855e5c5 [IDE] Fix crash when code-completing inside a closure initializer of a member.
rdar://18246941

Swift SVN r21809
2014-09-09 19:29:19 +00:00
Dmitri Hrybenko
b0c3a56c96 Code completion: fix some type checking issues of closures
Completely disable the AST transformation for single-expression closures.  When
this transformation picks up an incomplete expression, the resulting AST is
almost guaranteed to have type mismatches, and the type checker just marks
everything with error types.

rdar://17193319 rdar://17086137


Swift SVN r20153
2014-07-18 14:49:34 +00:00
Dmitri Hrybenko
8234c70f88 Code completion: fix delayed parsing of closures
The delayed parsing was in place, but the expressions were being thrown away by
"recovery" in the parser.

rdar://16274593


Swift SVN r20151
2014-07-18 11:43:38 +00:00