Module: Holistic::Ruby::Scope::ListReferences
- Extended by:
- ListReferences
- Included in:
- ListReferences
- Defined in:
- lib/holistic/ruby/scope/list_references.rb
Constant Summary collapse
- QueryReferencesRecursively =
->(application, scope) do references_to_scope = scope.referenced_by.to_a references_to_child_scopes = scope.lexical_children.flat_map { QueryReferencesRecursively.call(application, _1) } references_to_scope + references_to_child_scopes end
- Relevance =
->(reference) do # TODO: should the location answer the kind of file it is? application code, config, spec, etc. Not sure. looks_like_a_spec = reference.location.file.path.include?("_spec.rb") || reference.location.file.path.include?("_test.rb") looks_like_a_spec ? 1 : 0 end
Instance Method Summary collapse
Instance Method Details
#call(application:, cursor:) ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/holistic/ruby/scope/list_references.rb', line 22 def call(application:, cursor:) scope = application.scopes.find_by_cursor(cursor) return :not_found if scope.nil? references = QueryReferencesRecursively.call(application, scope).sort_by(&Relevance) [:references_listed, {references:}] end |