File tree Expand file tree Collapse file tree
packages/opencode/src/lsp Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import * as LSPClient from "./client"
2+
3+ const MAX_PER_FILE = 20
4+
5+ export function pretty ( diagnostic : LSPClient . Diagnostic ) {
6+ const severityMap = {
7+ 1 : "ERROR" ,
8+ 2 : "WARN" ,
9+ 3 : "INFO" ,
10+ 4 : "HINT" ,
11+ }
12+
13+ const severity = severityMap [ diagnostic . severity || 1 ]
14+ const line = diagnostic . range . start . line + 1
15+ const col = diagnostic . range . start . character + 1
16+
17+ return `${ severity } [${ line } :${ col } ] ${ diagnostic . message } `
18+ }
19+
20+ export function report ( file : string , issues : LSPClient . Diagnostic [ ] ) {
21+ const errors = issues . filter ( ( item ) => item . severity === 1 )
22+ if ( errors . length === 0 ) return ""
23+ const limited = errors . slice ( 0 , MAX_PER_FILE )
24+ const more = errors . length - MAX_PER_FILE
25+ const suffix = more > 0 ? `\n... and ${ more } more` : ""
26+ return `<diagnostics file="${ file } ">\n${ limited . map ( pretty ) . join ( "\n" ) } ${ suffix } \n</diagnostics>`
27+ }
28+
29+ export * as Diagnostic from "./diagnostic"
Original file line number Diff line number Diff line change @@ -505,30 +505,4 @@ export const layer = Layer.effect(
505505
506506export const defaultLayer = layer . pipe ( Layer . provide ( Config . defaultLayer ) )
507507
508- export namespace Diagnostic {
509- const MAX_PER_FILE = 20
510-
511- export function pretty ( diagnostic : LSPClient . Diagnostic ) {
512- const severityMap = {
513- 1 : "ERROR" ,
514- 2 : "WARN" ,
515- 3 : "INFO" ,
516- 4 : "HINT" ,
517- }
518-
519- const severity = severityMap [ diagnostic . severity || 1 ]
520- const line = diagnostic . range . start . line + 1
521- const col = diagnostic . range . start . character + 1
522-
523- return `${ severity } [${ line } :${ col } ] ${ diagnostic . message } `
524- }
525-
526- export function report ( file : string , issues : LSPClient . Diagnostic [ ] ) {
527- const errors = issues . filter ( ( item ) => item . severity === 1 )
528- if ( errors . length === 0 ) return ""
529- const limited = errors . slice ( 0 , MAX_PER_FILE )
530- const more = errors . length - MAX_PER_FILE
531- const suffix = more > 0 ? `\n... and ${ more } more` : ""
532- return `<diagnostics file="${ file } ">\n${ limited . map ( pretty ) . join ( "\n" ) } ${ suffix } \n</diagnostics>`
533- }
534- }
508+ export * as Diagnostic from "./diagnostic"
You can’t perform that action at this time.
0 commit comments