acquire resolves the file path (expansion + absolutization) and returns a ready session plus the absolute path.
(file string)
| 63 | // acquire resolves the file path (expansion + absolutization) and returns a |
| 64 | // ready session plus the absolute path. |
| 65 | func (a *lspToolAdapter) acquire(file string) (*lsp.Session, string, error) { |
| 66 | expanded, err := utils.ExpandPath(file) |
| 67 | if err != nil { |
| 68 | expanded = file |
| 69 | } |
| 70 | abs, err := filepath.Abs(expanded) |
| 71 | if err != nil { |
| 72 | return nil, "", err |
| 73 | } |
| 74 | // @lsp calls have no caller deadline of their own; bound the possible |
| 75 | // cold spawn + initialize here (same pattern as the @knowledge adapter). |
| 76 | ctx, cancel := context.WithTimeout(context.Background(), lspOpTimeout) |
| 77 | defer cancel() |
| 78 | sess, err := a.pool().Acquire(ctx, abs) |
| 79 | if err != nil { |
| 80 | return nil, "", err |
| 81 | } |
| 82 | return sess, abs, nil |
| 83 | } |
| 84 | |
| 85 | // relPath renders a location path relative to the session root when possible. |
| 86 | func relPath(root, uri string) string { |
no test coverage detected