lib/tapioca/commands/abstract_dsl.rb in tapioca-0.16.4 vs lib/tapioca/commands/abstract_dsl.rb in tapioca-0.16.5

- old
+ new

@@ -26,10 +26,11 @@ gem_dir: String, rbi_formatter: RBIFormatter, app_root: String, halt_upon_load_error: T::Boolean, compiler_options: T::Hash[String, T.untyped], + lsp_addon: T::Boolean, ).void end def initialize( requested_constants:, requested_paths:, @@ -45,11 +46,12 @@ auto_strictness: true, gem_dir: DEFAULT_GEM_DIR, rbi_formatter: DEFAULT_RBI_FORMATTER, app_root: ".", halt_upon_load_error: true, - compiler_options: {} + compiler_options: {}, + lsp_addon: false ) @requested_constants = requested_constants @requested_paths = requested_paths @outpath = outpath @only = only @@ -64,18 +66,23 @@ @rbi_formatter = rbi_formatter @app_root = app_root @halt_upon_load_error = halt_upon_load_error @skip_constant = skip_constant @compiler_options = compiler_options + @lsp_addon = lsp_addon super() end private sig { params(outpath: Pathname, quiet: T::Boolean).returns(T::Set[Pathname]) } def generate_dsl_rbi_files(outpath, quiet:) + if @lsp_addon + pipeline.active_compilers.each(&:reset_state) + end + existing_rbi_files = existing_rbi_filenames(all_requested_constants) generated_files = pipeline.run do |constant, contents| constant_name = T.must(Tapioca::Runtime::Reflection.name_of(constant)) @@ -114,10 +121,11 @@ Loaders::Dsl.load_application( tapioca_path: @tapioca_path, eager_load: @requested_constants.empty? && @requested_paths.empty?, app_root: @app_root, halt_upon_load_error: @halt_upon_load_error, + lsp_addon: @lsp_addon, ) end sig { returns(Tapioca::Dsl::Pipeline) } def create_pipeline @@ -131,10 +139,11 @@ say_error(error, :bold, :red) }, skipped_constants: constantize(@skip_constant, ignore_missing: true), number_of_workers: @number_of_workers, compiler_options: @compiler_options, + lsp_addon: @lsp_addon, ) end sig { params(requested_constants: T::Array[String], path: Pathname).returns(T::Set[Pathname]) } def existing_rbi_filenames(requested_constants, path: @outpath) @@ -168,10 +177,12 @@ end raise Thor::Error, "" end - processable_constants.map { |_, constant| constant } + processable_constants + .map { |_, constant| constant } + .grep(Module) end sig { params(compiler_names: T::Array[String]).returns(T::Array[T.class_of(Tapioca::Dsl::Compiler)]) } def constantize_compilers(compiler_names) compiler_map = compiler_names.to_h do |name|