inferLegacyFileFeatures function
Infers the fully-resolved FILE-level FeatureSet for a legacy syntax
("proto2" / "proto3", or "" ⇒ proto2).
In protoc's descriptor.cc, the file-level legacy inference is exactly the
selection of the syntax's edition floor: proto2 resolves through the LEGACY
floor (CLOSED enums, EXPANDED repeated, NONE utf8, LEGACY_BEST_EFFORT json,
EXPLICIT presence); proto3 through the PROTO3 floor (OPEN, PACKED, VERIFY,
ALLOW, IMPLICIT). The per-field shape adjustments (required/optional/group/
packed) are layered on top via inferLegacyFieldFeatures.
Returns all six runtime features. Throws nothing for unknown syntax — it floors to proto2 like protoc.
Implementation
Map<String, String> inferLegacyFileFeatures(String syntax) {
return baseFeaturesForEdition(syntaxToEdition(syntax));
}