From 8fa0a80b4482ad94e82c4a19e23de17fd69140b5 Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Thu, 4 Aug 2011 20:04:59 +0000 Subject: Add a new libclang API to return a CXCompletionString for an arbitrary cursor, from Connor Wakamo! Addresses . git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136911 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang-c/Index.h | 12 ++++++++++++ include/clang/Frontend/ASTUnit.h | 14 ++++++++++++++ 2 files changed, 26 insertions(+) (limited to 'include') diff --git a/include/clang-c/Index.h b/include/clang-c/Index.h index e52ed46131..e16a21ef35 100644 --- a/include/clang-c/Index.h +++ b/include/clang-c/Index.h @@ -2898,6 +2898,18 @@ clang_getCompletionPriority(CXCompletionString completion_string); CINDEX_LINKAGE enum CXAvailabilityKind clang_getCompletionAvailability(CXCompletionString completion_string); +/** + * \brief Retrieve a completion string for an arbitrary declaration or macro + * definition cursor. + * + * \param cursor The cursor to query. + * + * \returns A non-context-sensitive completion string for declaration and macro + * definition cursors, or NULL for other kinds of cursors. + */ +CINDEX_LINKAGE CXCompletionString +clang_getCursorCompletionString(CXCursor cursor); + /** * \brief Contains the results of code-completion. * diff --git a/include/clang/Frontend/ASTUnit.h b/include/clang/Frontend/ASTUnit.h index 6a3f9d5d42..4f81de53be 100644 --- a/include/clang/Frontend/ASTUnit.h +++ b/include/clang/Frontend/ASTUnit.h @@ -310,10 +310,24 @@ public: return CachedCompletionAllocator; } + /// \brief Retrieve the allocator used to cache global code completions. + /// Creates the allocator if it doesn't already exist. + llvm::IntrusiveRefCntPtr + getCursorCompletionAllocator() { + if (!CursorCompletionAllocator.getPtr()) { + CursorCompletionAllocator = new GlobalCodeCompletionAllocator; + } + return CursorCompletionAllocator; + } + private: /// \brief Allocator used to store cached code completions. llvm::IntrusiveRefCntPtr CachedCompletionAllocator; + + /// \brief Allocator used to store code completions for arbitrary cursors. + llvm::IntrusiveRefCntPtr + CursorCompletionAllocator; /// \brief The set of cached code-completion results. std::vector CachedCompletionResults; -- cgit v1.2.3-70-g09d2