|
|
|
|
@ -1,5 +1,7 @@
|
|
|
|
|
#include "TranslationUnit.h" |
|
|
|
|
|
|
|
|
|
const int TranslationUnitOptions = CXTranslationUnit_CacheCompletionResults | CXTranslationUnit_PrecompiledPreamble | CXTranslationUnit_Incomplete; |
|
|
|
|
|
|
|
|
|
clang::TranslationUnit:: |
|
|
|
|
~TranslationUnit() { |
|
|
|
|
// clang_disposeTranslationUnit(tu_);
|
|
|
|
|
@ -15,11 +17,15 @@ operator=(const clang::TranslationUnit &tu) {
|
|
|
|
|
clang::TranslationUnit:: |
|
|
|
|
TranslationUnit(Index *index, |
|
|
|
|
const std::string &filepath, |
|
|
|
|
const std::vector<const char*> &command_line_args) { |
|
|
|
|
const std::vector<std::string> &command_line_args) { |
|
|
|
|
std::vector<const char*> args; |
|
|
|
|
for(auto &a: command_line_args) { |
|
|
|
|
args.push_back(a.c_str()); |
|
|
|
|
} |
|
|
|
|
tu_ = clang_createTranslationUnitFromSourceFile(index->index_, |
|
|
|
|
filepath.c_str(), |
|
|
|
|
command_line_args.size(), |
|
|
|
|
command_line_args.data(), |
|
|
|
|
args.size(), |
|
|
|
|
args.data(), |
|
|
|
|
0, |
|
|
|
|
NULL); |
|
|
|
|
} |
|
|
|
|
@ -38,7 +44,7 @@ TranslationUnit(Index *index,
|
|
|
|
|
clang::TranslationUnit:: |
|
|
|
|
TranslationUnit(clang::Index *index, |
|
|
|
|
const std::string &filepath, |
|
|
|
|
const std::vector<const char*> &command_line_args, |
|
|
|
|
const std::vector<std::string> &command_line_args, |
|
|
|
|
const std::map<std::string, std::string> &buffers) { |
|
|
|
|
std::vector<CXUnsavedFile> files; |
|
|
|
|
for (auto &buffer : buffers) { |
|
|
|
|
@ -48,14 +54,18 @@ TranslationUnit(clang::Index *index,
|
|
|
|
|
file.Length = buffer.second.size(); |
|
|
|
|
files.push_back(file); |
|
|
|
|
} |
|
|
|
|
std::vector<const char*> args; |
|
|
|
|
for(auto &a: command_line_args) { |
|
|
|
|
args.push_back(a.c_str()); |
|
|
|
|
} |
|
|
|
|
tu_ = |
|
|
|
|
clang_parseTranslationUnit(index->index_, |
|
|
|
|
filepath.c_str(), |
|
|
|
|
command_line_args.data(), |
|
|
|
|
command_line_args.size(), |
|
|
|
|
args.data(), |
|
|
|
|
args.size(), |
|
|
|
|
files.data(), |
|
|
|
|
files.size(), |
|
|
|
|
clang_defaultEditingTranslationUnitOptions()); |
|
|
|
|
TranslationUnitOptions); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int clang::TranslationUnit:: |
|
|
|
|
@ -72,5 +82,5 @@ ReparseTranslationUnit(const std::string &file_path,
|
|
|
|
|
return clang_reparseTranslationUnit(tu_, |
|
|
|
|
files.size(), |
|
|
|
|
files.data(), |
|
|
|
|
clang_defaultReparseOptions(tu_)); |
|
|
|
|
TranslationUnitOptions); |
|
|
|
|
} |
|
|
|
|
|