Commit Graph

557 Commits

Author SHA1 Message Date
Ben Langmuir
bb90b38ae8 [ASTPrinter] Remove extra space after deinit
We already know to print one before printing the body brace (if we're
printing function bodies), and it certainly doesn't belong in the
*name* portion of the decl.

Also add a cursor info test with a deinit.
2016-02-12 16:40:53 -08:00
Ben Langmuir
efafb7e98a [ASTPrinter] Remove space between subscript and parameter list
To match the style of TSPL, documentation, the stdlib, etc. Found by
inspection.
2016-02-12 16:23:41 -08:00
Ben Langmuir
e327378b24 [SourceKit] Add annotation tags for decl names
This splits the printDeclNamEndLoc callback into NameEndLoc and
NameOrSignatureEndLoc variants to differentiate whether or not
signatures are included.  All existing clients move to
NameOrSignatureEndLoc to maintain the current behaviour. I'm still not
completely happy with how these are named, but I dont' have any better
ideas right now.

rdar://problem/24292226
2016-02-12 15:57:28 -08:00
Daniel Duan
efe230774b [AST] rename some isXXX methods to getAsXXX
There's a group of methods in `DeclContext` with names that start with *is*,
such as `isClassOrClassExtensionContext()`. These names suggests a boolean
return value, while the methods actually return a type declaration. This
patch replaces the *is* prefix with *getAs* to better reflect their interface.
2016-02-11 16:23:40 -08:00
Xi Ge
77b7180f1a Rename CodeCompletionTypeChecking.h to IDETypeChecking.h since it's used by more clients now. NFC 2016-02-04 11:09:21 -08:00
Xi Ge
6837c17c17 [SourceKit][CursorInfo] Replace archetypes in cursor info results to actual types. rdar://24494225 2016-02-03 17:14:13 -08:00
Xi Ge
ae60159816 [ModulePrint] Add the initial implementation for printing synthesized extensions.
For a concrete type, members from its conforming protocols' extensions can be hard
to manually surface. In this commit, when printing Swift modules, we start to replicate these
extensions and synthesize them as if they are the concrete type's native extensions.

Credit to Doug for suggesting this practice.
2016-02-02 14:53:21 -08:00
Alex Hoppen
722193a5f9 [CodeCompletion] Fix SR-627 Code Completion does not resolve generics that have been assigned a concrete type 2016-02-02 12:34:35 +01:00
Xi Ge
d6f8ad0008 Add a method to RequirementRepr that breaks the deserialized written string into detail. NFC 2016-01-27 13:23:20 -08:00
Doug Gregor
38c1de69e4 Reinstate "[SR-511][Parse] Add 'associatedtype' keyword and fixit"
This reverts commit ce7b2bcf09, tweaking
a few validation tests appropriately (1 crasher fixed, two -verify
tests that needed updating).
2016-01-14 00:21:48 -08:00
Erik Eckstein
ce7b2bcf09 Revert "[SR-511][Parse] Add 'associatedtype' keyword and fixit"
This reverts commit 2b2e9dc80e.

It broke some compiler crasher tests
2016-01-13 20:42:58 -08:00
Doug Gregor
8170f8ba31 Merge pull request #964 from gregomni/sr-511
[SR-511][Parse] Add 'associatedtype' keyword and fixit
2016-01-13 18:09:44 -08:00
gregomni
2b2e9dc80e [SR-511][Parse] Add 'associatedtype' keyword and fixit
Adds an associatedtype keyword to the parser tokens, and accepts either
typealias or associatedtype to create an AssociatedTypeDecl, warning
that the former is deprecated. The ASTPrinter now emits associatedtype
for AssociatedTypeDecls.

Separated AssociatedType from TypeAlias as two different kinds of
CodeCompletionDeclKinds. This part probably doesn’t turn out to be
absolutely necessary currently, but it is nice cleanup from formerly
specifically glomming the two together.

And then many, many changes to tests. The actual new tests for the fixits
is at the end of Generics/associated_types.swift.
2016-01-13 17:54:31 -08:00
Doug Gregor
67c81154af Add a swift3_migration attribute to describe how an API gets migrated.
Introduce a new attribute, swift3_migration, that lets us describe the
transformation required to map a Swift 2.x API into its Swift 3
equivalent. The only transformation understood now is "renamed" (to
some other declaration name), but there's a message field where we can
record information about other changes. The attribute can grow
somewhat (e.g., to represent parameter reordering) as we need it.

Right now, we do nothing but store and validate this attribute.
2016-01-13 16:53:01 -08:00
Chris Lattner
e30cd939d9 Fix rdar://20395243 QoI: type variable reconstruction failing for tuple types
ASTPrinter of type variables was trying to dig an original type out of the
locator and archetype that opened the type variable in the first place.  This
was prone to failure and never helped, so just always print type vars as _.

The affected diagnostics always come out better and this saves a word of storage
for each type variable.
2016-01-11 22:20:19 -08:00
John McCall
1f3b3142b4 Distinguish conformance and superclass generic requirements.
As part of this, use a different enum for parsed generic requirements.

NFC except that I noticed that ASTWalker wasn't visiting the second
type in a conformance constraint; fixing this seems to have no effect
beyond producing better IDE annotations.
2016-01-11 16:07:37 -08:00
Xi Ge
8ccf0e40ee [SourceKit][DocInfo] Check an extension's relevancy before printing the type interface of a type. rdar://24133008" 2016-01-11 11:19:48 -08:00
John McCall
5112864dad Remove the archetype from Substitution.
This eliminates some minor overheads, but mostly it eliminates
a lot of conceptual complexity due to the overhead basically
appearing outside of its context.
2016-01-08 15:27:13 -08:00
Xi Ge
d53c91c087 [SourceKit][DocInfo] Being consistent of the printed source and the reported annotation when the decl under request is an extension to a name alias type. rdar://22098995 2016-01-07 12:13:40 -08:00
Doug Gregor
5aa40dd0aa Extend DefaultArgumentKind with cases for nil, [], and [:].
Under -enable-infer-default-arguments, the Clang importer infers some
default arguments for imported declarations. Rather than jumping
through awful hoops to make sure that we create default argument
generators (which will likely imply eager type checking), simply
handle these cases as callee-side expansions.

This makes -enable-infer-default-arguments usable, fixing
rdar://problem/24049927.
2016-01-06 10:19:12 -08:00
practicalswift
ca92efc8e6 Use consistent formatting of header comments.
Correct format:
```
//===--- Name of file - Description ----------------------------*- Lang -*-===//
```

Notes:
* Comment line should be exactly 80 chars.
* Padding: Pad with dashes after "Description" to reach 80 chars.
* "Name of file", "Description" and "Lang" are all optional.
* In case of missing "Lang": drop the "-*-" markers.
* In case of missing space: drop one, two or three dashes before "Name of file".
2016-01-04 23:00:53 +01:00
practicalswift
50baf2e53b Use consistent formatting in top of file headers. 2016-01-04 02:17:48 +01:00
Chris Lattner
95f07f02b9 rename AST/Parameter.h to AST/ParameterList.h now that Parameter is gone. 2016-01-03 14:47:44 -08:00
Chris Lattner
6afe77d597 Eliminate the Parameter type completely - now ParameterList is just
an overblown array of ParamDecl*'s that also keeps track of parenlocs
and has helper methods.
2016-01-03 14:45:38 -08:00
Chris Lattner
b170b700f8 move the rest of the state out of Parameter and into ParamDecl,
in prep for Parameter going away.  NFC.
2016-01-01 15:27:53 -08:00
Chris Lattner
4479b46ef0 move the TypeLoc for a parameter out of Parameter and onto ParamDecl. NFC. 2016-01-01 14:13:13 -08:00
Chris Lattner
62e0680350 simplify PrintAST::printTypedPattern by removing the now-always-false 'StripOuterSliceType' parameter. 2015-12-31 21:15:54 -08:00
Chris Lattner
cc3f173040 remove variadics, default args etc, from tuple patterns, and simplify
the Pattern::clone interface now that the complexity isn't needed.
This also removes support for serializing this state.
2015-12-31 20:12:12 -08:00
Chris Lattner
a30ae2bf55 Merge pull request #836 from zachpanz88/new-year
Update copyright date
2015-12-31 19:36:14 -08:00
Chris Lattner
7daaa22d93 Completely reimplement/redesign the AST representation of parameters.
Parameters (to methods, initializers, accessors, subscripts, etc) have always been represented
as Pattern's (of a particular sort), stemming from an early design direction that was abandoned.
Being built on top of patterns leads to patterns being overly complicated (e.g. tuple patterns
have to have varargs and default parameters) and make working on parameter lists complicated
and error prone.  This might have been ok in 2015, but there is no way we can live like this in
2016.

Instead of using Patterns, carve out a new ParameterList and Parameter type to represent all the
parameter specific stuff.  This simplifies many things and allows a lot of simplifications.
Unfortunately, I wasn't able to do this very incrementally, so this is a huge patch.  The good
news is that it erases a ton of code, and the technical debt that went with it.  Ignoring test
suite changes, we have:
   77 files changed, 2359 insertions(+), 3221 deletions(-)

This patch also makes a bunch of wierd things dead, but I'll sweep those out in follow-on
patches.

Fixes <rdar://problem/22846558> No code completions in Foo( when Foo has error type
Fixes <rdar://problem/24026538> Slight regression in generated header, which I filed to go with 3a23d75.

Fixes an overloading bug involving default arguments and curried functions (see the diff to
Constraints/diagnostics.swift, which we now correctly accept).

Fixes cases where problems with parameters would get emitted multiple times, e.g. in the
test/Parse/subscripting.swift testcase.

The source range for ParamDecl now includes its type, which permutes some of the IDE / SourceModel tests
(for the better, I think).

Eliminates the bogus "type annotation missing in pattern" error message when a type isn't
specified for a parameter (see test/decl/func/functions.swift).

This now consistently parenthesizes argument lists in function types, which leads to many diffs in the
SILGen tests among others.

This does break the "sibling indentation" test in SourceKit/CodeFormat/indent-sibling.swift, and
I haven't been able to figure it out.  Given that this is experimental functionality anyway,
I'm just XFAILing the test for now.  i'll look at it separately from this mongo diff.
2015-12-31 19:24:46 -08:00
Zach Panzarino
e3a4147ac9 Update copyright date 2015-12-31 23:28:40 +00:00
Chris Lattner
feace85d5a Enhance SubscriptDecl to be a DeclContext, so it can hold its indices.
This is necessary for some other work I'm doing, which really wants
paramdecls to have reasonable declcontexts.  It is also a small step
towards generic subscripts.
2015-12-31 12:38:28 -08:00
practicalswift
81e7439a9a Fix typos. 2015-12-23 11:16:34 +01:00
Doug Gregor
c8dd8d0661 Implement SE-0001: Allow (most) keywords as argument labels.
Allow all keywords except for parameter introducers (var/let/inout) to
be argument labels when declaring or calling a
function/initializer/subscript, e.g., this

  func touchesMatching(phase: NSTouchPhase, `in` view: NSView?) -> Set<NSTouch>

can now be expressed as

  func touchesMatching(phase: NSTouchPhase, in view: NSView?) -> Set<NSTouch>

and the call goes from

  event.touchesMatching(phase, `in`: view)

to

  event.touchesMatching(phase, in: view)

Fixes [SR-344](https://bugs.swift.org/browse/SR-344) /
rdar://problem/22415674.
2015-12-22 16:18:28 -08:00
ken0nek
fcd8fcee91 Convert [Cc]an not -> [Cc]annot 2015-12-23 00:55:48 +09:00
Joe Groff
b1667ec705 SIL: Introduce a new @inout_aliasable parameter convention.
Modeling nonescaping captures as @inout parameters is wrong, because captures are allowed to share state, unlike 'inout' parameters, which are allowed to assume to some degree that there are no aliases during the parameter's scope. To model this, introduce a new @inout_aliasable parameter convention to indicate an indirect parameter that can be written to, not only by the current function, but by well-typed, well-synchronized aliasing accesses too. (This is unrelated to our discussions of adding a "type-unsafe-aliasable" annotation to pointer_to_address to allow for safe pointer punning.)
2015-12-08 14:35:47 -08:00
Xi Ge
70a1b5f34c Fixing a crash due to unguarded API call. rdar://22581469 2015-12-07 17:46:42 -08:00
Yukim
b672216aee Fix typo 2015-12-04 08:35:32 +09:00
Argyrios Kyrtzidis
7dd3046a4b [ASTPrint] Print documentation comments for extensions and subscripts. 2015-12-03 00:17:32 -08:00
Argyrios Kyrtzidis
8659022917 [ASTPrint] For when printing interface from a source file, introduce an option to
pick up the original source text for the declarations.
2015-12-02 23:51:49 -08:00
Argyrios Kyrtzidis
04e3949985 [ASTPrint] Introduce a printing option to hide underscored protocols in the stdlib. 2015-12-02 22:38:34 -08:00
Xi Ge
9beeb56a90 [TypeInterface] When printing type-specific interfaces, replace parameter and return types with instantiated types. 2015-11-17 19:12:30 -08:00
Xi Ge
a1493133a0 Refactor ArchetypeTransformer into a reusable IDE utility. NFC 2015-11-17 19:12:30 -08:00
Xi Ge
01ec4f2ebd [TypeInterface] Replace generic params with instantiated type when printing type-specific interface. 2015-11-17 19:12:30 -08:00
Doug Gregor
9491ec4c02 Add a swift-ide-test option to not print import declarations.
The import declarations get in the way when looking the results of
-enable-omit-needless-words.
2015-11-16 15:27:38 -08:00
Ben Langmuir
889b033964 [CodeCompletion] Add completion for property overrides
This mostly works the same as for functions. It required a slight tweak
to how we handle 'var <complete>' to avoid consuming the code completion
token prematurely.

rdar://problem/21012767

Swift SVN r32844
2015-10-23 05:38:07 +00:00
Xi Ge
20e1d6231d [ASTPrinter] Expose shouldPrint() as global function. NFC
Swift SVN r32817
2015-10-22 00:41:33 +00:00
Xi Ge
e1331252a3 [ClangModulePrint] If skipping an unavailable decl, skipping its following regular comments too. rdar://20092567
This only works for Clang-imported but unavailable decls, but not for Clang decls that
are not imported.

Swift SVN r32769
2015-10-20 00:19:40 +00:00
Xi Ge
dd113d0f6c Reapply "[InterfacePrint] When printing a type interface, omit the extensions that are not applicable."
After fixing a dangling pointer.

Swift SVN r32672
2015-10-13 22:08:08 +00:00
Xi Ge
ad3c03243f Revert "[InterfacePrint] When printing a type interface, omit the extensions that are not applicable."
For unhappy bots

Swift SVN r32666
2015-10-13 20:36:06 +00:00