castwide / vscode-solargraph

A Visual Studio Code extension for Solargraph.
Other
425 stars 23 forks source link

Request textDocument/hover failed #77

Closed dharshan closed 6 years ago

dharshan commented 6 years ago

Hi, I'm getting error message in my vscode output tab after I updated solargraph through VSCode popup.

[Error - 10:57:10 AM] Request textDocument/hover failed.
  Message: [NoMethodError] undefined method `qualify' for #<Solargraph::Pin::Method:0x000055cf056612d0>
  Code: -32603

Please find the bellow version.

solargraph : 0.27.1
vscode : 1.27.1
rvm : 1.29.4
ruby : 2.3.1

solargraph

castwide commented 6 years ago

Is there a more detailed error message in the developer console (Help -> Toggle Developer Tools)?

That error most likely occurs when you hover over a method name or goto/peek definition on it. Can you identify a code snippet where it happens?

dharshan commented 6 years ago

vs_error

Complete error log

TypeError: Cannot read property 'specs' of undefined
at watcher.onDidChange (/home/dharshan/.vscode/extensions/bung87.vscode-gemfile-0.0.2/out/src/extension.js:79:54)
at e.fire (/usr/share/code/resources/app/out/vs/workbench/node/extensionHostProcess.js:99:917)
at /usr/share/code/resources/app/out/vs/workbench/node/extensionHostProcess.js:743:257
at e.fire (/usr/share/code/resources/app/out/vs/workbench/node/extensionHostProcess.js:99:917)
at e.$onFileEvent (/usr/share/code/resources/app/out/vs/workbench/node/extensionHostProcess.js:744:808)
at e._doInvokeHandler (/usr/share/code/resources/app/out/vs/workbench/node/extensionHostProcess.js:681:309)
at e._invokeHandler (/usr/share/code/resources/app/out/vs/workbench/node/extensionHostProcess.js:681:27)
at e._receiveRequest (/usr/share/code/resources/app/out/vs/workbench/node/extensionHostProcess.js:679:802)
at e._receiveOneMessage (/usr/share/code/resources/app/out/vs/workbench/node/extensionHostProcess.js:678:993)
at /usr/share/code/resources/app/out/vs/workbench/node/extensionHostProcess.js:677:791
at /usr/share/code/resources/app/out/vs/workbench/node/extensionHostProcess.js:98:597
at e.fire (/usr/share/code/resources/app/out/vs/workbench/node/extensionHostProcess.js:99:917)
at a (/usr/share/code/resources/app/out/vs/workbench/node/extensionHostProcess.js:164:787)
at Socket._socketDataListener (/usr/share/code/resources/app/out/vs/workbench/node/extensionHostProcess.js:164:1006)
at emitOne (events.js:116:13)
at Socket.emit (events.js:211:7)
at addChunk (_stream_readable.js:263:12)
at readableAddChunk (_stream_readable.js:250:11)
at Socket.Readable.push (_stream_readable.js:208:10)
at Pipe.onread (net.js:594:20)
6
TypeError: Cannot read property 'contents' of null
at promise.then (/home/dharshan/.vscode/extensions/castwide.solargraph-0.17.6/out/src/language-client.js:27:27)
at <anonymous>
dharshan commented 6 years ago

Not a JS guy, hope above attachment will help.

thomthom commented 6 years ago

I'm seeing the same thing. Not sure what triggers it.

[Extension Host] undefined method `qualify' for #<Solargraph::Pin::Namespace:0x000000116358b0>

console.ts:136 [Extension Host] C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/solargraph-0.27.1/lib/solargraph/pin/base.rb:161:in `infer'
C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/solargraph-0.27.1/lib/solargraph/source/chain.rb:68:in `block in infer'
C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/solargraph-0.27.1/lib/solargraph/source/chain.rb:67:in `each'
C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/solargraph-0.27.1/lib/solargraph/source/chain.rb:67:in `infer'
C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/solargraph-0.27.1/lib/solargraph/pin/base_variable.rb:49:in `infer'
C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/solargraph-0.27.1/lib/solargraph/source/chain.rb:68:in `block in infer'
C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/solargraph-0.27.1/lib/solargraph/source/chain.rb:67:in `each'
C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/solargraph-0.27.1/lib/solargraph/source/chain.rb:67:in `infer'
C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/solargraph-0.27.1/lib/solargraph/source_map/clip.rb:26:in `complete'
C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/solargraph-0.27.1/lib/solargraph/library.rb:144:in `completions_at'
C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/solargraph-0.27.1/lib/solargraph/language_server/host.rb:352:in `completions_at'
C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/solargraph-0.27.1/lib/solargraph/language_server/message/text_document/completion.rb:20:in `inner_process'
C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/solargraph-0.27.1/lib/solargraph/language_server/message/text_document/completion.rb:9:in `process'
C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/solargraph-0.27.1/lib/solargraph/language_server/host.rb:75:in `start'
C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/solargraph-0.27.1/lib/solargraph/language_server/transport/socket.rb:19:in `process'
C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/solargraph-0.27.1/lib/solargraph/language_server/transport/socket.rb:13:in `block in post_init'
C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/solargraph-0.27.1/lib/solargraph/language_server/transport/data_reader.rb:53:in `call'
C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/solargraph-0.27.1/lib/solargraph/language_server/transport/data_reader.rb:53:in `parse_message_from_buffer'
C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/solargraph-0.27.1/lib/solargraph/language_server/transport/data_reader.rb:31:in `block in receive'
C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/solargraph-0.27.1/lib/solargraph/language_server/transport/data_reader.rb:26:in `each_char'
C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/solargraph-0.27.1/lib/solargraph/language_server/transport/data_reader.rb:26:in `receive'
C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/solargraph-0.27.1/lib/solargraph/language_server/transport/socket.rb:27:in `receive_data'
C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/eventmachine-1.2.5-x64-mingw32/lib/eventmachine.rb:194:in `run_machine'
C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/eventmachine-1.2.5-x64-mingw32/lib/eventmachine.rb:194:in `run'
C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/solargraph-0.27.1/lib/solargraph/shell.rb:25:in `socket'
C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/thor-0.20.0/lib/thor/command.rb:27:in `run'
C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/thor-0.20.0/lib/thor/invocation.rb:126:in `invoke_command'
C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/thor-0.20.0/lib/thor.rb:387:in `dispatch'
C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/thor-0.20.0/lib/thor/base.rb:466:in `start'
C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/solargraph-0.27.1/bin/solargraph:5:in `<top (required)>'
C:/Ruby22-x64/bin/solargraph:23:in `load'
C:/Ruby22-x64/bin/solargraph:23:in `<main>'
castwide commented 6 years ago

I haven't been able to reproduce this error yet, but based on the logs, I suspect it occurs when the server tries to infer a variable type for definition or completion. Possibly a class variable, e.g., @@foo. Does that help anyone identify a code snippet where it happens?

thomthom commented 6 years ago

Hm.. not really...

For me it appear to happen when I type PLUGIN. (notice the period). PLUGIN is a shortcut constant to another namespace I have in my code. So I type PLUGIN then period to start typing a method to call. That's when it triggers the warning in my case. But I don't know the exact factors that triggers it. This is a rather old and large project I'm working on.

castwide commented 6 years ago

@thomthom Can you show me the line(s) of code where PLUGIN is defined?

thomthom commented 6 years ago
#-------------------------------------------------------------------------------
#
# Thomas Thomassen
# thomas[at]thomthom[dot]net
#
#-------------------------------------------------------------------------------

require 'sketchup.rb'
require 'extensions.rb'
require 'json'

module TT
module Plugins
module VertexTools2

  # Resource paths.
  file = __FILE__.dup
  file.force_encoding('UTF-8') if file.respond_to?(:force_encoding)
  SUPPORT_FOLDER_NAME = File.basename(file, '.*')
  ROOT_PATH           = File.dirname(File.expand_path(file)).freeze
  PATH                = File.join(ROOT_PATH, SUPPORT_FOLDER_NAME).freeze

  # Extension information
  extension_json_file = File.join(PATH, 'extension.json')
  extension_json = File.read(extension_json_file)
  EXTENSION = ::JSON.parse(extension_json, symbolize_names: true).freeze
  # Syntax shortcut to the extension namespace.
  PLUGIN          = self
  # Backward compatible constants. Prefer EXTENSION over these.
  PLUGIN_ID       = EXTENSION[:product_id].freeze
  PLUGIN_NAME     = EXTENSION[:name].freeze
  PLUGIN_VERSION  = EXTENSION[:version].freeze

  PROXY_LOADER = File.join(PATH, 'bootstrap').freeze

  unless file_loaded?(__FILE__)
    @extension = SketchupExtension.new(EXTENSION[:name], PROXY_LOADER)
    @extension.description = EXTENSION[:description]
    @extension.version     = EXTENSION[:version]
    @extension.copyright   = EXTENSION[:copyright]
    @extension.creator     = EXTENSION[:creator]
    Sketchup.register_extension(@extension, true)
    file_loaded(__FILE__)
  end

  def self.extension
    @extension
  end

end # module VertexTools2
end # module Plugins
end # module TT
castwide commented 6 years ago

Perfect, thanks. The issue is with inferring types from variables assigned self (internally, a constant is treated as a kind of variable). I suspect there are related issues that have the same root cause. Now that I know where it happens, it should be fairly simple to fix.

castwide commented 6 years ago

The fix is in the master branch and will be released in gem v0.28.0.

castwide commented 6 years ago

The fix is published in gem v0.28.0.

KarolDaniluk commented 5 years ago

I get the exact same problem with Ruby 2.5.3 and Solargraph 0.31.3

[Error - 13:36:59] Request textDocument/hover failed. Message: [Solargraph::FileNotFoundError] ApiMap did not catalog {..}/example_scopes.rb Code: -32603

Code example:

universe = 'blue universe'
pr = proc {universe}

def m (passed_in_proc)
    universe = 'red universe'
    puts "Method's universe: " + universe
    puts "Proc's universe: " + passed_in_proc.call
end

m(pr)

I got error when hover last line: m(pr)