Commit Graph

334 Commits

Author SHA1 Message Date
Argyrios Kyrtzidis
69918a966d [ASTPrinter] Fix printing of nested typealias types and make it consistent with printing of nominal types.
This fixes several issues:
- By default parent types of alias types are not printed which results in
	- Erroneous fixits, for example when casting to 'Notification.Name' from a string, which ends up adding erroneous cast
	  as "Name(rawValue: ...)"
	- Hard to understand types in code-completion results and diagnostics
- When printing with 'fully-qualified' option typealias types are printed erroneously like this "<PARENT>.Type.<TYPEALIAS>"

The change make typealias printing same as nominal types and addresses the above.
2016-08-11 12:15:15 -07:00
Argyrios Kyrtzidis
80b3f56b40 [AST] Fix the cursor-info tests with these changes:
- Make sure VarDecls have an associated TypeLoc, like ParamDecls do, then use it for printing the VarDecl's type.
This is done by moving ParamDecl's TypeLoc up to the VarDecl.
This is useful for being able to display the parameter names of function types embedded in VarDecls.

- Use the result TypeLoc of functions for printing. This enables printing parameter names of function types embedded in return types.

- Make sure to annotate attributes while they are printed.
2016-08-09 20:52:09 -07:00
Michael Ilseman
c37751ae96 [noescape by defaul] make noescape the default
This flips the switch to have @noescape be the default semantics for
function types in argument positions, for everything except property
setters. Property setters are naturally escaping, so they keep their
escaping-by-default behavior.

Adds contentual printing, and updates the test cases.

There is some further (non-source-breaking) work to be done for
SE-0103:

- We need the withoutActuallyEscaping function
- Improve diagnostics and QoI to at least @noescape's standards
- Deprecate / drop @noescape, right now we allow it
- Update internal code completion printing to be contextual
- Add more tests to explore tricky corner cases
- Small regressions in fixits in attr/attr_availability.swift
2016-07-29 13:49:08 -07:00
practicalswift
7e89679404 [gardening] Fix recently introduced typos. 2016-07-24 22:32:40 +02:00
Alex Hoppen
c3b5b305b2 [Diag] Fixits for missing protocol requirements
To each note with a protocol requirement that is not met, a fixit is
added that inserts a stub for the requirement at the start of the
adoptee's declaration.
2016-07-20 11:47:08 +02:00
Alex Hoppen
4aa6485ba0 [Printer] Rename ArchetypeTransformer to TypeTransformer
The ArchetypeTransformer isn't actually limited to transforming archetypes
but can transform arbitrary types. Thus, we can rename it to TypeTransformer
2016-07-20 10:55:50 +02:00
Xi Ge
8cfefd35ce [libide] Finish related lib-ide work on generating type-interface, rdar://27306890. (#3501) 2016-07-14 08:48:28 -07:00
Trent Nadeau
78a420d850 Made use of @warn_unused_result a warning with a fixit (#2760)
https://bugs.swift.org/browse/SR-1052
2016-06-08 10:10:21 -07:00
Chris Lattner
679853d3b1 Merge pull request #1887 from tanadeau/sr-1052-add-attr
[WIP][Parser][SR-1052] Added @discardableResult attribute parsing.
2016-04-03 13:26:11 -07:00
Xi Ge
61248dec24 [SourceKit] DocInfo: Fixing a paired-callback mismatch issue when merging nominals with extensions. rdar://25431244 2016-03-31 12:43:34 -07:00
Trent Nadeau
3b5a8cdd44 Added @discardableResult attribute parsing.
Future commits will add use in diagnostic generation, stdlib, etc.
2016-03-26 22:24:22 +00:00
Xi Ge
f338bdfbb7 [SourceKit] Incorporate synthesized extensions into DocInfo request. rdar://24912860
This commit reuses our code for generating synthesized extensions from module printing to enhance
documentation generation.
2016-03-22 14:49:22 -07:00
Xi Ge
33c53a12eb ASTPrinter: Pass the bracket options to pre and post printing callbacks.
Need this for rdar://24912860
2016-03-22 14:49:22 -07:00
Xi Ge
66fb8062fe ModulePrinting: For decls without doc-comment, we print the doc-comment associated with their conformances, if any.
Inspired by rdar://24409720
2016-03-21 14:35:32 -07:00
practicalswift
a0d494c143 [gardening] Fix recently introduced typos: "fucntion" → "function", "functio" → "function", "mergable" → "mergeable", "mistmatched" → "mismatched" 2016-03-20 10:34:32 +01:00
Xi Ge
c85591bc25 [SourceKit] CursorInfo: not showing @warn_unused_result in quick help. 2016-03-18 16:39:27 -07:00
Xi Ge
a99a3556e7 ModulePrinting: Encapsulate bracket options into a sub-structure of PrintOptions. NFC 2016-03-17 21:34:51 -07:00
Xi Ge
d8a7118966 ModulePrinting: Rename merge group kinds. 2016-03-17 17:54:50 -07:00
Xi Ge
b894798e46 ModulePrinting: For those extensions have no doc-comments, no constraints and no inheritance, we merge their contents to the body of the type declaration. 2016-03-17 16:26:34 -07:00
Xi Ge
3dbd14be00 ModulePrinting: Refactoring SynthesizedExtensionAnalyzer to better expose the merge groups of extensions. NFC 2016-03-17 16:26:34 -07:00
Xi Ge
c3de0db612 ModulePrinting: Merge the content of extensions of the same constraints/inherits, disregarding of whether they are synthesized or actual. 2016-03-16 17:29:37 -07:00
Xi Ge
5168083bf3 ModulePrinting: Print new lines between members of a decl. 2016-03-11 12:26:04 -08:00
Xi Ge
13e7e1f7be ModulePrinting: Not showing @warn_unused_result in the printed module interface. 2016-03-10 17:56:35 -08:00
Xi Ge
c22e9bcf53 ModulePrinting: Merge synthesized extensions' bodies if they have the common constraints. 2016-03-10 17:50:24 -08:00
Argyrios Kyrtzidis
345d05e2e9 Introduce an internal attribute '@_show_in_interface' to be used in stdlib for underscored protocols that
should be shown in the interface.

Also switch the option and hide all underscored protocols by default, unless they are marked with the new attribute.
2016-03-08 23:30:58 -08:00
Xi Ge
ce12c6dc95 ModulePrinting: Add an option to synthesize unconditional extensions; true by default. 2016-03-08 18:34:38 -08:00
Ben Langmuir
e752de0d20 [SourceKit] Print and annotate the raw value expression of enum elements
For now, only do this in SourceKit (printQuickHelpDeclaration), but
there are probably other printing modes that should do this.

rdar://problem/24292226
2016-03-07 12:36:47 -08:00
Xi Ge
40f0c7c1f3 ModulePrinting: Save some copies by passing function pointer. NFC 2016-03-05 12:29:01 -08:00
practicalswift
5b2800225d [gardening] Fix recently introduced typos
Fixed:
* perfomance → performance
* requirments → requirements
* satisified → satisfied
* template template → template
2016-03-04 11:10:50 +01:00
Xi Ge
591249f953 Simplify some code. NFC 2016-03-03 18:25:35 -08:00
Xi Ge
326514e397 ModulePrinting: when printing synthesized extensions, avoid printing requirements that are known to be true. 2016-03-03 17:42:35 -08:00
Xi Ge
bafe60e91b Refactoring: move IsInSynthesizedExtension to Analyzer. NFC. 2016-03-02 17:30:11 -08:00
Xi Ge
3f20eb242d Refactoring: Moving the logic of collecting synthesized extensions to Analyzer. NFC. 2016-03-02 17:30:11 -08:00
Xi Ge
60be59953a ModulePrinting: Add the basic infrastructure to remove inapplicable synthesized extensions.
As the initial step, we remove any synthesized extensions requiring a tuple's conforming to nominals, which
never happens. This will remove multiple useless synthesized extensions for Dictionary.
2016-03-01 15:44:41 -08:00
Andrew Trick
ff02652108 Move enums into AttrKind.h.
This reorganization allows adding attributes that refer to types.
I need this for a @_specialize attribute with a type list.

PrintOptions.h and other headers depend on these enums. But Attr.h
defines a lot of classes that almost never need to be included.
2016-02-26 21:10:22 -08:00
Ben Langmuir
dbd32f31b9 [SourceKit] Add cursor/doc info for enum elements
Similarly to pattern binding decls, we want to be able to explode a case
decl out into a synthesized enum case for each individual enum element.
2016-02-26 16:28:13 -08:00
Doug Gregor
1c2ce6f22f [Omit needless words] Add a flag to let us skip overrides and witnesses.
When performing Swift API dumps, it's helpful to avoid putting
redundant APIs into the results. Therefore, filter out any APIs that
are overrides of another API or are witnesses for a protocol
requirement, since the original definition (that doesn't override any
other or is a protocol requirement) is what determines the APIs name.
2016-02-24 17:47:31 -08:00
practicalswift
6eefb5f8db [gardening] Fix recently introduced typo: "inteface" → "interface" 2016-02-19 14:19:56 +01:00
Xi Ge
17cde5322f [gardening] ASTPrinter: encapsulate archetype-transformation related stuff into a sub-structure. NFC 2016-02-17 15:35:28 -08:00
Xi Ge
d4f704bb2f ASTPrinter: Add pre and post callbacks for printing synthesized extensions and call them.
This is necessary for jump to synthesized extensions in IDE.
2016-02-15 17:41:49 -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
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
Zach Panzarino
e3a4147ac9 Update copyright date 2015-12-31 23:28:40 +00:00
practicalswift
22e10737e2 Fix typos 2015-12-26 01:19:40 +01: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
Slava Pestov
d432286980 Re-apply "Sema: Targeted fix for LLDB REPL issue"
Now with a change to the AST printer to never print @_fixed_layout.
Once some more groundwork is in place, we will be able to only print
this attribute when its needed, but this is good enough for now.
2015-11-20 20:01:46 -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