diff --git a/src/config.h b/src/config.h index e0ccf2a1..9b73c709 100644 --- a/src/config.h +++ b/src/config.h @@ -90,6 +90,11 @@ struct Config { // If true parameter declarations are included in code completion when calling // a function or method bool enableSnippetInsertion = true; + + //// For debugging + + // Dump AST after parsing if some pattern matches the source filename. + std::vector dumpAST; }; MAKE_REFLECT_STRUCT(Config, compilationDatabaseDirectory, @@ -125,7 +130,10 @@ MAKE_REFLECT_STRUCT(Config, codeLensOnLocalVariables, clientVersion, - enableSnippetInsertion); + enableSnippetInsertion, + + dumpAST + ); // Expected client version. We show an error if this doesn't match. constexpr const int kExpectedClientVersion = 3; diff --git a/src/iindexer.cc b/src/iindexer.cc index ba86ecd3..1753f23b 100644 --- a/src/iindexer.cc +++ b/src/iindexer.cc @@ -13,8 +13,14 @@ struct ClangIndexer : IIndexer { const std::vector& args, const std::vector& file_contents, PerformanceImportFile* perf) override { + bool dump_ast = false; + for (const std::string& pattern : config->dumpAST) + if (file.find(pattern) != std::string::npos) { + dump_ast = true; + break; + } return Parse(config, file_consumer_shared, file, args, file_contents, perf, - &index); + &index, dump_ast); } // Note: constructing this acquires a global lock