Commit Graph

490 Commits

Author SHA1 Message Date
Jordan Rose
613b194025 [IDE] Honer @testable for top-level completions as well.
This is the last planned Swift-side fix for testability in this release!

rdar://problem/17732115

Swift SVN r26949
2015-04-03 20:20:17 +00:00
Chris Lattner
79ed57f9f2 standardize naming of tuples and tuple patterns on "elements".
Previously some parts of the compiler referred to them as "fields",
and most referred to them as "elements".  Use the more generic 'elements'
nomenclature because that's what we refer to other things in the compiler
(e.g. the elements of a bracestmt).

At the same time, make the API better by providing "getElement" consistently
and using it, instead of getElements()[i].

NFC.



Swift SVN r26894
2015-04-02 20:23:49 +00:00
Doug Gregor
38cc1fe5c6 Remove LazyResolver arguments from API entry points to the conformance lookup table.
Swift SVN r26838
2015-04-02 00:06:01 +00:00
Ben Langmuir
ea6e1f24a7 Avoid unnecessary calls to CodeCompletionString::getName during sorting
This improves run time of this particular function by up to 8x in my
testing. For *really* large sets of code completions (I tested top-level
completion with Cocoa imported) this gives a 30-40% improvement across
the request, not including time spent in the client.  The tradeoff is a
slight increase in peak memory usage (I saw 0.7% or 1.2 MB for the
top-level Cocoa case).

<rdar://problem/20355626>

Swift SVN r26748
2015-03-31 03:27:06 +00:00
Xi Ge
cdf2e853ad [CodeCompletion] Use a better API to retrieve
all the protocols a type conform to.

Swift SVN r26694
2015-03-29 07:08:57 +00:00
Xi Ge
90cf8aec22 [CodeCompletion] Add types whose extensions
conform _ErrorType protocol to the completions of throw statement.

Swift SVN r26691
2015-03-29 05:56:06 +00:00
Jordan Rose
85a3751f6d Remove SourceFile::getImports in favor of FileUnit::getImportedModules.
getImportedModules is the canonical way to get imports, whether private,
public, or both. This is especially true now that we have more flags
for SourceFile imports that really shouldn't be consumed by anyone
outside of SourceFile.

In this same vein, provide addImports instead of setImports, since imports
are always additive.

No visible functionality change.

Swift SVN r26634
2015-03-27 16:36:47 +00:00
Jordan Rose
e334eed7a4 Record @testable in a SourceFile's import list.
No functionality change, since nothing's using it yet.

Swift SVN r26632
2015-03-27 16:36:44 +00:00
Xi Ge
18438647ef [CodeCompletion] Showing the member functions of Optional.
Previously, when code completing Optional<T>., we only show
the member functions of T; This fix adds the member functions
of Optional to the code completion list.
rdar://20316534

Swift SVN r26622
2015-03-27 02:53:09 +00:00
Xi Ge
256e038edf [CodeCompletion] Add exception handle clauses to catch stmt completion.
Swift SVN r26597
2015-03-26 18:32:13 +00:00
Xi Ge
0d9fb1aaa5 [CodeCompletion] Make sure only instantiable types are included
in code completion options when completing a throw statement.

Swift SVN r26571
2015-03-26 00:58:19 +00:00
Xi Ge
6f43e545fb [CodeCompletion] Auto-completing the throw statement.
When the code completion token appears after throw keyword,
a set of visible decls and instances conforming _ErrorType are
recommended as completion.

Swift SVN r26565
2015-03-25 23:46:26 +00:00
Xi Ge
8a64deb828 [codecompletion] auto-completing the catch statement.
When the code completion token is seen after the catch keyword, a set of
visible error types are suggested as completion.

Swift SVN r26519
2015-03-25 04:16:57 +00:00
Jordan Rose
f74bc7122c Split getAccessibility() into getFormalAccess() and getEffectiveAccess().
Currently a no-op, but effective access for entities within the current
module will soon need to take testability into account. This declaration:

  internal func foo() {}

has a formal access of 'internal', but an effective access of 'public' if
we're in a testable mode.

Part of rdar://problem/17732115 (testability)

Swift SVN r26472
2015-03-24 02:16:58 +00:00
John McCall
a0a16d78d2 Implement the do/catch statement. Tests to follow.
This patch also introduces some SILGen infrastructure for
dividing the function into "ordinary" and "postmatter"
sections, with error-handling-like stuff going into the
final section.  Currently, this is largely undermined by
SILBuilder, but I'm going to fix that in a follow-up.

Swift SVN r26422
2015-03-23 02:08:26 +00:00
Ben Langmuir
fff41e472e Hide _UnderscoredProtocols in code completion
We explicitly whitelist these "stdlib private" decls in interface
generation, because they may contain methods that users are required to
implement.  But in code-completion, there's no good reason to show them.
We still show completions for the methods themselves if you complete on
a public protocol that inherits from the private protocol. So,

<complete> => doesn't show _CollectionType

let a: CollectionType = ...
a.<complete> => *does* show startIndex, which comes from _CollectionType

rdar://problem/20086106

Swift SVN r26355
2015-03-20 17:14:08 +00:00
Doug Gregor
539c4b158e Use getAllConformances() in code completion rather than a manual wordlist.
Swift SVN r26324
2015-03-19 22:10:06 +00:00
Xi Ge
707071daa0 [CodeCompletion] Address Argyrios comments on r26134
Swift SVN r26271
2015-03-18 18:53:37 +00:00
Xi Ge
df187f7280 [CodeCompletion] Address Dmitri's comments on r26230
Swift SVN r26270
2015-03-18 18:53:34 +00:00
Ben Langmuir
5f2bcba8ba Update tests for code-completion modulename change
Add module name to OtherModule result output and update the tests
accordingly.

Swift SVN r26262
2015-03-18 16:40:28 +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
a83a8e4f34 [CodeCompletion] avoid duplicating keywords.
When a developer auto-completes an override function,
we collect the keywords that have already been specified
by the developer, so that the code completion strings do
not duplicate them.
rdar://16738036

Swift SVN r26230
2015-03-17 20:35:56 +00:00
Xi Ge
520df97787 [CodeCompletion] Adopt a more efficient algorithm
to find the nearest AST parent that meets a certain condition

Swift SVN r26134
2015-03-14 08:30:16 +00:00
Xi Ge
0ad419cce2 [CleanUp] Remove unnecessary undefs
Swift SVN r26117
2015-03-14 00:34:33 +00:00
Xi Ge
8367428ed0 [CodeCompletion] Literal complete.
When code completing a literal expr, it is likely that code completion engine only collects the expr
that is not fully type checked. Therefore, no members of the literal can be suggested. To address this,
we try to climb up expr hierarchy in AST to find an expr with a nominal type, and use the nominal type
to finish code completion.
rdar://20059173

Swift SVN r26116
2015-03-14 00:34:32 +00:00
Dmitri Hrybenko
129f921a91 Fix a use-after-free in code completion for attributes
The code was binding a temporary std::string to a StringRef.

Swift SVN r26094
2015-03-13 07:35:37 +00:00
Xi Ge
07c16436c2 [cleanup] adding undef to several usages of included def file
Swift SVN r26050
2015-03-12 18:14:44 +00:00
Xi Ge
48ba44dd2c [CodeCompletion] Fxing Dmitri's review comments
Swift SVN r25965
2015-03-10 22:50:13 +00:00
Xi Ge
737f0ca6a6 [CodeCompletion] Using canAttributeAppearOnDecl() to decide whether an attribute is applicable.
Swift SVN r25961
2015-03-10 22:31:43 +00:00
Xi Ge
c0bf1f54ff [CodeCompletion] Further support the context-sensitivity of
auto-completing @attributes. By delaying the handling of code completion token after the entire decl being parsed, we know
what are the targets of the attribute to finishe, thus, only suggesting those applicable attributes.

Swift SVN r25938
2015-03-10 18:40:39 +00:00
Xi Ge
32e9a0aca7 [CodeCompletion] Making the code completion of attributes
context-sensitive. The first step is to recommend parameter-applicable
attributes only when the code completion token is found inside a
param decl.

Swift SVN r25810
2015-03-06 23:20:17 +00:00
Xi Ge
039674b492 Remove most user-inaccessbile attributes from the
code completion strings.

Swift SVN r25790
2015-03-05 23:12:24 +00:00
Xi Ge
f962814017 [CodeCompletion] address Jordan's comments about filtering
out non-usable attributes in code completion strings.

Swift SVN r25786
2015-03-05 21:58:29 +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
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