Commit Graph

50 Commits

Author SHA1 Message Date
Hamish Knight
0fc825b6fb [Completion] Remove uses of unbounded generic types
Ensure we always produce bounded generic type annotations and
contextual types.
2025-02-25 14:49:12 +00:00
Alexander Cyon
a80b8ae06f [test/IDE] Fix typos 2024-08-08 19:35:00 +02: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
Alex Hoppen
4702f82914 [CodeCompletion] Check getContextualType in getTypeForCompletion 2023-08-24 08:48:36 -07:00
Alex Hoppen
c385fe5e87 [CodeCompletion] Migrate PostfixExprParen to solver-based 2023-07-07 19:50:46 +02: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
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
7f082e1c28 [Parser] Ignore generic arguments after a code completion token 2022-03-23 13:03:56 +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
154cd88c86 [CodeCompletion] Use 'Flair' to describe "is argument labels" 2021-06-07 17:25:01 -07:00
Rintaro Ishizaki
e2039406f4 [CodeCompletion] Migrate some tests to batch completion test
Reapply b810bb7bbd but without
'test/IDE/complete_where_clause.swift' which caused non-deterministic
failures.
2021-04-05 08:57:04 -07:00
Ted Kremenek
00534aa02a Revert "[CodeCompletion] Migrate some tests to batch completion test #4" 2021-04-03 09:20:45 -07:00
Rintaro Ishizaki
b810bb7bbd [CodeCompletion] Migrate some tests to batch completion test 2021-04-02 11:50:13 -07:00
Rintaro Ishizaki
62078c79dd [ASTPrinter/CodeCompletion] Stop printing base type when possible
rdar://problem/57033931
2019-12-17 16:26:37 -08:00
Rintaro Ishizaki
032c6e647e [CodeCompleiton] Don't hide members for unresolved base types
Don't filter out members if the base type has unresolved types.

Previously, initializers used to be hidden if the type has 'where'
requirements on the generic parameters.

This patch enables initializer completion for `SwiftUI.ForEach`.

rdar://problem/49480808
2019-06-18 12:18:27 -07:00
Rintaro Ishizaki
7b7c320bd5 [CodeCompletion] Allow ErrorType in constructor
Even if the constructor has `ErrorType` we can suggest it as long as it's
`FunctionType`.

rdar://problem/49480808
2019-05-13 01:32:57 -07:00
Rintaro Ishizaki
0c38f2df8a [CodeCompletion] Associate callee declaration with call patterns
In `addFunctionCallPattern()` we should associate declarations if
possible.

rdar://problem/49158044
2019-04-01 11:21:43 -07:00
Rintaro Ishizaki
445d426b16 [test] Update and re-enable test case disabled in 06b5ef36.
rdar://49240981
2019-03-25 20:39:29 -07:00
Harlan Haskins
7a76788a5b [test] Disable failing test to unblock the bots
rdar://49240981
2019-03-25 19:16:39 -07:00
Ted Kremenek
fe215edb9b Merge pull request #19743 from Azoy/smarter-struct-init
[Sema] Synthesize default values for memberwise init
2019-03-25 17:31:01 -07:00
Rintaro Ishizaki
7ae18ff0f1 [CodeCompletion] Provide empty call pattern after paren
This improves discoverability of no-parameter initializers.

rdar://problem/46215262
2019-03-22 10:56:40 -07:00
Rintaro Ishizaki
c01799cbcf [AST] Prefer available member in lookupVisibleDecls()
'init?()' and 'init()' are considerd conflicting. But user can declare
both if only one of them is available.

rdar://problem/47408946
2019-03-18 16:08:21 -07:00
Azoy
6f7d20b99e Synthesize default values for memberwise init
Introduce stored property default argument kind

Fix indent

Assign nil to optionals with no initializers

Don't emit generator for stored property default arg

Fix problem with rebase

Indentation

Serialize stored property default arg text

Fix some tests

Add missing constructor in test

Print stored property's initializer expression

cleanups

preserve switch

complete_constructor

formatting

fix conflict
2019-03-13 18:57:36 -05:00
Rintaro Ishizaki
01b8fbc1bf [CodeCompletion] Implement .Type completion in expression context
rdar://problem/22072865
2019-02-12 10:40:08 -08:00
fischertony
45c9038d0f corrections and review amendments 2018-05-31 19:13:50 +03:00
fischertony
7ef24b10c9 [SR-7789][Additions]
restore accidentally removed constructors from 'self'
replace illegal direct call completions on dynamic metatypes with .init, except archetypes.
2018-05-30 06:05:04 +03:00
fischertony
927598fbcc [CodeCompletion] Missing init completions for dotExpr
Fixes non-visible inherited convenience initializers
Fixes non-visible initializers from protocol extensions
Fixes visible initializers on dynamic metatypes for postfix and parenPostfix expressions
2018-05-28 05:59:49 +03:00
fischertony
7b41a41fb6 updated tests & added completions for postfixExpr 2018-05-12 09:05:57 +03:00
Pavel Yaskevich
c0f5711ee5 [ConstraintSystem] Don't apply types to expressions until solution is found
Resolves: rdar://problem/36744895
2018-02-13 00:08:45 -08:00
Ben Langmuir
b6d5a1f1a5 [code-complete] Do not insert rparen after a call pattern completion
When completing
  Foo(<here>
We will now provide
  bar: <#value#>
instead of
  bar: <#value#>)

Inserting the rparen caused some problems in practice:
* the old behaviour optimized for typing Foo(<complete> instead of
  Foo(<complete>), which can conflict with user behaviours or ...
* in editors with automatic brace-matching, we often conflicted with the
  editor, leading to extraneous closing parens

And in general, it is much more predictable for tooling to either insert
matching ( and ) or to not insert either.  While this change may not be
ideal For users of editors that do not do automatic brace-matching, I
believe it is still better overall to have to type a missing paren than
to have to delete an extraneous one.

rdar://31113161
2017-12-18 11:59:49 -08:00
Ben Langmuir
93956eb34b [code-complete] Put call-pattern heuristics under a flag
The original hope was we could make these heuristics really good, but
since that is not currently in sight (and may never be), we want to be
able to turn them off.  For now, just plumb through an internal flag to
control the behaviour.  A future change will customize the behaviour in
SourceKit.

rdar://31113161
2017-12-15 13:23:44 -08:00
Ben Langmuir
d8fa0b00ba [codecomplete] Handle null type in AbstractClosureExpr context
rdar://problem/27643235
2016-08-23 14:58:44 -07:00
Ben Langmuir
2855634999 [codecomplete] Check for ErrorType before asking for CD->getResultType()
Fixes a crash where we try to cast ErrorType to a function type to get
the result.

rdar://problem/27763826
2016-08-23 13:14:56 -07:00
Dmitri Gribenko
d175b3b66d Migrate FileCheck to %FileCheck in tests 2016-08-10 23:52:02 -07:00
Robert Widmann
4f465224ea Polish off uses of dynamicType in tests 2016-07-29 16:59:14 -07:00
Ben Langmuir
968b0491b8 [CodeCompletion] Make Void-returning functions "NotRecommended" in typed context
When we know we're expecting an expression that returns a value, make
the completion "NotRecommended" to deprioritize it.

rdar://problem/22810741
2016-03-29 14:20:25 -07:00
Ben Langmuir
a2c7298af5 [CodeCompletion] Don't complete entire call patterns inside existing calls
Peek at the token following the code completion location to decide
whether or not to provide completions for entire call patterns.  When
the next token looks like it's part of an existing call we don't show
the patterns because they will "push out" the existing arguments.

We should now get:
  Foo<here> =>  (blah, blah)
  Foo(<here> =>  ['(']blah, blah)
  Foo(<here>) => ['(']blah, blah[')']
  Foo(<here>, blah) => just complete the values for arg1**
  Foo(<here>blah, blah) => just complete the values for arg1

** A further improvement will be to add the argument label completion
for the first argument (if applicable) when we aren't showing a full
call pattern.

rdar://problem/22804670

Swift SVN r32765
2015-10-19 21:47:01 +00:00
Xi Ge
8d67a4ad12 [CodeComplete] Propagate type relation descriptor to the first argument, or the only argument, of call exprs.
rdar://22688827

Swift SVN r31928
2015-09-14 19:43:36 +00:00
Xi Ge
7b6b26a46d [CodeCompletion] Only filter out non-required inits for class type.
Swift SVN r30893
2015-08-01 00:05:03 +00:00
Xi Ge
29fcee3f0b [CodeCompletion] Show only required init() as members of dynamic metatype.
rdar://22074073

Swift SVN r30888
2015-07-31 22:49:55 +00:00
Xi Ge
33611bfe33 [Test] Update test to use locally defined types instead of those from stdlib.
Swift SVN r30803
2015-07-30 17:16:26 +00:00
Xi Ge
d0b61a8bd7 [Test][CodeCompletion] Add a test for dynamic type.
Swift SVN r30782
2015-07-30 00:35:07 +00:00
Xi Ge
5a1946eb53 [CodeCompletion] Add init() to the code completion results after metatype + dot.
rdar://21474100

Swift SVN r30781
2015-07-30 00:10:43 +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
Doug Gregor
e9037bcfa7 Default swift-ide-test to -implicit-objc-with like the rest of the world.
We require some level of consistency between the way the overlays were
built and what we work with in our mock SDK. The IDE/sdk_sugar.swift
test failure was because the overlay referenced "init(coder:)" while
the test was looking for "init(withCoder:)". Hilarity ensued
<rdar://problem/17791048>.

This only impacts testing.

Swift SVN r20564
2014-07-25 22:13:43 +00:00
Ben Langmuir
dfbd8b794f Don't desugar paren type when code-completing func params
We want to complete foo(p: (Int, Int)) as foo({#(p): (Int, Int)#}), not
as foo({#Int#}, {#Int#}).  Also, make initializers go through the
function parameter code path rather than the enum one, since we don't
want to recursively find parameters in tuples.

<rdar://problem/17461862>

Swift SVN r19514
2014-07-03 15:45:05 +00:00
Sonny Falk
22633c2d83 [IDE/CodeCompletion] Make code completion include the leading paren in calls.
The leading paren is included for display purposes only, not inserted
in the code if already present. It makes the displayed text in the
code completion list symmetrical with respect to open/close parens.

Add markups when printing annotation chunks so it becomes testable.
Update tests accordingly, and include tests for leading parens.

This addresses <rdar://problem/16918310>.

Swift SVN r18126
2014-05-15 21:09:56 +00:00
Ted Kremenek
fad874708e Adjust test cases.
Swift SVN r17964
2014-05-12 22:01:52 +00:00
Dmitri Hrybenko
a813e14b6d Code completion: complete 'super.init' in constructors
Also add tests for completing constructors declared with selector syntax.


Swift SVN r8412
2013-09-18 19:05:39 +00:00