Skip to content

Commit 4ca777e

Browse files
author
Adam Cozzette
committed
Merge tag 'refs/tags/sync-piper' into sync-stage
2 parents 2695895 + 6c09dde commit 4ca777e

2 files changed

Lines changed: 13 additions & 29 deletions

File tree

src/google/protobuf/compiler/js/js_generator.cc

Lines changed: 13 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1408,24 +1408,17 @@ bool HasFieldPresence(const GeneratorOptions& options,
14081408
// were the final one for a given filename.
14091409
class FileDeduplicator {
14101410
public:
1411-
explicit FileDeduplicator(const GeneratorOptions& options)
1412-
: error_on_conflict_(options.error_on_name_conflict) {}
1411+
explicit FileDeduplicator(const GeneratorOptions& options) {}
14131412

14141413
// params:
14151414
// filenames: a pair of {short filename, full filename}
14161415
// (short filename don't have extra information, full filename
14171416
// contains extra information)
14181417
// desc: The Descriptor or SCC pointer or EnumDescriptor.
1419-
// error: The returned error information.
14201418
bool AddFile(const std::pair<std::string, std::string> filenames,
1421-
const void* desc, std::string* error) {
1419+
const void* desc) {
14221420
if (descs_by_shortname_.find(filenames.first) !=
14231421
descs_by_shortname_.end()) {
1424-
if (error_on_conflict_) {
1425-
*error = "Name conflict: file name " + filenames.first +
1426-
" would be generated by two descriptors";
1427-
return false;
1428-
}
14291422
// Change old pointer's actual name to full name.
14301423
auto short_name_desc = descs_by_shortname_[filenames.first];
14311424
allowed_descs_actual_name_[short_name_desc] =
@@ -1443,7 +1436,6 @@ class FileDeduplicator {
14431436
}
14441437

14451438
private:
1446-
bool error_on_conflict_;
14471439
// The map that restores all the descs that are using short name as filename.
14481440
std::map<std::string, const void*> descs_by_shortname_;
14491441
// The final actual filename map.
@@ -1537,8 +1529,7 @@ struct DepsGenerator {
15371529
bool GenerateJspbAllowedMap(const GeneratorOptions& options,
15381530
const std::vector<const FileDescriptor*>& files,
15391531
std::map<const void*, std::string>* allowed_set,
1540-
SCCAnalyzer<DepsGenerator>* analyzer,
1541-
std::string* error) {
1532+
SCCAnalyzer<DepsGenerator>* analyzer) {
15421533
std::vector<const FileDescriptor*> files_ordered;
15431534
GenerateJspbFileOrder(files, &files_ordered);
15441535

@@ -1553,15 +1544,15 @@ bool GenerateJspbAllowedMap(const GeneratorOptions& options,
15531544
std::make_pair(
15541545
GetMessagesFileName(options, analyzer->GetSCC(desc), false),
15551546
GetMessagesFileName(options, analyzer->GetSCC(desc), true)),
1556-
analyzer->GetSCC(desc), error)) {
1547+
analyzer->GetSCC(desc))) {
15571548
return false;
15581549
}
15591550
}
15601551
for (int j = 0; j < files_ordered[i]->enum_type_count(); j++) {
15611552
const EnumDescriptor* desc = files_ordered[i]->enum_type(j);
15621553
if (!dedup.AddFile(std::make_pair(GetEnumFileName(options, desc, false),
15631554
GetEnumFileName(options, desc, true)),
1564-
desc, error)) {
1555+
desc)) {
15651556
return false;
15661557
}
15671558
}
@@ -1580,7 +1571,7 @@ bool GenerateJspbAllowedMap(const GeneratorOptions& options,
15801571
std::make_pair(
15811572
GetExtensionFileName(options, files_ordered[i], false),
15821573
GetExtensionFileName(options, files_ordered[i], true)),
1583-
files_ordered[i], error)) {
1574+
files_ordered[i])) {
15841575
return false;
15851576
}
15861577
}
@@ -3473,12 +3464,10 @@ bool GeneratorOptions::ParseFromOptions(
34733464
return false;
34743465
}
34753466
testonly = true;
3467+
34763468
} else if (options[i].first == "error_on_name_conflict") {
3477-
if (options[i].second != "") {
3478-
*error = "Unexpected option value for error_on_name_conflict";
3479-
return false;
3480-
}
3481-
error_on_name_conflict = true;
3469+
GOOGLE_LOG(WARNING) << "Ignoring error_on_name_conflict option, this "
3470+
"will be removed in a future release";
34823471
} else if (options[i].first == "output_dir") {
34833472
output_dir = options[i].second;
34843473
} else if (options[i].first == "namespace_prefix") {
@@ -3527,11 +3516,10 @@ bool GeneratorOptions::ParseFromOptions(
35273516

35283517
if (import_style != kImportClosure &&
35293518
(add_require_for_enums || testonly || !library.empty() ||
3530-
error_on_name_conflict || extension != ".js" ||
3531-
one_output_file_per_input_file)) {
3519+
extension != ".js" || one_output_file_per_input_file)) {
35323520
*error =
3533-
"The add_require_for_enums, testonly, library, error_on_name_conflict, "
3534-
"extension, and one_output_file_per_input_file options should only be "
3521+
"The add_require_for_enums, testonly, library, extension, and "
3522+
"one_output_file_per_input_file options should only be "
35353523
"used for import_style=closure";
35363524
return false;
35373525
}
@@ -3766,8 +3754,7 @@ bool Generator::GenerateAll(const std::vector<const FileDescriptor*>& files,
37663754
std::set<const Descriptor*> have_printed;
37673755
SCCAnalyzer<DepsGenerator> analyzer;
37683756
std::map<const void*, std::string> allowed_map;
3769-
if (!GenerateJspbAllowedMap(options, files, &allowed_map, &analyzer,
3770-
error)) {
3757+
if (!GenerateJspbAllowedMap(options, files, &allowed_map, &analyzer)) {
37713758
return false;
37723759
}
37733760

src/google/protobuf/compiler/js/js_generator.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ struct GeneratorOptions {
8383
add_require_for_enums(false),
8484
testonly(false),
8585
library(""),
86-
error_on_name_conflict(false),
8786
extension(".js"),
8887
one_output_file_per_input_file(false),
8988
annotate_code(false) {}
@@ -119,8 +118,6 @@ struct GeneratorOptions {
119118
// Create a library with name <name>_lib.js rather than a separate .js file
120119
// per type?
121120
std::string library;
122-
// Error if there are two types that would generate the same output file?
123-
bool error_on_name_conflict;
124121
// The extension to use for output file names.
125122
std::string extension;
126123
// Create a separate output file for each input file?

0 commit comments

Comments
 (0)