Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
charlieegan3 committed Apr 15, 2024
1 parent e79391b commit 2f95077
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
3 changes: 2 additions & 1 deletion internal/lsp/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,8 @@ func (l *LanguageServer) StartDiagnosticsWorker(ctx context.Context) {
if ok && len(aggDiags) > 0 {
l.diagnosticRequestWorkspace <- fmt.Sprintf("file %q with aggregate violation changed", evt.URI)
}
case <-l.diagnosticRequestWorkspace:
case r := <-l.diagnosticRequestWorkspace:
l.logError(fmt.Errorf("diagnostic request workspace: %s", r))
// results will be sent in response to the next workspace/diagnostics request
err := updateAllDiagnostics(ctx, l.cache, l.loadedConfig, l.clientRootURI)
if err != nil {
Expand Down
12 changes: 12 additions & 0 deletions internal/lsp/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,8 @@ allow := true
ctx, cancel := context.WithCancel(context.Background())
defer cancel()

fmt.Fprintf(os.Stderr, "start \n")

ls := NewLanguageServer(&LanguageServerOptions{
ErrorLog: os.Stderr,
})
Expand All @@ -592,8 +594,16 @@ allow := true
receivedMessages := make(chan jsonrpc2.Request, 1)
clientHandler := func(_ context.Context, _ *jsonrpc2.Conn, req *jsonrpc2.Request) (result any, err error) {
if req.Method == methodTextDocumentPublishDiagnostics {
fmt.Fprintf(os.Stderr, "received diagnostics: %v\n", req.Method)
receivedMessages <- *req

var requestData FileDiagnostics
err = json.Unmarshal(*req.Params, &requestData)
if err != nil {
t.Fatalf("failed to unmarshal diagnostics: %s", err)
}
fmt.Fprintf(os.Stderr, "received diagnostics: %v items\n", len(requestData.Items))

return struct{}{}, nil
}

Expand Down Expand Up @@ -691,6 +701,8 @@ allow := true
case <-time.After(3 * time.Second):
t.Fatalf("timed out waiting for file diagnostics to be sent")
}

t.Fatalf("done")
}

func createConnections(
Expand Down

0 comments on commit 2f95077

Please sign in to comment.