Commit Graph

1357 Commits

Author SHA1 Message Date
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
Argyrios Kyrtzidis
f0e269f9ce [IDE] Don't repeat the closure type in the name of the completion result.
Swift SVN r25777
2015-03-05 03:45:15 +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
e3d8172788 Use platform to describe attribute
Swift SVN r25711
2015-03-03 06:11:07 +00:00
Xi Ge
41fa84db51 Address code review comments to use
PlatformKinds.def

Swift SVN r25709
2015-03-03 05:33:55 +00:00
Xi Ge
5a8bb8ca9b [CodeCompletion] Extend code completion to decl attributes. As the first
step to achieve this goal, this change allows the first parameter of
@availability to be completed with either one of the following four
platforms: *,  iOS, iOSApplicationExtension, and OSX.
rdar://19541135

Swift SVN r25703
2015-03-03 03:21:46 +00:00
Xi Ge
3d60a205bd Each element in an enum decl was of the type EnumDecl.type-> (type ->) *->
EnumDecl. The EnumDecl.type may confuse swift users, thus show only
(type ->) *-> EnumDecl as the enum element type.
rdar://18460552

Swift SVN r25603
2015-02-27 18:09:57 +00:00
Xi Ge
7f668e7b49 Add isUserAccessible() in Decl to show whether swift users should know such decl exists. For instance, a.storage for lazy var a is a inaccessible decl. An implicit decl is not necessarily inaccessible, for instance, self.
Fixing rdar://18760063

Swift SVN r25556
2015-02-26 19:16:54 +00:00
Denis Vnukov
152df92966 [CodeCompletion] Code Completion String getName should always return non-empty string value for
valid code completions. Code completion tests call and validate getName’s result. 

A minor fix for code completion fro subscripts.



Swift SVN r25101
2015-02-09 22:32:05 +00:00
Jordan Rose
fac5a83bbf Allow capturing super in explicit closures and nested functions.
The previous commit enabled this; now it's just about removing the
restriction in the parser and tightening up code completion.

Using 'super' in a closure where 'self' is captured weak or unowned still
doesn't work; the reference to 'self' within the closure is treated as
strong regardless of how it's declared. Fixing this requires a cascade of
effort, so instead I just cloned rdar://problem/19755221.

rdar://problem/14883824

Swift SVN r25065
2015-02-07 03:56:11 +00:00
Doug Gregor
b642c555be Allow one to change the argument labels of curried function parameters.
Curried function parameters (i.e., those past the first written
parameter list) default to having argument labels (which they always
have), but any attempt to change or remove the argument labels would
fail. Use the fact that we keep both the argument labels and the
parameter names in patterns to generalize our handling of argument
labels to address this problem.

The IDE changes are due to some positive fallout from this change: we
were using the body parameters as labels in code completions for
subscript operations, which was annoying and wrong.

Fixes rdar://problem/17237268.

Swift SVN r24525
2015-01-19 22:15:14 +00:00
Jordan Rose
93a89467b8 [ClangImporter] Hide old API from the Carbon days.
This affects the MacTypes.h header in the Darwin module as well as the
CarbonCore and OSServices sub-frameworks of the CoreServices framework.
API hidden in this way can still be accessed through qualified lookup
in case it's really needed, but will not appear in the module interface
or in code completion.

This is a hack, and it would be nice to remove it if/when all of this API
is officially marked as deprecated. I did check with Nick for MacTypes.h
and Chris Linn from CoreServices that this was a reasonable action to take.

rdar://problem/16806148

Swift SVN r24424
2015-01-14 19:27:45 +00:00
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