Documentation ¶
Overview ¶
Package options contains the logic for interpreting options. The parse step of compilation stores the options in uninterpreted form, which contains raw identifiers and literal values.
The process of interpreting an option is to resolve identifiers, by examining descriptors for the Options types and their available extensions (custom options). As field names are resolved, the values can be type-checked against the types indicated in field descriptors.
On success, the various fields and extensions of the options message are populated and the field holding the uninterpreted form is cleared.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Index ¶
type Index map[*ast.OptionNode][]int32
Index is a mapping of AST nodes that define options to a corresponding path into the containing file descriptor. The path is a sequence of field tags and indexes that define a traversal path from the root (the file descriptor) to the resolved option field.
func InterpretOptions ¶
InterpretOptions interprets options in the given linked result, returning an index that can be used to generate source code info. This step mutates the linked result's underlying proto to move option elements out of the "uninterpreted_option" fields and into proper option fields and extensions.
The given handler is used to report errors and warnings. If any errors are reported, this function returns a non-nil error.
func InterpretOptionsLenient ¶
InterpretOptionsLenient interprets options in a lenient/best-effort way in the given linked result, returning an index that can be used to generate source code info. This step mutates the linked result's underlying proto to move option elements out of the "uninterpreted_option" fields and into proper option fields and extensions.
In lenient more, errors resolving option names and type errors are ignored. Any options that are uninterpretable (due to such errors) will remain in the "uninterpreted_option" fields.
func InterpretUnlinkedOptions ¶
InterpretUnlinkedOptions does a best-effort attempt to interpret options in the given parsed result, returning an index that can be used to generate source code info. This step mutates the parsed result's underlying proto to move option elements out of the "uninterpreted_option" fields and into proper option fields and extensions.
This is the same as InterpretOptionsLenient except that it accepts an unlinked result. Because the file is unlinked, custom options cannot be interpreted. Other errors resolving option names or type errors will be effectively ignored. Any options that are uninterpretable (due to such errors) will remain in the "uninterpreted_option" fields.