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

Include convention (eg. solargraph-rspec) pins in document_symbols #724

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

lekemula
Copy link

@lekemula lekemula commented Oct 3, 2024

Hi there,

It looks like currently the additional pins added from conventions are not included in documentSymbol request.

This PR adds them, thus enabling finding and easier navigation between RSpec describe/context blocks via solargraph-rspec plugin:

solargraph_rspec_document_symbols_1

solargraph_rspec_document_symbols_2

end

def convention_pins=(pins)
# unmemoizing the document_symbols in case it was called from any of convnetions
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For example, solargraph-rails:

https://github.com/iftheshoefritz/solargraph-rails/blob/144cec0d91028b8073029df0bbaf58f6a2adbb3b/lib/solargraph-rails.rb#L39

This leads to subsequent convention pins not being included, hence we need to clear the memorization after all convention pins are collected.

@@ -6,6 +6,8 @@ class Solargraph::LanguageServer::Message::TextDocument::DocumentSymbol < Solarg
def process
pins = host.document_symbols params['textDocument']['uri']
info = pins.map do |pin|
next nil unless pin.location&.filename
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

solargraph-rspec happens to be adding some RSpec DSL methods without a filename, which should be excluded.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant