Class: Oxc::TransformResult
- Defined in:
- lib/oxc/transform_result.rb,
sig/oxc/transform_result.rbs
Instance Attribute Summary collapse
- #declaration ⇒ String? readonly
- #declaration_map ⇒ String? readonly
- #helpers_used ⇒ Hash[String, String] readonly
Attributes inherited from Result
#code, #diagnostics, #legal_comments, #map
Class Method Summary collapse
-
.from_json(payload) ⇒ Oxc::TransformResult
: (String) -> Oxc::TransformResult.
Instance Method Summary collapse
- #initialize(declaration: nil, declaration_map: nil, helpers_used: {}) ⇒ TransformResult constructor
-
#parts ⇒ Array[String]
: () -> Array.
Methods inherited from Result
Methods included from Diagnosed
#errors, #errors?, #panicked?, #warnings, #warnings?
Constructor Details
#initialize(declaration: nil, declaration_map: nil, helpers_used: {}) ⇒ TransformResult
26 27 28 29 30 31 32 33 34 |
# File 'lib/oxc/transform_result.rb', line 26 def initialize(declaration: nil, declaration_map: nil, helpers_used: {}, **) super(**) @declaration = declaration @declaration_map = declaration_map @helpers_used = helpers_used.freeze freeze end |
Instance Attribute Details
#declaration ⇒ String? (readonly)
5 6 7 |
# File 'lib/oxc/transform_result.rb', line 5 def declaration @declaration end |
#declaration_map ⇒ String? (readonly)
6 7 8 |
# File 'lib/oxc/transform_result.rb', line 6 def declaration_map @declaration_map end |
#helpers_used ⇒ Hash[String, String] (readonly)
7 8 9 |
# File 'lib/oxc/transform_result.rb', line 7 def helpers_used @helpers_used end |
Class Method Details
.from_json(payload) ⇒ Oxc::TransformResult
: (String) -> Oxc::TransformResult
10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/oxc/transform_result.rb', line 10 def self.from_json(payload) parsed = JSON.parse(payload) new( code: parsed.fetch("code"), map: parsed["map"], declaration: parsed["declaration"], declaration_map: parsed["declaration_map"], legal_comments: parsed.fetch("legal_comments"), helpers_used: parsed.fetch("helpers_used"), diagnostics: parsed.fetch("errors").map { |diagnostic| Diagnostic.from_hash(diagnostic) }, panicked: parsed.fetch("panicked") ) end |
Instance Method Details
#parts ⇒ Array[String]
: () -> Array
39 40 41 42 43 44 45 |
# File 'lib/oxc/transform_result.rb', line 39 def parts parts = super parts << "declaration=#{declaration.length} bytes" if declaration parts << "helpers_used=#{helpers_used.length}" unless helpers_used.empty? parts end |