Commit Graph

23 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
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
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
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
Ben Langmuir
7685f7f31e [code-complete] Update literal protocol to show "" for Character
... and UnicodeScalar, which is technically more correct than only
showing it for String.  This also happens to workaround a bug where we
won't show "" for string.contains.

rdar://problem/34746368
2017-10-05 09:52:31 -07:00
Max Moiseev
391d49a31e [overlay] Hide the _ExpressibleByColorLiteral initializer from code completion.
Fixes: <rdar://problem/32726800>
2017-07-12 09:05:06 -07:00
Dmitri Gribenko
d175b3b66d Migrate FileCheck to %FileCheck in tests 2016-08-10 23:52:02 -07:00
Robert Widmann
f97e5dcb0e [SE-0115][1/2] Rename *LiteralConvertible protocols to ExpressibleBy*Literal. This
change includes both the necessary protocol updates and the deprecation
warnings
suitable for migration.  A future patch will remove the renamings and
make this
a hard error.
2016-07-12 15:25:24 -07:00
John McCall
a1c1693529 Change the names of the object-literal initializers to be
semantically unambiguous.

We didn't actually intend to change how programmers normally
constructed these types, but the change to the object literal
syntax accidentally caused these initializers to have very
natural-seeming signatures.  These initializers also created
possible ambiguities with the actual initializers.  Renaming
them to refer to their function as literal initializers is the
right thing to do.

Unfortunately, this provided to be somewhat annoying, as the
code was written to assume that the argument tuple following
e.g. #colorLiteral could be directly passed to the initializer.
We solve this by hacking on both ends of the constraint system:
during generation we form a conversion constraint to the
original, idealized parameter type, and during application we
rewrite the argument tuple type to use the actual labels.
This nicely limits the additional complexity to just the
parts dealing with object literals.

Note that we can't just implicitly rewrite the tuple expression
because that would break invariants tying the labels to physical
source ranges.  We also don't want to just change the literal
syntax again and break compatibility with existing uses.

rdar://26148507
2016-05-13 10:33:37 -07:00
Ted Kremenek
b8bbed8c13 [WIP] Implement SE-0039 (Modernizing Playground Literals) (#2215)
* Implement the majority of parsing support for SE-0039.

* Parse old object literals names using new syntax and provide FixIt.

For example, parse "#Image(imageLiteral:...)" and provide a FixIt to
change it to "#imageLiteral(resourceName:...)".  Now we see something like:

test.swift:4:9: error: '#Image' has been renamed to '#imageLiteral
var y = #Image(imageLiteral: "image.jpg")
        ^~~~~~ ~~~~~~~~~~~~
        #imageLiteral resourceName

Handling the old syntax, and providing a FixIt for that, will be handled in a separate
commit.

Needs tests.  Will be provided in later commit once full parsing support is done.

* Add back pieces of syntax map for object literals.

* Add parsing support for old object literal syntax.

... and provide fixits to new syntax.

Full tests to come in later commit.

* Improve parsing of invalid object literals with old syntax.

* Do not include bracket in code completion results.

* Remove defunct code in SyntaxModel.

* Add tests for migration fixits.

* Add literals to code completion overload tests.

@akyrtzi told me this should be fine.

* Clean up response tests not to include full paths.

* Further adjust offsets.

* Mark initializer for _ColorLiteralConvertible in UIKit as @nonobjc.

* Put attribute in the correct place.
2016-04-25 07:19:26 -07:00
Ben Langmuir
ce3c2de4a6 [CodeCompletion] Convert optionals when checking for literal protocol conformance
Except for nil literals, we don't want to look at the optional itself,
since the typechecker would implicitly look to the underlying type.

rdar://problem/24707210
2016-03-08 09:39:04 -08:00
Ben Langmuir
a927dc8a5a [CodeCompletion] Hide literals that don't match the type context in SourceKit
If there is a type context, hide literal suggesetions that don't match
it, unless they are keywords and we have filtered to their names.

Incidentally fix an output buffering issue when combining filtering with
the -raw flag in complete-test.

Part of rdar://problem/23865118
2016-02-03 10:51:07 -08:00
Ben Langmuir
e75402e49e [CodeCompletion] Add image literal similar to color
Part of rdar://problem/23865118
2016-02-03 07:55:07 -08:00
Ben Langmuir
c33f2faad2 [CodeCompletion] Tweak literal suggestion text
For rdar://problem/23865118
2016-02-03 07:33:50 -08:00
Ben Langmuir
838131dd2f [CodeCompletion] Remove 0.0 suggestion
In practice things that are float literal convertible are also integer
literal convertible so this isn't pulling its weight.

Part of rdar://problem/23865118
2016-02-03 07:20:05 -08:00
Ben Langmuir
978267b09e [CodeCompletion] Fix source text inserted for literal completions
Put the right content into the placeholders. Embarassingly this wasn't
tested at all.

rdar://problem/23439483
2015-11-06 18:24:23 -08:00
Ben Langmuir
54a28a40db [CodeCompletion] Split literals out into their own completion kind
For rdar://problem/21923069

Swift SVN r32906
2015-10-27 13:34:54 +00:00
Ben Langmuir
880ef5e9fd [CodeCompletion] Add _ColorLiteralConvertible completion
For rdar://problem/21923069

Swift SVN r32891
2015-10-26 20:41:57 +00:00
Ben Langmuir
7fda8964db [CodeCompletion] Add several more literal completions
Go beyond the existing keyword completions to include more literal
suggestions: 0, 0.0, "text", [item], [key: value], (item, item)

For rdar://problem/21923069

Swift SVN r32890
2015-10-26 20:41:56 +00:00
Ben Langmuir
ba7db29113 [CodeCompletion] Add type relation to literals
So that e.g. `true` gets prioritizied in
    let x: Bool = <complete-here>

For rdar://problem/21923069

Swift SVN r32889
2015-10-26 20:41:55 +00:00