diff options
author | Douglas Gregor <dgregor@apple.com> | 2011-07-26 15:24:30 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2011-07-26 15:24:30 +0000 |
commit | ea777403f999cba29ac23eee92fecbf996528a17 (patch) | |
tree | 67a789ae9ca0c783057d625e0b1a2bee5d15dce7 /clang/tools/libclang/CIndexCodeCompletion.cpp | |
parent | b84dc6bca84274dc03157bbddeb6b80450cc9a4c (diff) | |
download | bcm5719-llvm-ea777403f999cba29ac23eee92fecbf996528a17.tar.gz bcm5719-llvm-ea777403f999cba29ac23eee92fecbf996528a17.zip |
Add new libclang API, clang_codeCompleteGetObjCSelector(), which
provides the partial Objective-C selector used in a code
completion. From Connor Wakamo!
llvm-svn: 136084
Diffstat (limited to 'clang/tools/libclang/CIndexCodeCompletion.cpp')
-rw-r--r-- | clang/tools/libclang/CIndexCodeCompletion.cpp | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/clang/tools/libclang/CIndexCodeCompletion.cpp b/clang/tools/libclang/CIndexCodeCompletion.cpp index 59636bf2d85..84050b2cfdc 100644 --- a/clang/tools/libclang/CIndexCodeCompletion.cpp +++ b/clang/tools/libclang/CIndexCodeCompletion.cpp @@ -247,10 +247,17 @@ struct AllocatedCXCodeCompleteResults : public CXCodeCompleteResults { /// current context. unsigned long long Contexts; + /// \brief The kind of the container for the current context for completions. enum CXCursorKind ContainerKind; + /// \brief The USR of the container for the current context for completions. CXString ContainerUSR; - + /// \brief a boolean value indicating whether there is complete information + /// about the container unsigned ContainerIsIncomplete; + + /// \brief A string containing the Objective-C selector entered thus far for a + /// message send. + std::string Selector; }; /// \brief Tracks the number of code-completion result objects that are @@ -495,6 +502,18 @@ namespace { AllocatedResults.ContextKind = contextKind; AllocatedResults.Contexts = getContextsForContextKind(contextKind, S); + AllocatedResults.Selector = ""; + if (Context.getNumSelIdents() > 0) { + for (unsigned i = 0; i < Context.getNumSelIdents(); i++) { + IdentifierInfo *selIdent = Context.getSelIdents()[i]; + if (selIdent != NULL) { + StringRef selectorString = Context.getSelIdents()[i]->getName(); + AllocatedResults.Selector += selectorString.str(); + } + AllocatedResults.Selector += ":"; + } + } + QualType baseType = Context.getBaseType(); NamedDecl *D = NULL; @@ -677,7 +696,7 @@ void clang_codeCompleteAt_Impl(void *UserData) { } pchName.push_back('\0'); struct stat stat_results; - if (stat(pchName.data(), &stat_results) == 0) + if (stat(pchName.str().c_str(), &stat_results) == 0) usesPCH = true; continue; } @@ -810,6 +829,16 @@ CXString clang_codeCompleteGetContainerUSR(CXCodeCompleteResults *ResultsIn) { return createCXString(clang_getCString(Results->ContainerUSR)); } + + +CXString clang_codeCompleteGetObjCSelector(CXCodeCompleteResults *ResultsIn) { + AllocatedCXCodeCompleteResults *Results = + static_cast<AllocatedCXCodeCompleteResults *>(ResultsIn); + if (!Results) + return createCXString(""); + + return createCXString(Results->Selector); +} } // end extern "C" |