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

Goto definition/implementation #368

Closed
3 tasks done
soutaro opened this issue Mar 30, 2021 · 1 comment · Fixed by #371
Closed
3 tasks done

Goto definition/implementation #368

soutaro opened this issue Mar 30, 2021 · 1 comment · Fixed by #371
Milestone

Comments

@soutaro
Copy link
Owner

soutaro commented Mar 30, 2021

I plan to implement two LSP features:

Terminology

The terminology is specific to Steep. I don't know if the definition is common to projects other than Steep.

  • A declaration is a declaration in RBS files. Declaration cannot be written in Ruby code.
  • A implementation is a Ruby code. It may be a class definition, module definition, method definition, constant definition, ...
  • A definition is one of a declaration and implementation.

Based on the terminology, the Goto Definition feature would work as follows:

  1. When it is on a method call, constant, global, or anything defined in RBS, it navigates to declarations in RBS file.
  2. When it is on a declaration in RBS file, it navigates to implementation in Ruby code.
  3. When it is on a implementation in Ruby code, it navigatets to declarations in RBS file.

Goto Implementation would navigate to implementation, and it cannot go to declaration.

(We can extend the definition to Goto declaration in a straightforward way.)

Pull requests

@soutaro soutaro added this to the 2021-Q2 milestone Mar 30, 2021
@soutaro soutaro linked a pull request Apr 19, 2021 that will close this issue
@soutaro soutaro reopened this Apr 19, 2021
@soutaro
Copy link
Owner Author

soutaro commented Apr 21, 2021

Confirmed how it works for ... overloaded methods:

  • If the method is defined in the same class, it jumps to both of the def of the method
  • If the method is defined in a different class/module, it cannot jump to the original def
class Foo
  def to_s: (Integer) -> void
          | ...             # Overload with Object#to_s
end

The Foo.new.to_s cannot resolve to Object#to_s.

This is not the best behavior, but I think it's reasonable to ship without fixing the problem. :shipit:

@soutaro soutaro closed this as completed Apr 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant