Skip to content

swift-api-digester: detected getter/setter function to property updates should be explicit about the new property names instead of inferring them from the old function names. #10212

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 12, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/swift/IDE/DigesterEnums.def
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ NODE_ANNOTATION(GenericParamDownCast)
NODE_ANNOTATION(TypeAliasChangeFromInt)
NODE_ANNOTATION(GetterToProperty)
NODE_ANNOTATION(SetterToProperty)
NODE_ANNOTATION(PropertyName)
NODE_ANNOTATION(TypeRewritten)
NODE_ANNOTATION(TypeRewrittenLeft)
NODE_ANNOTATION(TypeRewrittenRight)
Expand Down
1 change: 1 addition & 0 deletions test/api-digester/Inputs/APINotesLeft/APINotesTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ extern int ANTGlobalValue;
@protocol TypeWithMethod
-(void) minusPrint;
+(void) plusPrint;
-(int) getPropertyA;
@end
1 change: 1 addition & 0 deletions test/api-digester/Inputs/APINotesRight/APINotesTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ extern int ANTGlobalValue;
@protocol TypeWithMethod
-(void) minusPrint;
+(void) plusPrint;
@property int PropertyA;
@end
22 changes: 22 additions & 0 deletions test/api-digester/Outputs/apinotes-migrator-gen.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,26 @@
[
{
"DiffItemKind": "CommonDiffItem",
"NodeKind": "Function",
"NodeAnnotation": "GetterToProperty",
"ChildIndex": "0",
"LeftUsr": "c:objc(pl)TypeWithMethod(im)getPropertyA",
"LeftComment": "",
"RightUsr": "",
"RightComment": "propertyA",
"ModuleName": "APINotesTest"
},
{
"DiffItemKind": "CommonDiffItem",
"NodeKind": "TypeDecl",
"NodeAnnotation": "Rename",
"ChildIndex": "0",
"LeftUsr": "c:objc(pl)TypeWithMethod",
"LeftComment": "SwiftTypeWithMethodLeft",
"RightUsr": "",
"RightComment": "SwiftTypeWithMethodRight",
"ModuleName": "APINotesTest"
},
{
"DiffItemKind": "TypeMemberDiffItem",
"Usr": "c:@ANTGlobalValue",
Expand Down
8 changes: 7 additions & 1 deletion tools/swift-api-digester/swift-api-digester.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1637,6 +1637,8 @@ class RemovedAddedNodeMatcher : public NodeMatcher, public MatchedNodeListener {
} else {
return false;
}
R->annotate(NodeAnnotation::PropertyName);
R->addAnnotateComment(NodeAnnotation::PropertyName, A->getPrintedName());
foundMatch(R, A);
return true;
}
Expand Down Expand Up @@ -1867,7 +1869,8 @@ class SameNameNodeMatcher : public NodeMatcher {
return FuncPriority;
} else {
static NameMatchKind OtherPriority[] = { NameMatchKind::PrintedNameAndUSR,
NameMatchKind::PrintedName };
NameMatchKind::PrintedName,
NameMatchKind::USR };
return OtherPriority;
}
}
Expand Down Expand Up @@ -2455,6 +2458,9 @@ class DiffItemEmitter : public SDKNodeVisitor {
return Node->getAnnotateComment(NodeAnnotation::ModernizeEnum);
case NodeAnnotation::Rename:
return Node->getAnnotateComment(NodeAnnotation::RenameNewName);
case NodeAnnotation::GetterToProperty:
case NodeAnnotation::SetterToProperty:
return Node->getAnnotateComment(NodeAnnotation::PropertyName);
default:
return StringRef();
}
Expand Down