Class: CodeGraph::InheritanceProcessor
- Inherits:
-
SexpProcessor
- Object
- SexpProcessor
- CodeGraph::InheritanceProcessor
- Defined in:
- lib/codegraph/inheritance_processor.rb
Instance Method Summary collapse
- #classes ⇒ Object
-
#initialize ⇒ InheritanceProcessor
constructor
A new instance of InheritanceProcessor.
- #process_class(exp) ⇒ Object
- #process_colon2(exp) ⇒ Object
- #process_const(exp) ⇒ Object
- #process_module(exp) ⇒ Object
Constructor Details
#initialize ⇒ InheritanceProcessor
Returns a new instance of InheritanceProcessor.
6 7 8 9 10 11 12 |
# File 'lib/codegraph/inheritance_processor.rb', line 6 def initialize super self.strict = false @scopes = [] @classes = {} end |
Instance Method Details
#classes ⇒ Object
14 15 16 17 |
# File 'lib/codegraph/inheritance_processor.rb', line 14 def classes fix_parents @classes end |
#process_class(exp) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/codegraph/inheritance_processor.rb', line 31 def process_class(exp) directive, klass, parent = exp[0..2] extra = exp[3..-1] exp.clear add_class atom(klass), atom(parent) @scopes.push klass processed = [directive, klass, parent].concat(extra.map{|e| process(e)}) @scopes.pop s(*processed) end |
#process_colon2(exp) ⇒ Object
25 26 27 28 29 |
# File 'lib/codegraph/inheritance_processor.rb', line 25 def process_colon2(exp) name = [atom(exp[1]), atom(exp[2])].join('::') exp.clear s(name) end |
#process_const(exp) ⇒ Object
19 20 21 22 23 |
# File 'lib/codegraph/inheritance_processor.rb', line 19 def process_const(exp) name = atom(exp[1]) exp.clear s(name) end |
#process_module(exp) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/codegraph/inheritance_processor.rb', line 45 def process_module(exp) directive, klass = exp[0..1] extra = exp[2..-1] exp.clear @scopes.push klass processed = [directive, klass].concat(extra.map{|e| process(e)}) @scopes.pop s(*processed) end |