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', _language = nil) ⇒ CtagsSourceStructure
constructor
A new instance of CtagsSourceStructure.
Methods inherited from SourceStructure
#class_node_by_line, #deep_node_by_line, #node_by_line, root
Constructor Details
#initialize(_file, _ctags_string = 'ctags', _language = nil) ⇒ CtagsSourceStructure
Returns a new instance of CtagsSourceStructure.
102 103 104 105 106 107 108 109 110 111 112 |
# File 'ext/ae-editor/ae-editor.rb', line 102 def initialize(_file, ='ctags', _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 build_structure end |
Instance Method Details
#build_structure ⇒ Object
114 115 116 117 118 119 120 121 122 123 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 |
# File 'ext/ae-editor/ae-editor.rb', line 114 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.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.rif = fields['line'] @last_node.rif_end = (node.rif.to_i-1).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
158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 |
# File 'ext/ae-editor/ae-editor.rb', line 158 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 |