Example #1
0
		public static void AddTask(string fileName, string message, int column, int line, TaskSeverity taskType)
		{
			// HACK: Use a compiler error since we cannot add an error
			// task otherwise (task type property is read-only and
			// no constructors usable).
			BuildError error = new BuildError ();
			error.Column = column;
			error.Line = line;
			error.ErrorText = message;
			error.FileName = fileName;
			error.IsWarning = false;
			
			//Task task = new Task(fileName, message, column, line);
			Task task = new Task (error);
			TaskService.Errors.Add(task);
		}
		public MessageBubbleTextMarker (TextEditor editor, Task task, LineSegment lineSegment, bool isError, string errorMessage)
		{
			this.editor = editor;
			this.task = task;
			this.IsVisible = true;
			this.lineSegment = lineSegment;
			this.initialText = editor.Document.GetTextAt (lineSegment);
			this.Flags = TextMarkerFlags.DrawsSelection;
			AddError (isError, errorMessage);
			editor.EditorOptionsChanged += HandleEditorEditorOptionsChanged;
			errorPixbuf = ImageService.GetPixbuf (MonoDevelop.Ide.Gui.Stock.Error, Gtk.IconSize.Menu);
			warningPixbuf = ImageService.GetPixbuf (MonoDevelop.Ide.Gui.Stock.Warning, Gtk.IconSize.Menu);
		}
		static TreeIter FindTask (ListStore store, Task task)
		{
			TreeIter iter;
			if (!store.GetIterFirst (out iter))
				return TreeIter.Zero;
			
			do {
				Task t = store.GetValue (iter, (int)Columns.Task) as Task;
				if (t == task)
					return iter;
			}
			while (store.IterNext (ref iter));
			
			return TreeIter.Zero;
		}
		void RemoveGeneratedTask (Task t)
		{
			TreeIter iter = FindTask (store, t);
			if (!iter.Equals (TreeIter.Zero))
				store.Remove (ref iter);
		}
		void NewUserTaskClicked (object obj, EventArgs e)
		{
			Task task = new Task ();
			task.WorkspaceObject = IdeApp.ProjectOperations.CurrentSelectedWorkspaceItem;
			updating = true;
			TaskService.UserTasks.Add (task);
			updating = false;
			TreeIter iter = store.AppendValues (GettextCatalog.GetString (Enum.GetName (typeof (TaskPriority), task.Priority)), task.Completed, task.Description, task, GetColorByPriority (task.Priority), task.Completed ? (int)Pango.Weight.Light : (int)Pango.Weight.Bold);
			view.Selection.SelectIter (iter);
			TreePath path = store.GetPath (iter);
			view.ScrollToCell (path, view.Columns[(int)Columns.Description], true, 0, 0);
			view.SetCursorOnCell (path, view.Columns[(int)Columns.Description], cellRendDesc, true);
			TaskService.SaveUserTasks (task.WorkspaceObject);
		}
		public void AddError (Task task, bool isError, string errorMessage)
		{
			var match = mcsErrorFormat.Match (errorMessage);
			if (match.Success)
				errorMessage = match.Groups [1].Value;
			errors.Add (new ErrorText (task, isError, errorMessage));
			DisposeLayout ();
		}
Example #7
0
		void AddTaskInternal (Task t)
		{
			if (tasks.Contains (t)) return;
			
			Gdk.Pixbuf stock;
			
			switch (t.Severity) {
				case TaskSeverity.Error:
					stock = iconError;
					errorCount++;
					UpdateErrorsNum ();
					break; 
				case TaskSeverity.Warning:
					stock = iconWarning;
					warningCount++;
					UpdateWarningsNum ();	
					break;
				default:
					stock = iconInfo;
					infoCount++;
					UpdateMessagesNum ();
					break;
			}
			
			tasks [t] = t;
			
			store.AppendValues (stock, false, t);
		}
Example #8
0
		static void SetText (CellRendererText textRenderer, TreeModel model, TreeIter iter, Task task, string text)
		{
			textRenderer.Text = text;
			textRenderer.Weight = (int)((bool)model.GetValue (iter, DataColumns.Read) ? Pango.Weight.Normal : Pango.Weight.Bold);
			textRenderer.Strikethrough = task.Completed;
		}
		internal MessageBubbleTextMarker (MessageBubbleCache cache, Task task, LineSegment lineSegment, bool isError, string errorMessage)
		{
			this.cache = cache;
			this.task = task;
			this.IsVisible = true;
			this.lineSegment = lineSegment;
			this.initialText = editor.Document.GetTextAt (lineSegment);
			this.Flags = TextMarkerFlags.DrawsSelection;
			AddError (isError, errorMessage);
//			cache.Changed += (sender, e) => CalculateLineFit (editor, lineSegment);
		}
		public ErrorText (Task task, bool isError, string errorMessage)
		{
			this.Task = task;
			this.IsError = isError;
			this.ErrorMessage = errorMessage;
		}
		void SignPackageDone (IProgressMonitor monitor, BuildResult result)
		{
			monitor.EndTask ();
			
			if (result != null && result.Errors.Count > 0) {
				var tasks = new Task [result.Errors.Count];
				for (int n = 0; n < tasks.Length; n++) {
					tasks [n] = new Task (result.Errors [n], this);
				}
				TaskService.Errors.AddRange (tasks);
				TaskService.ShowErrors ();
			}
			
			monitor.Dispose ();
		}
    /// <summary>
    /// Called when a violation is found.
    /// </summary>
    /// <param name="sender">The event sender.</param>
    /// <param name="e">The event arguments.</param>
    internal static void StyleCopCoreViolationEncountered(object sender, ViolationEventArgs e)
    {
      Param.Ignore(sender, e);

      // Check the violation count. At some point we don't allow any more violations so we cancel the analyze run.
      if (e.SourceCode.Project.MaxViolationCount > 0 && styleCopAnalysisResultList.Count == e.SourceCode.Project.MaxViolationCount)
      {
        IdeApp.ProjectOperations.CancelStyleCopAnalysis();
      }

      string trimmedNamespace = e.Violation.Rule.Namespace;
      string searchValue = global::StyleCop.Constants.ProductName + ".";

      int indexOfProductName = trimmedNamespace.IndexOf(searchValue, StringComparison.Ordinal);
      if (indexOfProductName != -1 && indexOfProductName < trimmedNamespace.Length - 1)
      {
        trimmedNamespace = trimmedNamespace.Substring(indexOfProductName + searchValue.Length);

        int indexOfRulesString = trimmedNamespace.LastIndexOf("Rules", StringComparison.Ordinal);
        trimmedNamespace = indexOfRulesString != -1 ? trimmedNamespace.Substring(0, indexOfRulesString) : trimmedNamespace;
      }
      else
      {
        trimmedNamespace = string.Empty;
      }

      string fileName = string.Empty;
      if (e.Element != null)
      {
        fileName = e.Element.Document.SourceCode.Path;
      }
      else
      {
        if (e.SourceCode != null)
        {
          fileName = e.SourceCode.Path;
        }
      }

      TaskSeverity severity = TaskSeverity.Error;
      if (e.Warning || !e.SourceCode.Project.ViolationsAsErrors)
      {
        severity = TaskSeverity.Warning;
      }

      Task styleCopWarning = new Task(
                               fileName,
                               string.Concat(e.Violation.Rule.CheckId, " : ", trimmedNamespace, " : ", e.Message),
                               e.Location != null ? e.Location.Value.StartPoint.IndexOnLine : 1,
                               e.LineNumber,
                               severity,
                               TaskPriority.Normal,
                               ProjectUtilities.Instance.CachedProjects.GetProjectForFile(fileName),
                               ProjectOperationsExtensions.ownerObject);

      styleCopAnalysisResultList.Add(styleCopWarning);
    }
Example #13
0
		void AddTaskInternal (Task t)
		{
			if (tasks.Contains (t)) return;
			
			Xwt.Drawing.Image stock;
			
			switch (t.Severity) {
				case TaskSeverity.Error:
					stock = iconError;
					errorCount++;
					UpdateErrorsNum ();
					break; 
				case TaskSeverity.Warning:
					stock = iconWarning;
					warningCount++;
					UpdateWarningsNum ();	
					break;
				default:
					stock = iconInfo;
					infoCount++;
					UpdateMessagesNum ();
					break;
			}
			
			tasks [t] = t;

			var indexOfNewLine = t.Description.IndexOfAny (new [] { '\n', '\r' });
			if (indexOfNewLine != -1) {
				var iter = store.AppendValues (stock, false, t, t.Description.Remove (indexOfNewLine));
				store.AppendValues (iter, iconEmpty, false, null, t.Description);
			} else {
				store.AppendValues (stock, false, t, t.Description);
			}

			UpdatePadIcon ();
		}
        /// <summary>
        /// Reports violations encountered by stylecop to the error pad
        /// </summary>
        /// <param name="sender">
        /// A <see cref="System.Object"/> determining which object sends this violation
        /// </param>
        /// <param name="args">
        /// A <see cref="ViolationEventArgs"/> determining elements composing the violation
        /// </param>
        private void OnViolationEncountered(object sender, ViolationEventArgs args)
        {
            try
            {
            MonoDevelop.Projects.BuildError b = new MonoDevelop.Projects.BuildError(args.Element.Document.SourceCode.Path, args.LineNumber, 0, args.Violation.Rule.CheckId, args.Message);
            b.IsWarning = args.Warning;
            Task errorTask = new Task(b, RunStyleCopHandler.styleCopAddinOwner);

            this.errorPad.AddTask(errorTask);
            }
            catch (Exception e)
            {
                this.logger.WriteLine("Error: {0}\nStackTrace:{1}", e.Message, e.StackTrace);
            }
        }
Example #15
0
		static string GetPath (Task task)
		{
			if (task.WorkspaceObject != null)
				return FileService.AbsoluteToRelativePath (task.WorkspaceObject.BaseDirectory, task.FileName);
			
			return task.FileName;
		}
Example #16
0
		/// <summary>
		/// Shows a description of the task in the status bar
		/// </summary>
		public static void ShowStatus (Task t)
		{
			if (t == null)
				IdeApp.Workbench.StatusBar.ShowMessage (GettextCatalog.GetString ("No more errors or warnings"));
			else if (t.Severity == TaskSeverity.Error)
				IdeApp.Workbench.StatusBar.ShowError (t.Description);
			else if (t.Severity == TaskSeverity.Warning)
				IdeApp.Workbench.StatusBar.ShowWarning (t.Description);
			else
				IdeApp.Workbench.StatusBar.ShowMessage (t.Description);
		}
Example #17
0
		static string GetProject (Task task)
		{
			return (task != null && task.WorkspaceObject is SolutionItem)? task.WorkspaceObject.Name: string.Empty;
		}
Example #18
0
		internal static void InformJumpToTask (Task task)
		{
			EventHandler<TaskEventArgs> handler = JumpedToTask;
			if (handler != null)
				handler (null, new TaskEventArgs (task));
		}
Example #19
0
		public void AddTask (Task t)
		{
			AddTaskInternal (t);
			filter.Refilter ();
		}
		void UpdateCommentTags (Solution wob, FilePath fileName, IEnumerable<Tag> tagComments)
		{
			if (fileName == FilePath.Null)
				return;
			
			fileName = fileName.FullPath;
			
			List<Task> newTasks = new List<Task> ();
			if (tagComments != null) {  
				foreach (Tag tag in tagComments) {
					if (!priorities.ContainsKey (tag.Key))
						continue;
					
					//prepend the tag if it's not already there
					string desc = tag.Text.Trim ();
					if (!desc.StartsWith (tag.Key)) {
						if (desc.StartsWith (":"))
							desc = tag.Key + desc;
						else if (tag.Key.EndsWith (":"))
							desc = tag.Key + " " + desc;
						else
							desc = tag.Key + ": " + desc;
					}
					
					Task t = new Task (fileName, desc, tag.Region.Start.Column, tag.Region.Start.Line,
					                   TaskSeverity.Information, priorities[tag.Key], wob);
					newTasks.Add (t);
				}
			}
			
			List<Task> oldTasks = new List<Task> (comments.GetFileTasks (fileName));

			for (int i = 0; i < newTasks.Count; ++i) {
				for (int j = 0; j < oldTasks.Count; ++j) {
					if (oldTasks[j] != null &&
					    newTasks[i].Line == oldTasks[j].Line &&
					    newTasks[i].Column == oldTasks[j].Column &&
					    newTasks[i].Description == oldTasks[j].Description &&
					    newTasks[i].Priority == oldTasks[j].Priority)
					{
						newTasks.RemoveAt (i);
						oldTasks.RemoveAt (j);
						i--;
						break;
					}
				}
			}
			
			comments.BeginTaskUpdates ();
			try {
				comments.AddRange (newTasks);
				comments.RemoveRange (oldTasks);
			} finally {
				comments.EndTaskUpdates ();
			}
		}
		internal MessageBubbleTextMarker (MessageBubbleCache cache, Task task, DocumentLine lineSegment, bool isError, string errorMessage)
		{
			if (cache == null)
				throw new ArgumentNullException ("cache");
			this.cache = cache;
			this.task = task;
			this.IsVisible = true;
			this.lineSegment = lineSegment;
			this.initialText = editor.Document.GetTextAt (lineSegment);
			this.isError = isError;
			AddError (task, isError, errorMessage);
//			cache.Changed += (sender, e) => CalculateLineFit (editor, lineSegment);
		}
		void AddGeneratedTask (Task t)
		{
			FilePath tmpPath = t.FileName;
			if (t.WorkspaceObject != null)
				tmpPath = tmpPath.ToRelative (t.WorkspaceObject.BaseDirectory);

			store.AppendValues (t.Line, t.Description, tmpPath.FileName, tmpPath.ParentDirectory.FileName, t, GetColorByPriority (t.Priority), (int)Pango.Weight.Bold);
		}
Example #23
0
		void BuildDone (IProgressMonitor monitor, BuildResult result, IBuildTarget entry, ITimeTracker tt)
		{
			Task[] tasks = null;
			tt.Trace ("Begin reporting build result");
			try {
				if (result != null) {
					lastResult = result;
					monitor.Log.WriteLine ();
					monitor.Log.WriteLine (GettextCatalog.GetString ("---------------------- Done ----------------------"));
					
					tt.Trace ("Updating task service");
					tasks = new Task [result.Errors.Count];
					for (int n=0; n<tasks.Length; n++) {
						tasks [n] = new Task (result.Errors [n]);
						tasks [n].Owner = this;
					}

					TaskService.Errors.AddRange (tasks);
					TaskService.Errors.ResetLocationList ();
					IdeApp.Workbench.ActiveLocationList = TaskService.Errors;
					
					tt.Trace ("Reporting result");
					
					string errorString = GettextCatalog.GetPluralString("{0} error", "{0} errors", result.ErrorCount, result.ErrorCount);
					string warningString = GettextCatalog.GetPluralString("{0} warning", "{0} warnings", result.WarningCount, result.WarningCount);

					if (result.ErrorCount == 0 && result.WarningCount == 0 && lastResult.FailedBuildCount == 0) {
						monitor.ReportSuccess (GettextCatalog.GetString ("Build successful."));
					} else if (result.ErrorCount == 0 && result.WarningCount > 0) {
						monitor.ReportWarning(GettextCatalog.GetString("Build: ") + errorString + ", " + warningString);
					} else if (result.ErrorCount > 0) {
						monitor.ReportError(GettextCatalog.GetString("Build: ") + errorString + ", " + warningString, null);
					} else {
						monitor.ReportError(GettextCatalog.GetString("Build failed."), null);
					}
					tt.Trace ("End build event");
					OnEndBuild (monitor, lastResult.FailedBuildCount == 0, lastResult, entry as SolutionItem);
				} else {
					tt.Trace ("End build event");
					OnEndBuild (monitor, false);
				}
				
				tt.Trace ("Showing results pad");
				
				try {
					Pad errorsPad = IdeApp.Workbench.GetPad<MonoDevelop.Ide.Gui.Pads.ErrorListPad> ();
					switch (IdeApp.Preferences.ShowErrorPadAfterBuild) {
					case BuildResultStates.Always:
						if (!errorsPad.Visible)
							errorsPad.IsOpenedAutomatically = true;
						errorsPad.Visible = true;
						errorsPad.BringToFront ();
						break;
					case BuildResultStates.Never:
						break;
					case BuildResultStates.OnErrors:
						if (TaskService.Errors.Any (task => task.Severity == TaskSeverity.Error))
							goto case BuildResultStates.Always;
						goto case BuildResultStates.Never;
					case BuildResultStates.OnErrorsOrWarnings:
						if (TaskService.Errors.Any (task => task.Severity == TaskSeverity.Error || task.Severity == TaskSeverity.Warning))
							goto case BuildResultStates.Always;
						goto case BuildResultStates.Never;
					}
				} catch {}
				
				if (tasks != null) {
					Task jumpTask = null;
					switch (IdeApp.Preferences.JumpToFirstErrorOrWarning) {
					case JumpToFirst.Error:
						jumpTask = tasks.FirstOrDefault (t => t.Severity == TaskSeverity.Error && TaskStore.IsProjectTaskFile (t));
						break;
					case JumpToFirst.ErrorOrWarning:
						jumpTask = tasks.FirstOrDefault (t => (t.Severity == TaskSeverity.Error || t.Severity == TaskSeverity.Warning) && TaskStore.IsProjectTaskFile (t));
						break;
					}
					if (jumpTask != null) {
						tt.Trace ("Jumping to first result position");
						jumpTask.JumpToPosition ();
					}
				}
				
			} finally {
				monitor.Dispose ();
				tt.End ();
			}
		}
Example #24
0
		/// <summary>
		/// Adds a violation to GUI (currently, Task View)
		/// </summary>
		private static void AddViolation (IViolation v)
		{
			// TODO: replace Task View with our own GUI			
			TaskSeverity type = TaskSeverity.Warning;
			
			if ((v.Severity == Severity.Critical || v.Severity == Severity.High)
			    && (v.Confidence == Confidence.Total || v.Confidence == Confidence.High))
				type = TaskSeverity.Error;
			
			string text = v.Problem + Environment.NewLine + v.Solution;

			// TODO: handle Location
			Task task = new Task (v.Location.File, text, v.Location.Column, v.Location.Line, type, TaskPriority.Normal, MainAnalyzer.CurrentProject);
			TaskService.Errors.Add (task);				  
		}