Commit Graph

58 Commits

Author SHA1 Message Date
Ben Langmuir
8f9299cc97 [CodeCompletion] Add assignment to experimental operator completion
When the LHS is an lvalue/assignable tuple and there is no leading
sequence of binary expressions.

It's a bit hacky right now since we don't have a good way to
differentiate general pattern completions from builtin operators.

rdar://problem/23209683
2016-03-02 18:21:37 -08:00
Doug Gregor
f1aac08bda [Code completion] Only escape var/let/inout in call argument lists.
Argument labels don't need to be escaped in calls, so don't escape
them in code completions for calls. Fixes <rdar://problem/24460721>.
2016-02-02 13:43:27 -08:00
practicalswift
1339b5403b Consistent use of header comment format.
Correct format:
//===--- Name of file - Description ----------------------------*- Lang -*-===//
2016-01-04 13:26:31 +01:00
Zach Panzarino
e3a4147ac9 Update copyright date 2015-12-31 23:28:40 +00:00
practicalswift
22e10737e2 Fix typos 2015-12-26 01:19:40 +01:00
ken0nek
fcd8fcee91 Convert [Cc]an not -> [Cc]annot 2015-12-23 00:55:48 +09:00
practicalswift
8ab8847684 Fix typos. 2015-12-16 22:09:32 +01:00
Xi Ge
827ea69fd3 [CodeComplete] Mark already-imported modules as not-recommended. rdar://23209864
When auto-completing import decls, we should prioritize not-yet imported modules
over already-imported modules. To do so, we mark the latter with not-recommended tag.
2015-11-10 11:57:29 -08:00
Xi Ge
22ba61bea1 Reapply "[CodeComplete] Teach code completion engine to recognize and manifest @recommended and @recommendedover." after fixing a linux failure. (thanks, Dmitri) 2015-11-09 16:36:25 -08:00
Xi Ge
0a82a6fa41 Revert "[CodeComplete] Teach code completion engine to recognize and manifest @recommended and @recommendedover."
This reverts commit 448a23c9af for failing linux bots.
2015-11-06 19:06:45 -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
Xi Ge
448a23c9af [CodeComplete] Teach code completion engine to recognize and manifest @recommended and @recommendedover.
Similar with @keyword, manifesting @recommended and @recommendedover content in code
completion results can help IDE users to choose the right API in the long candidate list.
This commit extract these two attributes from Clang doc comments and insert/cache them in
code completion results.

rdar://23101030 and rdar://23101029
2015-11-06 18:11:17 -08:00
Xi Ge
c022c9925c [CodeComplete] Start to support keyword-based code completion. rdar://23101032
Conventionally, code completion results are matched with user input solely by
names. However, names are limited in expressiveness. From this comments, we start to
decorate code completion results with @keywords fields extracted from Clang doc comments.
These fields are added by API authors to comment the decl with information that
is not manifested clear enough through names. Code completion users' typing of the
keyword leads to the corresponding code completion results being selected as well.
Keywords can be arbitrarily long and can be multiple.

For instance, a function called "index()" has "@keyword find" in its doc comment.
Users' typing of "find" leads to "index()" being selected in the code completion list.
2015-11-05 15:36:55 -08:00
Ben Langmuir
1992bb08b2 [CodeCompletion] Add keyword kind to code completion results
This lets us reliably distinguish keywords we care about without
resorting to string comparisons.  Also driveby fix throw to be a
statement keyword.
2015-11-02 13:27:34 -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
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
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
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
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
Ben Langmuir
d871c9a529 [CodeCompletion] Split code completion operator kind out
...into separate prefix, postfix and infix operators. Also incidentally
make the whitespace around operators special so we can decide when to
skip over it. Tested in SourceKit.

Swift SVN r32468
2015-10-06 22:52:16 +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
3865a6a037 [CodeComplete] Add type relation enum to the code completion results.
We use an enum to describe the relationship between a code completion result
and the expected type at the code completion site. We can use this relationship
to prioritize candidates on the SourceKit side.

Swift SVN r31371
2015-08-20 22:57:53 +00:00
Ben Langmuir
7fcd0eeae5 [CodeCompletion] Add 'throws' and 'rethrows' to call descriptions
Completions for calling functions will now show 'throws' in the
description text so that users can differentiate throwing and
non-throwing calls. We don't insert this into the source text, since
it's not part of the call syntax.

rdar://problem/20978869

Swift SVN r28791
2015-05-19 21:46:20 +00:00
Doug Gregor
b8995b0aa3 Transform the Module class into ModuleDecl.
Modules occupy a weird space in the AST now: they can be treated like
types (Swift.Int), which is captured by ModuleType. They can be
treated like values for disambiguation (Swift.print), which is
captured by ModuleExpr. And we jump through hoops in various places to
store "either a module or a decl".

Start cleaning this up by transforming Module into ModuleDecl, a
TypeDecl that's implicitly created to describe a module. Subsequent
changes will start folding away the special cases (ModuleExpr ->
DeclRefExpr, name lookup results stop having a separate Module case,
etc.).

Note that the Module -> ModuleDecl typedef is there to limit the
changes needed. Much of this patch is actually dealing with the fact
that Module used to have Ctx and Name public members that now need to
be accessed via getASTContext() and getName(), respectively.

Swift SVN r28284
2015-05-07 21:10:50 +00:00
Xi Ge
3c6419161e [CodeCompletion] Excape keywords.
When auto-completing a argument whose name is a reserved keyword, we escape
it by surrounding backticks.
rdar://18189510

Swift SVN r26464
2015-03-24 00:42:23 +00:00
Ben Langmuir
ece29ccfa4 Add a module name field to code completion results
For decls, we get the most specific submodule from clang modules.  For
macros, we don't yet have a way to get this information, since the
mapping from module ID to submodule is burried in the ClangImporter.
Having submodule information for macros would also help reduce the space
cost of storing the module names, since we would hit the single-element
module name cache more often.

There is no special handling of imported headers, which currently come
through with their internal clang module name '__ObjC'.  Possibly these
should be treated as part of the current module.

A future commit will add the module name to swift-ide-test's output and update
the tests.

Swift SVN r26260
2015-03-18 16:14:11 +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
71a3d88cfd Fixing indention on method signature.
Swift SVN r25765
2015-03-04 21:21:56 +00:00
Xi Ge
a740b8f156 Addressing Jordan's comments about conventions.
Swift SVN r25764
2015-03-04 21:14:04 +00:00
Xi Ge
e71588a414 [CodeCompletion] The second step to complete @availability. Adding the second
or the later parameters in this attribute. rdar://19541135

Swift SVN r25762
2015-03-04 20:55:30 +00:00
Xi Ge
1b6808a809 [CodeCompletion] When code completing a parameter whose type
is autoclosure, we show the the parameter is of the output
type of the closure, instead of the closure itself.
rdar://19715527

Swift SVN r25590
2015-02-27 02:48:58 +00:00
Xi Ge
f40003b0b1 Disallow the insertion of attributes such as @autoclosure in code complete string. fixing rdar://19710757
Swift SVN r25523
2015-02-25 00:52:16 +00:00
Dmitri Hrybenko
6a5f59831b Code completion: include access control keywords in override completion
When trying to implement deduplication of results, found and fixed an issue
with loose checks for generic overload checking.

rdar://17995317


Swift SVN r21276
2014-08-19 11:00:10 +00:00
Dmitri Hrybenko
045eca49ef Code completion: when preparing a pattern for closure expansion in function
parameters, don't consider autoclosures to be expandable

rdar://17842781


Swift SVN r21006
2014-08-04 12:17:33 +00:00
Dmitri Hrybenko
21dd66b6cc Code completion: don't adjust implicitly unwrapped optional types to normal
optionals

rdar://17732126


Swift SVN r20212
2014-07-19 18:41:41 +00:00
Sonny Falk
efa1ff8ab4 [IDE/CodeComplete] Add CallParameterClosureType chunk, which resolves
optional & alias types for closure type parameters.

This allows code completion placeholder expansion to properly expand
closure parameters utilizing a typealias, e.g. dispatch_block_t.

Update and add test for the above.

Work for <rdar://problem/15860693>.

Swift SVN r20206
2014-07-19 03:18:29 +00:00
Ben Langmuir
b31a6d125d Preserve vararg... syntax in code completions
Int... should now be shown as Int... rather than [Int].

Swift SVN r19464
2014-07-02 15:05:59 +00:00
Dmitri Hrybenko
b0eb481bff Code completion: display correct syntax and type when using an @optional member
on a value


Swift SVN r18742
2014-06-09 13:06:18 +00:00
Sonny Falk
a2680240c0 [IDE/CodeCompletion] Teach code completion to display the local parameter name
if there's no parameter API name. This is for display purposes only.
Update all relevant tests accordingly.
This addresses <rdar://problem/16768768>.

For example:
  class X {
    func f(a: Int, b: Int) { }
  }

Would previously display like this in code completion in Xcode:
  f(<#Int#>, b: <#Int#>)

The local parameter name, while not API, often still conveys meaning
to the user. So it's now included like this:
  f(<#a: Int#>, b: <#Int#>)

Swift SVN r18403
2014-05-19 08:31:10 +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
Argyrios Kyrtzidis
8f2b5a0458 [IDE/CodeCompletion] Remove the space before a BraceStmtWithCursor chunk, if we are going to ignore it then the space is noise.
Swift SVN r17401
2014-05-04 21:21:12 +00:00
Argyrios Kyrtzidis
5f24181015 [IDE/CodeComplete] Create a separate chunk for the 'override' keyword.
Swift SVN r17387
2014-05-04 17:29:59 +00:00
Argyrios Kyrtzidis
1a7e6485f4 [IDE/CodeCompletion] For override completions, separate the introducer keywords like "override func" in
a new chunk kind, so that we can sort/filter based on the name of the function.

Swift SVN r17369
2014-05-04 07:20:57 +00:00
Ted Kremenek
050fd53af7 Rename UncheckedOptional to ImplicitlyUnwrappedOptional.
Swift SVN r17232
2014-05-02 06:13:57 +00:00
Dmitri Hrybenko
0cb8ddd213 Code completion for overrides: use a special chunk BraceStmtWithCursor for
braces

This allows clients to process it in a special way, for example, to indent the
resulting code.


Swift SVN r16884
2014-04-26 17:52:16 +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
0aeb095416 Code completion: change the spelling of DynamicLookupMethodCallTail chunk to "!"
This is the "!" in method calls on AnyObject:

  var a: AnyObject = get()
  a.doFoo!()

rdar://15233283


Swift SVN r16366
2014-04-15 09:36:50 +00:00
Dmitri Hrybenko
677d352ddd Remove no-op and unused code from code completion that I have no idea about
Swift SVN r16365
2014-04-15 09:07:30 +00:00