Suggest the correct method name in Ruby::NoMethod.
This pull request introduces a new feature to provide method suggestions when a Ruby::NoMethod error occurs in the steep LSP.
It leverages the did_you_mean gem to suggest possible corrections based on a dictionary of method name list by RBS.
textDocument/codeAction
I implemented this feature using textDocument/codeAction.
Currently only for Ruby::NoMethod, but can be extended to support Ruby::UnknownConstant and RBS::UnknownTypeName, etc.
Implementation
I implemented Steep::Services::CodeActionProvider.
It is designed for textDocument/codeAction with reference to Steep::Services::CompletionProvider.
Example
sample.rb
o = Object.new
o.calss
# @type var a: {a: 1}
a = _ = nil
x = a.foo(1)
With an editor that can use LSP, such as VSCode, it is possible to propose a “Quick Fix” and actually fix the problem.
I reimplemented to use textDocument/codeAction.
The previous version, which added hover text.