Class: Mbeditor::JsDefinitionService
- Inherits:
-
Object
- Object
- Mbeditor::JsDefinitionService
- Defined in:
- app/services/mbeditor/js_definition_service.rb
Overview
Searches JS/JSX/TS/TSX files in the workspace for definitions of a named JavaScript global (variable, function, class, or window property assignment).
Delegates subprocess execution to CodeSearchService (rg/grep).
Returns an array of hashes:
{ file: String, line: Integer, snippet: String }
Constant Summary collapse
- MAX_RESULTS =
20
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(symbol, workspace_root) ⇒ JsDefinitionService
constructor
A new instance of JsDefinitionService.
Constructor Details
#initialize(symbol, workspace_root) ⇒ JsDefinitionService
Returns a new instance of JsDefinitionService.
14 15 16 17 |
# File 'app/services/mbeditor/js_definition_service.rb', line 14 def initialize(symbol, workspace_root) @symbol = symbol.to_s @workspace_root = workspace_root.to_s.chomp("/") end |
Instance Method Details
#call ⇒ Object
19 20 21 22 23 24 25 |
# File 'app/services/mbeditor/js_definition_service.rb', line 19 def call return [] if @symbol.empty? || @workspace_root.empty? return [] unless File.directory?(@workspace_root) lines = CodeSearchService.call(build_pattern, @workspace_root) parse_results(lines) end |