Commit Graph

894 Commits

Author SHA1 Message Date
Denis Vnukov
652e39f92b Fixing a possible race in CodeCompletionCacheImpl::getResults(...) causing V to have no value.
Swift SVN r24076
2014-12-22 21:04:35 +00:00
Argyrios Kyrtzidis
d039fb6369 [AST] Move ide::findUnderlyingClangModule() to Module::findUnderlyingClangModule() so that the ASTPrinter can use it.
Swift SVN r23691
2014-12-04 20:17:03 +00:00
Argyrios Kyrtzidis
972d460677 [IDE] Adjust CodeCompletionString::getFirstTextChunkIndex() to consider chunks containing
the parameters or the left parent for a constructor call.

Fixes crash in SourceKit test.

Swift SVN r22519
2014-10-04 04:47:59 +00:00
Jordan Rose
3fcdfd40e9 Remove the "swift/Basic/Optional.h" header.
llvm::Optional lives in "llvm/ADT/Optional.h". Like Clang, we can get
Optional in the 'swift' namespace by including "swift/Basic/LLVM.h".

We're now fully switched over to llvm::Optional!

Swift SVN r22477
2014-10-02 18:51:45 +00:00
Jordan Rose
042569a3be Optional: Replace uses of Nothing with None.
llvm::Optional (like Swift.Optional!) uses None as its placeholder value,
not Nothing.

Swift SVN r22476
2014-10-02 18:51:42 +00:00
Jordan Rose
d3a9e58133 Use Nothing instead of {} to initialize Optionals.
In preparation for the switch to llvm::Optional, which has an explicit
default constructor.

Swift SVN r22470
2014-10-02 18:51:33 +00:00
Dmitri Hrybenko
006dcecb61 Code completion: always validate typealiases
A shortcut to skip validation if the type is set does not work since the
underlying type might not be set.

No tests since I can not reproduce outside of Xcode.

rdar://18502983

Swift SVN r22428
2014-10-01 15:39:20 +00:00
Doug Gregor
51c1433ddd Add magic "literal" __DSO_HANDLE__ to refer to the DSO handle.
__DSO_HANDLE__ can be used as a callee-side default
argument. Addresses rdar://problem/17878114.


Swift SVN r21440
2014-08-25 16:33:54 +00:00
Dmitri Hrybenko
d02b55b288 Code completion: fix bugs that prevented completion for overrides to work in
extensions

rdar://17654014


Swift SVN r21305
2014-08-20 10:02:37 +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
Sonny Falk
db24ff2380 [IDE/CodeCompletion] Update copyAssociatedUSRs() to walk overridden
declarations exhaustively, including protocol conformances.

Refactor and simplify copyAssociatedUSRs() to copy each USR one by one. 

Manually copy the string array into the sink allocator, to work around
a clang-600 merge failure.

Swift SVN r20910
2014-08-01 19:07:20 +00:00
Sonny Falk
64e5c0b6a6 [IDE/CodeComplete] Add associated USRs to CodeCompletionResult.
If the completion result is a declaration, it contains the USR of the specified declaration and all overridden declarations.

Additional tests on SourceKit side.

This addresses <rdar://problem/17600891>.

Swift SVN r20877
2014-08-01 02:21:02 +00:00
Jordan Rose
9f64db085a Fill out the implementation of AvailabilityAttr.
This includes proper printing support as well as proper platform checking
when seeing if a decl is unavailable. A few other places in the code will
now use AvailabilityAttr::isUnavailable instead of just checking the
is-unavailable-always flag (and not always checking the platform).

No new tests yet because this doesn't include /parsing/ the other fields
of AvailabilityAttr. That will come next, at which point we'll test each
of the cases that has been switched over to use
AvailabilityAttr::isUnavailable.

Part of <rdar://problem/17024498>

Swift SVN r20844
2014-07-31 18:58:17 +00:00
Argyrios Kyrtzidis
fc7dbfe7c8 [IDE] Remove unavailable declarations from code-completion results.
rdar://17556494

Swift SVN r20815
2014-07-31 06:14:03 +00:00
Argyrios Kyrtzidis
3175251bb1 [IDE] Handle annotation of clang submodule imports properly.
rdar://17780613

Swift SVN r20595
2014-07-26 20:58:19 +00:00
Jordan Rose
a2af37a19b Split PrintOptions::printEverything into printEverything and printVerbose.
The former is for debugging, the latter is for detailed presentation to users.
swift -print-ast will continue using printEverything, as will swift-ide-test,
but all other features should use printVerbose.

Swift SVN r20432
2014-07-23 22:28:55 +00:00
Joe Groff
623aba1786 Encapsulate Substitution's state.
Expose Substitution's archetype, replacement, and conformances only through getters so we can actually assert invariants about them. To start, require  replacement types to be materializable in order to catch cases where the type-checker tries to bind type variables to lvalue or inout types, and require the conformance array to match the number of protocol conformances required by the archetype. This exposes some latent bugs in the test suite I've marked as failures for now:

- test/Constraints/overload.swift was quietly suffering from <rdar://problem/17507421>, but we didn't notice because we never tried to codegen it.
- test/SIL/Parser/array_roundtrip.swift doesn't correctly roundtrip substitutions, which I filed as <rdar://problem/17781140>.

Swift SVN r20418
2014-07-23 18:00:38 +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
Dmitri Hrybenko
b0c3a56c96 Code completion: fix some type checking issues of closures
Completely disable the AST transformation for single-expression closures.  When
this transformation picks up an incomplete expression, the resulting AST is
almost guaranteed to have type mismatches, and the type checker just marks
everything with error types.

rdar://17193319 rdar://17086137


Swift SVN r20153
2014-07-18 14:49:34 +00:00
Dmitri Hrybenko
8234c70f88 Code completion: fix delayed parsing of closures
The delayed parsing was in place, but the expressions were being thrown away by
"recovery" in the parser.

rdar://16274593


Swift SVN r20151
2014-07-18 11:43:38 +00:00
Dmitri Hrybenko
3f4436a272 Code completion: add simplistic support for keywords
rdar://15992120


Swift SVN r20082
2014-07-17 12:02:21 +00:00
Dmitri Hrybenko
082d79b490 Code completion: include __FUNCTION__ in results
rdar://17679174


Swift SVN r20081
2014-07-17 10:23:23 +00:00
Jordan Rose
67536dbb8a Respect access control in visible decl lookup (and code completion).
<rdar://problem/17648922>

Swift SVN r19963
2014-07-14 23:02:41 +00:00
Chris Lattner
fe95f81397 introduce a new 'DeclModifier' flag on attributes, which mark that the
attribute is a "modifier" of a decl, not an "attribute" and thus shouldn't
be spelt with an @ sign.  Teach the parser to parse "@foo" but reject it with
a nice diagnostic and a fixit if "foo" is a decl modifier.

Move 'dynamic' over to this (since it simplifies some code), and switch the
@optional and @required attributes to be declmodifiers (eliminating their @'s).



Swift SVN r19787
2014-07-10 05:49:10 +00:00
Chris Lattner
35dcc3aa10 Move the @optional attribute to being a SIMPLE_DECL_ATTR, which
simplifies a bunch of code, makes them more consistent with the
other attributes, and is generally the newfangled way to do things.



Swift SVN r19779
2014-07-10 04:34:00 +00:00
Doug Gregor
2f3f6acf21 Make "true" and "false" Boolean literal constants for the BooleanLiteralConvertible protocol.
Introduce the new BooleanLiteralConvertible protocol for Boolean
literals. Take "true" and "false" as real keywords (which is most of the
reason for the testsuite churn). Make Bool BooleanLiteralConvertible
and the default Boolean literal type, and ObjCBool
BooleanLiteralConvertible. Fixes <rdar://problem/17405310> and the
recent regression that made ObjCBool not work with true/false.


Swift SVN r19728
2014-07-09 16:57:35 +00:00
Ben Langmuir
dfbd8b794f Don't desugar paren type when code-completing func params
We want to complete foo(p: (Int, Int)) as foo({#(p): (Int, Int)#}), not
as foo({#Int#}, {#Int#}).  Also, make initializers go through the
function parameter code path rather than the enum one, since we don't
want to recursively find parameters in tuples.

<rdar://problem/17461862>

Swift SVN r19514
2014-07-03 15:45:05 +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
Ben Langmuir
a2aabbe575 Fix assertion failure completing anonymous default arguments
Parameters may be nameless VarDecls. Instead of asserting otherwise,
just don't provide a completion for that decl.

Swift SVN r19421
2014-07-01 18:51:23 +00:00
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