Class: Holistic::Ruby::Parser::ConstantResolution
- Inherits:
-
Object
- Object
- Holistic::Ruby::Parser::ConstantResolution
show all
- Defined in:
- lib/holistic/ruby/parser/constant_resolution.rb
Defined Under Namespace
Modules: MethodRegistrationMode
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
Returns a new instance of ConstantResolution.
12
13
14
15
16
17
|
# File 'lib/holistic/ruby/parser/constant_resolution.rb', line 12
def initialize(scope_repository:)
@scope_repository = scope_repository
@scope = scope_repository.root
@constant_resolution_possibilities = ["::"]
@method_registration_mode = MethodRegistrationMode::INSTANCE_METHODS
end
|
Instance Attribute Details
#method_registration_mode ⇒ Object
Returns the value of attribute method_registration_mode.
10
11
12
|
# File 'lib/holistic/ruby/parser/constant_resolution.rb', line 10
def method_registration_mode
@method_registration_mode
end
|
#scope ⇒ Object
Returns the value of attribute scope.
10
11
12
|
# File 'lib/holistic/ruby/parser/constant_resolution.rb', line 10
def scope
@scope
end
|
#scope_repository ⇒ Object
Returns the value of attribute scope_repository.
10
11
12
|
# File 'lib/holistic/ruby/parser/constant_resolution.rb', line 10
def scope_repository
@scope_repository
end
|
Instance Method Details
#change_method_registration_mode_to_class_methods! ⇒ Object
104
105
106
|
# File 'lib/holistic/ruby/parser/constant_resolution.rb', line 104
def change_method_registration_mode_to_class_methods!
@method_registration_mode = MethodRegistrationMode::CLASS_METHODS
end
|
#change_method_registration_mode_to_instance_methods! ⇒ Object
108
109
110
|
# File 'lib/holistic/ruby/parser/constant_resolution.rb', line 108
def change_method_registration_mode_to_instance_methods!
@method_registration_mode = MethodRegistrationMode::INSTANCE_METHODS
end
|
#current ⇒ Object
19
20
21
|
# File 'lib/holistic/ruby/parser/constant_resolution.rb', line 19
def current
@constant_resolution_possibilities.dup
end
|
#method_registration_class_methods? ⇒ Boolean
100
101
102
|
# File 'lib/holistic/ruby/parser/constant_resolution.rb', line 100
def method_registration_class_methods?
method_registration_mode == MethodRegistrationMode::CLASS_METHODS
end
|
#register_child_class(nesting:, location:, &block) ⇒ Object
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
# File 'lib/holistic/ruby/parser/constant_resolution.rb', line 50
def register_child_class(nesting:, location:, &block)
starting_scope = @scope
nesting.each do |name|
@scope =
::Holistic::Ruby::Scope::Store.call(
database: @scope_repository.database,
lexical_parent: @scope,
kind: ::Holistic::Ruby::Scope::Kind::CLASS,
name:,
location:
)
end
registered_class_scope = @scope
@constant_resolution_possibilities.unshift(@scope.fully_qualified_name)
block.call
change_method_registration_mode_to_instance_methods!
@constant_resolution_possibilities.shift
@scope = starting_scope
registered_class_scope
end
|
#register_child_method(nesting:, location:, kind:, &block) ⇒ Object
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
# File 'lib/holistic/ruby/parser/constant_resolution.rb', line 77
def register_child_method(nesting:, location:, kind:, &block)
starting_scope = @scope
nesting.each do |name|
@scope =
::Holistic::Ruby::Scope::Store.call(
database: @scope_repository.database,
lexical_parent: @scope,
kind:,
name:,
location:
)
end
registered_method_scope = @scope
block.call
@scope = starting_scope
registered_method_scope
end
|
#register_child_module(nesting:, location:, &block) ⇒ Object
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
# File 'lib/holistic/ruby/parser/constant_resolution.rb', line 23
def register_child_module(nesting:, location:, &block)
starting_scope = @scope
nesting.each do |name|
@scope =
::Holistic::Ruby::Scope::Store.call(
database: @scope_repository.database,
lexical_parent: @scope,
kind: ::Holistic::Ruby::Scope::Kind::MODULE,
name:,
location:
)
end
registered_module_scope = @scope
@constant_resolution_possibilities.unshift(@scope.fully_qualified_name)
block.call
change_method_registration_mode_to_instance_methods!
@constant_resolution_possibilities.shift
@scope = starting_scope
registered_module_scope
end
|