Skip to content

Commit a280c5b

Browse files
authored
Merge pull request #16821 from nkcsgexi/api-diff-enh-revert
2 parents 33a6e1c + b008455 commit a280c5b

File tree

2 files changed

+32
-13
lines changed

2 files changed

+32
-13
lines changed

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

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
"NodeAnnotation": "RevertSimpleStringRepresentableUpdate",
66
"ChildIndex": "1",
77
"LeftUsr": "c:objc(cs)AnimalStatusDescriptor(cm)animalStatusSingleAttribute:",
8-
"LeftComment": "",
8+
"LeftComment": "AnimalAttributeName",
99
"RightUsr": "",
10-
"RightComment": "",
10+
"RightComment": "String",
1111
"ModuleName": "APINotesTest"
1212
},
1313
{
@@ -27,9 +27,9 @@
2727
"NodeAnnotation": "RevertSimpleOptionalStringRepresentableUpdate",
2828
"ChildIndex": "1",
2929
"LeftUsr": "c:objc(cs)AnimalStatusDescriptor(cm)animalStatusSingleOptionalAttribute:",
30-
"LeftComment": "",
30+
"LeftComment": "AnimalAttributeName",
3131
"RightUsr": "",
32-
"RightComment": "",
32+
"RightComment": "String",
3333
"ModuleName": "APINotesTest"
3434
},
3535
{
@@ -49,9 +49,9 @@
4949
"NodeAnnotation": "RevertDictionaryKeyUpdate",
5050
"ChildIndex": "1",
5151
"LeftUsr": "c:objc(cs)AnimalStatusDescriptor(im)animalStatusDescriptorByAddingAttributes:",
52-
"LeftComment": "",
52+
"LeftComment": "AnimalAttributeName",
5353
"RightUsr": "",
54-
"RightComment": "",
54+
"RightComment": "String",
5555
"ModuleName": "APINotesTest"
5656
},
5757
{
@@ -71,9 +71,9 @@
7171
"NodeAnnotation": "RevertArrayMemberUpdate",
7272
"ChildIndex": "1",
7373
"LeftUsr": "c:objc(cs)AnimalStatusDescriptor(im)animalStatusDescriptorByAddingAttributesArray:",
74-
"LeftComment": "",
74+
"LeftComment": "AnimalAttributeName",
7575
"RightUsr": "",
76-
"RightComment": "",
76+
"RightComment": "String",
7777
"ModuleName": "APINotesTest"
7878
},
7979
{
@@ -93,9 +93,9 @@
9393
"NodeAnnotation": "RevertOptionalDictionaryKeyUpdate",
9494
"ChildIndex": "1",
9595
"LeftUsr": "c:objc(cs)AnimalStatusDescriptor(im)animalStatusDescriptorByAddingOptionalAttributes:",
96-
"LeftComment": "",
96+
"LeftComment": "AnimalAttributeName",
9797
"RightUsr": "",
98-
"RightComment": "",
98+
"RightComment": "String",
9999
"ModuleName": "APINotesTest"
100100
},
101101
{
@@ -115,9 +115,9 @@
115115
"NodeAnnotation": "RevertOptionalArrayMemberUpdate",
116116
"ChildIndex": "1",
117117
"LeftUsr": "c:objc(cs)AnimalStatusDescriptor(im)animalStatusDescriptorByAddingOptionalAttributesArray:",
118-
"LeftComment": "",
118+
"LeftComment": "AnimalAttributeName",
119119
"RightUsr": "",
120-
"RightComment": "",
120+
"RightComment": "String",
121121
"ModuleName": "APINotesTest"
122122
},
123123
{

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

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2704,7 +2704,8 @@ class InterfaceTypeChangeDetector {
27042704

27052705
bool detectTypeRewritten(SDKNodeType *Node, SDKNodeType *Counter) {
27062706
if (IsVisitingLeft &&
2707-
(Node->getName() != Counter->getName()||
2707+
Node->getPrintedName() != Counter->getPrintedName() &&
2708+
(Node->getName() != Counter->getName() ||
27082709
Node->getChildrenCount() != Counter->getChildrenCount())) {
27092710
Node->annotate(NodeAnnotation::TypeRewritten);
27102711
Node->annotate(NodeAnnotation::TypeRewrittenLeft, Node->getPrintedName());
@@ -2794,6 +2795,8 @@ class InterfaceTypeChangeDetector {
27942795
R->annotate(HasOptional ?
27952796
NodeAnnotation::RevertOptionalDictionaryKeyUpdate :
27962797
NodeAnnotation::RevertDictionaryKeyUpdate);
2798+
R->annotate(NodeAnnotation::RawTypeLeft, KeyChangedTo);
2799+
R->annotate(NodeAnnotation::RawTypeRight, Raw);
27972800
}
27982801
return true;
27992802
}
@@ -2843,6 +2846,8 @@ class InterfaceTypeChangeDetector {
28432846
R->annotate(HasOptional ?
28442847
NodeAnnotation::RevertOptionalArrayMemberUpdate :
28452848
NodeAnnotation::RevertArrayMemberUpdate);
2849+
R->annotate(NodeAnnotation::RawTypeLeft, KeyChangedTo);
2850+
R->annotate(NodeAnnotation::RawTypeRight, Raw);
28462851
}
28472852
return true;
28482853
}
@@ -2874,6 +2879,8 @@ class InterfaceTypeChangeDetector {
28742879
NodeAnnotation::SimpleOptionalStringRepresentableUpdate:
28752880
NodeAnnotation::SimpleStringRepresentableUpdate);
28762881
} else {
2882+
R->annotate(NodeAnnotation::RawTypeLeft, KeyChangedTo);
2883+
R->annotate(NodeAnnotation::RawTypeRight, Raw);
28772884
R->annotate(HasOptional ?
28782885
NodeAnnotation::RevertSimpleOptionalStringRepresentableUpdate:
28792886
NodeAnnotation::RevertSimpleStringRepresentableUpdate);
@@ -3051,6 +3058,12 @@ class DiffItemEmitter : public SDKNodeVisitor {
30513058
case NodeAnnotation::OptionalDictionaryKeyUpdate:
30523059
case NodeAnnotation::SimpleStringRepresentableUpdate:
30533060
case NodeAnnotation::SimpleOptionalStringRepresentableUpdate:
3061+
case NodeAnnotation::RevertArrayMemberUpdate:
3062+
case NodeAnnotation::RevertOptionalArrayMemberUpdate:
3063+
case NodeAnnotation::RevertDictionaryKeyUpdate:
3064+
case NodeAnnotation::RevertOptionalDictionaryKeyUpdate:
3065+
case NodeAnnotation::RevertSimpleStringRepresentableUpdate:
3066+
case NodeAnnotation::RevertSimpleOptionalStringRepresentableUpdate:
30543067
return Node->getAnnotateComment(NodeAnnotation::RawTypeLeft);
30553068
case NodeAnnotation::TypeRewritten:
30563069
return Node->getAnnotateComment(NodeAnnotation::TypeRewrittenLeft);
@@ -3069,6 +3082,12 @@ class DiffItemEmitter : public SDKNodeVisitor {
30693082
case NodeAnnotation::OptionalDictionaryKeyUpdate:
30703083
case NodeAnnotation::SimpleStringRepresentableUpdate:
30713084
case NodeAnnotation::SimpleOptionalStringRepresentableUpdate:
3085+
case NodeAnnotation::RevertArrayMemberUpdate:
3086+
case NodeAnnotation::RevertOptionalArrayMemberUpdate:
3087+
case NodeAnnotation::RevertDictionaryKeyUpdate:
3088+
case NodeAnnotation::RevertOptionalDictionaryKeyUpdate:
3089+
case NodeAnnotation::RevertSimpleStringRepresentableUpdate:
3090+
case NodeAnnotation::RevertSimpleOptionalStringRepresentableUpdate:
30723091
return Node->getAnnotateComment(NodeAnnotation::RawTypeRight);
30733092
case NodeAnnotation::TypeRewritten:
30743093
return Node->getAnnotateComment(NodeAnnotation::TypeRewrittenRight);

0 commit comments

Comments
 (0)