class

Noir::GoStructFields::Index

Inherits Reference < Object

Struct tables per package directory, parsed on first lookup.

Constants

ASSIGNED_TYPE = /\A\s*(\w+)\s*:?=\s*(?:&\s*)?(?:new\(\s*)?((?:\w+\.)?\w+)\s*[{)]/
DECLARED_TYPE = /\A\s*(?:var\s+)?(\w+)\s+\*?((?:\w+\.)?\w+)\s*\z/

Where a bind target's type is declared in a body: var req T, req T in a var (...) block, req := T{ / &T{ / new(T), or an anonymous struct { literal.

MAX_EMBED_DEPTH = 4
STRUCT_LITERAL = /\A\s*(?:var\s+)?(\w+)\s*(?::?=\s*)?struct\s*\{/

Constructors

new(file_contents : Hash(String, String), import_dirs : Hash(String, String))
Source

Instance methods

flatten(fields : Array(Field), path : String, depth : Int32 = 0) : Array(Field)

Embedded fields replaced by the fields of their struct, resolved from path's package.

Source
resolve(type_text : String, path : String, depth : Int32 = 0) : Array(Field) | Nil

type_text (T, *T, pkg.T) as written in the file path, resolved to its struct's fields with embedded structs flattened in. Nil when the type is not a struct declared in the scan.

Source
target_fields(lines : Array(String), name : String, path : String) : Array(Field) | Nil

The struct fields of the bind target name, from its declaration in the body lines of the file path; nil when it is not declared there as a known struct.

Source