Class: Solargraph::Arc::Autoload
- Inherits:
-
Object
- Object
- Solargraph::Arc::Autoload
- Defined in:
- lib/solargraph/arc/autoload.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.instance ⇒ Object
4 5 6 |
# File 'lib/solargraph/arc/autoload.rb', line 4 def self.instance @instance ||= self.new end |
Instance Method Details
#namespace_stubs(root_ns, ns) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/solargraph/arc/autoload.rb', line 16 def namespace_stubs(root_ns, ns) parts = ns.path.split("::") candidates = parts.each_with_index.reduce([]) do |acc, (_, i)| acc + [parts[0..i].join("::")] end.reject {|el| el == ns.path } previous_ns = root_ns pins = [] parts[0..-2].each_with_index do |name, i| gates = candidates[0..i].reverse + [""] path = gates.first next if path == ns.path previous_ns = Solargraph::Pin::Namespace.new( type: :class, location: ns.location, closure: previous_ns, name: name, comments: ns.comments, visibility: :public, gates: gates[1..-1] ) pins << previous_ns end pins end |
#process(source_map, ns, ds) ⇒ Object
8 9 10 11 12 13 14 |
# File 'lib/solargraph/arc/autoload.rb', line 8 def process(source_map, ns, ds) return [] unless ds.size == 1 && ns.path.include?("::") Solargraph.logger.debug("[Arc][Autoload] seeding class tree for #{ns.path}") root_ns = source_map.pins.find {|p| p.path == "" } namespace_stubs(root_ns, ns) end |