Module: RubySourceStructureUtils

Included in:
RubyCtagsFileSourceStructure, RubyGrepFileSourceStructure, RubySourceStructureParser
Defined in:
ext/ae-editor/ae-editor.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#injected_rowObject (readonly)

Returns the value of attribute injected_row.



119
120
121
# File 'ext/ae-editor/ae-editor.rb', line 119

def injected_row
  @injected_row
end

Instance Method Details

#scheletor_from_node(_node, _source = '', _injected_source = '', _injected_class = '') ⇒ Object



120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
# File 'ext/ae-editor/ae-editor.rb', line 120

def scheletor_from_node(_node, _source='', _injected_source='', _injected_class='')
  _hinner_source = ''
  #_sons = _node.sons.sort
  _sons = _node.sons
  for inode in 0.._sons.length - 1
    _son = _sons[inode]
    if _son.kind == 'class'
       _hinner_source = "#{_hinner_source}#{_son.helptext}\n"
    elsif _son.kind == 'module'
       _hinner_source = "#{_hinner_source}#{_son.helptext}\n"
    elsif _son.kind == 'method' && ((_son.label != 'initialize') || (_son.label == 'initialize') && _son.args)         
       _hinner_source = "#{_hinner_source}  def #{_son.label}#{_son.args}\n"
       _hinner_source = "#{_hinner_source}  end\n"
    elsif _son.kind == 'singleton method'
       _hinner_source = "#{_hinner_source}  def #{_son.label}\n"
       _hinner_source = "#{_hinner_source}  end\n"
    end
    _hinner_source= scheletor_from_node(_son, _hinner_source, _injected_source, _injected_class)
  end
  _source = "#{_source}#{_hinner_source}" if _hinner_source.strip.length>0
  if _node.kind == 'class' && _node.label == _injected_class
    _source = "#{_source}  def initialize\n  #{_injected_source}  end\n"
    @injected_row = _source.split("\n").length-2
  elsif _node.kind == 'class'
    _source = "#{_source}  def initialize\n  end\n"
  end
  _source = "#{_source}end\n" if _node.kind == 'class' || _node.kind == 'module'
  _source
end