Skip to content

Commit b76e034

Browse files
committed
[ExtractAPI] Include +/- symbols for ObjC methods (llvm#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 bbcba93 commit b76e034

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
@@ -344,6 +344,22 @@ Object serializeNames(const APIRecord *Record) {
344344
serializeArray(Names, "subHeading",
345345
serializeDeclarationFragments(Record->SubHeading));
346346
DeclarationFragments NavigatorFragments;
347+
// The +/- prefix for Objective-C methods is important information, and
348+
// should be included in the navigator fragment. The entire subheading is
349+
// not included as it can contain too much information for other records.
350+
switch (Record->getKind()) {
351+
case APIRecord::RK_ObjCClassMethod:
352+
NavigatorFragments.append("+ ", DeclarationFragments::FragmentKind::Text,
353+
/*PreciseIdentifier*/ "");
354+
break;
355+
case APIRecord::RK_ObjCInstanceMethod:
356+
NavigatorFragments.append("- ", DeclarationFragments::FragmentKind::Text,
357+
/*PreciseIdentifier*/ "");
358+
break;
359+
default:
360+
break;
361+
}
362+
347363
NavigatorFragments.append(Record->Name,
348364
DeclarationFragments::FragmentKind::Identifier,
349365
/*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)