Class: SourceStructure

Inherits:
Object
  • Object
show all
Defined in:
ext/ae-editor/ae-editor.rb

Direct Known Subclasses

CtagsSourceStructure, RubySourceStructure

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeSourceStructure

Returns a new instance of SourceStructure.



47
48
49
50
51
52
# File 'ext/ae-editor/ae-editor.rb', line 47

def initialize
  @root = SourceTreeNode.new(nil, 'root'){|_node|
    _node.rif= 'root'
    _node.label=''
  }
end

Instance Attribute Details

#rootObject (readonly)

Returns the value of attribute root.



45
46
47
# File 'ext/ae-editor/ae-editor.rb', line 45

def root
  @root
end

Instance Method Details

#class_node_by_line(_line) ⇒ Object



85
86
87
88
89
90
91
92
# File 'ext/ae-editor/ae-editor.rb', line 85

def (_line)
  line_node = (@root, _line)
  class_node = line_node
  while class_node != nil && class_node.kind != "class"
    class_node = class_node.parent
  end
  return class_node
end

#deep_node_by_line(_from_node, _line, _found_node = nil) ⇒ Object



71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'ext/ae-editor/ae-editor.rb', line 71

def (_from_node, _line, _found_node=nil)
  _begin = _from_node.rif.to_i
  _end = _from_node.rif_end.to_i
  if _line.to_i <= _end && _line.to_i >= _begin
    _found_node = _from_node
  end
  _sons = _from_node.sons
  for inode in 0.._sons.length - 1
    _son = _sons[inode]
    _found_node = (_son, _line, _found_node)
  end
  return _found_node
end

#node_by_line(_from_node, _line) ⇒ Object



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'ext/ae-editor/ae-editor.rb', line 54

def (_from_node, _line)
  _found_node = nil
  _begin = _from_node.rif.to_i
  _end = _from_node.rif_end.to_i
  if _line.to_i <= _end && _line.to_i >= _begin
    _found_node = _from_node
  else 
    _sons = _from_node.sons
    for inode in 0.._sons.length - 1
      _son = _sons[inode]
      _found_node = (_son, _line)
      break if _found_node
    end
  end
  return _found_node
end