Class: Mbeditor::CodeSearchService

Inherits:
Object
  • Object
show all
Defined in:
app/services/mbeditor/code_search_service.rb

Overview

Line-oriented regex search over the workspace's JS-family files. Backs the JS definition/member lookups. Same three-tier backend as SearchReplaceService (rg > git grep > grep), bounded by config.search_timeout and config.excluded_paths.

Constant Summary collapse

JS_GLOBS =
%w[*.js *.jsx *.ts *.tsx *.js.jsx *.js.erb *.jsx.erb].freeze

Class Method Summary collapse

Class Method Details

.call(pattern, workspace_root, globs: JS_GLOBS) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
# File 'app/services/mbeditor/code_search_service.rb', line 12

def call(pattern, workspace_root, globs: JS_GLOBS)
  root = workspace_root.to_s
  if SearchReplaceService.rg_available?
    run_rg(pattern, root, globs)
  elsif File.exist?(File.join(root, ".git"))
    run_git_grep(pattern, root, globs)
  else
    run_grep(pattern, root, globs)
  end
rescue StandardError
  []
end