Class: SourceStructure
- Inherits:
-
Object
show all
- Defined in:
- ext/ae-editor/ae-editor.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
Returns a new instance of SourceStructure.
39
40
41
42
43
44
|
# File 'ext/ae-editor/ae-editor.rb', line 39
def initialize
@root = TreeNode.new(nil, 'KRoot'){|_node|
_node.rif= 'root'
_node.label=''
}
end
|
Instance Attribute Details
#root ⇒ Object
Returns the value of attribute root.
37
38
39
|
# File 'ext/ae-editor/ae-editor.rb', line 37
def root
@root
end
|
Instance Method Details
#class_node_by_line(_line) ⇒ Object
77
78
79
80
81
82
83
84
|
# File 'ext/ae-editor/ae-editor.rb', line 77
def class_node_by_line(_line)
line_node = node_by_line(@root, _line)
class_node = line_node
while class_node != nil && class_node.kind != "KClass"
class_node = class_node.parent
end
return class_node
end
|
#deep_node_by_line(_from_node, _line, _found_node = nil) ⇒ Object
63
64
65
66
67
68
69
70
71
72
73
74
75
|
# File 'ext/ae-editor/ae-editor.rb', line 63
def deep_node_by_line(_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 = deep_node_by_line(_son, _line, _found_node)
end
return _found_node
end
|
#node_by_line(_from_node, _line) ⇒ Object
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
# File 'ext/ae-editor/ae-editor.rb', line 46
def node_by_line(_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 = node_by_line(_son, _line)
break if _found_node
end
end
return _found_node
end
|