hanami / hanami/ruby-lsp-hanami

Errors when opening a Dry::Validation::Contract

Open
#12 1 comment 1 reaction 1 assignee Claimed by @kyleplump View on GitHub
Dominant language
Ruby
Stars
4
Forks
1
PR merge metrics
No merged PRs in 30d

Description

I'm trying ruby-lsp-hanami in https://github.com/decafsucks/decafsucks using Zed, and when I open `slices/main/reviews/contract.rb` in a tab, I get a slew of errors show up in the LSP logs:

```
Determined that document should be indexed: file:///Users/tim/Source/decafsucks/decafsucks/slices/main/reviews/contract.rb
Error processing textDocument/definition: /Users/tim/.local/share/mise/installs/ruby/3.4.4/lib/ruby/gems/3.4.0/gems/prism-1.9.0/lib/prism/dispatcher.rb:2155:in 'block in Prism::Dispatcher::DispatchOnce#visit_symbol_node': undefined method 'on_symbol_node_enter' for an instance of RubyLsp::Hanami::Definition (NoMethodError)

listeners[:on_symbol_node_enter]&.each { |listener| listener.on_symbol_node_enter(node) }
^^^^^^^^^^^^^^^^^^^^^
Did you mean? on_string_node_enter
from /Users/tim/.local/share/mise/installs/ruby/3.4.4/lib/ruby/gems/3.4.0/gems/prism-1.9.0/lib/prism/dispatcher.rb:2155:in 'Array#each'
from /Users/tim/.local/share/mise/installs/ruby/3.4.4/lib/ruby/gems/3.4.0/gems/prism-1.9.0/lib/prism/dispatcher.rb:2155:in 'Prism::Dispatcher::DispatchOnce#visit_symbol_node'
from /Users/tim/.local/share/mise/installs/ruby/3.4.4/lib/ruby/gems/3.4.0/gems/prism-1.9.0/lib/prism/node.rb:18472:in 'Prism::SymbolNode#accept'
from /Users/tim/.local/share/mise/installs/ruby/3.4.4/lib/ruby/gems/3.4.0/gems/prism-1.9.0/lib/prism/dispatcher.rb:83:in 'Prism::Dispatcher#dispatch_once'
from /Users/tim/.local/share/mise/installs/ruby/3.4.4/lib/ruby/gems/3.4.0/gems/ruby-lsp-0.26.9/lib/ruby_lsp/requests/definition.rb:96:in 'RubyLsp::Requests::Definition#perform'
from /Users/tim/.local/share/mise/installs/ruby/3.4.4/lib/ruby/gems/3.4.0/gems/ruby-lsp-0.26.9/lib/ruby_lsp/server.rb:1008:in 'RubyLsp::Server#text_document_definition'
from /Users/tim/.local/share/mise/installs/ruby/3.4.4/lib/ruby/gems/3.4.0/gems/ruby-lsp-0.26.9/lib/ruby_lsp/server.rb:72:in 'RubyLsp::Server#process_message'
from /Users/tim/.local/share/mise/installs/ruby/3.4.4/lib/ruby/gems/3.4.0/gems/ruby-lsp-0.26.9/lib/ruby_lsp/base_server.rb:179:in 'RubyLsp::BaseServer#handle_incoming_message'
from /Users/tim/.local/share/mise/installs/ruby/3.4.4/lib/ruby/gems/3.4.0/gems/ruby-lsp-0.26.9/lib/ruby_lsp/base_server.rb:157:in 'block in RubyLsp::BaseServer#new_worker'
Error processing textDocument/definition: /Users/tim/.local/share/mise/installs/ruby/3.4.4/lib/ruby/gems/3.4.0/gems/prism-1.9.0/lib/prism/dispatcher.rb:2155:in 'block in Prism::Dispatcher::DispatchOnce#visit_symbol_node': undefined method 'on_symbol_node_enter' for an instance of RubyLsp::Hanami::Definition (NoMethodError)

listeners[:on_symbol_node_enter]&.each { |listener| listener.on_symbol_node_enter(node) }
^^^^^^^^^^^^^^^^^^^^^
Did you mean? on_string_node_enter
from /Users/tim/.local/share/mise/installs/ruby/3.4.4/lib/ruby/gems/3.4.0/gems/prism-1.9.0/lib/prism/dispatcher.rb:2155:in 'Array#each'
from /Users/tim/.local/share/mise/installs/ruby/3.4.4/lib/ruby/gems/3.4.0/gems/prism-1.9.0/lib/prism/dispatcher.rb:2155:in 'Prism::Dispatcher::DispatchOnce#visit_symbol_node'
from /Users/tim/.local/share/mise/installs/ruby/3.4.4/lib/ruby/gems/3.4.0/gems/prism-1.9.0/lib/prism/node.rb:18472:in 'Prism::SymbolNode#accept'
from /Users/tim/.local/share/mise/installs/ruby/3.4.4/lib/ruby/gems/3.4.0/gems/prism-1.9.0/lib/prism/dispatcher.rb:83:in 'Prism::Dispatcher#dispatch_once'
from /Users/tim/.local/share/mise/installs/ruby/3.4.4/lib/ruby/gems/3.4.0/gems/ruby-lsp-0.26.9/lib/ruby_lsp/requests/definition.rb:96:in 'RubyLsp::Requests::Definition#perform'
from /Users/tim/.local/share/mise/installs/ruby/3.4.4/lib/ruby/gems/3.4.0/gems/ruby-lsp-0.26.9/lib/ruby_lsp/server.rb:1008:in 'RubyLsp::Server#text_document_definition'
from /Users/tim/.local/share/mise/installs/ruby/3.4.4/lib/ruby/gems/3.4.0/gems/ruby-lsp-0.26.9/lib/ruby_lsp/server.rb:72:in 'RubyLsp::Server#process_message'
from /Users/tim/.local/share/mise/installs/ruby/3.4.4/lib/ruby/gems/3.4.0/gems/ruby-lsp-0.26.9/lib/ruby_lsp/base_server.rb:179:in 'RubyLsp::BaseServer#handle_incoming_message'
from /Users/tim/.local/share/mise/installs/ruby/3.4.4/lib/ruby/gems/3.4.0/gems/ruby-lsp-0.26.9/lib/ruby_lsp/base_server.rb:157:in 'block in RubyLsp::BaseServer#new_worker'
Error processing textDocument/definition: /Users/tim/.local/share/mise/installs/ruby/3.4.4/lib/ruby/gems/3.4.0/gems/prism-1.9.0/lib/prism/dispatcher.rb:2155:in 'block in Prism::Dispatcher::DispatchOnce#visit_symbol_node': undefined method 'on_symbol_node_enter' for an instance of RubyLsp::Hanami::Definition (NoMethodError)

listeners[:on_symbol_node_enter]&.each { |listener| listener.on_symbol_node_enter(node) }
^^^^^^^^^^^^^^^^^^^^^
Did you mean? on_string_node_enter
from /Users/tim/.local/share/mise/installs/ruby/3.4.4/lib/ruby/gems/3.4.0/gems/prism-1.9.0/lib/prism/dispatcher.rb:2155:in 'Array#each'
from /Users/tim/.local/share/mise/installs/ruby/3.4.4/lib/ruby/gems/3.4.0/gems/prism-1.9.0/lib/prism/dispatcher.rb:2155:in 'Prism::Dispatcher::DispatchOnce#visit_symbol_node'
from /Users/tim/.local/share/mise/installs/ruby/3.4.4/lib/ruby/gems/3.4.0/gems/prism-1.9.0/lib/prism/node.rb:18472:in 'Prism::SymbolNode#accept'
from /Users/tim/.local/share/mise/installs/ruby/3.4.4/lib/ruby/gems/3.4.0/gems/prism-1.9.0/lib/prism/dispatcher.rb:83:in 'Prism::Dispatcher#dispatch_once'
from /Users/tim/.local/share/mise/installs/ruby/3.4.4/lib/ruby/gems/3.4.0/gems/ruby-lsp-0.26.9/lib/ruby_lsp/requests/definition.rb:96:in 'RubyLsp::Requests::Definition#perform'
from /Users/tim/.local/share/mise/installs/ruby/3.4.4/lib/ruby/gems/3.4.0/gems/ruby-lsp-0.26.9/lib/ruby_lsp/server.rb:1008:in 'RubyLsp::Server#text_document_definition'
from /Users/tim/.local/share/mise/installs/ruby/3.4.4/lib/ruby/gems/3.4.0/gems/ruby-lsp-0.26.9/lib/ruby_lsp/server.rb:72:in 'RubyLsp::Server#process_message'
from /Users/tim/.local/share/mise/installs/ruby/3.4.4/lib/ruby/gems/3.4.0/gems/ruby-lsp-0.26.9/lib/ruby_lsp/base_server.rb:179:in 'RubyLsp::BaseServer#handle_incoming_message'
from /Users/tim/.local/share/mise/installs/ruby/3.4.4/lib/ruby/gems/3.4.0/gems/ruby-lsp-0.26.9/lib/ruby_lsp/base_server.rb:157:in 'block in RubyLsp::BaseServer#new_worker'
Error processing textDocument/definition: /Users/tim/.local/share/mise/installs/ruby/3.4.4/lib/ruby/gems/3.4.0/gems/prism-1.9.0/lib/prism/dispatcher.rb:2155:in 'block in Prism::Dispatcher::DispatchOnce#visit_symbol_node': undefined method 'on_symbol_node_enter' for an instance of RubyLsp::Hanami::Definition (NoMethodError)

listeners[:on_symbol_node_enter]&.each { |listener| listener.on_symbol_node_enter(node) }
^^^^^^^^^^^^^^^^^^^^^
Did you mean? on_string_node_enter
from /Users/tim/.local/share/mise/installs/ruby/3.4.4/lib/ruby/gems/3.4.0/gems/prism-1.9.0/lib/prism/dispatcher.rb:2155:in 'Array#each'
from /Users/tim/.local/share/mise/installs/ruby/3.4.4/lib/ruby/gems/3.4.0/gems/prism-1.9.0/lib/prism/dispatcher.rb:2155:in 'Prism::Dispatcher::DispatchOnce#visit_symbol_node'
from /Users/tim/.local/share/mise/installs/ruby/3.4.4/lib/ruby/gems/3.4.0/gems/prism-1.9.0/lib/prism/node.rb:18472:in 'Prism::SymbolNode#accept'
from /Users/tim/.local/share/mise/installs/ruby/3.4.4/lib/ruby/gems/3.4.0/gems/prism-1.9.0/lib/prism/dispatcher.rb:83:in 'Prism::Dispatcher#dispatch_once'
from /Users/tim/.local/share/mise/installs/ruby/3.4.4/lib/ruby/gems/3.4.0/gems/ruby-lsp-0.26.9/lib/ruby_lsp/requests/definition.rb:96:in 'RubyLsp::Requests::Definition#perform'
from /Users/tim/.local/share/mise/installs/ruby/3.4.4/lib/ruby/gems/3.4.0/gems/ruby-lsp-0.26.9/lib/ruby_lsp/server.rb:1008:in 'RubyLsp::Server#text_document_definition'
from /Users/tim/.local/share/mise/installs/ruby/3.4.4/lib/ruby/gems/3.4.0/gems/ruby-lsp-0.26.9/lib/ruby_lsp/server.rb:72:in 'RubyLsp::Server#process_message'
from /Users/tim/.local/share/mise/installs/ruby/3.4.4/lib/ruby/gems/3.4.0/gems/ruby-lsp-0.26.9/lib/ruby_lsp/base_server.rb:179:in 'RubyLsp::BaseServer#handle_incoming_message'
from /Users/tim/.local/share/mise/installs/ruby/3.4.4/lib/ruby/gems/3.4.0/gems/ruby-lsp-0.26.9/lib/ruby_lsp/base_server.rb:157:in 'block in RubyLsp::BaseServer#new_worker'
Error processing textDocument/definition: /Users/tim/.local/share/mise/installs/ruby/3.4.4/lib/ruby/gems/3.4.0/gems/prism-1.9.0/lib/prism/dispatcher.rb:2155:in 'block in Prism::Dispatcher::DispatchOnce#visit_symbol_node': undefined method 'on_symbol_node_enter' for an instance of RubyLsp::Hanami::Definition (NoMethodError)

listeners[:on_symbol_node_enter]&.each { |listener| listener.on_symbol_node_enter(node) }
^^^^^^^^^^^^^^^^^^^^^
Did you mean? on_string_node_enter
from /Users/tim/.local/share/mise/installs/ruby/3.4.4/lib/ruby/gems/3.4.0/gems/prism-1.9.0/lib/prism/dispatcher.rb:2155:in 'Array#each'
from /Users/tim/.local/share/mise/installs/ruby/3.4.4/lib/ruby/gems/3.4.0/gems/prism-1.9.0/lib/prism/dispatcher.rb:2155:in 'Prism::Dispatcher::DispatchOnce#visit_symbol_node'
from /Users/tim/.local/share/mise/installs/ruby/3.4.4/lib/ruby/gems/3.4.0/gems/prism-1.9.0/lib/prism/node.rb:18472:in 'Prism::SymbolNode#accept'
from /Users/tim/.local/share/mise/installs/ruby/3.4.4/lib/ruby/gems/3.4.0/gems/prism-1.9.0/lib/prism/dispatcher.rb:83:in 'Prism::Dispatcher#dispatch_once'
from /Users/tim/.local/share/mise/installs/ruby/3.4.4/lib/ruby/gems/3.4.0/gems/ruby-lsp-0.26.9/lib/ruby_lsp/requests/definition.rb:96:in 'RubyLsp::Requests::Definition#perform'
from /Users/tim/.local/share/mise/installs/ruby/3.4.4/lib/ruby/gems/3.4.0/gems/ruby-lsp-0.26.9/lib/ruby_lsp/server.rb:1008:in 'RubyLsp::Server#text_document_definition'
from /Users/tim/.local/share/mise/installs/ruby/3.4.4/lib/ruby/gems/3.4.0/gems/ruby-lsp-0.26.9/lib/ruby_lsp/server.rb:72:in 'RubyLsp::Server#process_message'
from /Users/tim/.local/share/mise/installs/ruby/3.4.4/lib/ruby/gems/3.4.0/gems/ruby-lsp-0.26.9/lib/ruby_lsp/base_server.rb:179:in 'RubyLsp::BaseServer#handle_incoming_message'
from /Users/tim/.local/share/mise/installs/ruby/3.4.4/lib/ruby/gems/3.4.0/gems/ruby-lsp-0.26.9/lib/ruby_lsp/base_server.rb:157:in 'block in RubyLsp::BaseServer#new_worker'
```

Here's the contents of that file:

```ruby
# frozen_string_literal: true

require "dry/validation"

module Main
module Reviews
class Contract < Dry::Validation::Contract
params do
optional(:cafe_name).filled(:string)
optional(:cafe_address).filled(:string)
required(:rating).filled(:integer, gteq?: 1, lteq?: 10)
required(:body).filled(:string)
end
end
end
end
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.