summaryrefslogtreecommitdiff
path: root/tools/libclang/CIndexCodeCompletion.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2011-07-26 15:24:30 +0000
committerDouglas Gregor <dgregor@apple.com>2011-07-26 15:24:30 +0000
commit0a47d69af8bda945352997af3da4687a3356096a (patch)
tree340e57a2b179434ab58d35e56c203ba85453d446 /tools/libclang/CIndexCodeCompletion.cpp
parent2ad63cf7146268a336b5a931f626adaa8a5150f0 (diff)
downloadclang-0a47d69af8bda945352997af3da4687a3356096a.tar.gz
clang-0a47d69af8bda945352997af3da4687a3356096a.tar.bz2
clang-0a47d69af8bda945352997af3da4687a3356096a.tar.xz
Add new libclang API, clang_codeCompleteGetObjCSelector(), which
provides the partial Objective-C selector used in a code completion. From Connor Wakamo! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136084 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/libclang/CIndexCodeCompletion.cpp')
-rw-r--r--tools/libclang/CIndexCodeCompletion.cpp33
1 files changed, 31 insertions, 2 deletions
diff --git a/tools/libclang/CIndexCodeCompletion.cpp b/tools/libclang/CIndexCodeCompletion.cpp
index 59636bf2d8..84050b2cfd 100644
--- a/tools/libclang/CIndexCodeCompletion.cpp
+++ b/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"