Class: Solargraph::Diagnostics::RequireNotFound

Inherits:
Base
  • Object
show all
Defined in:
lib/solargraph/diagnostics/require_not_found.rb

Overview

RequireNotFound reports required paths that could not be resolved to either a file in the workspace or a gem.

Instance Attribute Summary

Attributes inherited from Base

#args

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Solargraph::Diagnostics::Base

Instance Method Details

#diagnose(source, api_map) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/solargraph/diagnostics/require_not_found.rb', line 9

def diagnose source, api_map
  return [] unless source.parsed? && source.synchronized?
  result = []
  refs = {}
  map = api_map.source_map(source.filename)
  map.requires.each { |ref| refs[ref.name] = ref }
  api_map.missing_docs.each do |r|
    next unless refs.key?(r)
    result.push docs_error(r, refs[r].location)
  end
  api_map.unresolved_requires.each do |r|
    next unless refs.key?(r)
    result.push require_error(r, refs[r].location)
  end
  result
end