Module: ReactManifest::AstExtractor
- Extended by:
- Logging
- Defined in:
- lib/react_manifest/ast_extractor.rb
Overview
AST-based symbol extraction backed by an embedded V8 (mini_racer).
Mirrors SymbolExtractor's public interface exactly. Never raises — any
parse or runtime failure returns nil (after logging a warning) so the
caller (SymbolExtractor's dispatcher) can fall back to regex extraction
for that one file.
Constant Summary
collapse
- VENDOR_SCRIPT =
File.expand_path("vendor/ast_extractor.js", __dir__)
- GLUE =
<<~JS.freeze
function __reactManifestExtractDefinitions(content) {
return JSON.stringify(__astExtractor.extractDefinitions(content));
}
function __reactManifestExtractUsages(content) {
return JSON.stringify(__astExtractor.extractUsages(content));
}
JS
Class Method Summary
collapse
Methods included from Logging
log_debug, log_info, log_warn
Class Method Details
26
27
28
29
30
31
32
|
# File 'lib/react_manifest/ast_extractor.rb', line 26
def (content, file_path: nil)
result = call_js("__reactManifestExtractDefinitions", content)
return result["definitions"] if result["success"]
report_error(file_path, result["error"])
nil
end
|
34
35
36
37
38
39
40
|
# File 'lib/react_manifest/ast_extractor.rb', line 34
def (content, file_path: nil)
result = call_js("__reactManifestExtractUsages", content)
return result["usages"] if result["success"]
report_error(file_path, result["error"])
nil
end
|