private async void ActiveDocumentChanged() { var doc = IdeApp.Workbench.ActiveDocument; if (activeDocument == doc) { return; } if (activeDocument != null) { activeDocument.Saved -= HandleDocumentSaved; activeDocument = null; } var ext = doc?.FileName.Extension; if (ext == ".cs") { activeDocument = doc; activeDocument.Saved += HandleDocumentSaved; var analysedDocument = await GetAnalysisDocument(); DocumentChanged?.Invoke(this, new DocumentChangedEventArgs { NewDocument = analysedDocument }); } }
private async void OnWorkspaceChanged(object sender, WorkspaceChangeEventArgs e) { using (await changeLock.LockAsync()) { DocumentId?id = e.NewSolution.GetDocumentIdsWithFilePath(GetSolutionDocumentFilePath(file.Path)).FirstOrDefault(); Document? document = e.NewSolution.GetDocument(id); if (document != null) { bool isClassificationChanged = e.DocumentId != id || e.Kind != WorkspaceChangeKind.DocumentChanged; bool isTextChanged = e.DocumentId != id && e.Kind != WorkspaceChangeKind.DocumentChanged; if (isClassificationChanged || isTextChanged) { documentStack.Push(document); string? newText = null; Encoding?newEncoding = null; if (isTextChanged) { SourceText sourceText = await document.GetTextAsync(); newText = sourceText.ToString(); newEncoding = sourceText.Encoding; } DocumentChanged?.Invoke(sender, new DocumentChangedEventArgs(isClassificationChanged, newText, newEncoding)); } } } }
public async Task ApplyChangesAsync(TextChange change, Encoding?encoding) { if (!(change.Span.IsEmpty && string.IsNullOrEmpty(change.NewText))) { using (await changeLock.LockAsync()) { if (CurrentDocument != null) { Document document = CurrentDocument; SourceText text = await document.GetTextAsync(); SourceText newText = text.WithChanges(change); if (encoding != null && newText.Encoding != encoding) { newText = SourceText.From(newText.ToString(), encoding); } Document newDocument = document.WithText(newText); if (SolutionLoader.Workspace.TryApplyChanges(newDocument.Project.Solution)) { Solution solution = SolutionLoader.Workspace.CurrentSolution; DocumentId?id = solution.GetDocumentIdsWithFilePath(GetSolutionDocumentFilePath(file.Path)).FirstOrDefault(); documentStack.Push(solution.GetDocument(id) !); DocumentChanged?.Invoke(SolutionLoader.Workspace, new DocumentChangedEventArgs(true, null, null)); } } } } }
private void OnDocumentChanged(DocumentChanged msg) { Model.Doc = msg.Document; lock (_lock) { Model.ProcessDocumentChanged(msg, Groups); } }
void EmitDocumentChanged(SyntaxTree syntaxTree = null, SemanticModel semanticModel = null) { Log.Information($"XAML document changed {boundDoc.Name}"); DocumentChanged?.Invoke(this, new DocumentChangedEventArgs(boundDoc.FileName, boundDoc.Editor.Text, syntaxTree, semanticModel)); }
public void RaiseDocumentChanged(ITextSnapshot snapshot) { if (snapshot == null) { throw new ArgumentNullException(nameof(snapshot)); } DocumentChanged?.Invoke(this, new RoslynDocumentChangedEventArgs(snapshot)); }
private void OnDocumentChanged(object sender, XAMLatorDocument documentAnalysis) { if (documentAnalysis != null) { DocumentChangedEventArgs documentChangedEventArgs = new DocumentChangedEventArgs(documentAnalysis.Path, documentAnalysis.Code, documentAnalysis.SyntaxTree, documentAnalysis.SemanticModel); DocumentChanged?.Invoke(this, documentChangedEventArgs); } }
private void _HandleTextDocumentChanged(object sender, DidChangeTextDocumentParams e) { WorkspaceDocument document = _documents.Where(x => x.Uri.Equals(e.TextDocument.Uri)).FirstOrDefault(); if (document != null) { document.ApplyContentChanges(e.ContentChanges, e.TextDocument.Version); DocumentChanged?.Invoke(this, document); } }
private void QueueMessageHandler(IChoQueuedMsgServiceObject <ChoStandardQueuedMsg <object> > msgObject) { if (msgObject == null) { return; } lock (_syncRoot) { if (msgObject.State.Msg == null) { if (!_readOnly) { ChoNestedDictionary <string, XmlNode> xmlFileList = ContractIncludes(_xmlDocument, _filePath); foreach (string fileName in xmlFileList.Keys) { if (_lastWriteTimeCache.GetValue(fileName) <= File.GetLastWriteTime(fileName)) { ChoXmlDocument.Save(xmlFileList[fileName], fileName, true); } } } } else if (msgObject.State.Msg is ChoConfigurationCompositeFileChangedEventArgs) { ChoConfigurationCompositeFileChangedEventArgs e = msgObject.State.Msg as ChoConfigurationCompositeFileChangedEventArgs; if (e != null) { try { ChoXmlDocumentChangingEventArgs xmlDocumentChangingEventArgs = new ChoXmlDocumentChangingEventArgs(_filePath, e.ModifiedIncludeFiles); DocumentChanging.Raise(this, xmlDocumentChangingEventArgs); if (xmlDocumentChangingEventArgs.IgnoreLoadDocument) { return; } _xmlDocument = null; Load(); DocumentChanged.Raise(this, new ChoXmlDocumentChangedEventArgs(_filePath, e.ModifiedIncludeFiles)); } catch { DocumentLoaded = false; throw; } } } } }
/// <summary> /// Handles processing of Groups being added or removed. This can be done here instead of a External Command Handler /// because the only thing that we are updating is the UI so we don't need to be in Revit context. /// </summary> /// <param name="msg">Document Changed Message object.</param> /// <param name="groups">Groups stored on the UI.</param> public void ProcessDocumentChanged(DocumentChanged msg, ObservableCollection <GroupTypeWrapper> groups) { if (msg.Deleted.Any()) { // (Konrad) Handle GroupType being deleted groups.RemoveAll(x => msg.Deleted.Contains(x.Id)); // (Konrad) Handle instances of groups being deleted foreach (var gtw in groups) { gtw.Instances.RemoveAll(x => msg.Deleted.Contains(x)); } } // (Konrad) Handle new instances of GroupType being added var addedTypes = msg.Added.Intersect(new FilteredElementCollector(Doc).OfClass(typeof(GroupType)).ToElementIds()).ToList(); if (addedTypes.Any()) { foreach (var id in addedTypes) { if (!(Doc.GetElement(id) is GroupType gt)) { continue; } var gtw = new GroupTypeWrapper(gt); groups.Add(gtw); } } // (Konrad) Handle new instances of groups being added var added = msg.Added.Intersect(new FilteredElementCollector(Doc).OfClass(typeof(Group)).ToElementIds()).ToList(); if (!added.Any()) { return; } foreach (var id in added) { if (!(Doc.GetElement(id) is Group g)) { continue; } var existing = groups.FirstOrDefault(x => x.Id == g.GroupType.Id); existing?.Instances.Add(id); } }
private void ActiveDocumentChanged(Document document) { if (document != null && document.Language == "CSharp") { activeDocument = document; var analysedDocument = GetAnalysisDocument(document); if (analysedDocument != null) { DocumentChanged?.Invoke(this, new DocumentChangedEventArgs { NewDocument = analysedDocument }); } } }
protected void OnDocumentTextChanged(DocumentId documentId, SourceText newText) { using (_serializationLock.DisposableWait()) { CheckDocumentIsInCurrentSolution(documentId); var oldSolution = this.CurrentDocuments; var newSolution = this.SetCurrentDocuments(oldSolution.WithDocumentText(documentId, newText)); var newDocument = newSolution.GetDocument(documentId); this.OnDocumentTextChanged(newDocument); DocumentChanged?.Invoke(this, new DocumentEventArgs(newDocument)); } }
private void QueueMessageHandler(IChoQueuedMsgServiceObject <object> msgObject) { if (msgObject == null) { return; } lock (_syncRoot) { if (msgObject.State == null) { if (!_readOnly) { SaveInternal(); } } else if (msgObject.State is ChoConfigurationCompositeFileChangedEventArgs) { ChoConfigurationCompositeFileChangedEventArgs e = msgObject.State as ChoConfigurationCompositeFileChangedEventArgs; if (e != null) { try { ChoXmlDocumentChangingEventArgs xmlDocumentChangingEventArgs = new ChoXmlDocumentChangingEventArgs(_filePath, e.ModifiedIncludeFiles); DocumentChanging.Raise(this, xmlDocumentChangingEventArgs); if (xmlDocumentChangingEventArgs.IgnoreLoadDocument) { return; } _xmlDocument = null; Load(); DocumentChanged.Raise(this, new ChoXmlDocumentChangedEventArgs(_filePath, e.ModifiedIncludeFiles)); } catch { DocumentLoaded = false; throw; } } } } }
async void HandleDocumentSaved(object sender, EventArgs e) { SyntaxTree syntaxTree = null; SemanticModel semanticModel = null; if (boundDoc.FileName.Extension == ".cs" && boundDoc.AnalysisDocument != null) { syntaxTree = await boundDoc.AnalysisDocument.GetSyntaxTreeAsync(); semanticModel = await boundDoc.AnalysisDocument.GetSemanticModelAsync(); } Log.Information($"Document changed {boundDoc.Name}"); DocumentChanged?.Invoke(this, new DocumentChangedEventArgs(boundDoc.FileName, boundDoc.Editor.Text, syntaxTree, semanticModel)); }
private void ParseLogFile(string filename) { parser = new BackgroundLogParser(filename); LoadLogFileDialog loadDlg = new Dialogs.LoadLogFileDialog( parser, (s, ea) => { this.Enabled = false; }, (s, ea) => { this.Enabled = true; this.Focus(); }, filename ); loadDlg.ShowDialog(); Globals.GPUs = parser.gpus.Values.ToList(); gpuDetail.SetObjects(Globals.GPUs); gpuPanel.SetObjects(Globals.GPUs); DocumentChanged?.Invoke(this, null); }
private static void OnDocumentChanged(object sender, DocumentChangedEventArgs args) { if (isCommitting) { return; } var document = args.GetDocument(); if (!document.Equals(ActiveDBDocument)) { return; } CancelReadActions(); DocumentChanged?.Invoke(sender, args); }
void MimeTypeChanged(object sender, EventArgs e) { Document oldDoc = Document; if (activeDocument?.Editor?.MimeType == mimeType) { Document = activeDocument; } else { Document = null; } if (oldDoc != Document) { DocumentChanged?.Invoke(this, new DocumentChangedEventArgs(Document, oldDoc)); } }
public void Replace(int offset, int length, string text) { if (!ReadOnly) { DocumentAboutToBeChanged?.Invoke(this, new DocumentEventArgs() { Document = this, Offset = offset, Length = length, Text = text }); UndoStack.Push(new UndoableReplace(this, offset, GetText(offset, length), text)); TextBuffer.Replace(offset, length, text); LineManager.Replace(offset, length, text); DocumentChanged?.Invoke(this, new DocumentEventArgs() { Document = this, Offset = offset, Length = length, Text = text }); } }
public void Remove(int offset, int length) { if (!ReadOnly) { DocumentAboutToBeChanged?.Invoke(this, new DocumentEventArgs() { Document = this, Offset = offset, Length = length }); UndoStack.Push(new UndoableDelete(this, offset, GetText(offset, length))); TextBuffer.Remove(offset, length); LineManager.Remove(offset, length); DocumentChanged?.Invoke(this, new DocumentEventArgs() { Document = this, Offset = offset, Length = length }); } }
public void Insert(int offset, string text) { if (!ReadOnly) { DocumentAboutToBeChanged?.Invoke(this, new DocumentEventArgs() { Document = this, Offset = offset, Length = -1, Text = text }); TextBuffer.Insert(offset, text); LineManager.Insert(offset, text); UndoStack.Push(new UndoableInsert(this, offset, text)); DocumentChanged?.Invoke(this, new DocumentEventArgs() { Document = this, Offset = offset, Length = -1, Text = text }); } }
protected virtual void OnDocumentChanged() { DocumentChanged?.Invoke(this, EventArgs.Empty); }
private void OnDocumentChanged() { RefreshModifiedStatus(); DocumentChanged?.Invoke(); Application.InvalidateWindows(); }
/// <summary> /// Raises the <see cref="DocumentChanged"/> event. /// </summary> protected virtual void OnDocumentChanged(EventArgs e) { DocumentChanged?.Invoke(this, e); }
protected virtual void OnDocumentChanged() { DocumentChanged?.Invoke(this, EventArgs.Empty); // Update the AST, btw. //DocumentLinter.RequestAnalyze(); }
protected void OnDocumentOpened(IDocument d) { Trace("document {0} opened", d.Path); DocumentChanged?.Invoke(d); }
protected void OnDocumentRenamed(IDocument d) { Trace("document {0} renamed", d.Path); DocumentChanged?.Invoke(d); }
void OnDocumentChanged(DocumentEventArgs e) { DocumentChanged?.Invoke(this, e); }
private void UpdaterDocumentOnTick(object sender, EventArgs eventArgs) { updaterDocument.Stop(); DocumentChanged?.Invoke(this, EventArgs.Empty); }
protected void OnDocumentChanged(EventArgs e) { IsModified = true; DocumentChanged?.Invoke(this, e); }