Skip to content

Commit ce17eae

Browse files
committed
swift-api-digester: detected getter/setter function to property updates should be explicit about the new property names instead of inferring them from old function name.
1 parent 94c00c4 commit ce17eae

File tree

5 files changed

+32
-1
lines changed

5 files changed

+32
-1
lines changed

include/swift/IDE/DigesterEnums.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ NODE_ANNOTATION(GenericParamDownCast)
5656
NODE_ANNOTATION(TypeAliasChangeFromInt)
5757
NODE_ANNOTATION(GetterToProperty)
5858
NODE_ANNOTATION(SetterToProperty)
59+
NODE_ANNOTATION(PropertyName)
5960
NODE_ANNOTATION(TypeRewritten)
6061
NODE_ANNOTATION(TypeRewrittenLeft)
6162
NODE_ANNOTATION(TypeRewrittenRight)

test/api-digester/Inputs/APINotesLeft/APINotesTest.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ extern int ANTGlobalValue;
88
@protocol TypeWithMethod
99
-(void) minusPrint;
1010
+(void) plusPrint;
11+
-(int) getPropertyA;
1112
@end

test/api-digester/Inputs/APINotesRight/APINotesTest.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ extern int ANTGlobalValue;
88
@protocol TypeWithMethod
99
-(void) minusPrint;
1010
+(void) plusPrint;
11+
@property int PropertyA;
1112
@end

test/api-digester/Outputs/apinotes-migrator-gen.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,26 @@
11
[
2+
{
3+
"DiffItemKind": "CommonDiffItem",
4+
"NodeKind": "Function",
5+
"NodeAnnotation": "GetterToProperty",
6+
"ChildIndex": "0",
7+
"LeftUsr": "c:objc(pl)TypeWithMethod(im)getPropertyA",
8+
"LeftComment": "",
9+
"RightUsr": "",
10+
"RightComment": "propertyA",
11+
"ModuleName": "APINotesTest"
12+
},
13+
{
14+
"DiffItemKind": "CommonDiffItem",
15+
"NodeKind": "TypeDecl",
16+
"NodeAnnotation": "Rename",
17+
"ChildIndex": "0",
18+
"LeftUsr": "c:objc(pl)TypeWithMethod",
19+
"LeftComment": "SwiftTypeWithMethodLeft",
20+
"RightUsr": "",
21+
"RightComment": "SwiftTypeWithMethodRight",
22+
"ModuleName": "APINotesTest"
23+
},
224
{
325
"DiffItemKind": "TypeMemberDiffItem",
426
"Usr": "c:@ANTGlobalValue",

tools/swift-api-digester/swift-api-digester.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1637,6 +1637,8 @@ class RemovedAddedNodeMatcher : public NodeMatcher, public MatchedNodeListener {
16371637
} else {
16381638
return false;
16391639
}
1640+
R->annotate(NodeAnnotation::PropertyName);
1641+
R->addAnnotateComment(NodeAnnotation::PropertyName, A->getPrintedName());
16401642
foundMatch(R, A);
16411643
return true;
16421644
}
@@ -1867,7 +1869,8 @@ class SameNameNodeMatcher : public NodeMatcher {
18671869
return FuncPriority;
18681870
} else {
18691871
static NameMatchKind OtherPriority[] = { NameMatchKind::PrintedNameAndUSR,
1870-
NameMatchKind::PrintedName };
1872+
NameMatchKind::PrintedName,
1873+
NameMatchKind::USR };
18711874
return OtherPriority;
18721875
}
18731876
}
@@ -2455,6 +2458,9 @@ class DiffItemEmitter : public SDKNodeVisitor {
24552458
return Node->getAnnotateComment(NodeAnnotation::ModernizeEnum);
24562459
case NodeAnnotation::Rename:
24572460
return Node->getAnnotateComment(NodeAnnotation::RenameNewName);
2461+
case NodeAnnotation::GetterToProperty:
2462+
case NodeAnnotation::SetterToProperty:
2463+
return Node->getAnnotateComment(NodeAnnotation::PropertyName);
24582464
default:
24592465
return StringRef();
24602466
}

0 commit comments

Comments
 (0)