Skip to content

Commit f7995cc

Browse files
committed
fix: update "missing file" message and remove mutual exclusion change
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.
1 parent fafb0bb commit f7995cc

File tree

1 file changed

+13
-19
lines changed

1 file changed

+13
-19
lines changed

tools/generators/grpc/xpcf_grpc_gen.cpp

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -220,14 +220,6 @@ try
220220
serviceGenerator->setDestinationFolder(options["output"].as<std::string>());
221221
}
222222

223-
bool fileOptIsEmpty = !options.count("file") || options["file"].as<std::string>().empty();
224-
bool databaseDirOptIsEmpty = !options.count("database_dir") || options["database_dir"].as<std::string>().empty();
225-
226-
if (!fileOptIsEmpty && !databaseDirOptIsEmpty) {
227-
print_error("--file and --database_dir cannot be both set");
228-
return 1;
229-
}
230-
231223
auto astParser = cmpMgr->resolve<ITypeParser>("astParser");
232224

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

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

240-
if (!databaseDirOptIsEmpty) {
241-
assert(fileOptIsEmpty);
242-
if (int res = astParser->parse_database(options["database_dir"].as<std::string>(),options) != 0) {
243-
return res;
232+
if (!options.count("file") || options["file"].as<std::string>().empty()) {
233+
if (options.count("database_dir") && !options["database_dir"].as<std::string>().empty()) {
234+
std::cout<<"File argument is missing : parsing every file listed in database"<<std::endl;
235+
astParser->parse_database(options["database_dir"].as<std::string>(),options);
236+
//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); });
244237
}
245-
//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); });
246-
} else if (!fileOptIsEmpty) {
247-
if (int res = astParser->parse_file(options["file"].as<std::string>(), options.count("fatal_errors") == 1) != 0) {
248-
return res;
238+
else {
239+
print_error("missing one of file or database dir argument");
240+
return 1;
249241
}
250-
} else {
251-
print_error("missing one of --file or --database_dir argument");
252-
return 1;
242+
}
243+
else {
244+
result = astParser->parse_file(options["file"].as<std::string>(), options.count("fatal_errors") == 1);
245+
if (result != 0)
246+
return result;
253247
}
254248

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

0 commit comments

Comments
 (0)