Commit Graph

1357 Commits

Author SHA1 Message Date
Argyrios Kyrtzidis
4e6660388a [IDE/CodeCompletion] Hide internal symbols from the stdlib overlays as well.
rdar://16953431

Swift SVN r18524
2014-05-21 21:51:55 +00:00
Sonny Falk
795be8545b [IDE/CodeCompletion] Make addParamPatternFromFunction() iterate over inputType
instead, so it picks up substituted types. BodyParamPatterns is now only
used for the local non-api parameter name. 
Consolidate the two variations of addFunctionCallPattern() into one function.
Update the tests accordingly.
This addresses <rdar://problem/16956363>.

Swift SVN r18481
2014-05-21 05:47:10 +00:00
Argyrios Kyrtzidis
973beb0ae3 [IDE/CodeCompletion] Fix crash with code-completion when using -import-objc-header.
Swift SVN r18444
2014-05-20 04:05:52 +00:00
Argyrios Kyrtzidis
1e94b0f0f7 Revert "[IDE/CodeCompletion] Minor enhancement, abort all-visible-modules visitation if we already handled that particular ImportedModule."
This reverts commit r18426.
Per feedback from Jordan this does the wrong thing because it aborts the entire visitation, not just the current visitation path.

Swift SVN r18433
2014-05-19 22:25:11 +00:00
Argyrios Kyrtzidis
b59f9882ee [IDE/CodeCompletion] Minor enhancement, abort all-visible-modules visitation if we already handled that particular ImportedModule.
Swift SVN r18426
2014-05-19 18:32:02 +00:00
Dmitri Hrybenko
12ecf4b3f6 Code completion: 80 cols and add 'const'
Swift SVN r18406
2014-05-19 09:43:32 +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
Dmitri Hrybenko
fc9d546d2e Code completion: don't show internal SIL attributes in types of weak and
unowned variables

rdar://16849171


Swift SVN r18357
2014-05-18 21:50:13 +00:00
Argyrios Kyrtzidis
17f7684a20 [IDE/CodeCompletion] Make collecting and caching the global completion results more efficient.
We already don't try to detect and filter out shadowed declarations due to performance reasons, so cache the visible declarations contained
in a specific ImportedModule and collect all the results by recursing via calling Module::forAllVisibleModules().

This is more efficient because we avoid doing the work to collect all the global results for both Cocoa and AppKit, and we save on memory usage for the cache.
This also fixes a correctness issue where if you imported a module that was transitively imported by a previous import (e.g. Cocoa and AppKit) you would get duplicate results.

For this test case:

----------
import Cocoa
import AppKit
import Foundation

func foo() {
  <ESC>
}
----------

We go from
  - 7.05 secs to 1.43 secs to collect the results
  - 9.0 secs to 2.4 to ultimately show them in Xcode for first-time invocation.

Swift SVN r18344
2014-05-18 20:01:29 +00:00
Dmitri Hrybenko
49d10f7af7 Code completion: hide stdlib-private declarations
Swift SVN r18336
2014-05-18 17:37:39 +00:00
Dmitri Hrybenko
88dde39473 Code completion: fix use-after-free
A use-after-free could happen in the following scenario:

- code completion caches results from module A;
- code completion returns cached results -- result set 1;
- module is rebuilt;
- another code completion request arrives, cache is invalidated and re-filled.
  Old results are freed, even though someone could be still using the result
  set.

rdar://16953614


Swift SVN r18329
2014-05-18 16:55:45 +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
Sonny Falk
a19a0d1133 [IDE] Make CodeCompletionContext::sortCompletionResults() sort by full name.
This addresses <rdar://problem/16877804>.

Swift SVN r17991
2014-05-13 02:38:48 +00:00
Dmitri Hrybenko
b47f0e9598 Code completion: constructor and function call patterns: don't add top-level
right after the left paren if the function or constructor requires a keyword
for the first argument

Should significantly clean up code completion for Cocoa constructors.


Swift SVN r17817
2014-05-10 01:03:16 +00:00
Argyrios Kyrtzidis
caf5bc4a4a [IDE/CodeCompletion] Ignore the internal members of Optional, like getLogicValue() and getMirror().
These are not commonly used and cause noise and confusion when showing among the the members of the underlying type.

Swift SVN r17405
2014-05-04 21:45:12 +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
ee289793b0 [IDE/CodeCompletion] CodeCompletionString::getFirstTextChunkIndex() should return the chunk index where
the symbol name begins.

rdar://16712635

Swift SVN r17400
2014-05-04 21:21:07 +00:00
Argyrios Kyrtzidis
a0fa68b072 [IDE/CodeCompletion] Expose the getFirstTextChunk() function via a CodeCompletionString method.
Swift SVN r17388
2014-05-04 17:30:07 +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
Argyrios Kyrtzidis
7f2fa7f97e [IDE] Filter out attributes like @objc and @availability when code-completing overrides.
rdar://16766431

Swift SVN r17366
2014-05-04 05:19:11 +00:00
Ted Kremenek
050fd53af7 Rename UncheckedOptional to ImplicitlyUnwrappedOptional.
Swift SVN r17232
2014-05-02 06:13:57 +00:00
Dmitri Hrybenko
277e6a81b7 Code completion: fix a crash on invalid code
Swift SVN r17035
2014-04-29 14:31:28 +00:00
Doug Gregor
4e4173f2e6 Remove the "separated" declaration syntax <rdar://problem/16742067>.
Swift SVN r16979
2014-04-28 14:44:53 +00:00
Dmitri Hrybenko
df60e7751e Code completion for overrides: don't suggest to override members from outer
nominals in inner nominals


Swift SVN r16890
2014-04-26 20:08:11 +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
2916aebba8 Code completion for overrides: complete constructors
Swift SVN r16882
2014-04-26 16:08:33 +00:00
Dmitri Hrybenko
164b5829ea Code completion for overrides: don't suggest to override members of the current
nominal


Swift SVN r16822
2014-04-25 14:46:58 +00:00
Dmitri Hrybenko
014d42acb0 Remove WIP that I accidentally committed
Swift SVN r16821
2014-04-25 14:45:17 +00:00
Dmitri Hrybenko
a701104732 Code completion: add a test that produces wrong results now
Swift SVN r16820
2014-04-25 14:35:44 +00:00
Dmitri Hrybenko
3ee34efee4 Code completion: complete declarations that are required for declared protocol
conformances

rdar://16539292

This is a hack in visible decl lookup.  The general solution that would also
improve type checker errors would be to make the type checker keep these broken
conformances and syntethize missing declarations to make downstream code type
check.  For that, see:

<rdar://problem/16723339> [QoI] Type checker should not be dropping protocol
conformances explicitly spelled in the source


Swift SVN r16818
2014-04-25 14:03:39 +00:00
Dmitri Hrybenko
35c587aadf Code completion: don't complete associated types on non-metatypes
Swift SVN r16817
2014-04-25 12:46:32 +00:00
Dmitri Hrybenko
f06d124ef9 Code completion: fix crash on invalid protocol conformance
rdar://16723481


Swift SVN r16815
2014-04-25 09:58:44 +00:00
Dmitri Hrybenko
28c2514589 Remove unused member
Swift SVN r16756
2014-04-24 16:00:32 +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
Argyrios Kyrtzidis
9bd10774b0 [IDE/CodeCompletion] Mark a code-completion result as 'not-recommended' if the declaration
that it refers to is unavailable.

rdar://16675550

Swift SVN r16687
2014-04-23 04:26:14 +00:00
Dmitri Hrybenko
2812aba59c Code completion: speed up by more than 2x
... at the cost of correctness, see test changes

This change was suggested by Argyrios.

But we still take 10 seconds to compute completion results for Cocoa.

Swift SVN r16599
2014-04-20 20:03:25 +00:00
Doug Gregor
09797f7f99 Introduce a new declaration node, ParamDecl, for function parameters.
Use this node to capture the argument name and its source location in
the AST. We're only building these in one place at the moment; the
rest will be updated soon.


Swift SVN r16581
2014-04-20 05:23:35 +00:00
Dmitri Hrybenko
70ed107d69 Code completion: extend the hack to complete function call patterns after left
paren to work with method calls on AnyObject and curried function calls


Swift SVN r16412
2014-04-16 13:42:55 +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
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
a98375b286 Cleanup, NFC.
Swift SVN r16211
2014-04-11 10:44:10 +00:00
John McCall
f1180f5e6d in order to work correctly for non-@objc protocols.
Language features like erasing concrete metatype
values are also left for the future.  Still, baby steps.

The singleton ordinary metatype for existential types
is still potentially useful; we allow it to be written
as P.Protocol.

I've been somewhat cavalier in making code accept
AnyMetatypeType instead of a more specific type, and
it's likely that a number of these places can and
should be more restrictive.
When T is an existential type, parse T.Type as an
ExistentialMetatypeType instead of a MetatypeType.

An existential metatype is the formal type
 \exists t:P . (t.Type)
whereas the ordinary metatype is the formal type
 (\exists t:P . t).Type
which is singleton.  Our inability to express that
difference was leading to an ever-increasing cascade
of hacks where information is shadily passed behind
the scenes in order to make various operations with
static members of protocols work correctly.

This patch takes the first step towards fixing that
by splitting out existential metatypes and giving
them a pointer representation.  Eventually, we will
need them to be able to carry protocol witness tables

Swift SVN r15716
2014-04-01 00:38:28 +00:00
Joe Groff
9f7dab725c Make the ASTContext parameter to MetatypeType::get optional for type-checked types.
We can just get it from the instance type, if the instance type has been fully initialized, which is the case except during parsing of type decls when the decls' own types are being formed.

Swift SVN r15598
2014-03-29 02:50:30 +00:00
Joe Pamer
56e2b28b76 Remove more unnecessary semicolons.
Swift SVN r15489
2014-03-26 06:07:06 +00:00
Dmitri Hrybenko
04b9f8c384 Code completion: correctly call type checking routines for a function nested
inside a closure

rdar://16139669


Swift SVN r15453
2014-03-25 14:42:33 +00:00
Jordan Rose
8d35d75ce3 [ClangImporter] Resolve forward class declarations to definitions in Swift.
When we see an unresolved @class in a Clang module, we check the class name
against the classes in the Swift module with the same name.

This unfortunately necessitates putting a reference to the active type checker
into the ClangImporter, because the class in the current Swift module hasn't
been type-checked yet. This is now being used everywhere we do a lookup.

<rdar://problem/16295994>

Swift SVN r15355
2014-03-22 00:19:59 +00:00
Doug Gregor
195fb46e44 Typo correction in a variable name.
Swift SVN r15170
2014-03-17 23:23:55 +00:00
Dmitri Hrybenko
efa2f3b896 Code completion: add brief comments to code completion results
Swift SVN r15059
2014-03-14 17:53:22 +00:00