MCPcopy Create free account
hub / github.com/diillson/chatcli / formatLocations

Function formatLocations

cli/lsp_tool_adapter.go:230–240  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

228// formatLocations renders a bounded location list with 1-based positions and
229// root-relative paths, flagging any elision explicitly.
230func 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.
243var _ plugins.LSPAdapter = (*lspToolAdapter)(nil)

Callers 3

DefinitionMethod · 0.85
ReferencesMethod · 0.85

Calls 2

relPathFunction · 0.85
StringMethod · 0.45

Tested by 1