Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

autocomplete on method enum arguments should directly suggest enum values #7868

Open
froydnj opened this issue Apr 30, 2024 · 1 comment
Open
Labels
enhancement New feature or surprising current feature IDE Relating to Sorbet's LSP server or VS Code extension

Comments

@froydnj
Copy link
Contributor

froydnj commented Apr 30, 2024

Input

→ View on sorbet.run

# typed: true
class Outer
  class Inner
    class Nested
      class Namespace
        class Division
          class Mine < T::Enum
            enums do
              First = new
              Second = new
              Third = new
              Fourth = new
            end
          end
        end
      end
    end
  end
end

class Toplevel
  extend T::Sig

  sig {params(e: Outer::Inner::Nested::Namespace::Division::Mine).void}
  def func(e)
  end
end

Toplevel.new.func()
#                 ^ completion should know that we take enums and autocomplete enum values
#                   or at the very least the enum class itself

Observed output

Sorbet will only complete Outer, and then you have to laboriously complete all. the. nested. namespaces.

Expected behavior

Sorbet ought to be smart enough to know that we're completing a method parameter that is an enum, and therefore can only take enum values, and therefore should offer a better list of completions.

Bonus points if it modifies the completions to insert the shortest possible path for the enum value.

@froydnj froydnj added enhancement New feature or surprising current feature IDE Relating to Sorbet's LSP server or VS Code extension labels Apr 30, 2024
@jez
Copy link
Collaborator

jez commented Apr 30, 2024

As a prerequisite to this change, we should probably start by building completion for keyword argument names. See #5436.

No completions in Sorbet right now use the enclosing method call context to alter the list of completion suggestions. Adding that functionality is probably easiest to isolate in the context of keyword arguments (where the enclosing method's definition has the full list of keyword parameters in its method symbol definition).

@jez jez added this to the Autocompletion milestone Apr 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or surprising current feature IDE Relating to Sorbet's LSP server or VS Code extension
Projects
None yet
Development

No branches or pull requests

2 participants