Class: CtagsFileSourceStructure
- Inherits:
-
FileSourceStructure
- Object
- SourceStructure
- FileSourceStructure
- CtagsFileSourceStructure
- 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
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.
- #ctags ⇒ Object
-
#initialize(_file, _ctags_string = 'ctags', _row_rif = nil, _language = nil) ⇒ CtagsFileSourceStructure
constructor
A new instance of CtagsFileSourceStructure.
Methods inherited from FileSourceStructure
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) ⇒ CtagsFileSourceStructure
Returns a new instance of CtagsFileSourceStructure.
250 251 252 253 254 255 256 257 258 259 260 261 262 |
# File 'ext/ae-editor/ae-editor.rb', line 250 def initialize(_file, ='ctags', _row_rif = nil, _language=nil) super(_file, _row_rif) #@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
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
273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 |
# File 'ext/ae-editor/ae-editor.rb', line 273 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
322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 |
# File 'ext/ae-editor/ae-editor.rb', line 322 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 |