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 /tools/c-index-test/c-index-test.c | |
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 'tools/c-index-test/c-index-test.c')
-rw-r--r-- | tools/c-index-test/c-index-test.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/tools/c-index-test/c-index-test.c b/tools/c-index-test/c-index-test.c index 787671fa9a..43229fdc13 100644 --- a/tools/c-index-test/c-index-test.c +++ b/tools/c-index-test/c-index-test.c @@ -59,6 +59,8 @@ static unsigned getDefaultParsingOptions() { options &= ~CXTranslationUnit_CacheCompletionResults; if (getenv("CINDEXTEST_SKIP_FUNCTION_BODIES")) options |= CXTranslationUnit_SkipFunctionBodies; + if (getenv("CINDEXTEST_COMPLETION_BRIEF_COMMENTS")) + options |= CXTranslationUnit_IncludeBriefCommentsInCodeCompletion; return options; } @@ -1220,6 +1222,8 @@ void print_completion_result(CXCompletionResult *completion_result, unsigned annotationCount; enum CXCursorKind ParentKind; CXString ParentName; + CXString BriefComment; + const char *BriefCommentCString; fprintf(file, "%s:", clang_getCString(ks)); clang_disposeString(ks); @@ -1271,6 +1275,14 @@ void print_completion_result(CXCompletionResult *completion_result, } clang_disposeString(ParentName); } + + BriefComment = clang_getCompletionBriefComment( + completion_result->CompletionString); + BriefCommentCString = clang_getCString(BriefComment); + if (BriefCommentCString && *BriefCommentCString != '\0') { + fprintf(file, "(brief comment: %s)", BriefCommentCString); + } + clang_disposeString(BriefComment); fprintf(file, "\n"); } @@ -1383,6 +1395,8 @@ int perform_code_completion(int argc, const char **argv, int timing_only) { if (getenv("CINDEXTEST_CODE_COMPLETE_PATTERNS")) completionOptions |= CXCodeComplete_IncludeCodePatterns; + if (getenv("CINDEXTEST_COMPLETION_BRIEF_COMMENTS")) + completionOptions |= CXCodeComplete_IncludeBriefComments; if (timing_only) input += strlen("-code-completion-timing="); |