aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaCodeComplete.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-08-29 19:47:46 +0000
committerDouglas Gregor <dgregor@apple.com>2010-08-29 19:47:46 +0000
commitaba480862485ea1140a81f25c23f43bb080edc90 (patch)
treec98c011acd930093bf175a4561eb89b9e2d35829 /lib/Sema/SemaCodeComplete.cpp
parent0c431c8c001e4c1f7488663d98700a8ce1e89e2a (diff)
When providing a code completion for an Objective-C message send, drop
the parameter names from the completions, e.g., provide withString:(NSString *) instead of withString:(NSString *)string since the parameter name is, by convention, redundant with the selector piece that precedes it and the completions can get unnecessarily long. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112456 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaCodeComplete.cpp')
-rw-r--r--lib/Sema/SemaCodeComplete.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/lib/Sema/SemaCodeComplete.cpp b/lib/Sema/SemaCodeComplete.cpp
index a7ac0f1170..c154364505 100644
--- a/lib/Sema/SemaCodeComplete.cpp
+++ b/lib/Sema/SemaCodeComplete.cpp
@@ -1758,7 +1758,8 @@ static void MaybeAddSentinel(ASTContext &Context, NamedDecl *FunctionOrMethod,
}
static std::string FormatFunctionParameter(ASTContext &Context,
- ParmVarDecl *Param) {
+ ParmVarDecl *Param,
+ bool SuppressName = false) {
bool ObjCMethodParam = isa<ObjCMethodDecl>(Param->getDeclContext());
if (Param->getType()->isDependentType() ||
!Param->getType()->isBlockPointerType()) {
@@ -1766,7 +1767,7 @@ static std::string FormatFunctionParameter(ASTContext &Context,
// containing that parameter's type.
std::string Result;
- if (Param->getIdentifier() && !ObjCMethodParam)
+ if (Param->getIdentifier() && !ObjCMethodParam && !SuppressName)
Result = Param->getIdentifier()->getName();
Param->getType().getAsStringInternal(Result,
@@ -1775,7 +1776,7 @@ static std::string FormatFunctionParameter(ASTContext &Context,
if (ObjCMethodParam) {
Result = "(" + Result;
Result += ")";
- if (Param->getIdentifier())
+ if (Param->getIdentifier() && !SuppressName)
Result += Param->getIdentifier()->getName();
}
return Result;
@@ -2188,12 +2189,13 @@ CodeCompletionResult::CreateCodeCompletionString(Sema &S,
std::string Arg;
if ((*P)->getType()->isBlockPointerType() && !DeclaringEntity)
- Arg = FormatFunctionParameter(S.Context, *P);
+ Arg = FormatFunctionParameter(S.Context, *P, true);
else {
(*P)->getType().getAsStringInternal(Arg, S.Context.PrintingPolicy);
Arg = "(" + Arg + ")";
if (IdentifierInfo *II = (*P)->getIdentifier())
- Arg += II->getName().str();
+ if (DeclaringEntity || AllParametersAreInformative)
+ Arg += II->getName().str();
}
if (DeclaringEntity)