lib/tapioca/rbi_ext/model.rb in tapioca-0.6.4 vs lib/tapioca/rbi_ext/model.rb in tapioca-0.7.0
- old
+ new
@@ -1,61 +1,15 @@
# typed: strict
# frozen_string_literal: true
-require "rbi"
-
module RBI
- class File
- extend T::Sig
-
- sig { returns(String) }
- def transformed_string
- transform_rbi!
- string
- end
-
- sig { void }
- def transform_rbi!
- root.nest_singleton_methods!
- root.nest_non_public_methods!
- root.group_nodes!
- root.sort_nodes!
- end
-
- sig do
- params(
- command: String,
- reason: T.nilable(String),
- display_heading: T::Boolean
- ).void
- end
- def set_file_header(command, reason: nil, display_heading: true)
- return unless display_heading
- comments << RBI::Comment.new("DO NOT EDIT MANUALLY")
- comments << RBI::Comment.new("This is an autogenerated file for #{reason}.") unless reason.nil?
- comments << RBI::Comment.new("Please instead update this file by running `#{command}`.")
- end
-
- sig { void }
- def set_empty_body_content
- comments << RBI::BlankLine.new unless comments.empty?
- comments << RBI::Comment.new("THIS IS AN EMPTY RBI FILE.")
- comments << RBI::Comment.new("see https://github.com/Shopify/tapioca/wiki/Manual-Gem-Requires")
- end
-
- sig { returns(T::Boolean) }
- def empty?
- root.empty?
- end
- end
-
class Tree
extend T::Sig
sig { params(constant: ::Module, block: T.nilable(T.proc.params(scope: Scope).void)).void }
def create_path(constant, &block)
- constant_name = Tapioca::Reflection.name_of(constant)
+ constant_name = Tapioca::Runtime::Reflection.name_of(constant)
raise "given constant does not have a name" unless constant_name
instance = ::Module.const_get(constant_name)
case instance
when ::Class
@@ -135,10 +89,10 @@
private
SPECIAL_METHOD_NAMES = T.let(
["!", "~", "+@", "**", "-@", "*", "/", "%", "+", "-", "<<", ">>", "&", "|", "^", "<", "<=", "=>", ">", ">=",
- "==", "===", "!=", "=~", "!~", "<=>", "[]", "[]=", "`"].freeze,
+ "==", "===", "!=", "=~", "!~", "<=>", "[]", "[]=", "`",].freeze,
T::Array[String]
)
sig { params(name: String).returns(T::Boolean) }
def valid_method_name?(name)