Commit Graph

334 Commits

Author SHA1 Message Date
Xi Ge
01ec4f2ebd [TypeInterface] Replace generic params with instantiated type when printing type-specific interface. 2015-11-17 19:12:30 -08:00
Joe Groff
fbd2e4d872 Rename @asmname to @_silgen_name.
This reflects the fact that the attribute's only for compiler-internal use, and isn't really equivalent to C's asm attribute, since it doesn't change the calling convention to be C-compatible.
2015-11-17 14:13:48 -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
5ca83d97a5 [InterfacePrint] Enhance ASTPrinter to support type-specific interface printing.
When users try to print the interface of a specific type (most often through cursor
infor query of SourceKit), we should simplify the original decls by replacing
archetypes with instantiated types, hiding extension details, and omitting
unfulfilled extension requirements. So the users can get the straight-to-the-point
"type interface". This commit builds the testing infrastructure for this feature,
and implements the first trick that wraps extension contents into the interface body.

This commit also moves some generic testing support from SourceKit to Swift.

Swift SVN r32630
2015-10-12 19:14:58 +00:00
Argyrios Kyrtzidis
034ec91f1a [AST/PrintOptions] Refactor PrintOptions::printInterface(bool) and introduce separate printForDiagnostics() function.
This makes the use case clear both for the caller and when adding new options on where they should be enabled or not.

Swift SVN r32152
2015-09-22 17:54:21 +00:00
Doug Gregor
44b8d45288 Clean up inference of default arguments from imported APIs (mostly).
My temporary hackery around inferring default arguments from imported
APIs was too horrible. Make it slightly more sane by:

1) Actually marking these as default arguments in the type system,
rather than doing everything outside of the type system. This is a
step closer to what we would really do, if we go in this
direction. Put it behind the new -frontend flag
-enable-infer-default-arguments.

2) Only inferring a default argument from option sets and from
explicitly "nullable" parameters, as stated in the (Objective-)C API
or API notes. This eliminates a pile of spurious, non-sensical "=
nil"'s in the resulting output.

Note that there is one ugly tweak to the overloading rules to prefer
declarations with fewer defaulted arguments. This is a bad
implementation of what is probably a reasonable rule (prefer to bind
fewer default arguments), which intentionally only kicks in when we're
dealing with imported APIs that have default arguments.

Swift SVN r32078
2015-09-18 21:50:59 +00:00
Xi Ge
f63ab9f6f1 [ASTPrint] Still print extended types even though they err.
Swift SVN r32044
2015-09-17 20:48:07 +00:00
Xi Ge
cc3c73afff [ASTPrint] Add an option to avoid printing unresolved extension decls. rdar://22676315
Swift SVN r31983
2015-09-16 01:13:57 +00:00
Doug Gregor
dc820315ba Omit needless words: fake defaulted imported optional and option-set arguments.
Introduce a hack that allows us to fake importing optional and
option-set parameters as "nil" or "[]", respectively.

Swift SVN r31977
2015-09-15 22:45:47 +00:00
Xi Ge
efb19787a1 [InterfaceGen] Not printing '@rethrows' since we print 'rethrows'. rdar://22449614
Swift SVN r31538
2015-08-27 18:47:41 +00:00
Chris Lattner
be818c6193 Adjust how diagnostics synthesize decls (e.g.) when printing overload sets,
to print them with their interface representation.  This squelches attributes
like @_inline and @semantics.


Swift SVN r31462
2015-08-25 23:52:53 +00:00
Argyrios Kyrtzidis
e605b93b8e [IDE] For swift file interface generation, print the active parts and ignore IfConfigStmts.
Swift SVN r30938
2015-08-02 21:58:47 +00:00
Argyrios Kyrtzidis
0bb52f0621 [IDE] Fix the 'preamble' top-comment printing when printing the swift source interface.
It erroneously printed out accessibility keyword of the first decl and did not take into
account comment whitespacing.

Swift SVN r30933
2015-08-02 20:46:38 +00:00
Xi Ge
61ccc5f48e Move radar number out of source file.
Swift SVN r30546
2015-07-23 20:23:04 +00:00
Xi Ge
8e44a2f046 [InterfacePrinting] Address Jordan's comments on 30520.
We discussed this morning and agreed that the best way to fix rdar://20680375
is to differentiate between printing testable interfaces and printing general
interfaces, where the former includes internal decls and the latter does not.
Also, we always print accessibility keywords to be consistent.

Swift SVN r30543
2015-07-23 19:49:16 +00:00
Xi Ge
6471303c12 [InterfacePrinting] Alter PrintOptions for interface printing so that user-defined internal decls are visible in the generated interfaces.
Also, we always print accessibility keywords in the printed interfaces, so that users can differentiate public and
internal decls.
rdar://20680375

Swift SVN r30520
2015-07-23 01:37:20 +00:00
Xi Ge
af957bcad8 [InterfacePrinting] Add a print option to specify whether members of a decl should be separated by empty new lines.
By doing so, SourceKit can print Swift intefaces in the same fashion of what Xcode conventionally does.
rdar://21710381

Swift SVN r30430
2015-07-21 01:22:44 +00:00
Xi Ge
78c0874e5e [InterfacePrinting] Print @convention when printing module interfaces. rdar://21196514
Swift SVN r30416
2015-07-20 21:48:19 +00:00
Xi Ge
9e3e8fe94e [InterfacePrinting] do not leak private stdlib decls in quick help. rdar://20858548
Swift SVN r30415
2015-07-20 21:48:17 +00:00
Xi Ge
0ad59157ae Revert "[InterfacePrinting] Print stdlib internal protocols whose names start with no '_'"
This reverts commit ca7c1e5692bdd51cb0800be42c964462a3c84436.

Swift SVN r30191
2015-07-14 18:39:49 +00:00
Xi Ge
a6e43171e3 [InterfacePrinting] Print stdlib internal protocols whose names start with no '_'
rdar://21515803

Swift SVN r30178
2015-07-14 00:30:45 +00:00
Xi Ge
09c1d8f308 [DocCommentPrint] For quick help, print objc declarations in Swift. rdar://21097812
Swift SVN r29949
2015-07-08 00:05:52 +00:00
Argyrios Kyrtzidis
658d852f68 [IDE] When printing stdlib interface, hide underscored members of protocols, and subscript
decls that have underscored parameters.

Dmitri verified that the removals after this change are ok.

Swift SVN r29177
2015-05-31 00:41:09 +00:00
Argyrios Kyrtzidis
b5ada197f5 [ASTPrinter] When printing interface hide @inline attribute.
rdar://21043283

Swift SVN r28857
2015-05-20 23:12:22 +00:00
Argyrios Kyrtzidis
ef213fddcd [ASTPrinter] Add an extra print option to control printing 'internal' keyword if accessibility printing is enabled.
Swift SVN r28813
2015-05-20 01:45:56 +00:00
Ted Kremenek
62feb5c949 Change @availability to @available.
This came out of today's language review meeting.
The intent is to match #available with the attribute
that describes availability.

This is a divergence from Objective-C.

Swift SVN r28484
2015-05-12 20:06:13 +00:00
Joe Groff
6849ebda87 SIL printer: Disambiguate context archetypes with name collisions.
This can happen in witnesses, whose context archetypes are composed from the type-level archetypes of the witnessing type, and the method-level archetypes of the requirement. If you have something like:

protocol Foo {
  func foo<T>(x: T)
}

struct Bar<T>: Foo {
  func foo<U>(x: U)
}

Bar's witness to Foo.foo will end up with two archetypes named "T". Deal with this by having the SIL printer introduce a name mapping that disambiguates colliding archetypes. Refactor the SIL printer to do streaming through the SILPrinter itself, rather than directly on its ostream, so that we make sure it controls how subelements like types are printed, and it can pass the appropriate options down to the AST type printer. Fixes rdar://problem/20659406.

Swift SVN r27991
2015-04-30 18:42:31 +00:00
Doug Gregor
b2cc34c241 Remove '#' for making parameter names into argument labels.
If you want to make the parameter and argument label the same in
places where you don't get the argument label for free (i.e., the
first parameter of a function or a parameter of a subscript),
double-up the identifier:

  func translate(dx dx: Int, dy: Int) { }

Make this a warning with Fix-Its to ease migration. Part of
rdar://problem/17218256.

Swift SVN r27715
2015-04-24 23:58:57 +00:00
Xi Ge
c53aefb874 [ModulePrint] Skip user inaccessible decl attrs when printing module interfaces.
Not skipping them may cause internal-used attributes' leaking to external developers.
rdar://19903962

Swift SVN r27324
2015-04-15 20:06:08 +00:00
Joe Groff
c0a2994564 AST: Start printing function types with @convention instead of old attributes.
And update tests to match.

Swift SVN r27262
2015-04-13 22:51:34 +00:00
Argyrios Kyrtzidis
7fe32e1d6b [AST/Print] Add PrintOptions::printInterface(), used to retrieve the set of options suitable for interface generation.
These will affect how SourceKit prints the interface.

Swift SVN r25639
2015-02-28 19:58:14 +00:00
Xi Ge
95a431885b When printing the interfaces in a module, denit is not informative
. Thus, this change allows swift-ide-test to ignore deinit when printing
interfaces. Also, to ignore is the default setting. Attribut -skip-deinit
can switch it off.
rdar://19079711

Swift SVN r25608
2015-02-27 21:48:23 +00:00
John McCall
6287d913c3 By default, hide the actual implementing accessors of properties
and subscripts when printing them; just print them as get/set.

The important thing here is that we don't want to show the
names of addressors and mutable addressors when pretty-printing
the stdlib, but hiding observers is also general goodness.

Swift SVN r24875
2015-01-31 05:03:51 +00:00
Argyrios Kyrtzidis
8dba2bc129 [ASTPrinter] Control whether we should skip printing empty extensions or not.
Swift SVN r23469
2014-11-20 05:08:37 +00:00
Argyrios Kyrtzidis
442f34378f [ASTPrinter] Avoid printing @effects attribute by default.
We don't want to expose this attribute currently.
Test on the SourceKit side.

rdar://18262482

Swift SVN r21774
2014-09-08 16:29:56 +00:00
Manman Ren
d23e86fc62 [SILParser] parsing Self as part of where clause.
Do not print @sil_self when dumping top decls.

rdar://17979145


Swift SVN r21155
2014-08-12 21:38:25 +00:00
Jordan Rose
1a65ce0c16 Print @availability and @asmname on their own line.
These attributes are too long and would mess up the flow of the line if
placed directly before the decl introducer.

Swift SVN r20840
2014-07-31 18:58:13 +00:00
Jordan Rose
00b6a5cb08 Import Objective-C properties marked weak/copy as weak/@NSCopying.
...and 'assign' and 'unsafe_unretained' as 'unowned(unsafe)', if the
property is a class type.

This isn't important for the compiler, but it is documentation for users
when they look at the generated interface for an Objective-C module.

Note that this actually produces a decl users can't yet write:

  unowned(unsafe) var foo: UIView!

That's <rdar://problem/17277899> unowned pointers can't be optional.

<rdar://problem/17245555>

Swift SVN r20433
2014-07-23 22:29:01 +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
Dmitri Hrybenko
15fe0e2f69 Avoid double negative in comments
Swift SVN r20405
2014-07-23 16:05:13 +00:00
Dmitri Hrybenko
1007ef3f95 Module interface printing: add an option to filter declarations based on
access control

Swift SVN r20399
2014-07-23 15:03:58 +00:00
Manman Ren
1bd9d81971 [SILParser] fix a few issues to enable parsing of sil from swift array
Add PrintForSIL in PrintOptions
1> for NameAliasType, we print getSinglyDesugaredType()
I attempted another option: set FullyQualifiedTypes of PrintOptions, but that
will print xxx.Type.xxx and Parser can’t handle it.
2> for Self, we print @sil_self

We also work around parsing:
sil_witness_table _CocoaArrayType: _CocoaArrayType

sil_vtable uses internal classes in stdlib, so we use lookupTopDecl instead
of lookupValue when parsing sil_vtable, to find internal classes.

Fix rdar://17261925 rdar://17295316 rdar://17046276 rdar://17579890


Swift SVN r20070
2014-07-17 04:43:24 +00:00
Jordan Rose
20bc9ec2b9 Add accessibility printing, and test the accessibility inference so far.
Swift SVN r19144
2014-06-24 21:32:15 +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
16d4b98b83 [ASTPrinter] Add more printing options, SkipAttributes/SkipIntroducerKeywords/ArgAndParamPrintingMode.
Swift SVN r17677
2014-05-08 04:17:40 +00:00
Ted Kremenek
0b2c23ffec Remove special printing of ImplicitlyUnwrappedOptional<T>.
Part of <rdar://problem/16836463>

Swift SVN r17610
2014-05-07 06:59:52 +00:00
Argyrios Kyrtzidis
42484084f2 [ASTPrinter] Add an option to always print the keyword argument and the parameter,
even if they are the same.

rdar://16799973

Swift SVN r17412
2014-05-05 00:52:06 +00:00
Argyrios Kyrtzidis
f514d8862e [ASTPrinter] Remove PrintOptions option that is a leftover.
Swift SVN r17411
2014-05-05 00:08:59 +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