Class: CtagsSourceStructure
- Inherits:
-
SourceStructure
- Object
- SourceStructure
- CtagsSourceStructure
- Defined in:
- ext/ae-editor/ae-editor.rb
Direct Known Subclasses
Constant Summary collapse
- SUPPORTED_LANG =
['Ant','Asm','Asp','Awk','Basic','BETA','C','C++','C#','Cobol','DosBatch','Eiffel','Erlang','Flex','Fortran','HTML','Java','JavaScript','Lisp','Lua','Make','MatLab','OCaml','Pascal','Perl','PHP','Python','REXX','Ruby','Scheme','Sh','SLang','SML','SQL','Tcl','Tex','Vera','Verilog','VHDL','Vim','YACC']
Instance Attribute Summary
Attributes inherited from SourceStructure
Instance Method Summary collapse
- #build_structure ⇒ Object
- #ctags ⇒ Object
-
#initialize(_file, _ctags_string = 'ctags', _row_rif = nil, _language = nil) ⇒ CtagsSourceStructure
constructor
A new instance of CtagsSourceStructure.
- #initialize_blank_rows(_row = nil) ⇒ Object
Methods inherited from SourceStructure
#class_node_by_line, #deep_node_by_line, #node_by_line, root
Constructor Details
#initialize(_file, _ctags_string = 'ctags', _row_rif = nil, _language = nil) ⇒ CtagsSourceStructure
Returns a new instance of CtagsSourceStructure.
101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'ext/ae-editor/ae-editor.rb', line 101 def initialize(_file, ='ctags', _row_rif = nil, _language=nil) super() @file = _file @ctags_string = @language = (_language.nil?)?nil:_language.capitalize @classes = Hash.new @last_root = @root @last_class_node = @root @last_node = @root @blank_rows = [] initialize_blank_rows(_row_rif) if !_row_rif.nil? build_structure end |
Instance Method Details
#build_structure ⇒ Object
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 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 |
# File 'ext/ae-editor/ae-editor.rb', line 124 def build_structure output = output.each {|line| b1,brest = line.split("/^") b2,b3 = brest.split('$/;"') name,file = b1.strip.split("\t") definition = b2.strip fields_raw = b3.nil? ? [] : b3.strip.split("\t") fields = Hash.new fields_raw.each{|item| k,v=item.split(":") fields[k.strip]=v.strip if !k.nil? && !v.nil? } if fields['class'] != nil parent = @classes[fields['class']] elsif fields['interface'] != nil parent = @classes[fields['interface']] elsif ['method','singleton method'].include?(fields['kind']) parent = @last_class_node else parent = @last_root end node = SourceTreeNode.new(parent, fields['kind']) node.label = name node.helptext = definition node.args = '' definition.split(name)[1..-1].each { |part| node.args += "#{part}" } node.rif = fields['line'] ln_rif = node.rif.to_i - 1 while @blank_rows.include?(ln_rif) && ln_rif > 0 ln_rif = ln_rif - 1 end @last_node.rif_end = ln_rif.to_s if ['class','module','interface','package'].include?(fields['kind']) if fields['class'] != nil @classes["#{fields['class']}.#{name}"]=node else @classes[name]=node end @last_class_node = node end node.sortable = !['package','field'].include?(fields['kind']) @last_node = node } end |
#ctags ⇒ Object
173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 |
# File 'ext/ae-editor/ae-editor.rb', line 173 def if @language != nil && SUPPORTED_LANG.include?(@language) @ctags_string = "#{@ctags_string} --language-force=#{@language}" end _cmd_ = "|#{@ctags_string} --fields=+a+f+m+i+k+K+n+s+S+t+z -uf - #{@file}" to_ret = '' begin open(_cmd_, "r"){|f| to_ret = f.readlines } rescue RuntimeError => e Arcadia.runtime_error(e) end to_ret end |
#initialize_blank_rows(_row = nil) ⇒ Object
115 116 117 118 119 120 121 122 |
# File 'ext/ae-editor/ae-editor.rb', line 115 def initialize_blank_rows(_row = nil) File::open(@file,'rb'){ |file| file.readlines.each_with_index{| line, i | @blank_rows << i+1 if line.strip == '' } } @blank_rows << _row if _row end |