Commit Graph

228 Commits

Author SHA1 Message Date
Max Moiseev
e1de9fcf0c More test fixes 2017-01-09 16:17:21 -08:00
David Farler
f450f0ccdf Revert "Preserve whitespace and comments during lexing as Trivia"
This reverts commit d6e2b58382.
2016-11-18 13:23:31 -08:00
David Farler
d6e2b58382 Preserve whitespace and comments during lexing as Trivia
Store leading a trailing "trivia" around a token, such as whitespace,
comments, doc comments, and escaping backticks. These are syntactically
important for preserving formatting when printing ASTs but don't
semantically affect the program.

Tokens take all trailing trivia up to, but not including, the next
newline. This is important to maintain checks that statements without
semicolon separators start on a new line, among other things.

Trivia are now data attached to the ends of tokens, not tokens
themselves.

Create a new Syntax sublibrary for upcoming immutable, persistent,
thread-safe ASTs, which will contain only the syntactic information
about source structure, as well as for generating new source code, and
structural editing. Proactively move swift::Token into there.

Since this patch is getting a bit large, a token fuzzer which checks
for round-trip equivlence with the workflow:

fuzzer => token stream => file1
  => Lexer => token stream => file 2 => diff(file1, file2)

Will arrive in a subsequent commit.

This patch does not change the grammar.
2016-11-15 16:11:57 -08:00
Xi Ge
25179e1769 update existing test. 2016-10-21 12:59:50 -07:00
Michael Ilseman
8923a12585 [ASTPrinter] Switch to new ParameterTypeFlags
Switch printing off of using Function's ExtInfo for autoclosure and
escaping, and onto the ParameterTypeFlags, which let us do precise and
accurate context-sensitive printing of these parameter type
attributes. This fixes a huge list of issues where we were printing
@escaping for things like optional ObjC completion handlers, among
many others. We now correctly print @escaping in more places, and
don't print it when it's not correct.

Also updates the dumper to be consistent and give a good view of the
AST as represented in memory. Tests updated, more involved testing
coming soon.
2016-09-22 12:24:02 -07:00
Ingmar Stein
1eb0556bc3 Update test data 2016-09-03 18:01:23 +02:00
Ingmar Stein
dd3cc17cd2 Update test reference data 2016-09-03 16:43:11 +02:00
Ingmar Stein
98240ab871 [ClangImporter] import compound macros independent of order
This patch fixes an importer problem which occurred for macros defined
in terms of two other macros which might not have been imported before.
For example, the macro CPU_TYPE_X86_64 (defined as CPU_TYPE_X86 |
CPU_ARCH_ABI64) in Foundation wasn't imported although the importing
logic was implemented.

importMacro is now called for each of the constituents before checking
the constant value.
2016-09-03 16:43:11 +02:00
Dmitri Gribenko
55864d10cb Tests: use 'mkdir -p' 2016-09-02 21:36:45 -07:00
Doug Gregor
b56bb3d344 [AST] Fix the source range of pattern bindings with accessors.
The source range didn’t include the accessors themselves, so it wasn’t covering its child nodes.
2016-09-02 16:30:08 -07:00
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
Dmitri Gribenko
d175b3b66d Migrate FileCheck to %FileCheck in tests 2016-08-10 23:52:02 -07:00
Jordan Rose
b4e6f45083 [ClangImporter] Don't bridge weak and unsafe_unretained properties.
...to value types. Do continue bridging BOOL to Bool and such.

If the Objective-C API author went out of their way to indicate
ownership, they're probably using the reference semantics for
something. Give them the benefit of the doubt and leave the properties
declared using reference types. (It's not that they wouldn't work
correctly using Any, but that it's obscuring the intended interface.
And any /specific/ bridged value types /might/ actually cause issues
by causing copies.)

There is one wrinkle here involving declarations in the "accessibility
protocols" on Apple platforms, which sometimes use methods and
sometimes properties. The Swift compiler already deals with these by
always importing these as methods, so treat these like any other
methods and use value types when relevant.

rdar://problem/27526957
2016-08-03 20:43:35 -07:00
John McCall
afdda3d107 Implement SE-0117.
One minor revision: this lifts the proposed restriction against
overriding a non-open method with an open one.  On reflection,
that was inconsistent with the existing rule permitting non-public
methods to be overridden with public ones.  The restriction on
subclassing a non-open class with an open class remains, and is
in fact consistent with the existing access rule.
2016-08-02 07:46:38 -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
Joe Groff
5bfd6cc0c7 Update SourceKit tests for id-as-Any. 2016-07-25 06:40:36 -07:00
Slava Pestov
ddc51c5917 AST: Implement SE-0102, introducing new semantics for Never alongside @noreturn
No migrator support yet, and the code for @noreturn is still in
place.
2016-07-22 14:56:39 -07:00
Luke Larson
74e0498015 Revert "Update master to build with Xcode 8 beta 3, OS X 10.12, iOS 10, tvOS 10, and watchOS 3 SDKs."
This reverts commit 62d1fa760c.
2016-07-19 15:18:17 -07:00
Mishal Shah
62d1fa760c Update master to build with Xcode 8 beta 3, OS X 10.12, iOS 10, tvOS 10, and watchOS 3 SDKs. 2016-07-19 22:31:34 +02:00
Xi Ge
2a860100a5 [SourceKit] Implement a new SourceKit request to generate the interface for a given type. rdar://27306890 (#3586)
This patch allows SourceKit to generate the interface for a given type specified by its mangled name.
Type interface is refined decl printing with type parameters localized and unusable members hidden.

Required field:
   "key.request": "source.request.editor.open.interface.swifttype"
   "key.usr": the mangled name of the given type.
2016-07-18 18:05:47 -07:00
Chris Lattner
af30ae3222 Remove the last parts of the Boolean protocol, finishing up:
SE-0109: Remove the Boolean protocol.

We still love you George, even if we forgot your e.
2016-07-17 22:18:17 -07:00
Robert Widmann
c39da37525 Merge pull request #3474 from CodaFi/postminimalist-abstract-expressionism
[SE-0115] Rename *LiteralConvertible protocols to ExpressibleBy*…
2016-07-12 21:08:52 -07:00
Xi Ge
b665de844c Merge pull request #3472 from nkcsgexi/type-interface
[SourceKit] In CursorInfo response, include the mangle name of type.
2016-07-12 17:49:16 -07:00
Robert Widmann
f97e5dcb0e [SE-0115][1/2] Rename *LiteralConvertible protocols to ExpressibleBy*Literal. This
change includes both the necessary protocol updates and the deprecation
warnings
suitable for migration.  A future patch will remove the renamings and
make this
a hard error.
2016-07-12 15:25:24 -07:00
Xi Ge
a5e51a3494 [SourceKit] In CursorInfo response, include the mangle name of the type of the underlying decl.
The mangled name of the type is identical to those for debugger. These
mangled names allow us to reconstruct the type from AST and generate interface
specifically for that type.

Related rdar://27306890
2016-07-12 13:10:58 -07:00
Doug Gregor
823c24b355 [SE-0112] Rename ErrorProtocol to Error.
This is bullet (5) of the proposed solution in SE-0112, and the last
major piece to be implemented.
2016-07-12 10:53:52 -07:00
Jordan Rose
aee92ff612 SE-0025: Parsing and basic completion for 'fileprivate'. (#3391)
Right now 'fileprivate' is parsed as an alias for 'private' (or
perhaps vice versa, since the semantics of 'private' haven't changed
yet). This allows us to migrate code to 'fileprivate' without waiting
for the full implementation.
2016-07-07 15:20:41 -07:00
Brian Croom
98e3ca8bc4 Annotate some SourceKit tests that fail on Linux.
* A bunch of them require objc_interop because they import code containing
  Objective-C.
* Many others fail on Ubuntu 14.04 because the C++ there doesn't have a
  functional std::regex implementation which is required by the
  `complete-test` tool.

It may be possible to adjust some of these tests in the future to not
need these extra requirements, but this is a straightforward way to
clean up Linux test results for now.
2016-06-14 08:55:48 -04:00
Nate Cook
dee12dca75 [stdlib] Update tests for new String documentation
In addition to a new test fixture for 'SourceKit/DocSupport/
doc_clang_module.swift', this removes the check for an ASCII-only
generated standard library interface from 'SourceKit/InterfaceGen/
gen_stdlib.swift'.
2016-05-22 03:11:00 -05:00
Dmitri Gribenko
c52787e900 Merge commit '9cdbec13eee72feccfc5f8b987882a8c52e8107b' into swift-3-indexing-model 2016-04-14 16:23:53 -07:00
Dmitri Gribenko
3e708a9328 Merge commit '8e292daec1bc790c96b5ee39b8d55dadcac6ce1b' into swift-3-indexing-model 2016-04-14 15:10:26 -07:00
Dmitri Gribenko
10697f939f Merge commit '510f29abf77e202780c11d5f6c7449313c819030' into swift-3-indexing-model 2016-04-14 13:45:27 -07:00
Jordan Rose
bc83940301 Make pointer nullability explicit using Optional.
Implements SE-0055: https://github.com/apple/swift-evolution/blob/master/proposals/0055-optional-unsafe-pointers.md

- Add NULL as an extra inhabitant of Builtin.RawPointer (currently
  hardcoded to 0 rather than being target-dependent).
- Import non-object pointers as Optional/IUO when nullable/null_unspecified
  (like everything else).
- Change the type checker's *-to-pointer conversions to handle a layer of
  optional.
- Use 'AutoreleasingUnsafeMutablePointer<NSError?>?' as the type of error
  parameters exported to Objective-C.
- Drop NilLiteralConvertible conformance for all pointer types.
- Update the standard library and then all the tests.

I've decided to leave this commit only updating existing tests; any new
tests will come in the following commits. (That may mean some additional
implementation work to follow.)

The other major piece that's missing here is migration. I'm hoping we get
a lot of that with Swift 1.1's work for optional object references, but
I still need to investigate.
2016-04-11 20:06:38 -07:00
Jordan Rose
1c25faaec3 [test] Adjust SourceKit test for CF importing.
The test was supposed to use a CF type, but it wasn't updated
for the switch from a naming convention to an attribute. This
restores the original intent (and unfortunately slides all the
offsets).
2016-04-11 17:55:10 -07:00
practicalswift
ea0ac3ac67 [gardening] Remove all tabs in C++ code 2016-04-08 21:22:57 +02:00
Manav Gabhawala
7928140f79 [SE-0046] Implements consistent function parameter labels by discarding extraneous parameter names and adding _ where necessary 2016-04-06 20:21:58 -04:00
Xi Ge
173e954cc2 test: update IDE and SourceKit tests due to stdlib changes. 2016-04-05 15:19:28 -07:00
Manav Gabhawala
7862f104c9 [Parser] Cleans up parsing of parameter attributes. Implements SE-0053. Fixes SR-979, SR-1020 and cleans up implementation of SE-0003. Provides better fix-its and diagnostics for misplaced 'inout' and prohibits 'var' and 'let' from parameter attributes 2016-03-29 13:55:46 -04:00
Xi Ge
fda0751cae [SourceKit] In interface-gen request, allow clients to send SourceKit an interested USR from which we can infer the group name. 2016-03-23 17:26:44 -07:00
Xi Ge
a9727dbace ModuleGroup: Add several subgroups. 2016-03-15 17:00:00 -07:00
Daniel Duan
7cabf3555b [Parser] update test for SE-0040 changes 2016-03-11 16:01:37 -08:00
Xi Ge
5168083bf3 ModulePrinting: Print new lines between members of a decl. 2016-03-11 12:26:04 -08:00
Max Moiseev
a49dab6bf8 Merge remote-tracking branch 'origin/master' into swift-3-api-guidelines 2016-02-29 12:08:52 -08:00
Dmitri Gribenko
a257715fcc Revert "[stdlib] [SE-0031] update stdlib for SE-0031 (inout adjustment)" 2016-02-26 11:17:10 -08:00
Daniel Duan
13b5c8f3bc [SE-0031] update code base for SE-0031 (inout adjustment) 2016-02-26 10:52:10 -08:00
Xi Ge
48754aabfa Module groups: Respect IDE's conventions, use '/' as sub-group indicators. 2016-02-25 18:03:39 -08:00
Dmitri Gribenko
f3389273ba stdlib: String indices: samePositionIn(_:) => samePosition(in:) 2016-02-24 16:29:27 -08:00
Max Moiseev
bb3eaaf308 Merging in latest master 2016-02-24 15:10:25 -08:00
Xi Ge
b812efa4cc Module groups: Make 'lazy views' a sub-group of the 'collection' group. 2016-02-23 13:57:48 -08:00
Max Moiseev
fcad164e18 Merge remote-tracking branch 'origin/master' into swift-3-api-guidelines 2016-02-22 12:59:57 -08:00