* Maps LSPTool operation to LSP method and params
( input: Input, absolutePath: string, )
| 425 | * Maps LSPTool operation to LSP method and params |
| 426 | */ |
| 427 | function getMethodAndParams( |
| 428 | input: Input, |
| 429 | absolutePath: string, |
| 430 | ): { method: string; params: unknown } { |
| 431 | const uri = pathToFileURL(absolutePath).href |
| 432 | // Convert from 1-based (user-friendly) to 0-based (LSP protocol) |
| 433 | const position = { |
| 434 | line: input.line - 1, |
| 435 | character: input.character - 1, |
| 436 | } |
| 437 | |
| 438 | switch (input.operation) { |
| 439 | case 'goToDefinition': |
| 440 | return { |
| 441 | method: 'textDocument/definition', |
| 442 | params: { |
| 443 | textDocument: { uri }, |
| 444 | position, |
| 445 | }, |
| 446 | } |
| 447 | case 'findReferences': |
| 448 | return { |
| 449 | method: 'textDocument/references', |
| 450 | params: { |
| 451 | textDocument: { uri }, |
| 452 | position, |
| 453 | context: { includeDeclaration: true }, |
| 454 | }, |
| 455 | } |
| 456 | case 'hover': |
| 457 | return { |
| 458 | method: 'textDocument/hover', |
| 459 | params: { |
| 460 | textDocument: { uri }, |
| 461 | position, |
| 462 | }, |
| 463 | } |
| 464 | case 'documentSymbol': |
| 465 | return { |
| 466 | method: 'textDocument/documentSymbol', |
| 467 | params: { |
| 468 | textDocument: { uri }, |
| 469 | }, |
| 470 | } |
| 471 | case 'workspaceSymbol': |
| 472 | return { |
| 473 | method: 'workspace/symbol', |
| 474 | params: { |
| 475 | query: '', // Empty query returns all symbols |
| 476 | }, |
| 477 | } |
| 478 | case 'goToImplementation': |
| 479 | return { |
| 480 | method: 'textDocument/implementation', |
| 481 | params: { |
| 482 | textDocument: { uri }, |
| 483 | position, |
| 484 | }, |