diff --git a/jekyll/design-and-roadmap.markdown b/jekyll/design-and-roadmap.markdown index 003d23772..68f0fd1ae 100644 --- a/jekyll/design-and-roadmap.markdown +++ b/jekyll/design-and-roadmap.markdown @@ -230,8 +230,8 @@ Interested in contributing? Check out the issues tagged with [help-wanted] or [g ## Guessed types -Guessed types is an experimental feature where the Ruby LSP attempts to identify the type of a receiver based on its -identifier name. For example: +Guessed types is a feature where the Ruby LSP attempts to identify the type of a receiver based on its identifier name. +For example: ```ruby # The receiver identifier here is `user` and so the Ruby LSP will assign to it the `User` type if that class exists @@ -307,6 +307,4 @@ end user.a ``` -This is an experimental feature and can only be accessed if `initializationOptions.experimentalFeaturesEnabled` is -`true` (the `"rubyLsp.enableExperimentalFeatures": true` setting for VS Code users). If you have feedback about this -experiment, please let us know in a GitHub issue. +This feature has been stabilized. If you have feedback about this experiment, please let us know in a GitHub issue. diff --git a/jekyll/index.markdown b/jekyll/index.markdown index 24b2c2439..3e1601c8c 100644 --- a/jekyll/index.markdown +++ b/jekyll/index.markdown @@ -51,7 +51,6 @@ Want to discuss Ruby developer experience? Consider joining the public - [Test explorer](#test-explorer) - [Experimental Features](#experimental-features) - [Ancestors Hierarchy Request](#ancestors-hierarchy-request) - - [Guessed Types](#guessed-types) - [Copilot chat participant](#copilot-chat-participant) - [Configuration](#configuration) - [Configuring code indexing](#configuring-code-indexing) @@ -422,30 +421,6 @@ This feature is supported by the [Type Hierarchy Supertypes LSP request](https:/ We created [an issue](https://github.com/microsoft/language-server-protocol/issues/1984) to seek clarification from the LSP maintainers. We will adjust this feature's design and behavior based on their response and your feedback. -### Guessed Types - -The guessed types feature is an experimental addition to Ruby LSP that attempts to identify the type of a receiver based on its identifier name. This helps improve code completion and navigation by providing type information. - -This feature is disabled by default but can be enabled with the `rubyLsp.enableExperimentalFeatures` setting in VS Code. - -#### How It Works - -Ruby LSP guesses the type of a variable by matching its identifier name to a class. For example, a variable named `user` would be assigned the `User` type if such a class exists: - -```ruby -user.name # Guessed to be of type `User` -@post.like! # Guessed to be of type `Post` -``` - -By guessing the types of variables, Ruby LSP can expand the code navigation features to even more cases. - -#### Important Notes - -- Identifiers are not ideal for complex type annotations and can be easily misled by non-matching names. -- We do NOT recommend renaming identifiers just to make this feature work. - -For more information, please refer to the [documentation](https://shopify.github.io/ruby-lsp/design-and-roadmap.html#guessed-types). - ### Copilot chat participant The Ruby LSP includes a Copilot chat participant that comes with built-in knowledge of Ruby and Rails commands, helping you build these commands efficiently. diff --git a/lib/ruby_lsp/global_state.rb b/lib/ruby_lsp/global_state.rb index 5071f9ae2..0149a61f2 100644 --- a/lib/ruby_lsp/global_state.rb +++ b/lib/ruby_lsp/global_state.rb @@ -39,7 +39,7 @@ def initialize @supported_formatters = T.let({}, T::Hash[String, Requests::Support::Formatter]) @supports_watching_files = T.let(false, T::Boolean) @experimental_features = T.let(false, T::Boolean) - @type_inferrer = T.let(TypeInferrer.new(@index, @experimental_features), TypeInferrer) + @type_inferrer = T.let(TypeInferrer.new(@index), TypeInferrer) @addon_settings = T.let({}, T::Hash[String, T.untyped]) @supports_request_delegation = T.let(false, T::Boolean) end @@ -124,7 +124,6 @@ def apply_options(options) end @experimental_features = options.dig(:initializationOptions, :experimentalFeaturesEnabled) || false - @type_inferrer.experimental_features = @experimental_features addon_settings = options.dig(:initializationOptions, :addonSettings) if addon_settings diff --git a/lib/ruby_lsp/type_inferrer.rb b/lib/ruby_lsp/type_inferrer.rb index be44dcda4..2fbf9f86d 100644 --- a/lib/ruby_lsp/type_inferrer.rb +++ b/lib/ruby_lsp/type_inferrer.rb @@ -7,13 +7,9 @@ module RubyLsp class TypeInferrer extend T::Sig - sig { params(experimental_features: T::Boolean).returns(T::Boolean) } - attr_writer :experimental_features - - sig { params(index: RubyIndexer::Index, experimental_features: T::Boolean).void } - def initialize(index, experimental_features = true) + sig { params(index: RubyIndexer::Index).void } + def initialize(index) @index = index - @experimental_features = experimental_features end sig { params(node_context: NodeContext).returns(T.nilable(Type)) } @@ -93,8 +89,6 @@ def infer_receiver_for_call_node(node, node_context) Type.new("#{parts.join("::")}::#{last}::") else - return unless @experimental_features - raw_receiver = node.receiver&.slice if raw_receiver