Commit Graph

113 Commits

Author SHA1 Message Date
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
Dmitri Hrybenko
236c581de7 Code completion: complete "?.member" on T?, and ".member" on @unchecked T?
In order for Xcode to use these completions, we complete "?.member" when the
user has typed "anOptional.", but we also say that in order to apply this
result, N bytes to the left of the cursor should be erased first.

rdar://16579657 rdar://15233283


Swift SVN r16409
2014-04-16 10:50:14 +00:00
Dmitri Hrybenko
da41b2e766 Code completion: provide results for initializers after the left paren:
class A {
    init(a: Int) {}
  }
  A(#^HERE^#

In its current state, this is a hack that I am not proud of.  There is
potential here to provide such completions for all function calls:

  class A {
    func foo(a: Int) {}
    func foo(a: Double) {}
  }
  A().foo(#^HERE^#

but this requires code completion doing its own name lookup, since the type
checker will give us an error type due to ambiguity of overloaded functions.

Type checker also sometimes gives up in cases like these:

  struct A {
    func foo() {}
  }
  A().foo

which is understandable, since we disallow partial applications of functions on
values, but returning the correct type here is useful for code completion.

rdar://16597372


Swift SVN r16367
2014-04-15 12:05:05 +00:00
Dmitri Hrybenko
238d898a0d Code completion for enums: model completion in switch case as a separate kind
of completion.  This approach (rather than SourceLoc tricks) better reflects
the intent and allows us to fix the rest of testcases.


Swift SVN r9557
2013-10-21 20:58:23 +00:00
Dmitri Hrybenko
63c264446d Code completion for enums: complete "switch e { case .#^A^#"
Swift SVN r9551
2013-10-21 18:53:31 +00:00
Dmitri Hrybenko
de6a0a0f8c Code completion: complete references to enum elements in switch statements when
we have enough type context to find the correct enum


Swift SVN r9439
2013-10-17 02:09:49 +00:00
Dmitri Hrybenko
2415cd9028 Code completion: rename a variable for consistency with AST node name
Swift SVN r9425
2013-10-16 22:28:26 +00:00