Class: Jade::Entry
- Inherits:
-
Data
- Object
- Data
- Jade::Entry
- Defined in:
- lib/jade/entry.rb
Instance Attribute Summary collapse
-
#ast ⇒ Object
readonly
Returns the value of attribute ast.
-
#defined_types ⇒ Object
readonly
Returns the value of attribute defined_types.
-
#defined_values ⇒ Object
readonly
Returns the value of attribute defined_values.
-
#diagnostics ⇒ Object
readonly
Returns the value of attribute diagnostics.
-
#entry ⇒ Object
readonly
Returns the value of attribute entry.
-
#env ⇒ Object
readonly
Returns the value of attribute env.
-
#exposes ⇒ Object
readonly
Returns the value of attribute exposes.
-
#generated ⇒ Object
readonly
Returns the value of attribute generated.
-
#implementations ⇒ Object
readonly
Returns the value of attribute implementations.
-
#imports ⇒ Object
readonly
Returns the value of attribute imports.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
-
#usage_index ⇒ Object
readonly
Returns the value of attribute usage_index.
Class Method Summary collapse
Instance Method Summary collapse
- #define(symbol) ⇒ Object
- #expose(symbol) ⇒ Object
- #exposed_type(unqualified_name) ⇒ Object
- #exposed_type_variants(unqualified_name) ⇒ Object
- #exposed_value(unqualified_name) ⇒ Object
- #import(import_entry) ⇒ Object
- #imported_types ⇒ Object
- #imported_values ⇒ Object
-
#interface_digest ⇒ Object
Source spans are stripped so unrelated edits (e.g. whitespace) shifting one definition’s span don’t bust caches for consumers of others.
- #lookup_qualified_type(as, type_name) ⇒ Object
- #lookup_type(name) ⇒ Object
- #lookup_value(name) ⇒ Object
- #path ⇒ Object
- #types ⇒ Object
- #values ⇒ Object
Instance Attribute Details
#ast ⇒ Object (readonly)
Returns the value of attribute ast
2 3 4 |
# File 'lib/jade/entry.rb', line 2 def ast @ast end |
#defined_types ⇒ Object (readonly)
Returns the value of attribute defined_types
2 3 4 |
# File 'lib/jade/entry.rb', line 2 def defined_types @defined_types end |
#defined_values ⇒ Object (readonly)
Returns the value of attribute defined_values
2 3 4 |
# File 'lib/jade/entry.rb', line 2 def defined_values @defined_values end |
#diagnostics ⇒ Object (readonly)
Returns the value of attribute diagnostics
2 3 4 |
# File 'lib/jade/entry.rb', line 2 def diagnostics @diagnostics end |
#entry ⇒ Object (readonly)
Returns the value of attribute entry
2 3 4 |
# File 'lib/jade/entry.rb', line 2 def entry @entry end |
#env ⇒ Object (readonly)
Returns the value of attribute env
2 3 4 |
# File 'lib/jade/entry.rb', line 2 def env @env end |
#exposes ⇒ Object (readonly)
Returns the value of attribute exposes
2 3 4 |
# File 'lib/jade/entry.rb', line 2 def exposes @exposes end |
#generated ⇒ Object (readonly)
Returns the value of attribute generated
2 3 4 |
# File 'lib/jade/entry.rb', line 2 def generated @generated end |
#implementations ⇒ Object (readonly)
Returns the value of attribute implementations
2 3 4 |
# File 'lib/jade/entry.rb', line 2 def implementations @implementations end |
#imports ⇒ Object (readonly)
Returns the value of attribute imports
2 3 4 |
# File 'lib/jade/entry.rb', line 2 def imports @imports end |
#name ⇒ Object (readonly)
Returns the value of attribute name
2 3 4 |
# File 'lib/jade/entry.rb', line 2 def name @name end |
#source ⇒ Object (readonly)
Returns the value of attribute source
2 3 4 |
# File 'lib/jade/entry.rb', line 2 def source @source end |
#usage_index ⇒ Object (readonly)
Returns the value of attribute usage_index
2 3 4 |
# File 'lib/jade/entry.rb', line 2 def usage_index @usage_index end |
Class Method Details
.empty(name) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/jade/entry.rb', line 18 def self.empty(name) new( name:, defined_values: {}, defined_types: {}, imports: ::Set[], exposes: ::Set[], ast: nil, source: nil, generated: nil, env: nil, implementations: {}, entry: false, diagnostics: Diagnostics::List.empty, usage_index: nil, ) end |
Instance Method Details
#define(symbol) ⇒ Object
90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/jade/entry.rb', line 90 def define(symbol) case symbol in Symbol::Union | Symbol::Struct | Symbol::Interface add_defined_type(symbol) in Symbol::Implementation add_implementation(symbol) in Symbol::Function | Symbol::StdlibFunction | Symbol::Constructor | Symbol::Variant | Symbol::InteropFunction | Symbol::InterfaceFunction add_defined_value(symbol) end end |
#expose(symbol) ⇒ Object
36 37 38 |
# File 'lib/jade/entry.rb', line 36 def expose(symbol) with(exposes: exposes + ::Set[symbol]) end |
#exposed_type(unqualified_name) ⇒ Object
49 50 51 52 |
# File 'lib/jade/entry.rb', line 49 def exposed_type(unqualified_name) exposes .find { it.is_a?(Symbol::TypeRef) && it.name == unqualified_name } end |
#exposed_type_variants(unqualified_name) ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/jade/entry.rb', line 54 def exposed_type_variants(unqualified_name) type_ref = exposes .find { it.is_a?(Symbol::TypeRef) && it.name == unqualified_name } return nil unless type_ref types[unqualified_name] .constructor_refs .then { it & exposes.to_a } .then { it.empty? ? nil : it } end |
#exposed_value(unqualified_name) ⇒ Object
44 45 46 47 |
# File 'lib/jade/entry.rb', line 44 def exposed_value(unqualified_name) exposes .find { it.is_a?(Symbol::ValueRef) && it.name == unqualified_name } end |
#import(import_entry) ⇒ Object
40 41 42 |
# File 'lib/jade/entry.rb', line 40 def import(import_entry) with(imports: imports + ::Set[import_entry]) end |
#imported_types ⇒ Object
74 75 76 77 78 79 80 |
# File 'lib/jade/entry.rb', line 74 def imported_types imports .flat_map(&:unqualified_symbols) .select { it.is_a?(Symbol::TypeRef) } .map { [it.name, it] } .to_h end |
#imported_values ⇒ Object
66 67 68 69 70 71 72 |
# File 'lib/jade/entry.rb', line 66 def imported_values imports .flat_map(&:unqualified_symbols) .select { it.is_a?(Symbol::ValueRef) } .map { [it.name, it] } .to_h end |
#interface_digest ⇒ Object
Source spans are stripped so unrelated edits (e.g. whitespace) shifting one definition’s span don’t bust caches for consumers of others.
125 126 127 |
# File 'lib/jade/entry.rb', line 125 def interface_digest Digest::SHA256.hexdigest(Marshal.dump(interface_snapshot)) end |
#lookup_qualified_type(as, type_name) ⇒ Object
113 114 115 116 117 |
# File 'lib/jade/entry.rb', line 113 def lookup_qualified_type(as, type_name) imports .find { it.alias == as } &.qualified_symbols&.find { it.is_a?(Symbol::TypeRef) && it.name == type_name } end |
#lookup_type(name) ⇒ Object
109 110 111 |
# File 'lib/jade/entry.rb', line 109 def lookup_type(name) types[name] end |
#lookup_value(name) ⇒ Object
105 106 107 |
# File 'lib/jade/entry.rb', line 105 def lookup_value(name) values[name] end |
#path ⇒ Object
119 120 121 |
# File 'lib/jade/entry.rb', line 119 def path source.uri.gsub('.jd', '.rb') end |
#types ⇒ Object
86 87 88 |
# File 'lib/jade/entry.rb', line 86 def types imported_types.merge(defined_types) end |
#values ⇒ Object
82 83 84 |
# File 'lib/jade/entry.rb', line 82 def values imported_values.merge(defined_values) end |