Fix bin/publish: use correct .env path for rspade_system Fix bin/publish script: prevent grep exit code 1 from terminating script 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
3.5 KiB
Executable File
3.5 KiB
Executable File
Go to Definition - JavaScript to PHP Navigation
Overview
The RSpade VS Code extension now supports "Go to Definition" navigation from JavaScript class references to their corresponding PHP implementations. This feature is particularly useful when working with RSX's Internal API system, where JavaScript code calls PHP methods through auto-generated stubs.
How It Works
When you right-click on an identifier and select "Go to Definition", the extension will:
For JavaScript Class References
- Detect if the identifier looks like an RSX class (contains underscore, starts with capital letter)
- Query the IDE helper endpoint (
/_idehelper) to resolve the PHP file location - If a method is being called (e.g.,
Demo_Index_Controller.hello_world()), navigate directly to that method - Open the PHP file at the exact line where the class or method is defined
For Bundle Aliases in PHP
- Detect if you're in a bundle's
'include'array - Check if the string is a bundle alias (lowercase single word like 'bootstrap5', 'jquery')
- Query the IDE helper to resolve the alias to its bundle class
- Open the bundle PHP file at the class definition
Technical Implementation
IDE Helper Endpoint
The endpoint /_idehelper (implemented in /app/RSpade/Ide/Helper/Ide_Helper_Controller.php) accepts:
classparameter: The PHP class name to resolvemethodparameter (optional): The specific method to navigate to
Returns JSON with:
found: Whether the class was foundfile: Relative path to the PHP fileline: Line number where the class/method is definedmetadata: Additional information about the class
VS Code Extension
The RspadeDefinitionProvider (in /app/RSpade/Extension/src/definition_provider.ts):
- Implements VS Code's
DefinitionProviderinterface - Registers for JavaScript and TypeScript files
- Makes HTTPS requests to the IDE helper endpoint
- Returns a
Locationobject pointing to the PHP file
Usage Examples
JavaScript to PHP Navigation
// In rsx/app/demo/demo_index.js
console.log(await Demo_Index_Controller.hello_world());
// ^^^^^^^^^^^^^^^^^^^^^ Right-click here
// Select "Go to Definition"
// Opens demo_index_controller.php at line 48
Bundle Alias Navigation
// In rsx/app/frontend/frontend_bundle.php
public static function define(): array
{
return [
'include' => [
'bootstrap5', // <- Right-click here, Go to Definition
// Opens Bootstrap5_Bundle.php
'jquery', // <- Opens Jquery_Bundle.php
'lodash', // <- Opens Lodash_Bundle.php
],
];
}
Configuration
The base URL for the IDE helper can be configured in VS Code settings:
{
"rspade.baseUrl": "https://rspade.claude.dev.hanson.xyz"
}
Security
- The IDE helper endpoint is only available in development mode
- Production environments return a 403 Forbidden error
- No sensitive information is exposed through this endpoint
Installation
After building the extension with ./build.sh, install the generated .vsix file:
- In VS Code: Extensions → ... → Install from VSIX
- Or via command line:
code --install-extension rspade-framework.vsix
Limitations
- Only works for RSX class names (containing underscores, starting with capital letter)
- Requires the RSpade manifest to be up-to-date
- The PHP file must exist and be indexed in the manifest