struct

Bindgen::Crystal::Format

Inherits Struct < Value < Object

Formatter for Crystal style code.

Constructors

new(db : TypeDatabase)
Source

Instance methods

argument(arg : Call::Argument, idx, expose_default = true, binding = false) : String

Formats arg as type name. If binding is true, treat this as argument for a fun declaration.

Source
argument_list(arguments : Enumerable(Call::Argument), binding = false) : String

Formats arguments as name : type, .... If binding is true, treats this as argument for a fun declaration.

Source
literal(type_name, value) : String | Nil

Generates a literal value suitable for Crystal code, using the value of type_name. type_name is a completely deduced Crystal type-name.

Returns nil if type_name is unknown (It's not built-in). Try #qualified_enum_name in that case if it might be an enum.

Source
named_argument_list(arguments : Enumerable(Call::Argument), binding = false) : String

Formats arguments as *, name : type, ....

Source
number_literal(type_name, value) : String | Nil

Returns the number literal of type_name with value. The result is valid a Crystal literal, and can be directly written.

Source
number_literal_suffix(type_name) : String | Nil

Returns the literal-suffix for Crystal code, to signify a literal matching the intended type_name.

If type_name is unknown, returns nil.

Source
qualified_enum_name(type : Parser::Type, value : Int) : String | Nil

Returns the qualified name of value in the enum called enum_name. Builds a .flags(...) list if the enum turns out to be a @[Flags].

Source