| 293 | } |
| 294 | |
| 295 | func (s *Session) DidOpenFile(ctx context.Context, uri lsproto.DocumentUri, version int32, content string, languageKind lsproto.LanguageKind) { |
| 296 | s.cancelWarmAutoImportCache() |
| 297 | s.scheduleIdleCacheClean() |
| 298 | s.cancelScheduledSnapshotUpdate() |
| 299 | s.snapshotUpdateMu.Lock() |
| 300 | defer s.snapshotUpdateMu.Unlock() |
| 301 | s.pendingFileChangesMu.Lock() |
| 302 | s.pendingFileChanges = append(s.pendingFileChanges, FileChange{ |
| 303 | Kind: FileChangeKindOpen, |
| 304 | URI: uri, |
| 305 | Version: version, |
| 306 | Content: content, |
| 307 | LanguageKind: languageKind, |
| 308 | }) |
| 309 | changes, overlays := s.flushChangesLocked(ctx) |
| 310 | s.pendingFileChangesMu.Unlock() |
| 311 | s.UpdateSnapshot(ctx, overlays, SnapshotChange{ |
| 312 | reason: UpdateReasonDidOpenFile, |
| 313 | fileChanges: changes, |
| 314 | ResourceRequest: ResourceRequest{ |
| 315 | Documents: []lsproto.DocumentUri{uri}, |
| 316 | }, |
| 317 | }) |
| 318 | } |
| 319 | |
| 320 | func (s *Session) DidCloseFile(ctx context.Context, uri lsproto.DocumentUri) { |
| 321 | s.cancelWarmAutoImportCache() |