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

Method Diagnostics

cli/lsp_tool_adapter.go:97–121  ·  view source on GitHub ↗

Diagnostics implements plugins.LSPAdapter.

(file string)

Source from the content-addressed store, hash-verified

95
96// Diagnostics implements plugins.LSPAdapter.
97func (a *lspToolAdapter) Diagnostics(file string) (string, error) {
98 sess, abs, err := a.acquire(file)
99 if err != nil {
100 return "", err
101 }
102 diags, ok := sess.Client.Diagnostics(sess.URI, lspDiagnosticsWait)
103 if !ok {
104 return fmt.Sprintf("%s: the language server produced no diagnostics report within %s — treat as inconclusive, not clean.",
105 relPath(sess.Root, "file://"+abs), lspDiagnosticsWait), nil
106 }
107 if len(diags) == 0 {
108 return fmt.Sprintf("%s: no diagnostics — the file is clean.", relPath(sess.Root, "file://"+abs)), nil
109 }
110 var b strings.Builder
111 fmt.Fprintf(&b, "%d diagnostic(s) in %s:\n", len(diags), relPath(sess.Root, "file://"+abs))
112 for _, d := range diags {
113 src := d.Source
114 if src != "" {
115 src = " (" + src + ")"
116 }
117 fmt.Fprintf(&b, "- L%d:%d [%s] %s%s\n",
118 d.Range.Start.Line+1, d.Range.Start.Character+1, d.SeverityLabel(), d.Message, src)
119 }
120 return strings.TrimRight(b.String(), "\n"), nil
121}
122
123// Definition implements plugins.LSPAdapter. line/column are 1-based.
124func (a *lspToolAdapter) Definition(file string, line, column int) (string, error) {

Callers

nothing calls this directly

Calls 5

acquireMethod · 0.95
relPathFunction · 0.85
SeverityLabelMethod · 0.80
DiagnosticsMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected