| 77 | } |
| 78 | |
| 79 | func NewServer(docManager *document.Manager) *Server { |
| 80 | hubService := hub.NewService() |
| 81 | scoutService := scout.NewService() |
| 82 | handler := protocol.Handler{} |
| 83 | sessionTelemetryProperties := make(map[string]string) |
| 84 | sessionTelemetryProperties["server_session"] = identity.NewID() |
| 85 | sessionTelemetryProperties["server_version"] = metadata.Version |
| 86 | s := &Server{ |
| 87 | docs: docManager, |
| 88 | definitionLinkSupport: false, |
| 89 | analyzedFiles: make(map[string]map[string]bool), |
| 90 | gitRemotes: make(map[string]string), |
| 91 | gs: server.NewServer(&handler, "", false), |
| 92 | initialized: false, |
| 93 | telemetry: telemetry.NewClient(), |
| 94 | hubService: &hubService, |
| 95 | scoutService: scoutService, |
| 96 | sessionTelemetryProperties: sessionTelemetryProperties, |
| 97 | composeSupport: true, |
| 98 | composeCompletion: true, |
| 99 | diagnosticsCollectors: []textdocument.DiagnosticsCollector{ |
| 100 | buildkit.NewBuildKitDiagnosticsCollector(), |
| 101 | scoutService, |
| 102 | compose.NewComposeDiagnosticsCollector(), |
| 103 | hcl.NewBakeHCLDiagnosticsCollector(docManager, scoutService), |
| 104 | }, |
| 105 | } |
| 106 | |
| 107 | handler.Initialize = s.Initialize |
| 108 | handler.Initialized = s.Initialized |
| 109 | handler.Shutdown = s.shutdown |
| 110 | handler.SetTrace = s.setTrace |
| 111 | |
| 112 | handler.TextDocumentCodeAction = s.TextDocumentCodeAction |
| 113 | handler.TextDocumentCodeLens = s.TextDocumentCodeLens |
| 114 | handler.TextDocumentCompletion = s.TextDocumentCompletion |
| 115 | handler.TextDocumentDefinition = s.TextDocumentDefinition |
| 116 | handler.TextDocumentFormatting = s.TextDocumentFormatting |
| 117 | handler.TextDocumentDocumentHighlight = s.TextDocumentDocumentHighlight |
| 118 | handler.TextDocumentDocumentLink = s.TextDocumentDocumentLink |
| 119 | handler.TextDocumentDocumentSymbol = s.TextDocumentDocumentSymbol |
| 120 | handler.TextDocumentHover = s.TextDocumentHover |
| 121 | handler.TextDocumentInlayHint = s.TextDocumentInlayHint |
| 122 | handler.TextDocumentInlineCompletion = s.TextDocumentInlineCompletion |
| 123 | handler.TextDocumentPrepareRename = s.TextDocumentPrepareRename |
| 124 | handler.TextDocumentRename = s.TextDocumentRename |
| 125 | handler.TextDocumentSemanticTokensFull = s.TextDocumentSemanticTokensFull |
| 126 | |
| 127 | handler.TextDocumentDidOpen = s.TextDocumentDidOpen |
| 128 | handler.TextDocumentDidChange = s.TextDocumentDidChange |
| 129 | handler.TextDocumentDidClose = s.TextDocumentDidClose |
| 130 | |
| 131 | handler.WorkspaceDidChangeConfiguration = s.WorkspaceDidChangeConfiguration |
| 132 | handler.WorkspaceExecuteCommand = s.WorkspaceExecuteCommand |
| 133 | |
| 134 | handler.Recover = func(method string, recovered interface{}) error { |
| 135 | if s.handleRecovered(method, recovered) { |
| 136 | return &jsonrpc2.Error{Code: -32803, Message: "Internal server error"} |