Class: Solargraph::LiveParser
- Inherits:
-
Object
- Object
- Solargraph::LiveParser
- Defined in:
- lib/solargraph/live_parser.rb
Class Method Summary collapse
Instance Method Summary collapse
- #get_yard_return(path) ⇒ Object
-
#initialize ⇒ LiveParser
constructor
A new instance of LiveParser.
- #parse(namespace = nil) ⇒ Object
Constructor Details
#initialize ⇒ LiveParser
Returns a new instance of LiveParser.
41 42 43 |
# File 'lib/solargraph/live_parser.rb', line 41 def initialize end |
Class Method Details
.parse(n) ⇒ Object
73 74 75 |
# File 'lib/solargraph/live_parser.rb', line 73 def self.parse n LiveParser.new.parse(n) end |
Instance Method Details
#get_yard_return(path) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/solargraph/live_parser.rb', line 17 def get_yard_return(path) objects = [] yardocs = ['yard/2.2.0/.yardoc', 'ruby/yard/2.2.0/.yardoc-stdlib'] yardocs.each { |y| YARD::Registry.load!(y) o = YARD::Registry.at(path) if !o.nil? objects.push o end } result = nil objects.each { |x| meth = x if !meth.tag(:return) and meth.tag(:overload) and meth.tag(:overload).tag(:return) meth = meth.tag(:overload) end meth.(:return).each { |r| result = "#{r.types[0]}" break } break if !result.nil? } result end |
#parse(namespace = nil) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/solargraph/live_parser.rb', line 44 def parse namespace = nil #puts "Namespace: #{namespace}" @parsed = [] code = "" fqns = namespace if fqns.nil? #code += parse("BasicObject") #code += parse("Object") #code += parse("Kernel") code += parse("Module") return code end mod = eval("#{fqns}") if !mod.nil? if mod.instance_of?(Class) #puts "Parsing class #{mod} to #{fqns}" code += parse_class mod, fqns elsif mod.instance_of?(Module) #puts "Parsing module #{mod} to #{fqns}" code += parse_module mod, fqns else #raise "I don't know what a #{fqns} is." code += "#{fqns} = nil\n" end else #puts "NIL!" end code end |