diff options
| author | Erik Verbruggen <erikjv@me.com> | 2011-10-14 15:31:08 +0000 |
|---|---|---|
| committer | Erik Verbruggen <erikjv@me.com> | 2011-10-14 15:31:08 +0000 |
| commit | 98ea7f6737834029b60081105b73e6f5c7c420e9 (patch) | |
| tree | 8326cac88c8962e1f1218078fd63227acbe9d692 /clang/tools | |
| parent | a447e0f38f9236a61407ebed49cd16d08ddb3676 (diff) | |
| download | bcm5719-llvm-98ea7f6737834029b60081105b73e6f5c7c420e9.tar.gz bcm5719-llvm-98ea7f6737834029b60081105b73e6f5c7c420e9.zip | |
Added clang_getCompletionAnnotation and clang_getCompletionNumAnnotations to
retrieve annotations from completion string.
llvm-svn: 141953
Diffstat (limited to 'clang/tools')
| -rw-r--r-- | clang/tools/c-index-test/c-index-test.c | 17 | ||||
| -rw-r--r-- | clang/tools/libclang/CIndexCodeCompletion.cpp | 14 | ||||
| -rw-r--r-- | clang/tools/libclang/libclang.exports | 2 |
3 files changed, 33 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 063c4adc903..2a3584b892b 100644 --- a/clang/tools/c-index-test/c-index-test.c +++ b/clang/tools/c-index-test/c-index-test.c @@ -1033,6 +1033,7 @@ void print_completion_result(CXCompletionResult *completion_result, CXClientData client_data) { FILE *file = (FILE *)client_data; CXString ks = clang_getCursorKindSpelling(completion_result->CursorKind); + unsigned annotationCount; fprintf(file, "%s:", clang_getCString(ks)); clang_disposeString(ks); @@ -1056,6 +1057,22 @@ void print_completion_result(CXCompletionResult *completion_result, fprintf(file, " (inaccessible)"); break; } + + annotationCount = clang_getCompletionNumAnnotations( + completion_result->CompletionString); + if (annotationCount) { + unsigned i; + fprintf(file, " ("); + for (i = 0; i < annotationCount; ++i) { + if (i != 0) + fprintf(file, ", "); + fprintf(file, "\"%s\"", + clang_getCString(clang_getCompletionAnnotation( + completion_result->CompletionString, i))); + } + fprintf(file, ")"); + } + fprintf(file, "\n"); } diff --git a/clang/tools/libclang/CIndexCodeCompletion.cpp b/clang/tools/libclang/CIndexCodeCompletion.cpp index 3ce0d245cf3..c19b3404920 100644 --- a/clang/tools/libclang/CIndexCodeCompletion.cpp +++ b/clang/tools/libclang/CIndexCodeCompletion.cpp @@ -203,6 +203,20 @@ clang_getCompletionAvailability(CXCompletionString completion_string) { : CXAvailability_Available; } +unsigned clang_getCompletionNumAnnotations(CXCompletionString completion_string) +{ + CodeCompletionString *CCStr = (CodeCompletionString *)completion_string; + return CCStr ? CCStr->getAnnotationCount() : 0; +} + +CXString clang_getCompletionAnnotation(CXCompletionString completion_string, + unsigned annotation_number) { + CodeCompletionString *CCStr = (CodeCompletionString *)completion_string; + return CCStr ? createCXString(CCStr->getAnnotation(annotation_number)) + : createCXString((const char *) 0); +} + + /// \brief The CXCodeCompleteResults structure we allocate internally; /// the client only sees the initial CXCodeCompleteResults structure. struct AllocatedCXCodeCompleteResults : public CXCodeCompleteResults { diff --git a/clang/tools/libclang/libclang.exports b/clang/tools/libclang/libclang.exports index 68c0ad5c272..989ed837ea2 100644 --- a/clang/tools/libclang/libclang.exports +++ b/clang/tools/libclang/libclang.exports @@ -54,9 +54,11 @@ clang_getCanonicalCursor clang_getCanonicalType clang_getClangVersion clang_getCompletionAvailability +clang_getCompletionAnnotation clang_getCompletionChunkCompletionString clang_getCompletionChunkKind clang_getCompletionChunkText +clang_getCompletionNumAnnotations clang_getCompletionPriority clang_getCursor clang_getCursorAvailability |

