Skip to content

Commit

Permalink
fix: update "missing file" message and remove mutual exclusion change
Browse files Browse the repository at this point in the history
Options --file and --database_dir are actually not mutually exclusive.
When parsing a file, the compilation database is used to resolve symbols
when passed to initOptions().

Change "File is missing" by a message that sounds less as an error.
  • Loading branch information
jim-bcom committed Feb 26, 2024
1 parent fafb0bb commit f7995cc
Showing 1 changed file with 13 additions and 19 deletions.
32 changes: 13 additions & 19 deletions tools/generators/grpc/xpcf_grpc_gen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,14 +220,6 @@ try
serviceGenerator->setDestinationFolder(options["output"].as<std::string>());
}

bool fileOptIsEmpty = !options.count("file") || options["file"].as<std::string>().empty();
bool databaseDirOptIsEmpty = !options.count("database_dir") || options["database_dir"].as<std::string>().empty();

if (!fileOptIsEmpty && !databaseDirOptIsEmpty) {
print_error("--file and --database_dir cannot be both set");
return 1;
}

auto astParser = cmpMgr->resolve<ITypeParser>("astParser");

int result = astParser->initOptions(options);
Expand All @@ -237,19 +229,21 @@ try

cppast::cpp_entity_index idx; // the entity index is used to resolve cross references in the AST

if (!databaseDirOptIsEmpty) {
assert(fileOptIsEmpty);
if (int res = astParser->parse_database(options["database_dir"].as<std::string>(),options) != 0) {
return res;
if (!options.count("file") || options["file"].as<std::string>().empty()) {
if (options.count("database_dir") && !options["database_dir"].as<std::string>().empty()) {
std::cout<<"File argument is missing : parsing every file listed in database"<<std::endl;
astParser->parse_database(options["database_dir"].as<std::string>(),options);
//parse_database(options["database_dir"].as<std::string>(),idx,options, [&](const cppast::cpp_entity_index& idx, std::ostream& out, const cppast::cpp_file& file) { astParser->parseAst(idx,out,file); });
}
//parse_database(options["database_dir"].as<std::string>(),idx,options, [&](const cppast::cpp_entity_index& idx, std::ostream& out, const cppast::cpp_file& file) { astParser->parseAst(idx,out,file); });
} else if (!fileOptIsEmpty) {
if (int res = astParser->parse_file(options["file"].as<std::string>(), options.count("fatal_errors") == 1) != 0) {
return res;
else {
print_error("missing one of file or database dir argument");
return 1;
}
} else {
print_error("missing one of --file or --database_dir argument");
return 1;
}
else {
result = astParser->parse_file(options["file"].as<std::string>(), options.count("fatal_errors") == 1);
if (result != 0)
return result;
}

//update types : try to qualify non fqdn types in parameters ... from classes found during parsing
Expand Down

0 comments on commit f7995cc

Please sign in to comment.