lib/rbi/parser.rb in rbi-0.0.4 vs lib/rbi/parser.rb in rbi-0.0.5
- old
+ new
@@ -1,9 +1,9 @@
# typed: strict
# frozen_string_literal: true
-require "unparser"
+require "parser"
module RBI
class ParseError < StandardError
extend T::Sig
@@ -24,9 +24,15 @@
::Parser::Builders::Default.emit_lambda = true
::Parser::Builders::Default.emit_procarg0 = true
::Parser::Builders::Default.emit_encoding = true
::Parser::Builders::Default.emit_index = true
::Parser::Builders::Default.emit_arg_inside_procarg0 = true
+
+ sig { void }
+ def initialize
+ # Delay load unparser and only if it has not been loaded already.
+ require "unparser" unless defined?(::Unparser)
+ end
sig { params(string: String).returns(Tree) }
def self.parse_string(string)
Parser.new.parse_string(string)
end