Browse Source

Added preference option to enable detailed preprocessing record when parsing C/C++ buffers

pipelines/235045657
eidheim 5 years ago
parent
commit
452b40d82a
  1. 2
      CMakeLists.txt
  2. 1
      src/config.cpp
  3. 2
      src/config.hpp
  4. 2
      src/files.hpp
  5. 4
      src/source_clang.cpp
  6. 3
      src/usages_clang.cpp

2
CMakeLists.txt

@ -1,7 +1,7 @@
cmake_minimum_required (VERSION 2.8.8) cmake_minimum_required (VERSION 2.8.8)
project(juci) project(juci)
set(JUCI_VERSION "1.6.1") set(JUCI_VERSION "1.6.1.1")
set(CPACK_PACKAGE_NAME "jucipp") set(CPACK_PACKAGE_NAME "jucipp")
set(CPACK_PACKAGE_CONTACT "Ole Christian Eidheim <eidheim@gmail.com>") set(CPACK_PACKAGE_CONTACT "Ole Christian Eidheim <eidheim@gmail.com>")

1
src/config.cpp

@ -174,6 +174,7 @@ void Config::read(const boost::property_tree::ptree &cfg) {
source.clang_usages_threads = static_cast<unsigned>(source_json.get<int>("clang_usages_threads")); source.clang_usages_threads = static_cast<unsigned>(source_json.get<int>("clang_usages_threads"));
source.enable_clang_tidy = source_json.get<bool>("enable_clang_tidy"); source.enable_clang_tidy = source_json.get<bool>("enable_clang_tidy");
source.clang_tidy_checks = source_json.get<std::string>("clang_tidy_checks"); source.clang_tidy_checks = source_json.get<std::string>("clang_tidy_checks");
source.enable_clang_detailed_preprocessing_record = source_json.get<bool>("enable_clang_detailed_preprocessing_record");
source.debug_place_cursor_at_stop = source_json.get<bool>("debug_place_cursor_at_stop"); source.debug_place_cursor_at_stop = source_json.get<bool>("debug_place_cursor_at_stop");
auto pt_doc_search = cfg.get_child("documentation_searches"); auto pt_doc_search = cfg.get_child("documentation_searches");
for(auto &pt_doc_search_lang : pt_doc_search) { for(auto &pt_doc_search_lang : pt_doc_search) {

2
src/config.hpp

@ -100,6 +100,8 @@ public:
bool enable_clang_tidy; bool enable_clang_tidy;
std::string clang_tidy_checks; std::string clang_tidy_checks;
bool enable_clang_detailed_preprocessing_record = false;
bool debug_place_cursor_at_stop; bool debug_place_cursor_at_stop;
std::unordered_map<std::string, DocumentationSearch> documentation_searches; std::unordered_map<std::string, DocumentationSearch> documentation_searches;

2
src/files.hpp

@ -72,6 +72,8 @@ const std::string default_config_file = R"RAW({
"enable_clang_tidy": false, "enable_clang_tidy": false,
"clang_tidy_checks_comment": "In new C/C++ buffers, these checks are appended to the value of 'Checks' in the .clang-tidy file, if any", "clang_tidy_checks_comment": "In new C/C++ buffers, these checks are appended to the value of 'Checks' in the .clang-tidy file, if any",
"clang_tidy_checks": "", "clang_tidy_checks": "",
"enable_clang_detailed_preprocessing_record_comment": "Set to true to include all macro definitions and instantiations when parsing C/C++ buffers, at the cost of increased resource use. You should reopen buffers and delete build/.usages_clang after changing this option.",
"enable_clang_detailed_preprocessing_record": false,
"debug_place_cursor_at_stop": false "debug_place_cursor_at_stop": false
}, },
"terminal": { "terminal": {

4
src/source_clang.cpp

@ -124,7 +124,9 @@ void Source::ClangViewParse::parse_initialize() {
build->update_default(); build->update_default();
auto arguments = CompileCommands::get_arguments(build->get_default_path(), file_path); auto arguments = CompileCommands::get_arguments(build->get_default_path(), file_path);
clang_tokens.reset(); clang_tokens.reset();
clang_tu = std::make_unique<clangmm::TranslationUnit>(std::make_shared<clangmm::Index>(0, Config::get().log.libclang), file_path.string(), arguments, &buffer_raw); int flags = clangmm::TranslationUnit::DefaultFlags() & ~(CXTranslationUnit_DetailedPreprocessingRecord | CXTranslationUnit_Incomplete);
flags |= Config::get().source.enable_clang_detailed_preprocessing_record ? CXTranslationUnit_DetailedPreprocessingRecord : CXTranslationUnit_Incomplete;
clang_tu = std::make_unique<clangmm::TranslationUnit>(std::make_shared<clangmm::Index>(0, Config::get().log.libclang), file_path.string(), arguments, &buffer_raw, flags);
clang_tokens = clang_tu->get_tokens(); clang_tokens = clang_tu->get_tokens();
clang_tokens_offsets.clear(); clang_tokens_offsets.clear();
clang_tokens_offsets.reserve(clang_tokens->size()); clang_tokens_offsets.reserve(clang_tokens->size());

3
src/usages_clang.cpp

@ -259,11 +259,10 @@ boost::optional<std::vector<Usages::Clang::Usages>> Usages::Clang::get_usages(co
else else
++it; ++it;
} }
int flags = CXTranslationUnit_Incomplete; int flags = Config::get().source.enable_clang_detailed_preprocessing_record ? CXTranslationUnit_DetailedPreprocessingRecord : CXTranslationUnit_Incomplete;
#if CINDEX_VERSION_MAJOR > 0 || (CINDEX_VERSION_MAJOR == 0 && CINDEX_VERSION_MINOR >= 35) #if CINDEX_VERSION_MAJOR > 0 || (CINDEX_VERSION_MAJOR == 0 && CINDEX_VERSION_MINOR >= 35)
flags |= CXTranslationUnit_KeepGoing; flags |= CXTranslationUnit_KeepGoing;
#endif #endif
clangmm::TranslationUnit translation_unit(std::make_shared<clangmm::Index>(0, 0), path.string(), arguments, &buffer, flags); clangmm::TranslationUnit translation_unit(std::make_shared<clangmm::Index>(0, 0), path.string(), arguments, &buffer, flags);
{ {

Loading…
Cancel
Save