struct Bindgen::Crystal::Format

Overview

Formatter for Crystal style code.

Defined in:

bindgen/crystal/format.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(db : TypeDatabase) #

[View source]

Instance Method Detail

def 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.


[View source]
def 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.


[View source]
def 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.


[View source]
def named_argument_list(arguments : Enumerable(Call::Argument), binding = false) : String #

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


[View source]
def 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.


[View source]
def 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.


[View source]
def 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].


[View source]