Class: Jade::Frontend::UsageAnalysis::ReferenceIndex
- Inherits:
-
Data
- Object
- Data
- Jade::Frontend::UsageAnalysis::ReferenceIndex
- Defined in:
- lib/jade/frontend/usage_analysis/reference_index.rb
Instance Attribute Summary collapse
-
#references ⇒ Object
readonly
Returns the value of attribute references.
Class Method Summary collapse
- .empty ⇒ Object
-
.key_for(symbol) ⇒ Object
Locals key on
decl_span; module-level symbols on[module_name, name].
Instance Method Summary collapse
- #ever_referenced?(symbol) ⇒ Boolean
- #for(symbol) ⇒ Object
-
#initialize(references: {}) ⇒ ReferenceIndex
constructor
A new instance of ReferenceIndex.
- #passed_as_value?(symbol) ⇒ Boolean
- #references_in(module_name) ⇒ Object
Constructor Details
#initialize(references: {}) ⇒ ReferenceIndex
Returns a new instance of ReferenceIndex.
11 12 13 |
# File 'lib/jade/frontend/usage_analysis/reference_index.rb', line 11 def initialize(references: {}) super end |
Instance Attribute Details
#references ⇒ Object (readonly)
Returns the value of attribute references
10 11 12 |
# File 'lib/jade/frontend/usage_analysis/reference_index.rb', line 10 def references @references end |
Class Method Details
.empty ⇒ Object
15 16 17 |
# File 'lib/jade/frontend/usage_analysis/reference_index.rb', line 15 def self.empty new(references: {}) end |
.key_for(symbol) ⇒ Object
Locals key on decl_span; module-level symbols on
[module_name, name]. NOTE: when :type_annotation refs land
they may point at a Symbol::Variable that's a type
variable, which would collide with value-level locals under
[:local, decl_span]. Revisit the keying scheme then —
likely split into [:local_value, ...] vs [:local_type, ...].
44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/jade/frontend/usage_analysis/reference_index.rb', line 44 def self.key_for(symbol) case symbol in Symbol::Variable [:local, symbol.decl_span] in Symbol::Implementation [:impl, symbol.interface.qname, symbol.type.qname] in Symbol::ValueRef | Symbol::TypeRef [symbol.module_name, symbol.name] else [symbol.module_name, symbol.name] end end |
Instance Method Details
#ever_referenced?(symbol) ⇒ Boolean
27 28 29 |
# File 'lib/jade/frontend/usage_analysis/reference_index.rb', line 27 def ever_referenced?(symbol) self.for(symbol).any? end |
#for(symbol) ⇒ Object
19 20 21 |
# File 'lib/jade/frontend/usage_analysis/reference_index.rb', line 19 def for(symbol) references[ReferenceIndex.key_for(symbol)] || [] end |
#passed_as_value?(symbol) ⇒ Boolean
23 24 25 |
# File 'lib/jade/frontend/usage_analysis/reference_index.rb', line 23 def passed_as_value?(symbol) self.for(symbol).any? { it.kind == :as_value } end |
#references_in(module_name) ⇒ Object
31 32 33 34 35 36 |
# File 'lib/jade/frontend/usage_analysis/reference_index.rb', line 31 def references_in(module_name) references .values .flatten .select { it.symbol_key.first == module_name } end |