Commit Graph

69 Commits

Author SHA1 Message Date
John McCall
7a4aeed570 Implement generalized accessors using yield-once coroutines.
For now, the accessors have been underscored as `_read` and `_modify`.
I'll prepare an evolution proposal for this feature which should allow
us to remove the underscores or, y'know, rename them to `purple` and
`lettuce`.

`_read` accessors do not make any effort yet to avoid copying the
value being yielded.  I'll work on it in follow-up patches.

Opaque accesses to properties and subscripts defined with `_modify`
accessors will use an inefficient `materializeForSet` pattern that
materializes the value to a temporary instead of accessing it in-place.
That will be fixed by migrating to `modify` over `materializeForSet`,
which is next up after the `read` optimizations.

SIL ownership verification doesn't pass yet for the test cases here
because of a general fault in SILGen where borrows can outlive their
borrowed value due to being cleaned up on the general cleanup stack
when the borrowed value is cleaned up on the formal-access stack.
Michael, Andy, and I discussed various ways to fix this, but it seems
clear to me that it's not in any way specific to coroutine accesses.

rdar://35399664
2018-07-23 18:59:58 -04:00
Ben Langmuir
b394e35fdd [codecomplete] Add completion of if after else
At some point we stopped completing keywords after `else` in an if
statement. Bring back the completion of `if`, which is the only valid
continuation other than a brace.

rdar://37467474
2018-07-10 11:45:10 -07:00
Rintaro Ishizaki
574d39bcb6 [Parse] Split ParserPosition declaration to dedicated header file 2017-12-09 13:58:50 +09:00
Rintaro Ishizaki
07957070cd [CodeComplete] Remove C-style-for specific facilities 2017-08-04 23:25:26 +09:00
Ben Langmuir
534c0cc2cb [code-completion] Generic where clauses
Complete generic parameters and their members inside generic where
clauses on structs, classes, enums, extensions, typealiases, funcs,
subscripts and inits.

Still not handled correctly are associatedtypes.

rdar://problem/20582394
2017-07-31 09:57:00 -07:00
Ben Langmuir
93d22c9ff0 [code-completion] Add a new custom completion context for a for-each sequence
For normal completions it behaves the same as PostfixExprBeginning, but
it provides a hook for clients to provide a custom completion for this
position.  For example, you might want to a x ..< y snippet in this
position.

rdar://problem/29910383
2017-07-19 13:29:36 -07:00
Joe Groff
eb5d006e40 Rename ObjCKeyPathExpr -> KeyPathExpr.
We can use the same general shape of expression for native key paths.
2017-04-04 11:31:15 -07:00
practicalswift
6d1ae2a39c [gardening] 2016 → 2017 2017-01-06 16:41:22 +01:00
practicalswift
797b80765f [gardening] Use the correct base URL (https://swift.org) in references to the Swift website
Remove all references to the old non-TLS enabled base URL (http://swift.org)
2016-11-20 17:36:03 +01:00
Doug Gregor
814a08a5da [IDE] Code completion for Objective-C #keyPath expressions.
Implement code completion support for Objective-C #keyPath
expressions, using semantic analysis of the partially-typed keypath
argument to provide an appropriate set of results (i.e., just
properties and types).

This implements all of the necessary parts of SE-0062 / SR-1237 /
rdar://problem/25710611, although at some point I'd like to follow it
up with some warnings to help migrate existing string literals to
2016-05-21 22:28:51 -07:00
Alex Hoppen
a0a74aeb46 SE-0064 / SR-1239: Code completion for #selector of property getters/setters.
Implement basic code completion support for #selector with property
getters/setters. The vast majority of this implementation comes from
Alex Hoppen (@ahoppen), with only a handful of my own tweaks. Alex has
more interesting ideas on improving this that I wasn't quite ready to
commit to, so this is more basic than the overall goal.
2016-05-11 23:03:37 -07:00
Xi Ge
9ff84e145d [CodeCompletion] For submodules, also use ASTContext to collect their visibility. 2016-02-10 13:03:17 -08:00
Jacob Bandes-Storch
4a6046e8c3 [Code completion] Fix InObjCSelectorExprRAII destructor from f5cb115 2016-02-03 01:00:51 -08:00
Doug Gregor
f5cb1151c1 [Code completion] Code complete compound function names within #selector.
When we're code completing a postfix or dot expression inside the
subexpression of an #selector expression, prefer compound function
names. This helps us write, e.g.,

  #selector(UIView.

and get completions such as "insertSubview(_:aboveSubview:)". Fixes
rdar://problem/24470075.
2016-02-02 16:06:32 -08:00
Xi Ge
0f4e7a5ea5 [CodeCompletion] Add code completion for where clauses. rdar://24245022
When completing at "extension A where #^HERE^#", we suggest the generic params of A to users.
2016-01-19 14:17:15 -08:00
practicalswift
ca92efc8e6 Use consistent formatting of header comments.
Correct format:
```
//===--- Name of file - Description ----------------------------*- Lang -*-===//
```

Notes:
* Comment line should be exactly 80 chars.
* Padding: Pad with dashes after "Description" to reach 80 chars.
* "Name of file", "Description" and "Lang" are all optional.
* In case of missing "Lang": drop the "-*-" markers.
* In case of missing space: drop one, two or three dashes before "Name of file".
2016-01-04 23:00:53 +01:00
Zach Panzarino
e3a4147ac9 Update copyright date 2015-12-31 23:28:40 +00:00
Ben Langmuir
04138e2cd0 [CodeCompletion] Add a new StmtOrExpr code completion kind
We want to distinguish keywords that are only valid at
statement/declaration context from those valid in any expression.
2015-11-02 13:27:34 -08:00
Xi Ge
6c983366cc [CodeComplete] Show #available completion only in guard and if statements. rdar://23228191
Swift SVN r32893
2015-10-26 20:54:00 +00:00
Xi Ge
0f881f5ad7 [CodeComplete] Add code completion for Clang sub-modules at import decls. rdar://23244877
e.g. completing at "import Foundation.<HERE>" should give the list of the submodules of Foundation.

Swift SVN r32852
2015-10-24 00:22:25 +00:00
Xi Ge
afe90ff3c2 [CodeComplete] Suggested by Ben, deliver #available completion after # token and add placeholder to represent platform names.
Swift SVN r32847
2015-10-23 19:49:57 +00:00
Ben Langmuir
dc910fe53b [CodeCompletion] Handle sequence expression where the LHS type-checks
Now we can handle simple cases like
  1 + 1 == 2 <here>

and correctly suggest both + on the 2 and || on the boolean. When the
LHS doesn't type-check we fallback to using only the operand immediately
to the left.

Swift SVN r32489
2015-10-07 07:30:11 +00:00
Ben Langmuir
f969a9941b [CodeCompletion] Handle simple cases of space in front of postfix completions
This is pretty crude, but handles the common cases of there being 0 or 1
space between the LHS and an operator completion.

Swift SVN r32472
2015-10-06 23:35:39 +00:00
Xi Ge
dfc48c8aee [CodeComplete] Add type relation descriptor when completing return statement. rdar://22788321
Swift SVN r32125
2015-09-21 21:18:26 +00:00
Xi Ge
d4922f3bd4 Update to more meaningful param name.
Swift SVN r31910
2015-09-12 00:54:05 +00:00
Xi Ge
1cb84686d4 [CodeComplete] Preserve call expr when code completion token appears in the first arg.
Swift SVN r31909
2015-09-12 00:28:28 +00:00
Xi Ge
ec4e469062 [CodeComplete] Introduce code completion expr to better preserve the context of the code completion token in ASTs.
Swift SVN r31908
2015-09-11 22:59:12 +00:00
Xi Ge
ef3b45871b [CodeComplete] Complete arguments of call expressions.
When users invoke code completion at an argument position, we suggest argument names,
if required however not specified, or a list of argument values. These values are annotated
with their type relation to the expected argument types, so that
Xcode can prioritize those values that apply over those that do not.
This also fixes: rdar://21727063

Swift SVN r31505
2015-08-26 22:01:25 +00:00
Xi Ge
c33e3efe59 [CodeComplete] Complete the right hand side of assignment expressions.
When users complete the right-hand side of an assignment expression, we only
show the results whose types are convertible to those of the left-hand side.

Swift SVN r31357
2015-08-20 01:35:30 +00:00
Xi Ge
40a9d61103 [CodeComplete] when completing unresolved members, we also perform name lookups for enum elements, var decls and nominal types in addition to functions.
fixes: rdar://22282057, rdar://22282116, rdar://22282224, and rdar://22282278

Swift SVN r31274
2015-08-17 21:01:54 +00:00
Xi Ge
a450a08723 [CodeCompletion] Collect the identifiers appearing before unresolved members.
We can use these identifiers to perform manual look up.

Swift SVN r31250
2015-08-14 21:16:41 +00:00
Xi Ge
0bab23961a [CodeComplete] Refine the code completion results for unresolved members by using constraint solver.
Before this commit, for unresolved members, code completion suggests all visible enum elements
 and option set types. To refine the results, this commit uses constraint solver to infer
the type of unresolved members by analyzing parental expressions. If the solver has solutions,
we complete the unresolved member, otherwise abort.
rdar://16659653

Swift SVN r31195
2015-08-13 00:19:58 +00:00
Xi Ge
0df10311a0 [CodeCompletion] Add the initial support for unresolved members.
This commit completes an unresolved member with all visible enum elements.
We need future work to reduce the list to those that are guaranteed to be
resolved under the current context.

Swift SVN r31063
2015-08-06 23:15:14 +00:00
Chris Willmore
7f12c9ffd5 [CodeCompletion] Add the initial support for code completing import declaration.
When a user invoke code completion after import keywords, the names of
visible top level clang modules were recommended for finishing the import decl.

(Undoing revert r30961 of r30957, which just required lockstep commit to
SourceKit -- cwillmore)

Swift SVN r30962
2015-08-03 21:08:32 +00:00
Chris Willmore
e4d1ac9c24 Revert "[CodeCompletion] Add the initial support for code completing import declaration."
This reverts r30957 because it broke the following tests on Jenkins:

    SourceKit :: CodeComplete/complete_open.swift
    SourceKit :: CodeComplete/complete_test.swift

<rdar://problem/22120345> swift-incremental-RA #8289 failed to build

Swift SVN r30961
2015-08-03 21:04:46 +00:00
Xi Ge
5e0014bcc4 [CodeCompletion] Add the initial support for code completing import declaration.
When a user invoke code completion after import keywords, the names of
visible top level clang modules were recommended for finishing the import decl.

Swift SVN r30957
2015-08-03 20:02:17 +00:00
Xi Ge
c783def2f5 [CodeCompletion] Add code completion for platform names inside #available() condition.
The code for generating the code completion string reuses that of the @available attribute.
rdar://21467109

Swift SVN r30346
2015-07-18 00:10:37 +00:00
Ben Langmuir
882959b60d [CodeCompletion] Remove incorrect special-casing for throw/catch
It's not okay to filter to only ErrorType results, since we may be
trying to chain to an error type result foo.bar.getError().  And the
existing logic had no way to handle results from other modules, so we
were missing key results like 'NSError'.

Eventually we'll want to bring back something like this that handles all
modules, but as a way to bump the priority of ErrorType results rather
than to filter out everything else.

rdar://problem/20985515

Swift SVN r28716
2015-05-18 19:00:04 +00:00
Ted Kremenek
62feb5c949 Change @availability to @available.
This came out of today's language review meeting.
The intent is to match #available with the attribute
that describes availability.

This is a divergence from Objective-C.

Swift SVN r28484
2015-05-12 20:06:13 +00:00
Xi Ge
6f43e545fb [CodeCompletion] Auto-completing the throw statement.
When the code completion token appears after throw keyword,
a set of visible decls and instances conforming _ErrorType are
recommended as completion.

Swift SVN r26565
2015-03-25 23:46:26 +00:00
John McCall
a0a16d78d2 Implement the do/catch statement. Tests to follow.
This patch also introduces some SILGen infrastructure for
dividing the function into "ordinary" and "postmatter"
sections, with error-handling-like stuff going into the
final section.  Currently, this is largely undermined by
SILBuilder, but I'm going to fix that in a follow-up.

Swift SVN r26422
2015-03-23 02:08:26 +00:00
Xi Ge
df187f7280 [CodeCompletion] Address Dmitri's comments on r26230
Swift SVN r26270
2015-03-18 18:53:34 +00:00
Xi Ge
a83a8e4f34 [CodeCompletion] avoid duplicating keywords.
When a developer auto-completes an override function,
we collect the keywords that have already been specified
by the developer, so that the code completion strings do
not duplicate them.
rdar://16738036

Swift SVN r26230
2015-03-17 20:35:56 +00:00
Xi Ge
48ba44dd2c [CodeCompletion] Fxing Dmitri's review comments
Swift SVN r25965
2015-03-10 22:50:13 +00:00
Xi Ge
c0bf1f54ff [CodeCompletion] Further support the context-sensitivity of
auto-completing @attributes. By delaying the handling of code completion token after the entire decl being parsed, we know
what are the targets of the attribute to finishe, thus, only suggesting those applicable attributes.

Swift SVN r25938
2015-03-10 18:40:39 +00:00
Xi Ge
32e9a0aca7 [CodeCompletion] Making the code completion of attributes
context-sensitive. The first step is to recommend parameter-applicable
attributes only when the code completion token is found inside a
param decl.

Swift SVN r25810
2015-03-06 23:20:17 +00:00
Xi Ge
f962814017 [CodeCompletion] address Jordan's comments about filtering
out non-usable attributes in code completion strings.

Swift SVN r25786
2015-03-05 21:58:29 +00:00
Xi Ge
566e54a81c [CodeCompletion] Supporting auto-completion of declaration attribute keywords. When a
developer inputs @, the code completion engine recommends built-in attributes.

Swift SVN r25785
2015-03-05 19:35:27 +00:00
Xi Ge
5a8bb8ca9b [CodeCompletion] Extend code completion to decl attributes. As the first
step to achieve this goal, this change allows the first parameter of
@availability to be completed with either one of the following four
platforms: *,  iOS, iOSApplicationExtension, and OSX.
rdar://19541135

Swift SVN r25703
2015-03-03 03:21:46 +00:00
Dmitri Hrybenko
e36baf4123 Code completion: add basic support for completing overriding decls
rdar://16539292


Swift SVN r16755
2014-04-24 15:59:05 +00:00