Closed grncdr closed 1 year ago
@grncdr this does seem to fix #473, and I'm excited to see it go in!
However I'm not seeing what I'd expect if https://github.com/iftheshoefritz/solargraph-rails/issues/34 were fixed. It looks like in an ActiveRecord model, when I autocomplete my_associated_models.first
, there is still no type on .first
.
In the LSP server response:
{
"label": "first",
"kind": 2,
"detail": "(limit = nil)",
"data": {
"path": "ActiveRecord::Associations::CollectionProxy#first",
"return_type": "undefined",
"location": {
"filename": "/Users/fritz/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-7.0.1/lib/active_record/associations/collection_proxy.rb",
"range": {
"start": {
"line": 141,
"character": 0
},
"end": {
"line": 141,
"character": 0
}
}
},
...
What I expect is "return_type": "MyAssociatedModel"
in the response from solargraph.
I'm not sure though if this change could solve that? What is the behaviour that you observe?
Again, I still hope this goes in on the strength of it fixing #473 .
I'm not sure though if this change could solve that? What is the behaviour that you observe?
I don't expect it to. As far as I know, the original Rdoc doesn't specify a return type and so it needs augmentation on the part of solargraph-rails.
I've fixed that (and loads of other stuff) in my "hacks" branch of solargraph-rails, but that branch depends on some of my other changes to solargraph (which are in my "hacks" branch for solargraph).
If you switch to using those branches in your Gemfile, you'll get a very improved solargraph-rails experience, but it all needs more specs and especially some feedback on whether my Pin::DelegatedMethod PR (#602, #591) is on the right track.
Thanks!
This fixes #473 (at least for me, see extended notes below).
The core issue is that the
obj.filename
property would sometimes be prefixed with the string "file ", which then causesYardMap::Mapper#map
to remove the pins: https://github.com/castwide/solargraph/blob/18854d7577737cf9929063d96dd99b3d0a77f703/lib/solargraph/yard_map/mapper.rb#L26This change adds the prefix stripping regardless of whether we get a filename from
in_files
orfilename
.lots of notes about debugging this, feel free to skip
Reviving this thread, as I'm trying to fix https://github.com/iftheshoefritz/solargraph-rails/issues/34. Here is what I observe: ## Preamble ``` => bundle exec solargraph --version 0.46.0 => bundle exec yard --version yard 0.9.28 => bundle exec rails --version Rails 7.0.2.4 ``` ## Part 1 - generating YARD objects Starting from scratch: ``` bundle exec yard gems bundle exec solargraph bundle ``` ```rb require 'yard' yardoc_file = "#{ENV['HOME']}/.solargraph/cache/gems/activerecord-7.0.2.4/yardoc" YARD::Registry.load_yardoc(yardoc_file) YARD::Registry.all.select { |o| o.namespace.name == :QueryMethods } #=> [#