Diagnostics implements plugins.LSPAdapter.
(file string)
| 95 | |
| 96 | // Diagnostics implements plugins.LSPAdapter. |
| 97 | func (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. |
| 124 | func (a *lspToolAdapter) Definition(file string, line, column int) (string, error) { |
nothing calls this directly
no test coverage detected