internal async Task HandleDidOpenTextDocumentNotification( DidOpenTextDocumentNotification openParams, EventContext eventContext) { try { Logger.Write(LogLevel.Verbose, "HandleDidOpenTextDocumentNotification"); if (IsScmEvent(openParams.TextDocument.Uri)) { return; } // read the SQL file contents into the ScriptFile ScriptFile openedFile = Workspace.GetFileBuffer(openParams.TextDocument.Uri, openParams.TextDocument.Text); if (openedFile == null) { return; } // Propagate the changes to the event handlers var textDocOpenTasks = TextDocOpenCallbacks.Select( t => t(openedFile, eventContext)); await Task.WhenAll(textDocOpenTasks); } catch (Exception ex) { Logger.Write(LogLevel.Error, "Unknown error " + ex.ToString()); // Swallow exceptions here to prevent us from crashing // TODO: this probably means the ScriptFile model is in a bad state or out of sync with the actual file; we should recover here return; } }
internal async Task HandleDidOpenTextDocumentNotification( DidOpenTextDocumentNotification openParams, EventContext eventContext) { Logger.Write(LogLevel.Verbose, "HandleDidOpenTextDocumentNotification"); // read the SQL file contents into the ScriptFile ScriptFile openedFile = Workspace.GetFileBuffer(openParams.TextDocument.Uri, openParams.TextDocument.Text); // Propagate the changes to the event handlers var textDocOpenTasks = TextDocOpenCallbacks.Select( t => t(openedFile, eventContext)); await Task.WhenAll(textDocOpenTasks); }
/// <summary> /// Adds a new task to be called when a file is opened /// </summary> /// <param name="task">Delegate to call when a document is opened</param> public void RegisterTextDocOpenCallback(TextDocOpenCallback task) { TextDocOpenCallbacks.Add(task); }