-
Notifications
You must be signed in to change notification settings - Fork 234
Open
Labels
enhancementNew feature or requestNew feature or request
Description
I have checked that this feature is not already implemented
- This feature does not exist
Use case
In Ruby, class names are often represented as strings in mappings and configurations:
WORKERS_MAPPING = {
....Worker => 'Another::Worker',
#. ...
}
'User', "Go to Definition" works on direct class references (User) but not on string literals ('User'). When invoking "Go to Definition" on 'User', it should navigate to the User class definition.
Description
Ruby LSP should recognize string literals containing class/module names and allow navigating to their definitions. When a user invokes "Go to Definition" on a string literal:
- LSP checks if the string content is a valid class/module name
- Searches for that class definition in the workspace
- If found, navigates to the definition
- If not found, shows standard string behavior
Implementation
In lib/ruby_lsp/requests/definition.rb:
- On definition request, check the AST node type
- If it's a string literal, extract its value
- Check if the value is a valid constant name (e.g.,
User,Communication::User) - If yes, resolve the class/module using
Object.const_getor Ruby LSP's index - Return the position of the found class definition
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request