handleDidOpen handles document open notifications
(params json.RawMessage)
| 254 | |
| 255 | // handleDidOpen handles document open notifications |
| 256 | func (h *Handler) handleDidOpen(params json.RawMessage) { |
| 257 | var p DidOpenTextDocumentParams |
| 258 | if err := json.Unmarshal(params, &p); err != nil { |
| 259 | h.server.Logger().Printf("textDocument/didOpen: failed to parse params: %v (raw: %s)", err, truncateForLog(params)) |
| 260 | h.sendParseError("didOpen", err) |
| 261 | return |
| 262 | } |
| 263 | |
| 264 | h.server.Logger().Printf("Document opened: %s", p.TextDocument.URI) |
| 265 | |
| 266 | // Check document size limit |
| 267 | if len(p.TextDocument.Text) > h.server.MaxDocumentSizeBytes() { |
| 268 | h.server.Logger().Printf("Document too large: %d bytes (max: %d)", len(p.TextDocument.Text), h.server.MaxDocumentSizeBytes()) |
| 269 | h.server.SendNotification("window/showMessage", ShowMessageParams{ |
| 270 | Type: MessageWarning, |
| 271 | Message: fmt.Sprintf("Document is too large for full analysis (%d bytes, max %d bytes)", len(p.TextDocument.Text), h.server.MaxDocumentSizeBytes()), |
| 272 | }) |
| 273 | // Still open the document but skip validation |
| 274 | h.server.Documents().Open( |
| 275 | p.TextDocument.URI, |
| 276 | p.TextDocument.LanguageID, |
| 277 | p.TextDocument.Version, |
| 278 | p.TextDocument.Text, |
| 279 | ) |
| 280 | return |
| 281 | } |
| 282 | |
| 283 | h.server.Documents().Open( |
| 284 | p.TextDocument.URI, |
| 285 | p.TextDocument.LanguageID, |
| 286 | p.TextDocument.Version, |
| 287 | p.TextDocument.Text, |
| 288 | ) |
| 289 | |
| 290 | // Validate and publish diagnostics |
| 291 | h.validateDocument(p.TextDocument.URI, p.TextDocument.Text, p.TextDocument.Version) |
| 292 | } |
| 293 | |
| 294 | // handleDidChange handles document change notifications |
| 295 | func (h *Handler) handleDidChange(params json.RawMessage) { |
no test coverage detected