Names

nscn.polaris2.protoc.codegen.Names
object Names

Translating proto names into Scala ones.

Attributes

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

Members list

Value members

Concrete methods

def escape(name: String): String

Backquotes an identifier that Scala would otherwise reject.

Backquotes an identifier that Scala would otherwise reject.

Attributes

def escapePackage(pkg: String): String

Escapes a dotted package so each segment can be a Scala identifier.

Escapes a dotted package so each segment can be a Scala identifier.

Attributes

def fileBaseName(protoFileName: String): String

The package segment derived from a file name, for the non-flat package layout.

The package segment derived from a file name, for the non-flat package layout.

Attributes

def fileObjectName(protoFileName: String): String

The Scala object name for a .proto file, as my_file.proto to MyFileProto.

The Scala object name for a .proto file, as my_file.proto to MyFileProto.

Attributes

def snakeCaseToCamelCase(name: String, upperInitial: Boolean = ...): String

foo_bar to fooBar, or to FooBar with upperInitial.

foo_bar to fooBar, or to FooBar with upperInitial.

Follows protoc's own rule rather than a general one, because the generated names have to match what every other protobuf implementation produces: a digit makes the next letter uppercase, and an already-uppercase first letter is lowered unless the caller asked for Pascal case.

Attributes

def stripEnumPrefix(valueName: String, enumName: String): String

Strips an enum's own name from the front of one of its values.

Strips an enum's own name from the front of one of its values.

proto style prefixes every value with the enum name (Color.COLOR_RED), which in Scala reads as a stutter (Color.COLOR_RED where Color.RED would do). Comparison ignores underscores and case, so COLOR_RED, Color_Red and colorRed all strip. A value that would be left empty, starting with a digit, or no longer unique is left alone.

Attributes

def toAllCaps(name: String): String

fooBar to FOO_BAR, for enum values renamed to Scala's constant convention.

fooBar to FOO_BAR, for enum values renamed to Scala's constant convention.

Attributes

Concrete fields

val ScalaReservedWords: Set[String]

Every word Scala 3 will not accept as a plain identifier.

Every word Scala 3 will not accept as a plain identifier.

Longer than Scala 2's list: enum, given, export, then, ?=> and the soft keywords arrived with Scala 3, and proto files in the wild do contain fields called type, object and val.

Attributes