Module: Tapioca::Static::SymbolLoader
- Extended by:
- T::Sig, Runtime::Reflection, Tapioca::SorbetHelper
- Defined in:
- lib/tapioca/static/symbol_loader.rb
Constant Summary
Constants included from Runtime::Reflection
Runtime::Reflection::ANCESTORS_METHOD, Runtime::Reflection::CLASS_METHOD, Runtime::Reflection::CONSTANTS_METHOD, Runtime::Reflection::EQUAL_METHOD, Runtime::Reflection::METHOD_METHOD, Runtime::Reflection::NAME_METHOD, Runtime::Reflection::OBJECT_ID_METHOD, Runtime::Reflection::PRIVATE_INSTANCE_METHODS_METHOD, Runtime::Reflection::PROTECTED_INSTANCE_METHODS_METHOD, Runtime::Reflection::PUBLIC_INSTANCE_METHODS_METHOD, Runtime::Reflection::REQUIRED_FROM_LABELS, Runtime::Reflection::SINGLETON_CLASS_METHOD, Runtime::Reflection::SUPERCLASS_METHOD, Runtime::Reflection::UNDEFINED_CONSTANT
Constants included from Tapioca::SorbetHelper
Tapioca::SorbetHelper::FEATURE_REQUIREMENTS, Tapioca::SorbetHelper::SORBET_BIN, Tapioca::SorbetHelper::SORBET_EXE_PATH_ENV_VAR, Tapioca::SorbetHelper::SORBET_GEM_SPEC, Tapioca::SorbetHelper::SORBET_PAYLOAD_URL, Tapioca::SorbetHelper::SPOOM_CONTEXT
Class Method Summary collapse
- .engine_symbols(gem) ⇒ Object
- .gem_symbols(gem) ⇒ Object
- .payload_symbols ⇒ Object
- .symbols_from_paths(paths) ⇒ Object
Methods included from Runtime::Reflection
abstract_type_of, ancestors_of, are_equal?, class_of, constant_defined?, constantize, constants_of, descendants_of, file_candidates_for, final_module?, inherited_ancestors_of, method_of, name_of, name_of_type, object_id_of, private_instance_methods_of, protected_instance_methods_of, public_instance_methods_of, qualified_name_of, resolve_loc, sealed_module?, signature_of, signature_of!, singleton_class_of, superclass_of
Methods included from Runtime::AttachedClassOf
Methods included from Tapioca::SorbetHelper
sorbet, sorbet_path, sorbet_supports?
Class Method Details
.engine_symbols(gem) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/tapioca/static/symbol_loader.rb', line 23 def engine_symbols(gem) gem_engine = engines.find do |engine| gem.full_gem_path == engine.config.root.to_s end return Set.new unless gem_engine # https://github.com/rails/rails/commit/ebfca905db14020589c22e6937382e6f8f687664 config = gem_engine.config eager_load_paths = if config.respond_to?(:all_eager_load_paths) config.all_eager_load_paths else config.eager_load_paths end paths = eager_load_paths.flat_map do |load_path| Pathname.glob("#{load_path}/**/*.rb") end symbols_from_paths(paths) rescue Set.new end |
.gem_symbols(gem) ⇒ Object
48 49 50 |
# File 'lib/tapioca/static/symbol_loader.rb', line 48 def gem_symbols(gem) symbols_from_paths(gem.files) end |
.payload_symbols ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'lib/tapioca/static/symbol_loader.rb', line 13 def payload_symbols unless @payload_symbols output = symbol_table_json_from("-e ''", table_type: "symbol-table-full-json") @payload_symbols = T.let(SymbolTableParser.parse_json(output), T.nilable(T::Set[String])) end T.must(@payload_symbols) end |
.symbols_from_paths(paths) ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/tapioca/static/symbol_loader.rb', line 53 def symbols_from_paths(paths) return Set.new if paths.empty? output = Tempfile.create("sorbet") do |file| file.write(Array(paths).join("\n")) file.flush symbol_table_json_from("@#{file.path.shellescape}") end return Set.new if output.empty? SymbolTableParser.parse_json(output) end |