Editions

nscn.polaris2.protoc.bridge.codegen.Editions
object Editions

The descriptor queries a generator needs for editions, including stand-ins for the three protobuf-java methods that are package-private.

A generator should ask these questions through feature-resolved predicates - hasPresence, isPacked, isClosed - and not by testing the syntax. What is left here is the handful of cases where protobuf-java's public API has a gap.

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Self type
Editions.type

Members list

Value members

Concrete methods

def editionOf(file: FileDescriptor): Edition

The edition of a file, including the synthetic editions standing for proto2 and proto3.

The edition of a file, including the synthetic editions standing for proto2 and proto3.

FileDescriptor.getEdition is package-private, and the edition field on the proto is only set for a real edition = "..." file - protoc leaves it EDITION_UNKNOWN and sets syntax instead for proto2 and proto3. Reading either one alone therefore gets two thirds of the cases wrong.

Attributes

def hasOptionalKeyword(field: FieldDescriptor): Boolean

Whether the field was written with an explicit optional keyword.

Whether the field was written with an explicit optional keyword.

FieldDescriptor.hasOptionalKeyword is package-private. proto3_optional on the proto covers proto3; for proto2 and editions the equivalent is a field with presence that is not inside a real oneof and is not required.

Attributes

def isClosedEnumField(field: FieldDescriptor): Boolean

Whether an enum-typed field should be treated as closed.

Whether an enum-typed field should be treated as closed.

Not the same question as getEnumType.isClosed: a proto3 file may reference an enum declared in a proto2 file, and protobuf's rule is that such a field behaves as open even though the enum itself is closed.

Attributes

def isDelimited(field: FieldDescriptor): Boolean

Whether the field uses group-style delimited encoding.

Whether the field uses group-style delimited encoding.

In editions this is features.message_encoding = DELIMITED rather than the group keyword, but protobuf-java reports both as TYPE_GROUP.

Attributes

def isEditions(file: FileDescriptor): Boolean
def isProto2(file: FileDescriptor): Boolean
def isProto3(file: FileDescriptor): Boolean
def isSupported(file: FileDescriptor): Boolean
def isSynthetic(oneof: OneofDescriptor): Boolean

Whether this oneof is the wrapper protoc invents for a proto3 optional field.

Whether this oneof is the wrapper protoc invents for a proto3 optional field.

OneofDescriptor.isSynthetic is package-private. The observable difference is that getRealContainingOneof skips synthetic oneofs, so a field that is in a oneof but has no real containing oneof is in a synthetic one.

Attributes

def succeed(files: Seq[File]): CodeGenResponse

Succeeds with the feature flags and edition window this project always advertises.

Succeeds with the feature flags and edition window this project always advertises.

Attributes

Concrete fields

val GeneratorFeatures: Set[Feature]

The features a generator here advertises, and protoc gate-keeps on both of them.

The features a generator here advertises, and protoc gate-keeps on both of them.

Omitting FEATURE_PROTO3_OPTIONAL is the easy one to miss, because it fails only for a proto3 file that actually uses optional: "is a proto3 file that contains optional fields, but code generator ... hasn't been updated to support optional fields in proto3". Omitting FEATURE_SUPPORTS_EDITIONS rejects every edition file.

Attributes

val MaximumEdition: Edition
val MinimumEdition: Edition

Every edition this project generates code for.

Every edition this project generates code for.

Attributes