[sourcekitd] Take the colons out of name-translation API

This makes us more lenient about what we accept for Objective-C
selectors by allowing you to include or not include the trailing colons.
We don't actually need that information, because we have access to the
declaration, so it was only being used for validation, which made the
API harder to use for clients that didn't carefully track zero vs
one-arg selector names.

Also remove the colons from the response, and instead add a bit to say
whether it is a zero-arg or one-arg selector.  This makes the response
easier to use for clients that don't care about this information, and
more consistent with the change to the input.

rdar://problem/32177934
This commit is contained in:
Ben Langmuir
2017-05-14 08:46:09 -07:00
parent 3f5569015c
commit 8aaf2d64ed
9 changed files with 48 additions and 21 deletions

View File

@@ -900,17 +900,10 @@ getClangDeclarationName(const clang::NamedDecl *ND, NameTranslatingInfo &Info) {
if (!Info.BaseName.empty()) {
return clang::DeclarationName(&Ctx.Idents.get(Info.BaseName));
} else {
StringRef last = Info.ArgNames.back();
switch (OrigName.getNameKind()) {
case clang::DeclarationName::ObjCZeroArgSelector:
if (last.endswith(":"))
return clang::DeclarationName();
break;
case clang::DeclarationName::ObjCOneArgSelector:
case clang::DeclarationName::ObjCMultiArgSelector:
if (!last.empty() && !last.endswith(":"))
return clang::DeclarationName();
break;
default:
return clang::DeclarationName();
@@ -982,8 +975,8 @@ static bool passNameInfoForDecl(const ValueDecl *VD, NameTranslatingInfo &Info,
if (Selector.getNumArgs()) {
assert(Pieces.back().empty());
Pieces.pop_back();
std::transform(Pieces.begin(), Pieces.end(), Pieces.begin(),
[](StringRef P) { return StringRef(P.data(), P.size() + 1); });
} else {
Result.IsZeroArgSelector = true;
}
Result.ArgNames.insert(Result.ArgNames.begin(), Pieces.begin(), Pieces.end());
Receiver(Result);