summaryrefslogtreecommitdiffstats
path: root/clang/tools/c-index-test/c-index-test.c
diff options
context:
space:
mode:
authorDmitri Gribenko <gribozavr@gmail.com>2012-07-02 17:35:10 +0000
committerDmitri Gribenko <gribozavr@gmail.com>2012-07-02 17:35:10 +0000
commit3292d06a1ba34eaa99226cc2133e03b47c471c3b (patch)
tree5848f53d170f2bfae94597eef269249e6e647e46 /clang/tools/c-index-test/c-index-test.c
parent22972210287a4977a2054e180066007d7368df9f (diff)
downloadbcm5719-llvm-3292d06a1ba34eaa99226cc2133e03b47c471c3b.tar.gz
bcm5719-llvm-3292d06a1ba34eaa99226cc2133e03b47c471c3b.zip
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). llvm-svn: 159539
Diffstat (limited to 'clang/tools/c-index-test/c-index-test.c')
-rw-r--r--clang/tools/c-index-test/c-index-test.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/clang/tools/c-index-test/c-index-test.c b/clang/tools/c-index-test/c-index-test.c
index 787671fa9a5..43229fdc131 100644
--- a/clang/tools/c-index-test/c-index-test.c
+++ b/clang/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=");
OpenPOWER on IntegriCloud