handleDidSave processes didSave notifications
(ctx context.Context, reply jsonrpc2.Replier, req jsonrpc2.Request)
| 608 | |
| 609 | // handleDidSave processes didSave notifications |
| 610 | func (s *Server) handleDidSave(ctx context.Context, reply jsonrpc2.Replier, req jsonrpc2.Request) error { |
| 611 | var params protocol.DidSaveTextDocumentParams |
| 612 | if err := json.Unmarshal(req.Params(), ¶ms); err != nil { |
| 613 | return reply(ctx, nil, err) |
| 614 | } |
| 615 | |
| 616 | // Handle .dingo file save |
| 617 | if isDingoFile(params.TextDocument.URI) { |
| 618 | dingoPath := params.TextDocument.URI.Filename() |
| 619 | |
| 620 | // Run linter on save (always, regardless of auto-transpile setting) |
| 621 | go s.runLintOnSave(ctx, params.TextDocument.URI) |
| 622 | |
| 623 | // Auto-transpile if enabled |
| 624 | // Note: The file watcher also triggers transpilation with 500ms debounce. |
| 625 | // We trigger here too for immediate feedback, but the transpiler has internal |
| 626 | // locking to prevent concurrent transpilations of the same file. |
| 627 | if s.config.AutoTranspile { |
| 628 | s.config.Logger.Debugf("Auto-transpile on save: %s", dingoPath) |
| 629 | go s.transpiler.OnFileChange(ctx, dingoPath) |
| 630 | } |
| 631 | |
| 632 | // Don't forward to gopls - transpiler handles it after successful transpilation |
| 633 | return reply(ctx, nil, nil) |
| 634 | } |
| 635 | |
| 636 | // Forward non-dingo files to gopls |
| 637 | if err := s.gopls.DidSave(ctx, params); err != nil { |
| 638 | s.config.Logger.Warnf("gopls didSave failed: %v", err) |
| 639 | } |
| 640 | |
| 641 | return reply(ctx, nil, nil) |
| 642 | } |
| 643 | |
| 644 | // handleDidClose processes didClose notifications |
| 645 | func (s *Server) handleDidClose(ctx context.Context, reply jsonrpc2.Replier, req jsonrpc2.Request) error { |
no test coverage detected