mirror of https://gitlab.com/cppit/libclangmm
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
1.2 KiB
40 lines
1.2 KiB
|
11 years ago
|
#include "CodeCompleteResults.h"
|
||
|
|
#include "CompletionString.h"
|
||
|
|
|
||
|
|
clang::CodeCompleteResults::
|
||
|
|
CodeCompleteResults(clang::TranslationUnit *tu,
|
||
|
|
const std::string &file_name,
|
||
|
|
const std::map<std::string, std::string> &buffers,
|
||
|
|
int line_num,
|
||
|
|
int column) {
|
||
|
|
std::vector<CXUnsavedFile> files;
|
||
|
|
for (auto &buffer : buffers) {
|
||
|
|
CXUnsavedFile file;
|
||
|
|
file.Filename = buffer.first.c_str();
|
||
|
|
file.Contents = buffer.second.c_str();
|
||
|
|
file.Length = buffer.second.size();
|
||
|
|
files.push_back(file);
|
||
|
|
}
|
||
|
|
results_ = clang_codeCompleteAt(tu->tu_,
|
||
|
|
file_name.c_str(),
|
||
|
|
line_num,
|
||
|
|
column,
|
||
|
|
files.data(),
|
||
|
|
files.size(),
|
||
|
|
clang_defaultCodeCompleteOptions());
|
||
|
|
clang_sortCodeCompletionResults(results_->Results, results_->NumResults);
|
||
|
|
}
|
||
|
|
|
||
|
|
int clang::CodeCompleteResults::
|
||
|
|
size() {
|
||
|
|
return results_->NumResults;
|
||
|
|
}
|
||
|
|
|
||
|
|
clang::CompletionString clang::CodeCompleteResults::
|
||
|
|
get(int i) {
|
||
|
|
if (i > size()) {
|
||
|
|
// TODO(zalox) return type
|
||
|
|
}
|
||
|
|
return CompletionString(results_->Results[i].CompletionString);
|
||
|
|
}
|