From 5ed8b91570b030d173e6052d769352da99558663 Mon Sep 17 00:00:00 2001 From: Vinicius Stock Date: Fri, 20 Sep 2024 15:48:19 -0400 Subject: [PATCH] Remove all autoloads (#2589) --- lib/ruby_lsp/internal.rb | 43 ++++++++++++++++++++- lib/ruby_lsp/requests.rb | 64 ------------------------------- lib/ruby_lsp/response_builders.rb | 13 ------- test/requests/formatting_test.rb | 4 +- 4 files changed, 43 insertions(+), 81 deletions(-) delete mode 100644 lib/ruby_lsp/requests.rb delete mode 100644 lib/ruby_lsp/response_builders.rb diff --git a/lib/ruby_lsp/internal.rb b/lib/ruby_lsp/internal.rb index 0f5ded017..6cb064161 100644 --- a/lib/ruby_lsp/internal.rb +++ b/lib/ruby_lsp/internal.rb @@ -30,8 +30,6 @@ require "ruby_lsp/global_state" require "ruby_lsp/server" require "ruby_lsp/type_inferrer" -require "ruby_lsp/requests" -require "ruby_lsp/response_builders" require "ruby_lsp/node_context" require "ruby_lsp/document" require "ruby_lsp/ruby_document" @@ -39,6 +37,47 @@ require "ruby_lsp/rbs_document" require "ruby_lsp/store" require "ruby_lsp/addon" + +# Response builders +require "ruby_lsp/response_builders/response_builder" +require "ruby_lsp/response_builders/collection_response_builder" +require "ruby_lsp/response_builders/document_symbol" +require "ruby_lsp/response_builders/hover" +require "ruby_lsp/response_builders/semantic_highlighting" +require "ruby_lsp/response_builders/signature_help" + +# Request support +require "ruby_lsp/requests/support/rubocop_diagnostic" +require "ruby_lsp/requests/support/selection_range" +require "ruby_lsp/requests/support/annotation" +require "ruby_lsp/requests/support/sorbet" +require "ruby_lsp/requests/support/common" +require "ruby_lsp/requests/support/formatter" require "ruby_lsp/requests/support/rubocop_runner" require "ruby_lsp/requests/support/rubocop_formatter" require "ruby_lsp/requests/support/syntax_tree_formatter" + +# Requests +require "ruby_lsp/requests/request" +require "ruby_lsp/requests/code_action_resolve" +require "ruby_lsp/requests/code_actions" +require "ruby_lsp/requests/code_lens" +require "ruby_lsp/requests/completion_resolve" +require "ruby_lsp/requests/completion" +require "ruby_lsp/requests/definition" +require "ruby_lsp/requests/diagnostics" +require "ruby_lsp/requests/document_highlight" +require "ruby_lsp/requests/document_link" +require "ruby_lsp/requests/document_symbol" +require "ruby_lsp/requests/folding_ranges" +require "ruby_lsp/requests/formatting" +require "ruby_lsp/requests/hover" +require "ruby_lsp/requests/inlay_hints" +require "ruby_lsp/requests/on_type_formatting" +require "ruby_lsp/requests/prepare_type_hierarchy" +require "ruby_lsp/requests/selection_ranges" +require "ruby_lsp/requests/semantic_highlighting" +require "ruby_lsp/requests/show_syntax_tree" +require "ruby_lsp/requests/signature_help" +require "ruby_lsp/requests/type_hierarchy_supertypes" +require "ruby_lsp/requests/workspace_symbol" diff --git a/lib/ruby_lsp/requests.rb b/lib/ruby_lsp/requests.rb deleted file mode 100644 index 1b92f7404..000000000 --- a/lib/ruby_lsp/requests.rb +++ /dev/null @@ -1,64 +0,0 @@ -# typed: strict -# frozen_string_literal: true - -module RubyLsp - # Supported features - # - # - [DocumentSymbol](rdoc-ref:RubyLsp::Requests::DocumentSymbol) - # - [DocumentLink](rdoc-ref:RubyLsp::Requests::DocumentLink) - # - [Hover](rdoc-ref:RubyLsp::Requests::Hover) - # - [FoldingRange](rdoc-ref:RubyLsp::Requests::FoldingRanges) - # - [SelectionRange](rdoc-ref:RubyLsp::Requests::SelectionRanges) - # - [SemanticHighlighting](rdoc-ref:RubyLsp::Requests::SemanticHighlighting) - # - [Formatting](rdoc-ref:RubyLsp::Requests::Formatting) - # - [OnTypeFormatting](rdoc-ref:RubyLsp::Requests::OnTypeFormatting) - # - [Diagnostic](rdoc-ref:RubyLsp::Requests::Diagnostics) - # - [CodeAction](rdoc-ref:RubyLsp::Requests::CodeActions) - # - [CodeActionResolve](rdoc-ref:RubyLsp::Requests::CodeActionResolve) - # - [DocumentHighlight](rdoc-ref:RubyLsp::Requests::DocumentHighlight) - # - [InlayHint](rdoc-ref:RubyLsp::Requests::InlayHints) - # - [Completion](rdoc-ref:RubyLsp::Requests::Completion) - # - [CompletionResolve](rdoc-ref:RubyLsp::Requests::CompletionResolve) - # - [CodeLens](rdoc-ref:RubyLsp::Requests::CodeLens) - # - [Definition](rdoc-ref:RubyLsp::Requests::Definition) - # - [ShowSyntaxTree](rdoc-ref:RubyLsp::Requests::ShowSyntaxTree) - # - [WorkspaceSymbol](rdoc-ref:RubyLsp::Requests::WorkspaceSymbol) - # - [SignatureHelp](rdoc-ref:RubyLsp::Requests::SignatureHelp) - - module Requests - autoload :Request, "ruby_lsp/requests/request" - autoload :DocumentSymbol, "ruby_lsp/requests/document_symbol" - autoload :DocumentLink, "ruby_lsp/requests/document_link" - autoload :Hover, "ruby_lsp/requests/hover" - autoload :FoldingRanges, "ruby_lsp/requests/folding_ranges" - autoload :SelectionRanges, "ruby_lsp/requests/selection_ranges" - autoload :SemanticHighlighting, "ruby_lsp/requests/semantic_highlighting" - autoload :Formatting, "ruby_lsp/requests/formatting" - autoload :OnTypeFormatting, "ruby_lsp/requests/on_type_formatting" - autoload :Diagnostics, "ruby_lsp/requests/diagnostics" - autoload :CodeActions, "ruby_lsp/requests/code_actions" - autoload :CodeActionResolve, "ruby_lsp/requests/code_action_resolve" - autoload :DocumentHighlight, "ruby_lsp/requests/document_highlight" - autoload :InlayHints, "ruby_lsp/requests/inlay_hints" - autoload :Completion, "ruby_lsp/requests/completion" - autoload :CompletionResolve, "ruby_lsp/requests/completion_resolve" - autoload :CodeLens, "ruby_lsp/requests/code_lens" - autoload :Definition, "ruby_lsp/requests/definition" - autoload :ShowSyntaxTree, "ruby_lsp/requests/show_syntax_tree" - autoload :WorkspaceSymbol, "ruby_lsp/requests/workspace_symbol" - autoload :SignatureHelp, "ruby_lsp/requests/signature_help" - autoload :PrepareTypeHierarchy, "ruby_lsp/requests/prepare_type_hierarchy" - autoload :TypeHierarchySupertypes, "ruby_lsp/requests/type_hierarchy_supertypes" - - # :nodoc: - module Support - autoload :RuboCopDiagnostic, "ruby_lsp/requests/support/rubocop_diagnostic" - autoload :SelectionRange, "ruby_lsp/requests/support/selection_range" - autoload :Annotation, "ruby_lsp/requests/support/annotation" - autoload :Sorbet, "ruby_lsp/requests/support/sorbet" - autoload :RailsDocumentClient, "ruby_lsp/requests/support/rails_document_client" - autoload :Common, "ruby_lsp/requests/support/common" - autoload :Formatter, "ruby_lsp/requests/support/formatter" - end - end -end diff --git a/lib/ruby_lsp/response_builders.rb b/lib/ruby_lsp/response_builders.rb deleted file mode 100644 index 134355fd3..000000000 --- a/lib/ruby_lsp/response_builders.rb +++ /dev/null @@ -1,13 +0,0 @@ -# typed: strict -# frozen_string_literal: true - -module RubyLsp - module ResponseBuilders - autoload :CollectionResponseBuilder, "ruby_lsp/response_builders/collection_response_builder" - autoload :DocumentSymbol, "ruby_lsp/response_builders/document_symbol" - autoload :Hover, "ruby_lsp/response_builders/hover" - autoload :ResponseBuilder, "ruby_lsp/response_builders/response_builder" - autoload :SemanticHighlighting, "ruby_lsp/response_builders/semantic_highlighting" - autoload :SignatureHelp, "ruby_lsp/response_builders/signature_help" - end -end diff --git a/test/requests/formatting_test.rb b/test/requests/formatting_test.rb index 53c04fd07..34b8980f4 100644 --- a/test/requests/formatting_test.rb +++ b/test/requests/formatting_test.rb @@ -84,7 +84,7 @@ def foo end def test_syntax_tree_formatting_ignores_syntax_invalid_documents - require "ruby_lsp/requests" + require "ruby_lsp/requests/formatting" @global_state.formatter = "syntax_tree" document = RubyLsp::RubyDocument.new(source: "def foo", version: 1, uri: URI::Generic.from_path(path: __FILE__)) assert_nil(RubyLsp::Requests::Formatting.new(@global_state, document).perform) @@ -160,7 +160,7 @@ def test_returns_nil_when_formatter_is_none private def formatted_document(formatter) - require "ruby_lsp/requests" + require "ruby_lsp/requests/formatting" @global_state.formatter = formatter RubyLsp::Requests::Formatting.new(@global_state, @document).perform&.first&.new_text end