Class: Mbeditor::JsMembersService
- Inherits:
-
Object
- Object
- Mbeditor::JsMembersService
- Defined in:
- app/services/mbeditor/js_members_service.rb
Overview
Searches JS/JSX/TS/TSX files for properties/methods attached to a named global object (direct assignment and prototype assignment patterns).
Examples matched for symbol “ReactWindow”:
ReactWindow.open = function() { ... }
ReactWindow.prototype.close = function() { ... }
Delegates subprocess execution to CodeSearchService (rg/grep).
Returns an array of hashes:
{ name: String, snippet: String }
Constant Summary collapse
- MAX_RESULTS =
50
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(symbol, workspace_root) ⇒ JsMembersService
constructor
A new instance of JsMembersService.
Constructor Details
#initialize(symbol, workspace_root) ⇒ JsMembersService
Returns a new instance of JsMembersService.
18 19 20 21 |
# File 'app/services/mbeditor/js_members_service.rb', line 18 def initialize(symbol, workspace_root) @symbol = symbol.to_s @workspace_root = workspace_root.to_s.chomp("/") end |
Instance Method Details
#call ⇒ Object
23 24 25 26 27 28 29 |
# File 'app/services/mbeditor/js_members_service.rb', line 23 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 |