Skip to content

Commit

Permalink
feat: rework diagnostics
Browse files Browse the repository at this point in the history
  • Loading branch information
qvalentin committed May 11, 2024
1 parent 46aaa98 commit 1077299
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
2 changes: 1 addition & 1 deletion internal/adapter/yamlls/documentSync.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func (yamllsConnector Connector) DocumentDidChangeFullSync(doc *lsplocal.Documen
return
}

logger.Println("Sending DocumentDidChange with full sync, current content:", doc.Content)
logger.Debug("Sending DocumentDidChange with full sync, current content:", doc.Content)
trimmedText := lsplocal.TrimTemplate(doc.Ast.Copy(), doc.Content)

params.ContentChanges = []lsp.TextDocumentContentChangeEvent{
Expand Down
22 changes: 18 additions & 4 deletions internal/handler/text_document.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,16 @@ func (h *langHandler) DidOpen(ctx context.Context, params *lsp.DidOpenTextDocume
if err != nil {
logger.Error("Error getting chart info for file", doc.URI, err)
}
notification := lsplocal.GetDiagnosticsNotification(chart, doc)
notifications := lsplocal.GetDiagnosticsNotifications(chart, doc)

Check failure on line 31 in internal/handler/text_document.go

View workflow job for this annotation

GitHub Actions / tests (1.21.5, ubuntu-latest)

undefined: lsplocal.GetDiagnosticsNotifications

Check failure on line 31 in internal/handler/text_document.go

View workflow job for this annotation

GitHub Actions / lint (1.21.5, ubuntu-latest)

undefined: lsplocal.GetDiagnosticsNotifications

Check failure on line 31 in internal/handler/text_document.go

View workflow job for this annotation

GitHub Actions / lint (1.21.5, ubuntu-latest)

undefined: lsplocal.GetDiagnosticsNotifications

Check failure on line 31 in internal/handler/text_document.go

View workflow job for this annotation

GitHub Actions / tests (1.21.5, macos-latest)

undefined: lsplocal.GetDiagnosticsNotifications

return h.client.PublishDiagnostics(ctx, notification)
defer func() {
for _, notification := range notifications {
logger.Println("Publishing", notification)
h.client.PublishDiagnostics(ctx, &notification)
}
}()

return nil
}

func (h *langHandler) DidClose(ctx context.Context, params *lsp.DidCloseTextDocumentParams) (err error) {
Expand All @@ -48,9 +55,16 @@ func (h *langHandler) DidSave(ctx context.Context, params *lsp.DidSaveTextDocume
}

h.yamllsConnector.DocumentDidSave(doc, *params)
notification := lsplocal.GetDiagnosticsNotification(chart, doc)
notifications := lsplocal.GetDiagnosticsNotifications(chart, doc)

Check failure on line 58 in internal/handler/text_document.go

View workflow job for this annotation

GitHub Actions / tests (1.21.5, ubuntu-latest)

undefined: lsplocal.GetDiagnosticsNotifications

Check failure on line 58 in internal/handler/text_document.go

View workflow job for this annotation

GitHub Actions / lint (1.21.5, ubuntu-latest)

undefined: lsplocal.GetDiagnosticsNotifications) (typecheck)

Check failure on line 58 in internal/handler/text_document.go

View workflow job for this annotation

GitHub Actions / lint (1.21.5, ubuntu-latest)

undefined: lsplocal.GetDiagnosticsNotifications (typecheck)

Check failure on line 58 in internal/handler/text_document.go

View workflow job for this annotation

GitHub Actions / tests (1.21.5, macos-latest)

undefined: lsplocal.GetDiagnosticsNotifications

return h.client.PublishDiagnostics(ctx, notification)
defer func() {
for _, notification := range notifications {
logger.Println("Publishing", notification)
h.client.PublishDiagnostics(ctx, &notification)
}
}()

return nil
}

func (h *langHandler) DidChange(ctx context.Context, params *lsp.DidChangeTextDocumentParams) (err error) {
Expand Down

0 comments on commit 1077299

Please sign in to comment.