Skip to content

Commit 05b4bfe

Browse files
authored
[ExtractAPI] Include +/- symbols for ObjC methods (#145035)
ObjC methods include a +/- prefix to indicate if they are a class or instance method. This information is valuable, and must be included in the navigator generated by ExtractAPI. rdar://150870936
1 parent 9dc59cc commit 05b4bfe

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,22 @@ Object serializeNames(const APIRecord *Record) {
341341
serializeArray(Names, "subHeading",
342342
serializeDeclarationFragments(Record->SubHeading));
343343
DeclarationFragments NavigatorFragments;
344+
// The +/- prefix for Objective-C methods is important information, and
345+
// should be included in the navigator fragment. The entire subheading is
346+
// not included as it can contain too much information for other records.
347+
switch (Record->getKind()) {
348+
case APIRecord::RK_ObjCClassMethod:
349+
NavigatorFragments.append("+ ", DeclarationFragments::FragmentKind::Text,
350+
/*PreciseIdentifier*/ "");
351+
break;
352+
case APIRecord::RK_ObjCInstanceMethod:
353+
NavigatorFragments.append("- ", DeclarationFragments::FragmentKind::Text,
354+
/*PreciseIdentifier*/ "");
355+
break;
356+
default:
357+
break;
358+
}
359+
344360
NavigatorFragments.append(Record->Name,
345361
DeclarationFragments::FragmentKind::Identifier,
346362
/*PreciseIdentifier*/ "");

clang/test/ExtractAPI/objc_instancetype.m

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,10 @@ - (id) reset;
157157
},
158158
"names": {
159159
"navigator": [
160+
{
161+
"kind": "text",
162+
"spelling": "- "
163+
},
160164
{
161165
"kind": "identifier",
162166
"spelling": "init"
@@ -228,6 +232,10 @@ - (id) reset;
228232
},
229233
"names": {
230234
"navigator": [
235+
{
236+
"kind": "text",
237+
"spelling": "- "
238+
},
231239
{
232240
"kind": "identifier",
233241
"spelling": "reset"

0 commit comments

Comments
 (0)