diff options
author | Douglas Gregor <dgregor@apple.com> | 2010-08-29 19:47:46 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2010-08-29 19:47:46 +0000 |
commit | 981a0c4613bc0f4b86f117217e327020ce84d415 (patch) | |
tree | e034e8832cfa550d2fc45bd76bcb47acea2c71bd /clang/lib/Sema/SemaCodeComplete.cpp | |
parent | d94a7c3dc1b3c22f6884781e686d7b9a96b625b0 (diff) | |
download | bcm5719-llvm-981a0c4613bc0f4b86f117217e327020ce84d415.tar.gz bcm5719-llvm-981a0c4613bc0f4b86f117217e327020ce84d415.zip |
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.
llvm-svn: 112456
Diffstat (limited to 'clang/lib/Sema/SemaCodeComplete.cpp')
-rw-r--r-- | clang/lib/Sema/SemaCodeComplete.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/clang/lib/Sema/SemaCodeComplete.cpp b/clang/lib/Sema/SemaCodeComplete.cpp index a7ac0f11709..c154364505f 100644 --- a/clang/lib/Sema/SemaCodeComplete.cpp +++ b/clang/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) |