Solargraph: Peek Definition goes to wrong line

Created on 21 Mar 2019  路  10Comments  路  Source: castwide/solargraph

When I Ctrl + Hover then click on method, it goes to wrong place (line) of the target.

See here:

dfg

Sample project in GIF:

sample.zip

All 10 comments

Confirmed. I'll look into it.

One thing I noticed: the first time I tried, it opened the same location shown in your GIF; but the second time, it opened the correct definition.

@castwide, yes this happened to me once. But in general, it finds the wrong line.

The root cause appears to be end-of-line sequences. When I change Email.rb from CRLF to LF, definitions get located correctly.

Solargraph is supposed to be EOL-agnostic, so I'm not sure what broke down here. I'll keep looking into it.

Ah, This explains why it's only have issues for the files I sent you.

One more clue: it looks like the problem happens because the EOL sequence is mixed. If the entire file uses either CRLF or LF, it works.

@castwide, btw, one more issue. When I say Restart Solargraph in VSCode, in the past I can see the notification (bottom bar not vscode notification slide) that solargraph is initializing message and loader animation. Last 1-2 builds removed this feature.

I only see Solargraph Restarted message and not status for current state. (Like if its really restarting or failed or succeeded/ready.)

@gencer The issue with progress notification during restart was a minor oversight in the VSCode extension. It'll be fixed in the next release.

@castwide, I did not want to open a ticket just for a simple question. I see that domains support for DSL. You have an example for Sinatra.

May I ask how to get it work with Grape? (https://github.com/ruby-grape/grape)

If you can tell me this, I will understand domains setting better and config further settings by myself.

Thanks,
Gencer.

It looks like Grape uses a fair amount of Rails-style magic that Solargraph can't detect through static analysis. The @!domains directive probably won't handle it. I'm afraid I don't have a good recommendation for this one.

While I was testing Grape, I also found a bug in how completion requests handle extended class methods. I might be able to propose a solution that maps the Grape API, but I'll have to fix that bug first.

Okay, the bug I encountered was in a development branch, so this solution should work with the current gem.

You can use the @!parse directive to make the runtime extensions to Grape::API explicit:

class MyAPI < Grape::API
  # @!parse
  #   extend Grape::DSL::Validations::ClassMethods
  #   extend Grape::DSL::Callbacks::ClassMethods
  #   extend Grape::DSL::Configuration::ClassMethods
  #   extend Grape::DSL::Helpers::ClassMethods
  #   extend Grape::DSL::Middleware::ClassMethods
  #   extend Grape::DSL::RequestResponse::ClassMethods
  #   extend Grape::DSL::Routing::ClassMethods
  b # <- Solargraph will suggest Grape::API class methods like `before`
end

It's not pretty, but it works.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

cuongn265 picture cuongn265  路  3Comments

bry-guy picture bry-guy  路  3Comments

gencer picture gencer  路  5Comments

clmay picture clmay  路  3Comments

patilarpith picture patilarpith  路  5Comments