Class: Hiptest::Nodes::ParameterTypeAdder
- Inherits:
-
Object
- Object
- Hiptest::Nodes::ParameterTypeAdder
- Defined in:
- lib/hiptest-publisher/parameter_type_adder.rb
Instance Attribute Summary collapse
-
#call_types ⇒ Object
readonly
Returns the value of attribute call_types.
Class Method Summary collapse
Instance Method Summary collapse
- #add_arguments_from(node, context = nil) ⇒ Object
- #gather_call_argument_types(node) ⇒ Object
- #gather_scenarios_argument_types(project) ⇒ Object
-
#initialize ⇒ ParameterTypeAdder
constructor
A new instance of ParameterTypeAdder.
- #process(project) ⇒ Object
- #write_parameter_types_to_item(callable_item) ⇒ Object
Constructor Details
#initialize ⇒ ParameterTypeAdder
Returns a new instance of ParameterTypeAdder.
14 15 16 |
# File 'lib/hiptest-publisher/parameter_type_adder.rb', line 14 def initialize @call_types = CallTypes.new end |
Instance Attribute Details
#call_types ⇒ Object (readonly)
Returns the value of attribute call_types.
8 9 10 |
# File 'lib/hiptest-publisher/parameter_type_adder.rb', line 8 def call_types @call_types end |
Class Method Details
.add(project) ⇒ Object
10 11 12 |
# File 'lib/hiptest-publisher/parameter_type_adder.rb', line 10 def self.add(project) Hiptest::Nodes::ParameterTypeAdder.new.process(project) end |
Instance Method Details
#add_arguments_from(node, context = nil) ⇒ Object
53 54 55 56 57 |
# File 'lib/hiptest-publisher/parameter_type_adder.rb', line 53 def add_arguments_from(node, context = nil) node.each_sub_nodes(Argument) do |argument| @call_types.add_argument_type(argument.children[:name], get_type(argument, context)) end end |
#gather_call_argument_types(node) ⇒ Object
40 41 42 43 44 45 |
# File 'lib/hiptest-publisher/parameter_type_adder.rb', line 40 def gather_call_argument_types(node) node.each_sub_nodes(Call) do |call| @call_types.add_callable_item(call.children[:actionword], Actionword) add_arguments_from(call, node) end end |
#gather_scenarios_argument_types(project) ⇒ Object
33 34 35 36 37 38 |
# File 'lib/hiptest-publisher/parameter_type_adder.rb', line 33 def gather_scenarios_argument_types(project) project.children[:scenarios].children[:scenarios].each do |scenario| @call_types.add_callable_item(scenario.children[:name], Scenario) add_arguments_from(scenario.children[:datatable]) end end |
#process(project) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/hiptest-publisher/parameter_type_adder.rb', line 18 def process(project) gather_scenarios_argument_types(project) # To have the most accurate type, the closest calls must be computed # first, and deepest calls must be computed last (because they depend # on previous calls types). distances_index = Hiptest::ProjectGrapher.distances_index(project) distances_index.each_value do |items| # distances_index items are sorted by distance, from closest to deepest items.each do |item| write_parameter_types_to_item(item) gather_call_argument_types(item) end end end |
#write_parameter_types_to_item(callable_item) ⇒ Object
47 48 49 50 51 |
# File 'lib/hiptest-publisher/parameter_type_adder.rb', line 47 def write_parameter_types_to_item(callable_item) callable_item.each_sub_nodes(Parameter) do |parameter| parameter.children[:type] = @call_types.type_of(callable_item.children[:name], parameter.children[:name], callable_item.class) end end |