Ejemplo n.º 1
0
		async Task UpdateQuickTasks (DocumentContext ctx, ParsedDocument doc, CancellationToken token)
		{
			if (isDisposed)
				return;
			var newTasks = ImmutableArray<QuickTask>.Empty.ToBuilder ();
			if (doc != null) {
				foreach (var cmt in await doc.GetTagCommentsAsync(token).ConfigureAwait (false)) {
					if (token.IsCancellationRequested)
						return;
					int offset;
					try {
						offset = textEditor.LocationToOffset (cmt.Region.Begin.Line, cmt.Region.Begin.Column);
					} catch (Exception) {
						return;
					}
					var newTask = new QuickTask (cmt.Text, offset, DiagnosticSeverity.Info);
					newTasks.Add (newTask);
				}

				foreach (var error in await doc.GetErrorsAsync(token).ConfigureAwait (false)) {
					if (token.IsCancellationRequested)
						return;
					if (ctx.IsAdHocProject && !lexicalError.Contains (error.Id))
						continue;
					int offset;
					try {
						offset = textEditor.LocationToOffset (error.Region.Begin.Line, error.Region.Begin.Column);
					} catch (Exception) {
						return;
					}
					var newTask = new QuickTask (error.Message, offset, error.ErrorType == MonoDevelop.Ide.TypeSystem.ErrorType.Error ? DiagnosticSeverity.Error : DiagnosticSeverity.Warning);
					newTasks.Add (newTask);
				}
			}
			if (token.IsCancellationRequested)
				return;
			Application.Invoke (delegate {
				if (token.IsCancellationRequested || isDisposed)
					return;
				tasks = newTasks.ToImmutable ();
				OnTasksUpdated (EventArgs.Empty);
			});
		}