Commit Graph

136 Commits

Author SHA1 Message Date
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
Dmitri Hrybenko
547e1b5874 Code completion: print non-inout '@unchecked' optional arguments as normal
optionals, because the difference is not important for the caller.

rdar://16576739


Swift SVN r16212
2014-04-11 10:58:07 +00:00
Dmitri Hrybenko
06be7781f8 Fix code completion for 'inout' by completing '&' in the function argument
Partially addresses rdar://15999689


Swift SVN r14299
2014-02-24 12:48:56 +00:00
Dmitri Hrybenko
07d3fc3505 Coding style fix
Swift SVN r13574
2014-02-06 09:27:56 +00:00
Chris Lattner
79cbda7f88 convert a heck of a lot of tests to use the new inout syntax (yay for regex's),
and implement code completion and ast-printer support for the new syntax.



Swift SVN r13562
2014-02-06 05:35:36 +00:00
Dmitri Hrybenko
b7d3a23518 Code completion result cache: use libcache
Swift SVN r9653
2013-10-24 20:59:28 +00:00
Dmitri Hrybenko
8d8b60f973 Code completion: implement result caching per-imported module across muptiple
ASTContexts

This introduces swift::ide::CodeCompletionCache, which is a persistent code
completion result cache.

Right now REPL happens to use it (try importing Cocoa and doing code
completion), and the difference is noticeable.  But completion in REPL is
still slow, because Cocoa goes through the AST Verifier on every completion
(for unknown reasons).

This commit does not implement cache invalidation yet, and it does not use
libcache to evict cache entries under memory pressure.

This commit also introduces two regressions:
- We get fewer Cocoa results that expected.  Module::isModuleVisible in Clang
does not incorrectly reports that that ObjectiveC.NSObject submodule is not
visible from Cocoa.

- We are not implementing the decl hiding rules correctly.  We used to rely on
visible decl lookup to do it for us, but now we have a different data structure
we have real decls from the current module and we have a text-only cache, so we
are forced to reimplement this part of name lookup in code completion.


Swift SVN r9633
2013-10-24 02:13:34 +00:00
Dmitri Hrybenko
55d7744c76 Code completion: don't copy static strings to a separate allocator
Swift SVN r9486
2013-10-18 18:16:14 +00:00
Dmitri Hrybenko
4ce90a83a9 Code completion: move result builder to a private header
Swift SVN r9485
2013-10-18 18:13:23 +00:00