Class: Riml::AST_Rewriter::RegisterImportedClasses

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, #initialize, #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

This class inherits a constructor from Riml::AST_Rewriter

Instance Method Details

#match?(node) ⇒ Boolean

Returns:

  • (Boolean)


316
317
318
# File 'lib/riml/ast_rewriter.rb', line 316

def match?(node)
  RimlClassCommandNode === node
end

#max_recursion_lvlObject



334
335
336
# File 'lib/riml/ast_rewriter.rb', line 334

def max_recursion_lvl
  1
end

#replace(node) ⇒ Object



320
321
322
323
324
325
326
327
328
329
330
331
332
# File 'lib/riml/ast_rewriter.rb', line 320

def replace(node)
  node.class_names_without_modifiers.each do |class_name|
    # TODO: check for wrong scope modifier
    imported_class = ImportedClass.new(class_name)
    if imported_class.globbed?
      classes.globbed_imports << imported_class
    else
      imported_class.instance_variable_set("@registered_state", true)
      classes["g:#{class_name}"] = imported_class
    end
  end
  node.remove
end