Commit Graph

1315 Commits

Author SHA1 Message Date
Sonny Falk
d2e4115556 [IDE/CodeCompletion] Don't include text annotation chunks in the name.
Leading paren in constructor patterns should be included in the description
text, but not in the name.

This addresses the first part of <rdar://problem/17004638>.

Swift SVN r19114
2014-06-24 01:22:24 +00:00
Jordan Rose
727a7eb77a Attributes: Use class names in the DAK_* enum instead of attribute spellings.
This allows for single attributes that can be spelled multiple ways.
No functionality change.

Swift SVN r18993
2014-06-18 23:28:28 +00:00
Bob Wilson
9ab1136ba8 Update error_code usage to match llvm trunk.
LLVM's system_error.h has been changed to forward to the standard
version of the same. Update usage for the minor API changes that this
entails.

Based in part on a patch by Justin Bogner.

Swift SVN r18832
2014-06-12 19:48:39 +00:00
Dmitri Hrybenko
a83eb20500 Code completion: skip parameters that are defaulted to either of __FILE__,
__LINE__, __COLUMN__, or __FUNCTION__

rdar://16906142


Swift SVN r18746
2014-06-09 15:47:40 +00:00
Dmitri Hrybenko
d148917e00 Code completion for overrides: don't offer 'override override func'
in a sub-sub-class

rdar://17181252


Swift SVN r18744
2014-06-09 14:49:40 +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
Dmitri Hrybenko
550232536d Code completion: don't crash when the user is trying to complete attributes
rdar://17033622


Swift SVN r18638
2014-05-26 19:52:36 +00:00
Argyrios Kyrtzidis
95bd9e1d28 [AST/IDE] Centralize the logic to determine if a symbols is a 'private' stdlib one and hide them more extensively.
-Hide vars that have a private type.
-Hide functions that have a parameter with private type or a parameter name with leading underscore.
-Minor change in StringUTF16.swift to avoid printing "func generate() -> IndexingGenerator<_StringCore>".

rdar://17027294

Swift SVN r18623
2014-05-25 03:49:02 +00:00
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