void OnTodoListUpdated(object sender, TodoItemsUpdatedArgs args) { src.Cancel(); src = new CancellationTokenSource(); var token = src.Token; if (DocumentContext.AnalysisDocument == null || DocumentContext.AnalysisDocument.Id != args.DocumentId) { return; } var ws = args.Workspace as MonoDevelopWorkspace; if (ws == null) { // could be WebEditorRoslynWorkspace return; } var doc = ws.GetDocument(args.DocumentId); if (doc == null) { return; } var project = ws.GetMonoProject(args.ProjectId); if (project == null) { return; } var newTasks = ImmutableArray.CreateBuilder <QuickTask> (args.TodoItems.Length); Runtime.RunInMainThread(() => { foreach (var todoItem in args.TodoItems) { if (token.IsCancellationRequested) { return; } var offset = Editor.LocationToOffset(todoItem.MappedLine + 1, todoItem.MappedColumn + 1); var newTask = new QuickTask(todoItem.Message, offset, DiagnosticSeverity.Info); newTasks.Add(newTask); } if (token.IsCancellationRequested || isDisposed) { return; } tasks = newTasks.MoveToImmutable(); OnTasksUpdated(EventArgs.Empty); }); }
private bool CheckAggregateKey(ImmutableArray <DocumentId> key, TodoItemsUpdatedArgs args) { if (args?.DocumentId == null || args?.Solution == null) { return(true); } var documents = GetDocumentsWithSameFilePath(args.Solution, args.DocumentId); return(key == documents); }
static void OnTodoListUpdated(object sender, TodoItemsUpdatedArgs args) { if (TryCache(args)) { return; } var change = ToCommentTaskChange(args); TaskService.InformCommentTasks(new CommentTasksChangedEventArgs(new [] { change })); }
private bool CheckAggregateKey(ImmutableArray <DocumentId> key, TodoItemsUpdatedArgs args) { if (args?.DocumentId == null || args?.Solution == null) { return(true); } var documents = args.Solution.GetRelatedDocumentIds(args.DocumentId); return(key == documents); }
public static CommentTaskChange ToCommentTaskChange(this TodoItemsUpdatedArgs args) { if (!TryGetDocument(args, out var doc, out var project)) { return(null); } var file = doc.Name; var tags = args.TodoItems.Length == 0 ? (IReadOnlyList <Tag>)null : args.TodoItems.SelectAsArray(x => x.ToTag()); return(new CommentTaskChange(file, tags, project)); }
private void OnTodoListUpdated(object sender, TodoItemsUpdatedArgs e) { if (_workspace != e.Workspace) { return; } Contract.Requires(e.DocumentId != null); if (e.TodoItems.Length == 0) { OnDataRemoved(e); return; } OnDataAddedOrChanged(e); }
static bool TryCache(TodoItemsUpdatedArgs args) { if (cachedUntilViewCreated == null) { return(false); } lock (lockObject) { if (cachedUntilViewCreated == null) { return(false); } cachedUntilViewCreated [args.Id] = args; if (triggerLoad != null) { LoadCachedContents(); } return(true); } }