diff options
author | Douglas Gregor <dgregor@apple.com> | 2012-03-27 23:34:16 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2012-03-27 23:34:16 +0000 |
commit | ba1030698dbc276db86b11c5329a1edee8a1805e (patch) | |
tree | 05795b249632407ea75e576411c56c9078255b80 /tools/c-index-test/c-index-test.c | |
parent | 2259286fc5c1514089b17ec93e26ca56ba8ac2b6 (diff) |
Introduce a new libclang API to determine the parent context of a code
completion item. For example, if the code completion itself represents
a declaration in a namespace (say, std::vector), then this API
retrieves the cursor kind and name of the namespace (std). Implements
<rdar://problem/11121951>.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153545 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 | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/tools/c-index-test/c-index-test.c b/tools/c-index-test/c-index-test.c index 67de8508cd..39bb8ebed0 100644 --- a/tools/c-index-test/c-index-test.c +++ b/tools/c-index-test/c-index-test.c @@ -1082,7 +1082,9 @@ void print_completion_result(CXCompletionResult *completion_result, FILE *file = (FILE *)client_data; CXString ks = clang_getCursorKindSpelling(completion_result->CursorKind); unsigned annotationCount; - + enum CXCursorKind ParentKind; + CXString ParentName; + fprintf(file, "%s:", clang_getCString(ks)); clang_disposeString(ks); @@ -1121,6 +1123,19 @@ void print_completion_result(CXCompletionResult *completion_result, fprintf(file, ")"); } + if (!getenv("CINDEXTEST_NO_COMPLETION_PARENTS")) { + ParentName = clang_getCompletionParent(completion_result->CompletionString, + &ParentKind); + if (ParentKind != CXCursor_NotImplemented) { + CXString KindSpelling = clang_getCursorKindSpelling(ParentKind); + fprintf(file, " (parent: %s '%s')", + clang_getCString(KindSpelling), + clang_getCString(ParentName)); + clang_disposeString(KindSpelling); + } + clang_disposeString(ParentName); + } + fprintf(file, "\n"); } |