Skip to content
Snippets Groups Projects
Commit 4048aad8 authored by Zixu Wang's avatar Zixu Wang
Browse files

[clang][ExtractAPI] Fix declaration fragments for ObjC methods

Objective-C methods selector parts should be considered as identifiers.

Depends on D123259

Differential Revision: https://reviews.llvm.org/D123261
parent 17fdaccc
No related branches found
No related tags found
No related merge requests found
......@@ -593,20 +593,21 @@ DeclarationFragments DeclarationFragmentsBuilder::getFragmentsForObjCMethod(
// For Objective-C methods that take arguments, build the selector slots.
for (unsigned i = 0, end = Method->param_size(); i != end; ++i) {
Fragments.appendSpace()
.append(Selector.getNameForSlot(i),
// The first slot is the name of the method, record as an
// identifier, otherwise as exteranl parameters.
i == 0 ? DeclarationFragments::FragmentKind::Identifier
: DeclarationFragments::FragmentKind::ExternalParam)
.append(":", DeclarationFragments::FragmentKind::Text);
// Objective-C method selector parts are considered as identifiers instead
// of "external parameters" as in Swift. This is because Objective-C method
// symbols are referenced with the entire selector, instead of just the
// method name in Swift.
SmallString<32> ParamID(Selector.getNameForSlot(i));
ParamID.append(":");
Fragments.appendSpace().append(
ParamID, DeclarationFragments::FragmentKind::Identifier);
// Build the internal parameter.
const ParmVarDecl *Param = Method->getParamDecl(i);
Fragments.append(getFragmentsForParam(Param));
}
return Fragments;
return Fragments.append(";", DeclarationFragments::FragmentKind::Text);
}
DeclarationFragments DeclarationFragmentsBuilder::getFragmentsForObjCProperty(
......
......@@ -136,6 +136,10 @@
{
"kind": "identifier",
"spelling": "InstanceMethod"
},
{
"kind": "text",
"spelling": ";"
}
],
"identifier": {
......@@ -190,6 +194,10 @@
{
"kind": "identifier",
"spelling": "ClassMethod"
},
{
"kind": "text",
"spelling": ";"
}
],
"identifier": {
......
......@@ -146,11 +146,7 @@
},
{
"kind": "identifier",
"spelling": "getWithProperty"
},
{
"kind": "text",
"spelling": ":"
"spelling": "getWithProperty:"
},
{
"kind": "text",
......@@ -168,6 +164,10 @@
{
"kind": "internalParam",
"spelling": "Property"
},
{
"kind": "text",
"spelling": ";"
}
],
"identifier": {
......@@ -403,6 +403,10 @@
{
"kind": "identifier",
"spelling": "getIvar"
},
{
"kind": "text",
"spelling": ";"
}
],
"identifier": {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment