Class: SourceStructure
- Inherits:
-
Object
show all
- Defined in:
- ext/ae-editor/ae-editor.rb
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
Returns a new instance of SourceStructure.
46
47
48
|
# File 'ext/ae-editor/ae-editor.rb', line 46
def initialize
@root = SourceStructure.root
end
|
Instance Attribute Details
#root ⇒ Object
Returns the value of attribute root.
44
45
46
|
# File 'ext/ae-editor/ae-editor.rb', line 44
def root
@root
end
|
Class Method Details
.root ⇒ Object
50
51
52
53
54
55
|
# File 'ext/ae-editor/ae-editor.rb', line 50
def SourceStructure.root
SourceTreeNode.new(nil, 'root'){|_node|
_node.rif= 'root'
_node.label=''
}
end
|
Instance Method Details
#class_node_by_line(_line) ⇒ Object
88
89
90
91
92
93
94
95
|
# File 'ext/ae-editor/ae-editor.rb', line 88
def class_node_by_line(_line)
line_node = node_by_line(@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
74
75
76
77
78
79
80
81
82
83
84
85
86
|
# File 'ext/ae-editor/ae-editor.rb', line 74
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
# File 'ext/ae-editor/ae-editor.rb', line 57
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
|