Commit 5f6126f1 authored by Ole Christian Eidheim's avatar Ole Christian Eidheim
Browse files

Cleanup of CodeCompleteResults

parent 979a5964
......@@ -18,16 +18,31 @@ clangmm::CodeCompleteResults::CodeCompleteResults(CXTranslationUnit &cx_tu,
files,
1,
clang_defaultCodeCompleteOptions()|CXCodeComplete_IncludeBriefComments);
if(cx_results!=NULL)
if(cx_results)
clang_sortCodeCompletionResults(cx_results->Results, cx_results->NumResults);
}
clangmm::CodeCompleteResults::CodeCompleteResults(CodeCompleteResults &&rhs) : cx_results(rhs.cx_results) {
rhs.cx_results = nullptr;
}
clangmm::CodeCompleteResults &clangmm::CodeCompleteResults::operator=(CodeCompleteResults &&rhs) {
if(this!=&rhs) {
if(cx_results)
clang_disposeCodeCompleteResults(cx_results);
cx_results=rhs.cx_results;
rhs.cx_results=nullptr;
}
return *this;
}
clangmm::CodeCompleteResults::~CodeCompleteResults() {
clang_disposeCodeCompleteResults(cx_results);
if(cx_results)
clang_disposeCodeCompleteResults(cx_results);
}
unsigned clangmm::CodeCompleteResults::size() const {
if(cx_results==NULL)
if(!cx_results)
return 0;
return cx_results->NumResults;
}
......@@ -37,5 +52,7 @@ clangmm::CompletionString clangmm::CodeCompleteResults::get(unsigned i) const {
}
std::string clangmm::CodeCompleteResults::get_usr() const {
if(!cx_results)
return std::string();
return to_string(clang_codeCompleteGetContainerUSR(cx_results));
}
......@@ -12,9 +12,10 @@ namespace clangmm {
CodeCompleteResults(CXTranslationUnit &cx_tu, const std::string &buffer,
unsigned line_num, unsigned column);
public:
CodeCompleteResults(CodeCompleteResults &&rhs) : cx_results(rhs.cx_results) {
rhs.cx_results = nullptr;
}
CodeCompleteResults(CodeCompleteResults &) = delete;
CodeCompleteResults(CodeCompleteResults &&rhs);
CodeCompleteResults &operator=(const CodeCompleteResults &rhs) = delete;
CodeCompleteResults &operator=(CodeCompleteResults &&rhs);
~CodeCompleteResults();
CompletionString get(unsigned index) const;
unsigned size() const;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment