-
Notifications
You must be signed in to change notification settings - Fork 17
Open
Description
Hi, I found an issue with global methods defined in _top_level.rb.
While defining a global method as:
def file_loaded(filename)
endworks in actual Ruby execution (top-level methods become global),
it causes issues with static analysis tools like Solargraph. Solargraph can't see those methods, so things like documentation on hover and go to definition are broken for those methods.
Suggested fix
Fortunately this is a really simple fix.
Wrap all global methods in a module Kernel block to explicitly tell static analyzers these methods should be available everywhere:
module Kernel
def file_loaded(filename)
end
def file_loaded?(filename)
end
def inputbox(*args)
end
# ... other global methods
endKernel is where Ruby's own global methods live, so this fixes the issue. Constants need to remain outside of Kernel module.
I've tested it locally and it fixes the problem.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels