diff options
author | Dmitri Gribenko <gribozavr@gmail.com> | 2012-07-02 17:35:10 +0000 |
---|---|---|
committer | Dmitri Gribenko <gribozavr@gmail.com> | 2012-07-02 17:35:10 +0000 |
commit | d99ef536b241071b6f4c01db6525dc03242ac30b (patch) | |
tree | ad1f07e99303c902595dd6d3045158d361726975 /lib/Sema/SemaCodeComplete.cpp | |
parent | f45f23493d762b7548afc02563b1908a101c6721 (diff) |
Add a new libclang completion API to get brief documentation comment that is
attached to a declaration in the completion string.
Since extracting comments isn't free, a new code completion option is
introduced.
A new code completion option that enables including brief comments
into CodeCompletionString should be a, err, code completion option.
But because ASTUnit caches global declarations during parsing before
even completion consumer is created, the option is duplicated as a
translation unit option (in both libclang and ASTUnit, like the option
to cache code completion results).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159539 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaCodeComplete.cpp')
-rw-r--r-- | lib/Sema/SemaCodeComplete.cpp | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/lib/Sema/SemaCodeComplete.cpp b/lib/Sema/SemaCodeComplete.cpp index ff83324de2..d4289742d1 100644 --- a/lib/Sema/SemaCodeComplete.cpp +++ b/lib/Sema/SemaCodeComplete.cpp @@ -2453,8 +2453,10 @@ static void AddTypedNameChunk(ASTContext &Context, const PrintingPolicy &Policy, CodeCompletionString *CodeCompletionResult::CreateCodeCompletionString(Sema &S, CodeCompletionAllocator &Allocator, - CodeCompletionTUInfo &CCTUInfo) { - return CreateCodeCompletionString(S.Context, S.PP, Allocator, CCTUInfo); + CodeCompletionTUInfo &CCTUInfo, + bool IncludeBriefComments) { + return CreateCodeCompletionString(S.Context, S.PP, Allocator, CCTUInfo, + IncludeBriefComments); } /// \brief If possible, create a new code completion string for the given @@ -2467,7 +2469,8 @@ CodeCompletionString * CodeCompletionResult::CreateCodeCompletionString(ASTContext &Ctx, Preprocessor &PP, CodeCompletionAllocator &Allocator, - CodeCompletionTUInfo &CCTUInfo) { + CodeCompletionTUInfo &CCTUInfo, + bool IncludeBriefComments) { CodeCompletionBuilder Result(Allocator, CCTUInfo, Priority, Availability); PrintingPolicy Policy = getCompletionPrintingPolicy(Ctx, PP); @@ -2537,7 +2540,14 @@ CodeCompletionResult::CreateCodeCompletionString(ASTContext &Ctx, assert(Kind == RK_Declaration && "Missed a result kind?"); NamedDecl *ND = Declaration; Result.addParentContext(ND->getDeclContext()); - + + if (IncludeBriefComments) { + // Add documentation comment, if it exists. + if (const RawComment *RC = Ctx.getRawCommentForDecl(ND)) { + Result.addBriefComment(RC->getBriefText(Ctx)); + } + } + if (StartsNestedNameSpecifier) { Result.AddTypedTextChunk( Result.getAllocator().CopyString(ND->getNameAsString())); |