Add Config->dumpAST for dumping AST after parsing

Example initializationOptions: {"dumpAST": ["a.cc"]}
This commit is contained in:
Fangrui Song 2018-01-07 23:51:36 -08:00
parent a3a89af14f
commit 7b8f8e9cad
2 changed files with 16 additions and 2 deletions

View File

@ -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<std::string> 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;

View File

@ -13,8 +13,14 @@ struct ClangIndexer : IIndexer {
const std::vector<std::string>& args,
const std::vector<FileContents>& 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