Commit Graph

80 Commits

Author SHA1 Message Date
Xi Ge
a138744e45 migrator: teach the tool to handle OptionalDictionaryKeyUpdate attributes emitted from swift-api-digester.
For a function call used to take [String: Any]? as argument and now
takes [StringRepresentableStruct: Any]?, a helper function is inserted
to help the bridging of types.
2018-04-16 10:57:36 -07:00
Xi Ge
4c10f16c0e migrator: teach the tool to handle DictionaryKeyUpdate attribute on arguments.
When a user's code calls a function that used to take [String: Any] as
argument and now takes [StringRepresentableStruct: Any], this migration
inserts a helper function to convert the argument to the
expected type.
2018-04-13 16:55:19 -07:00
Xi Ge
4c4e4d2b79 migrator: handle simple attribute assignment and reference.
This patch migrates simple attribute assignment and reference when the
attribute used to be of type String and later became StringRepresentable struct.

Related: rdar://38192995
2018-04-12 11:54:28 -07:00
Xi Ge
4705e0790c swift-api-digester: rename SDK nodes internally. NFC 2018-04-05 15:55:41 -07:00
Huon Wilson
e307e54098 [AST] Explicitly track things marked __owned. 2018-03-08 12:36:24 +11:00
David Zarzycki
408bf0d840 [AST] NFC: Migrate CompoundIdentTypeRepr to llvm::TrailingObjects 2017-12-30 10:56:37 -05:00
Xi Ge
f2ef42baed [migrator] When renaming a function decl, we should use underscore to represent empty external argument label. rdar://34569243 (#12221) 2017-10-02 12:31:09 -07:00
Robert Widmann
b77f2c147c Parse Shared
Add parser support for __shared and __owned as type attributes.  Also, extend parser diagnostics and tests to account for the new type attributes.
2017-07-23 21:47:25 -07:00
Harlan
e89e7f58b2 [Parse] [Syntax] Simplify TupleTypeRepr parsing and add attributes for Syntax (#8298)
* Simplify TupleTypeRepr parsing

This patch introduces a TupleTypeReprElement struct that holds the
locations for all relevant bits of tuple elements. It removes the
NameLoc and UnderscoreLoc arrays from TupleTypeReprElement in favor of
holding each of these on TupleTypeReprElement. These extra bits of info
are required for full-fidelity representation in the Syntax library.

* Remove TupleTypeReprBitfields and move EllipsisLoc out of TrailingObjects

* Update users of TupleTypeRepr

* Don't resize the elts if we're going to push_back

* getType -> getElementType

* Move ellipsis back into TrailingObjects.

* Move NumElements into TupleTypeReprBitfields
2017-06-27 10:54:47 -07:00
Xi Ge
476534d1e2 migrator: handle qualified replacement for member reference expression. rdar://32845918 (#10593)
Previously, we only handle dot syntax call expression for qualified
replacement, i.e. changing from A.a to B.b. This patch teaches the tool
to handle the migration of member reference expression tool.
2017-06-26 15:47:17 -07:00
David Farler
789bd3749f [Migrator] Use toLowercaseWord to lowercase SetterToProperty changes
Post-commit review follow-up:
This works better for properties that were all-caps, such as `URL`.

Thanks @harlanhaskins for the tip!

rdar://problem/32845968
2017-06-26 12:53:15 -07:00
David Farler
71e38d85d4 [Migrator] Make sure to lowercase properties in SetterToProperty
Previously we were only stripping `set` from the name and not
lowercasing the property.

rdar://problem/32845968
2017-06-23 16:37:16 -07:00
David Farler
c2876dfb69 [Migrator] Migrate x.toIntMax() to Int64(x)
These protocol methods were hard-obsoleted in Swift 4.

rdar://problem/32437759
2017-06-14 14:21:51 -07:00
David Farler
970127b745 [Migrator] Add special-case migration for NSOpenGLGetVersion
This was added in the AppKit overlay as a part of general
AppKit API improvements for Swift 4.

rdar://problem/32178777
2017-06-14 14:21:50 -07:00
Xi Ge
9f456b19a3 migrator: use the right method to get the location of return type. rdar://32545812
TypeLoc::getLoc() is not necessarily the start location of the type repr.
2017-06-02 15:17:24 -07:00
Xi Ge
0b8b0207e6 migrator: teach the tool to handle qualified replacement. rdar://32466196 2017-06-01 13:15:12 -07:00
Pavel Yaskevich
c94fe94d5d [Diagnostics] Add a fix-it for optional to raw representable type conversion
Situations where there is a contextual RawRepresentable type is
used incorrectly would produce `<Type>(rawValue: )` fix-it only
in cases where neither or both sides of the expression are optional.
Let's fix that by adding a fix-it for optional to contextual raw
value type conversion.

Resolves: rdar://problem/32431736
2017-05-31 13:58:17 -07:00
Xi Ge
824aaa11e2 swift-api-digester: detect the move of static members only.
This patch restricts the detection of moved members to be static members,
since only in this case we need to update qualified access to
them. The move of instance members will be either handled by rename or
we don't need to update anything at all.

Additionally, this patch introduces a sub-kind of type member diff item
called qualified replacement to describe the aforementioned case. However,
the migrator part has not started to honor this sub-kind yet.

rdar://32466196
2017-05-31 11:47:27 -07:00
Xi Ge
ee4293fea1 IDE Utils: For DeclNameViewer, we should use empty StringRef to represent empty argument label instead of using "_". (#9988) 2017-05-30 17:29:57 -07:00
Xi Ge
c7b4e36476 [migrator] Handle renaming from explicit argument label to empty argument label at call sites. rdar://32241559 (#9873) 2017-05-23 11:34:05 -07:00
Xi Ge
1019396663 [migrator] Handle getter function to property change in function overrides. (#9844)
We used to only migrate them in call sites, e.g. changing from
``p.getHeight()`` to ``p.Height``. However, with experimenting on more real-world
projects, we realize migrating overrides is equally important.

rdar://32265583
2017-05-22 16:11:53 -07:00
Xi Ge
058d7f62e8 [migrator] Various quality improvement on type-hoist API migrations. rdar://32186526 (#9600) 2017-05-14 19:25:01 -07:00
David Farler
0baa7c6dd8 [Migrator] Migrate Static member abs function calls to Swift.abs
These are deprecated in Swift 3, but are hard obsoleted in Swift 4.

rdar://problem/31070486
2017-05-14 16:55:34 -07:00
Xi Ge
ff2622734e migrator: handle the special migration cases of NSOpenGLSetOption/NSOpenGLGetOption. rdar://32178753 (#9591) 2017-05-14 13:00:03 -07:00
Xi Ge
65b9043eb1 migrator: handle function hoist API changes and several its varieties. rdar://31234806 (#9544) 2017-05-12 21:34:06 -07:00
Xi Ge
fb77682b5a [Migrator] Add a stub for authored API change list to handle API changes that are not detected automatically. (#9477) 2017-05-10 21:51:25 -07:00
swift-ci
c352f98ae9 Merge pull request #9428 from practicalswift/gardening-20170509b 2017-05-09 15:01:08 -07:00
practicalswift
8c40c65c80 [gardening] Fix typos. 2017-05-09 21:50:04 +02:00
Nathan Hawes
0410f17c1b [Migrator] Fix optional types not being updated correctly in some cases
If the replacement type was a function type or protocol-constrained type (e.g.  'Class & Proto) and the existing type had a postfix ? or !, we weren't wrapping the replacement in parens. This would result in an incorrect/ambiguous new type. This patch wraps the replacement in parens if it contains an & or ->, the existing type has a trailing ? or !.

Resolves rdar://problem/32082269.
2017-05-09 12:08:13 -07:00
David Farler
0774db030f [Migrator] Separate AST Pass implementations
The SyntacticMigratorPass is getting Too Big To Fail and covers
multiple migrations. There was already an early exit to not run
the pass if APIDigesterDataStorePath wasn't supplied, so SE-0110
tuple splat fix-its weren't getting run. This manifested in Migrator
tests not printing migrated contents on Linux.

New: ASTMigratorPass
Renamed: SyntacticMigratorPass -> APIDiffMigratorPass
New: TupleSplatMigratorPass

These implementations are entirely hidden and can only be invoked
by a swift::migrator function.

rdar://problem/32025974
2017-05-05 23:35:13 -07:00