Skip to content

Commit a31d810

Browse files
committed
[migrator] Handle simple renames for TypeDecl
Previously we only handle VarDecl, but it ought to work for types as well.
1 parent 3801f4b commit a31d810

File tree

5 files changed

+20
-1
lines changed

5 files changed

+20
-1
lines changed

lib/Migrator/APIDiffMigratorPass.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,8 @@ struct APIDiffMigratorPass : public ASTMigratorPass, public SourceEntityWalker {
295295

296296
// Simple rename.
297297
if (auto CI = dyn_cast<CommonDiffItem>(Item)) {
298-
if (CI->NodeKind == SDKNodeKind::DeclVar && CI->isRename()) {
298+
if (CI->isRename() && (CI->NodeKind == SDKNodeKind::DeclVar ||
299+
CI->NodeKind == SDKNodeKind::DeclType)) {
299300
Text = CI->getNewName();
300301
return true;
301302
}

test/Migrator/Inputs/API.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -498,5 +498,16 @@
498498
"NewTypeName": "example",
499499
"SelfIndex": 0,
500500
"RemovedIndex": 1
501+
},
502+
{
503+
"DiffItemKind": "CommonDiffItem",
504+
"NodeKind": "TypeDecl",
505+
"NodeAnnotation": "Rename",
506+
"ChildIndex": "0",
507+
"LeftUsr": "c:objc(cs)BarBaseNested",
508+
"LeftComment": "BarBaseNested",
509+
"RightUsr": "",
510+
"RightComment": "BarBase.Nested",
511+
"ModuleName": "bar"
501512
}
502513
]

test/Migrator/mock-sdk/Bar.framework/Headers/Bar.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,8 @@ typedef NS_ENUM(long, FooComparisonResult) {
5353
FooOrderedSame,
5454
FooOrderedDescending
5555
};
56+
57+
@interface BarBase
58+
@end
59+
@interface BarBaseNested
60+
@end

test/Migrator/rename.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ func foo(_ b: BarForwardDeclaredClass) {
1717
barGlobalFuncOldName(2)
1818
_ = barGlobalVariableOldEnumElement
1919
_ = PropertyUserInterface.methodPlus()
20+
let _: BarBaseNested
2021
}
2122

2223
func foo1(_ b: BarForwardDeclaredClass) {

test/Migrator/rename.swift.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ func foo(_ b: BarForwardDeclaredClass) {
1717
barGlobalFuncNewName(newlabel: 2)
1818
_ = NewEnum.enumElement
1919
_ = PropertyUserInterface.newMethodPlus()
20+
let _: BarBase.Nested
2021
}
2122

2223
func foo1(_ b: BarForwardDeclaredClass) {

0 commit comments

Comments
 (0)