diff options
author | Douglas Gregor <dgregor@apple.com> | 2010-08-04 16:47:14 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2010-08-04 16:47:14 +0000 |
commit | 8e984da800594aefdeaf33da2f75cb66782f328e (patch) | |
tree | eacc759e6cb7e0cf847782e7e7aa2bdfbcb569ed /clang/tools/c-index-test | |
parent | 988bfce174f5debeb5f79e5050b933a418f53477 (diff) | |
download | bcm5719-llvm-8e984da800594aefdeaf33da2f75cb66782f328e.tar.gz bcm5719-llvm-8e984da800594aefdeaf33da2f75cb66782f328e.zip |
Add code-completion support directly to ASTUnit, which performs code
completion within the translation unit using the same command-line
arguments for parsing the translation unit. Eventually, we'll reuse
the precompiled preamble to improve code-completion performance, and
this also gives us a place to cache results.
Expose this function via the new libclang function
clang_codeCompleteAt(), which performs the code completion within a
CXTranslationUnit. The completion occurs in-process
(clang_codeCompletion() runs code completion out-of-process).
llvm-svn: 110210
Diffstat (limited to 'clang/tools/c-index-test')
-rw-r--r-- | clang/tools/c-index-test/c-index-test.c | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/clang/tools/c-index-test/c-index-test.c b/clang/tools/c-index-test/c-index-test.c index 795c19c0cb5..81462132251 100644 --- a/clang/tools/c-index-test/c-index-test.c +++ b/clang/tools/c-index-test/c-index-test.c @@ -888,11 +888,21 @@ int perform_code_completion(int argc, const char **argv, int timing_only) { return -1; CIdx = clang_createIndex(0, 1); - results = clang_codeComplete(CIdx, - argv[argc - 1], argc - num_unsaved_files - 3, - argv + num_unsaved_files + 2, - num_unsaved_files, unsaved_files, - filename, line, column); + if (getenv("CINDEXTEST_EDITING")) { + CXTranslationUnit *TU = clang_parseTranslationUnit(CIdx, 0, + argv + num_unsaved_files + 2, + argc - num_unsaved_files - 2, + unsaved_files, + num_unsaved_files, + getDefaultParsingOptions()); + results = clang_codeCompleteAt(TU, filename, line, column, + unsaved_files, num_unsaved_files); + } else + results = clang_codeComplete(CIdx, + argv[argc - 1], argc - num_unsaved_files - 3, + argv + num_unsaved_files + 2, + num_unsaved_files, unsaved_files, + filename, line, column); if (results) { unsigned i, n = results->NumResults; |