formatLocations renders a bounded location list with 1-based positions and root-relative paths, flagging any elision explicitly.
(noun, root string, locs []lsp.Location, total int)
| 228 | // formatLocations renders a bounded location list with 1-based positions and |
| 229 | // root-relative paths, flagging any elision explicitly. |
| 230 | func formatLocations(noun, root string, locs []lsp.Location, total int) string { |
| 231 | var b strings.Builder |
| 232 | fmt.Fprintf(&b, "%d %s(s):\n", total, noun) |
| 233 | for _, l := range locs { |
| 234 | fmt.Fprintf(&b, "- %s:%d:%d\n", relPath(root, l.URI), l.Range.Start.Line+1, l.Range.Start.Character+1) |
| 235 | } |
| 236 | if len(locs) < total { |
| 237 | fmt.Fprintf(&b, "… %d more not shown (raise \"limit\" to see them).\n", total-len(locs)) |
| 238 | } |
| 239 | return strings.TrimRight(b.String(), "\n") |
| 240 | } |
| 241 | |
| 242 | // compile-time assertion that the adapter satisfies the plugin interface. |
| 243 | var _ plugins.LSPAdapter = (*lspToolAdapter)(nil) |