Fix code quality violations and enhance ROUTE-EXISTS-01 rule
Implement JQHTML function cache ID system and fix bundle compilation Implement underscore prefix for system tables Fix JS syntax linter to support decorators and grant exception to Task system SPA: Update planning docs and wishlists with remaining features SPA: Document Navigation API abandonment and future enhancements Implement SPA browser integration with History API (Phase 1) Convert contacts view page to SPA action Convert clients pages to SPA actions and document conversion procedure SPA: Merge GET parameters and update documentation Implement SPA route URL generation in JavaScript and PHP Implement SPA bootstrap controller architecture Add SPA routing manual page (rsx:man spa) Add SPA routing documentation to CLAUDE.md Phase 4 Complete: Client-side SPA routing implementation Update get_routes() consumers for unified route structure Complete SPA Phase 3: PHP-side route type detection and is_spa flag Restore unified routes structure and Manifest_Query class Refactor route indexing and add SPA infrastructure Phase 3 Complete: SPA route registration in manifest Implement SPA Phase 2: Extract router code and test decorators Rename Jqhtml_Component to Component and complete SPA foundation setup 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -236,13 +236,14 @@ export class RspadeDefinitionProvider implements vscode.DefinitionProvider {
|
||||
/**
|
||||
* Handle Route() pattern for both PHP and JavaScript
|
||||
* Detects patterns like:
|
||||
* - Rsx::Route('Controller') (PHP, defaults to 'index')
|
||||
* - Rsx::Route('Controller', 'method') (PHP)
|
||||
* - Rsx.Route('Controller') (JavaScript, defaults to 'index')
|
||||
* - Rsx.Route('Controller', 'method') (JavaScript)
|
||||
* - Rsx::Route('Controller') (defaults to 'index')
|
||||
* - Rsx::Route('Controller::method') (explicit method via ::)
|
||||
* - Rsx::Route('Spa_Action_Name') (SPA action)
|
||||
* - Rsx.Route('Controller') (JavaScript)
|
||||
* - Rsx.Route('Controller::method') (JavaScript)
|
||||
*
|
||||
* Resolution: Routes always point to PHP controllers (server-side)
|
||||
* Type: 'php_class'
|
||||
* Resolution: Routes can point to PHP controllers OR SPA actions (JavaScript)
|
||||
* Type: 'php_class,js_class' (try PHP first for controllers, then JS for SPA actions)
|
||||
*/
|
||||
private async handleRoutePattern(
|
||||
document: vscode.TextDocument,
|
||||
@@ -250,27 +251,39 @@ export class RspadeDefinitionProvider implements vscode.DefinitionProvider {
|
||||
): Promise<vscode.Definition | undefined> {
|
||||
const line = document.lineAt(position.line).text;
|
||||
|
||||
// First try to match two-parameter version
|
||||
// Matches: Rsx::Route('Controller', 'method') or Rsx.Route("Controller", "method")
|
||||
const routePatternTwo = /(?:Rsx::Route|Rsx\.Route)\s*\(\s*['"]([A-Z][A-Za-z0-9_]*)['"],\s*['"]([a-z_][a-z0-9_]*)['"].*?\)/;
|
||||
let match = line.match(routePatternTwo);
|
||||
// Match Route() with single string parameter
|
||||
// Matches: Rsx::Route('Something') or Rsx.Route("Something") or Rsx::Route('Class::method')
|
||||
const routePattern = /(?:Rsx::Route|Rsx\.Route)\s*\(\s*['"]([A-Z][A-Za-z0-9_:]+)['"].*?\)/;
|
||||
const match = line.match(routePattern);
|
||||
|
||||
if (match) {
|
||||
const [fullMatch, controller, method] = match;
|
||||
const [fullMatch, action] = match;
|
||||
const matchStart = line.indexOf(fullMatch);
|
||||
const matchEnd = matchStart + fullMatch.length;
|
||||
|
||||
// Check if cursor is within the Route() call
|
||||
if (position.character >= matchStart && position.character <= matchEnd) {
|
||||
// Always go to the method when clicking anywhere in Route()
|
||||
// This takes precedence over individual class name lookups
|
||||
// Parse the action string for :: delimiter
|
||||
let controller: string;
|
||||
let method: string | undefined;
|
||||
|
||||
if (action.includes('::')) {
|
||||
// Format: "Controller::method" or "Spa_Action::method"
|
||||
[controller, method] = action.split('::', 2);
|
||||
} else {
|
||||
// Format: "Controller" or "Spa_Action_Name" - defaults to 'index'
|
||||
controller = action;
|
||||
method = 'index';
|
||||
}
|
||||
|
||||
// Try to resolve as PHP controller first, then JS SPA action
|
||||
try {
|
||||
const result = await this.queryIdeHelper(controller, method, 'php_class');
|
||||
const result = await this.queryIdeHelper(controller, method, 'php_class,js_class');
|
||||
return this.createLocationFromResult(result);
|
||||
} catch (error) {
|
||||
// If method lookup fails, try just the controller
|
||||
// If method lookup fails, try just the class
|
||||
try {
|
||||
const result = await this.queryIdeHelper(controller, undefined, 'php_class');
|
||||
const result = await this.queryIdeHelper(controller, undefined, 'php_class,js_class');
|
||||
return this.createLocationFromResult(result);
|
||||
} catch (error2) {
|
||||
console.error('Error querying IDE helper for route:', error);
|
||||
@@ -279,38 +292,6 @@ export class RspadeDefinitionProvider implements vscode.DefinitionProvider {
|
||||
}
|
||||
}
|
||||
|
||||
// Try single-parameter version (defaults to 'index')
|
||||
// Matches: Rsx::Route('Controller') or Rsx.Route("Controller")
|
||||
const routePatternOne = /(?:Rsx::Route|Rsx\.Route)\s*\(\s*['"]([A-Z][A-Za-z0-9_]*)['"].*?\)/;
|
||||
match = line.match(routePatternOne);
|
||||
|
||||
if (match) {
|
||||
const [fullMatch, controller] = match;
|
||||
const matchStart = line.indexOf(fullMatch);
|
||||
const matchEnd = matchStart + fullMatch.length;
|
||||
|
||||
// Check if cursor is within the Route() call
|
||||
if (position.character >= matchStart && position.character <= matchEnd) {
|
||||
// Check if this is actually a two-parameter call by looking for a comma
|
||||
if (!fullMatch.includes(',')) {
|
||||
// Single parameter - default to 'index'
|
||||
const method = 'index';
|
||||
try {
|
||||
const result = await this.queryIdeHelper(controller, method, 'php_class');
|
||||
return this.createLocationFromResult(result);
|
||||
} catch (error) {
|
||||
// If method lookup fails, try just the controller
|
||||
try {
|
||||
const result = await this.queryIdeHelper(controller, undefined, 'php_class');
|
||||
return this.createLocationFromResult(result);
|
||||
} catch (error2) {
|
||||
console.error('Error querying IDE helper for route:', error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user