Class: Mbeditor::CodeSearchService
- Inherits:
-
Object
- Object
- Mbeditor::CodeSearchService
- 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
- MINIFIED_GLOBS =
Minified bundles are skipped, matching JsProgramService and JsGlobalsService (which use the same [.-]min.ext convention as a Regexp). A bundle's globals are one-letter names inside a closure, so it can never hold the definition being looked for — but it is usually the largest file in the workspace and one enormous line, which is the worst case for the -E alternation these lookups run. Pure cost, no results.
%w[*.min.js *.min.jsx *.min.ts *.min.tsx *-min.js *-min.jsx *-min.ts *-min.tsx].freeze
Class Method Summary collapse
Class Method Details
.call(pattern, workspace_root, globs: JS_GLOBS) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'app/services/mbeditor/code_search_service.rb', line 21 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 |