Class: Riml::AST_Rewriter::RegisterClassDependencies

Inherits:
Riml::AST_Rewriter show all
Defined in:
lib/riml/ast_rewriter.rb

Constant Summary

Constants included from Constants

Constants::BUILTIN_COMMANDS, Constants::BUILTIN_FUNCTIONS, Constants::COMPARISON_OPERATORS, Constants::COMPILED_STRING_LOCATION, Constants::DEFINE_KEYWORDS, Constants::END_KEYWORDS, Constants::IGNORECASE_CAPABLE_OPERATORS, Constants::KEYWORDS, Constants::REGISTERS, Constants::RIML_CLASS_COMMANDS, Constants::RIML_COMMANDS, Constants::RIML_END_KEYWORDS, Constants::RIML_FILE_COMMANDS, Constants::RIML_KEYWORDS, Constants::SPECIAL_VARIABLE_PREFIXES, Constants::SPLAT_LITERAL, Constants::UNKNOWN_LOCATION_INFO, Constants::VIML_COMMANDS, Constants::VIML_END_KEYWORDS, Constants::VIML_KEYWORDS

Instance Attribute Summary

Attributes inherited from Riml::AST_Rewriter

#ast, #classes, #options

Instance Method Summary collapse

Methods inherited from Riml::AST_Rewriter

#add_SID_function!, #add_SID_function?, #do_establish_parents, #do_rewrite_on_match, #establish_parents, #max_recursion_lvl, #reorder_includes_based_on_class_dependencies!, #resolve_class_dependencies!, #resolve_class_dependencies?, #rewrite, #rewrite_included_and_sourced_files!, #rewrite_on_match, #watch_for_class_pickup

Constructor Details

#initialize(ast, classes, class_dependency_graph, filename) ⇒ RegisterClassDependencies

Returns a new instance of RegisterClassDependencies.



161
162
163
164
# File 'lib/riml/ast_rewriter.rb', line 161

def initialize(ast, classes, class_dependency_graph, filename)
  super(ast, classes, class_dependency_graph)
  @filename = filename
end

Instance Method Details

#match?(node) ⇒ Boolean

Returns:

  • (Boolean)


166
167
168
# File 'lib/riml/ast_rewriter.rb', line 166

def match?(node)
  ClassDefinitionNode === node || ObjectInstantiationNode === node
end

#replace(node) ⇒ Object



170
171
172
173
174
175
176
177
178
179
180
181
182
# File 'lib/riml/ast_rewriter.rb', line 170

def replace(node)
  if ClassDefinitionNode === node
    @class_dependency_graph.class_defined(
      @filename, class_node_full_name(node),
      class_name_full_name(node.superclass_name)
    )
  else
    @class_dependency_graph.class_encountered(
      @filename,
      class_node_full_name(node.call_node)
    )
  end
end