Closed asux closed 5 years ago
I suspect this issue is fixed in v0.33.0 (currently in the master branch), but if you can give me a simple reproducible example, I can investigate further. Based on the message, it looks the error happened during autocomplete, while collecting information about an attribute (e.g., a method declared with one of the attr_*
methods).
Seems you're right, when I start type flash
or params
, error occurs:
module Web::Controllers::Exports
module InternalContracts
class Create
include Web::Action
params do
required(:internal_contract).schema do
required(:start_date).filled(:str?)
required(:end_date).filled(:str?)
required(:state).maybe(:str?)
end
end
def call(params)
authorize! :contracts, :export
if params.valid?
schedule_mail
flash[:info] = t('controllers.exports.contracts.mail_scheduled')
else
flash[:error] = params.errors
end
redirect_to routes.export_path
end
private
def schedule_mail
Mailers::Exports::Contract.schedule(
user_id: current_user.id,
export_type: :base,
**params[:internal_contract]
)
end
end
end
end
Is that Hanami? I tried creating a Hanami project and adding that controller, just to see how Solargraph handled it. It definitely looks like the project's maps are incomplete, but I still couldn't reproduce the error.
Yes, this is Hanami project. But it has many files.
Gem v0.33.0 is released. It should fix the problem with resolving attribute completion items.
Seems works fine. Thank you @castwide!
Wait, I restarted VS code and now see this:
[Error - 4:46:39 PM] Server initialization failed.
Message: [TypeError] no implicit conversion of nil into String
Code: -32603
/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.main.js:3241 Error: [TypeError] no implicit conversion of nil into String
at new ResponseError (/Users/asux/.vscode/extensions/castwide.solargraph-0.19.6/node_modules/vscode-languageclient/node_modules/vscode-jsonrpc/lib/messages.js:46)
at handleResponse (/Users/asux/.vscode/extensions/castwide.solargraph-0.19.6/node_modules/vscode-languageclient/node_modules/vscode-jsonrpc/lib/main.js:430)
at processMessageQueue (/Users/asux/.vscode/extensions/castwide.solargraph-0.19.6/node_modules/vscode-languageclient/node_modules/vscode-jsonrpc/lib/main.js:258)
at Immediate.<anonymous> (/Users/asux/.vscode/extensions/castwide.solargraph-0.19.6/node_modules/vscode-languageclient/node_modules/vscode-jsonrpc/lib/main.js:242)
at runCallback (/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/code/electron-browser/workbench/timers.js:696)
at tryOnImmediate (/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/code/electron-browser/workbench/timers.js:667)
at processImmediate (/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/code/electron-browser/workbench/timers.js:649)
Can you go to the workspace in a terminal and run solargraph scan -v
? If something caused an exception, that might pinpoint where it happened. (The -v
option will dump information about each map location it's scanning, which will be extremely verbose. The important part will be the last location and the result, which should either be a success message or an error.)
% solargraph scan -v
[INFO] Indexing workspace files in /Users/asux/Projects/enbro_crm
/Users/asux/.rvm/gems/ruby-2.3.8@enbro/gems/solargraph-0.33.0/lib/solargraph/pin/attribute.rb:25:in `+': no implicit conversion of nil into String (TypeError)
from /Users/asux/.rvm/gems/ruby-2.3.8@enbro/gems/solargraph-0.33.0/lib/solargraph/pin/attribute.rb:25:in `path'
from /Users/asux/.rvm/gems/ruby-2.3.8@enbro/gems/solargraph-0.33.0/lib/solargraph/api_map/store.rb:226:in `block in index'
from /Users/asux/.rvm/gems/ruby-2.3.8@enbro/gems/solargraph-0.33.0/lib/solargraph/api_map/store.rb:203:in `each'
from /Users/asux/.rvm/gems/ruby-2.3.8@enbro/gems/solargraph-0.33.0/lib/solargraph/api_map/store.rb:203:in `index'
from /Users/asux/.rvm/gems/ruby-2.3.8@enbro/gems/solargraph-0.33.0/lib/solargraph/api_map/store.rb:12:in `initialize'
from /Users/asux/.rvm/gems/ruby-2.3.8@enbro/gems/solargraph-0.33.0/lib/solargraph/api_map.rb:109:in `new'
from /Users/asux/.rvm/gems/ruby-2.3.8@enbro/gems/solargraph-0.33.0/lib/solargraph/api_map.rb:109:in `catalog'
from /Users/asux/.rvm/gems/ruby-2.3.8@enbro/gems/solargraph-0.33.0/lib/solargraph/api_map.rb:149:in `load'
from /Users/asux/.rvm/gems/ruby-2.3.8@enbro/gems/solargraph-0.33.0/lib/solargraph/shell.rb:148:in `block in scan'
from /Users/asux/.rvm/rubies/ruby-2.3.8/lib/ruby/2.3.0/benchmark.rb:293:in `measure'
from /Users/asux/.rvm/gems/ruby-2.3.8@enbro/gems/solargraph-0.33.0/lib/solargraph/shell.rb:147:in `scan'
from /Users/asux/.rvm/rubies/ruby-2.3.8/lib/ruby/gems/2.3.0/gems/thor-0.19.4/lib/thor/command.rb:27:in `run'
from /Users/asux/.rvm/rubies/ruby-2.3.8/lib/ruby/gems/2.3.0/gems/thor-0.19.4/lib/thor/invocation.rb:126:in `invoke_command'
from /Users/asux/.rvm/rubies/ruby-2.3.8/lib/ruby/gems/2.3.0/gems/thor-0.19.4/lib/thor.rb:369:in `dispatch'
from /Users/asux/.rvm/rubies/ruby-2.3.8/lib/ruby/gems/2.3.0/gems/thor-0.19.4/lib/thor/base.rb:444:in `start'
from /Users/asux/.rvm/gems/ruby-2.3.8@enbro/gems/solargraph-0.33.0/bin/solargraph:5:in `<top (required)>'
from /Users/asux/.rvm/gems/ruby-2.3.8@enbro/bin/solargraph:23:in `load'
from /Users/asux/.rvm/gems/ruby-2.3.8@enbro/bin/solargraph:23:in `<main>'
from /Users/asux/.rvm/gems/ruby-2.3.8@enbro/bin/ruby_executable_hooks:24:in `eval'
from /Users/asux/.rvm/gems/ruby-2.3.8@enbro/bin/ruby_executable_hooks:24:in `<main>'
Thanks. I suspect that happened because of an @!attribute
directive without a name. I reproduced it like this:
class Example
# @!attribute
end
Can you confirm whether your code contains an unnamed @!attribute
? Either way, that shouldn't crash the server, so I'll fix it in a patch update.
Yes, I found this:
# @!attribute [r]
# @return [String] the field name of the contract PDF template
attribute :field_name, Types::String
This syntax should work:
# @!attribute [r] field_name
# @return [String] the field name of the contract PDF template
attribute :field_name, Types::String
Note that the @return
tag is indented to attach it to the directive. More information: https://www.rubydoc.info/gems/yard/file/docs/Tags.md#attribute
I'll have the unnamed attribute bug fixed in a patch release tomorrow.
Gem v0.33.1 fixes the unnamed attribute bug.
It no longer crashes, thanks!
I receiving this in output console many times when type:
VS Code: 1.35.1 (1.35.1) Solargraph: 0.32.5
gem env
:From developer console: