예제 #1
0
        public void AddError(DiagnosticBase diagnostic, TextSpan span)
        {
            lock (_lockObject)
            {
                if (_disposed)
                    return;

                var sourceText = span.SourceText as VisualStudioSourceText;
                if (sourceText == null)
                    return;

                var line = sourceText.Snapshot.GetLineFromPosition(span.Start);

                var task = new ErrorTask
                {
                    Text = diagnostic.Message,
                    Line = line.LineNumber,
                    Column = span.Start - line.Start.Position,
                    Category = TaskCategory.CodeSense,
                    ErrorCategory = (diagnostic.Severity == DiagnosticSeverity.Error)
                        ? TaskErrorCategory.Error
                        : TaskErrorCategory.Warning,
                    Priority = TaskPriority.Normal,
                    Document = span.Filename ?? _textDocument.FilePath
                };

                task.Navigate += OnTaskNavigate;

                _errorListProvider.Tasks.Add(task);
            }
        }
예제 #2
0
파일: ErrorList.cs 프로젝트: saaadhu/naggy
        public static void Show(Diagnostic diag)
        {
            var task = new ErrorTask
                           {
                               Text = string.Format(@"[N] {0,4} : {1}", diag.ID, diag.Message),
                               Category = TaskCategory.CodeSense,
                               ErrorCategory =
                                   diag.Level == DiagnosticLevel.Warning
                                       ? TaskErrorCategory.Warning
                                       : TaskErrorCategory.Error,
                               Column = diag.StartColumn,
                               Line = diag.StartLine - 1,
                               Document = diag.FilePath,
                               HierarchyItem = (IVsHierarchy)(AVRStudio.GetProjectItem(dte, diag.FilePath).ContainingProject != null ? AVRStudio.GetProjectItem(dte, diag.FilePath).ContainingProject.Object : null),
                           };

            task.Navigate += (sender, args) =>
                                 {
                                     task.Line++;
                                     errorListProvider.Navigate(task, Guid.Parse(EnvDTE.Constants.vsViewKindCode));
                                     task.Line--;
                                 };

            errorListProvider.Tasks.Add(task);
        }
예제 #3
0
        private void CreateErrors()
        {
            var errors = errorListProvider.GetErrors(textView.TextBuffer);

            // Check if we should update the error list based on the error count to avoid refreshing the list without changes
            if (errors.Count != this.previousErrors.Count)
            {
                // remove any previously created errors to get a clean start
                ClearErrors();

                foreach (ValidationError error in errors)
                {
                    // creates the instance that will be added to the Error List
                    ErrorTask task = new ErrorTask();
                    task.Category = TaskCategory.All;
                    task.Priority = TaskPriority.Normal;
                    task.Document = textView.TextBuffer.Properties.GetProperty<ITextDocument>(typeof(ITextDocument)).FilePath;
                    task.ErrorCategory = TranslateErrorCategory(error.Severity);
                    task.Text = error.Description;
                    task.Line = textView.TextSnapshot.GetLineNumberFromPosition(error.Span.Start);
                    task.Column = error.Span.Start - textView.TextSnapshot.GetLineFromLineNumber(task.Line).Start;
                    task.Navigate += OnTaskNavigate;
                    errorList.Tasks.Add(task);
                    previousErrors.Add(task);

                    ITrackingSpan span = textView.TextSnapshot.CreateTrackingSpan(error.Span, SpanTrackingMode.EdgeNegative);
                    squiggleTagger.CreateTagSpan(span, new ErrorTag("syntax error", error.Description));
                    previousSquiggles.Add(new TrackingTagSpan<IErrorTag>(span, new ErrorTag("syntax error", error.Description)));
                }
            }
        }
        public void AddError(Project project, string path, string errorText, TaskErrorCategory category, int iLine, int iColumn)
        {
            ErrorTask task;
              IVsSolution solution;
              IVsHierarchy hierarchy;

              if (project != null)
              {
              try
              {
              solution = (IVsSolution)GetService(typeof(IVsSolution));
              ErrorHandler.ThrowOnFailure(solution.GetProjectOfUniqueName(project.UniqueName, out hierarchy));

              task = new ErrorTask();
              task.ErrorCategory = category;
              task.HierarchyItem = hierarchy;
              task.Document = path;

              // VS uses indexes starting at 0 while the automation model uses indexes starting at 1
              task.Line = iLine - 1;
              task.Column = iColumn;
              task.Text = errorText;
              task.Navigate += ErrorTaskNavigate;
              if (ContainsLink(errorText))
              {
                  task.Help += new EventHandler(task_Help);
              }
              _errorListProvider.Tasks.Add(task);
              }
              catch (Exception ex)
              {
              MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
              }
              }
        }
예제 #5
0
 public void LogError(Exception ex)
 {
     ErrorTask task = new ErrorTask(ex);
     task.ErrorCategory = TaskErrorCategory.Error;
     task.Category = TaskCategory.Misc;
     m_errorListPrivider.Tasks.Add(task);
 }
예제 #6
0
        public static void AddHierarchyItem(ErrorTask task, EnvDTE.Project project)
        {
            IVsHierarchy hierarchyItem = null;
            IVsSolution solution = BundlerMinifierPackage.GetGlobalService(typeof(SVsSolution)) as IVsSolution;

            if (solution != null && project != null)
            {
                int flag = -1;

                try
                {
                    flag = solution.GetProjectOfUniqueName(project.FullName, out hierarchyItem);
                }
                catch (COMException ex)
                {
                    if ((uint)ex.ErrorCode != DISP_E_MEMBERNOTFOUND)
                    {
                        throw;
                    }
                }

                if (0 == flag)
                {
                    task.HierarchyItem = hierarchyItem;
                }
            }
        }
예제 #7
0
 public void LogError(string message)
 {
     ErrorTask task = new ErrorTask();
     task.ErrorCategory = TaskErrorCategory.Error;
     task.Text = message;
     task.Category = TaskCategory.Misc;
     m_errorListPrivider.Tasks.Add(task);
 }
        internal SettingsManager(IWpfTextView view, ITextDocument document, ErrorListProvider messageList)
        {
            _view = view;
            _messageList = messageList;
            _message = null;

            LoadSettings(document.FilePath);
        }
예제 #9
0
 public virtual void ShowError(string error)
 {
     var errorTask = new ErrorTask
                         {
                             Category = TaskCategory.Misc,
                             Text = error,
                             CanDelete = true,
                         };
     errorProvider.Tasks.Add(errorTask);
 }
예제 #10
0
파일: TaskList.cs 프로젝트: cbilson/chirpy
 public void Add(Project project, TaskErrorCategory category, string file, int line, int column, string description)
 {
     var task = new ErrorTask
     {
         ErrorCategory = category,
         Document = file,
         Line = Math.Max(line - 1, 0),
         Column = Math.Max(column - 1, 0),
         Text = description,
     };
     this.Add(project, task);
 }
예제 #11
0
        public Plugin(IWpfTextView view, ITextDocument document, DTE dte, ErrorListProvider messageList)
        {
            this.view = view;
            this.dte = dte;
            this.messageList = messageList;
            this.message = null;

            document.FileActionOccurred += FileActionOccurred;
            view.GotAggregateFocus += GotAggregateFocus;
            view.Closed += Closed;

            LoadSettings(document.FilePath);
        }
예제 #12
0
        /// <summary>
        /// Adds a message of the given document to the error list.
        /// </summary>
        public void AddMessage(string message, string document, ErrorCategory errorCategory)
        {
            var errorTask = new ErrorTask
                {
                    ErrorCategory = (TaskErrorCategory)errorCategory,
                    Text = message,
                    Document = document,
                };

            this.ErrorListProvider.Tasks.Add(errorTask);
            this.ErrorListProvider.Show();
            this.ErrorListProvider.BringToFront();
        }
예제 #13
0
 /// <summary>
 /// Creates task from occurence
 /// </summary>
 /// <param name="occurence"> occurence of defect</param>
 /// <param name="fileName">file name of occurence</param>
 /// <returns></returns>
 Task CreateTask(Occurence occurence, string fileName)
 {
     var defectTask = new ErrorTask()
     {
         Category = TaskCategory.User,
         ErrorCategory = TaskErrorCategory.Warning,
         CanDelete = false,
         Text = occurence.Message,
         Document = fileName,
         Line = int.Parse(occurence.StartLine)
     };
     defectTask.Navigate += navigateEventHandler;
     return defectTask;
 }
        public void Can_add_clear_error_list_tasks()
        {
            var mockServiceProvider = new Mock<IServiceProvider>();
            mockServiceProvider.Setup(p => p.GetService(typeof(SVsTaskList))).Returns(new Mock<IVsTaskList>().Object);

            var task = new ErrorTask();
            var errorList = new DesignerErrorList(mockServiceProvider.Object);

            Assert.Empty(errorList.Provider.Tasks);
            errorList.AddItem(task);
            Assert.Equal(new[] { task }, errorList.Provider.Tasks.Cast<ErrorTask>());
            errorList.Clear();
            Assert.Empty(errorList.Provider.Tasks);
        }
        /// <summary>
        /// Adds an error message to the Visual Studio tasks pane
        /// </summary>
        private void ShowError(string path, string text)
        {
            _message = new ErrorTask
            {
                ErrorCategory = TaskErrorCategory.Error,
                Category = TaskCategory.Comments,
                Document = path,
                Line = 0,
                Column = 0,
                Text = text
            };

            _messageList.Tasks.Add(_message);
            _messageList.Show();
        }
        public void AddHierarchyItem(ErrorTask task)
        {
            IVsHierarchy HierarchyItem;
            IVsSolution solution = EditorExtensionsPackage.GetGlobalService<IVsSolution>(typeof(SVsSolution));

            if (solution != null)
            {
                int flag = solution.GetProjectOfUniqueName(_connection.Project.FullName, out HierarchyItem);

                if (0 == flag)
                {
                    task.HierarchyItem = HierarchyItem;
                }
            }
        }
        public static Task ProduceErrorListTask(this IStylingRule rule, TaskErrorCategory category, Project project, string format)
        {
            var item = ResolveVsHierarchyItem(project.UniqueName);

            var task = new ErrorTask
            {
                Document = rule.File,
                Line = rule.Line - 1,
                Column = rule.Column,
                ErrorCategory = category,
                Category = TaskCategory.Html,
                Text = string.Format(format, project.Name, rule.DisplaySelectorName, rule.File, rule.Line, rule.Column),
                HierarchyItem = item
            };

            task.Navigate += NavigateToItem;
            return task;
        }
 public static ErrorTask add_Task(this ErrorListProvider errorListProvider, TaskErrorCategory errorCategory, string text, string file = null, int line = 1, int column= 1)
 {
     var errorTask = new ErrorTask()
     {
         ErrorCategory = errorCategory,
         Category = TaskCategory.BuildCompile,
         Text = text,
         Document 	 = file, 
         Line = line -1,
         Column = column -1,
         //HierarchyItem = hierarchyItem			
     };
     errorListProvider.Tasks.Add(errorTask);
     errorTask.Navigate += (sender,e)=> {
     										file.open_Document();
     										(VisualStudio_2010.DTE2.ActiveDocument.Selection as EnvDTE.TextSelection).GotoLine(line, true);
     									};
     return errorTask;
 }
예제 #19
0
        public Plugin(IWpfTextView view, ITextDocument document, DTE dte,
            ErrorListProvider messageList, IViewSettingsContainer viewSettingsContainer)
        {
            this.view = view;
            this.document = document;
            this.dte = dte;
            this.messageList = messageList;
            this.message = null;
            this.viewSettingsContainer = viewSettingsContainer;

            document.FileActionOccurred += FileActionOccurred;
            view.GotAggregateFocus += GotAggregateFocus;
            view.Closed += Closed;

            documentPath = document.FilePath;

            LoadSettings(documentPath);
            viewSettingsContainer.Register(documentPath, view, settings);
        }
예제 #20
0
        private IEnumerable<IGooseErrorTask> BuildErrorTask(ShellCommand command, string content)
        {
            var output = this.logParser.Parse(content);

            return output.Results
                         .Where(error => error.Type.Equals(CommandOutputItemType.Error))
                         .Select(error =>
                             {
                                 var errorTask = new ErrorTask
                                     {
                                         CanDelete = true,
                                         Column = 0,
                                         Line = (int) error.Line,
                                         Document = error.FullPath,
                                         Text = string.Format("{0}{1}{2}", error.Message, Environment.NewLine, error.Excerpt)
                                     };
                                 return new GooseErrorTask(command, errorTask);
                             });
        }
예제 #21
0
        public void AddError(ITextSnapshot snapshot, Diagnostic diagnostic, TextSpan span)
        {
            var line = snapshot.GetLineFromPosition(span.Start);

            var task = new ErrorTask
            {
                Text = diagnostic.Message,
                Line = line.LineNumber,
                Column = span.Start - line.Start.Position,
                Category = TaskCategory.CodeSense,
                ErrorCategory = TaskErrorCategory.Error,
                Priority = TaskPriority.Normal,
                Document = span.Filename
            };

            task.Navigate += OnTaskNavigate;

            _errorListProvider.Tasks.Add(task);
        }
예제 #22
0
    public void Write(TaskCategory category, TaskErrorCategory errorCategory, string text, string document, int? line = null, int? column = null)
    {
      ErrorTask task = new ErrorTask();
      task.Text = text;
      task.ErrorCategory = errorCategory;

      int? startLine, startColumn, endLine, endColumn;
      ParseErrorLocation(text, out startLine, out startColumn, out endLine, out endColumn);

      task.Line = (line ?? startLine ?? 1) - 1;
      task.Column = (column ?? startColumn ?? 1) - 1;
      task.Document = document;
      task.Category = category;

      if (!string.IsNullOrEmpty(document))
      {
        task.Navigate += NavigateDocument;
      }
      _errorListProvider.Tasks.Add(task);
    }
예제 #23
0
        private static void AddHierarchyItem(ErrorTask task, EnvDTE.Project project)
        {
            IVsSolution solution = Package.GetGlobalService(typeof(SVsSolution)) as IVsSolution;

            if (solution == null || project == null)
                return;

            try
            {
                IVsHierarchy hierarchyItem = null;
                if (solution.GetProjectOfUniqueName(project.FullName, out hierarchyItem) == 0)
                {
                    task.HierarchyItem = hierarchyItem;
                }
            }
            catch (COMException ex)
            {
                Logger.Log(ex);
            }
        }
예제 #24
0
파일: ErrorsManager.cs 프로젝트: joj/clide
        private IErrorItem Add(string text, Action<IErrorItem> handler, bool isWarning)
        {
            var errorTask = new ErrorTask();

            errorTask.Category = TaskCategory.Misc;
            errorTask.ErrorCategory = isWarning ? TaskErrorCategory.Warning : TaskErrorCategory.Error;
            errorTask.Text = text;

            var errorItem = new ErrorItem(this.errorListProvider, errorTask);

            errorTask.Navigate += (sender, e) =>
            {
                if (handler != null)
                    handler(errorItem);
            };

            this.errorListProvider.Tasks.Add(errorTask);

            return errorItem;
        }
        private void AddErrorToErrorList(
            //Project objProject
            //, ProjectItem objProjectItem
            //,
            string sErrorText
            , TaskErrorCategory eTaskErrorCategory
            , int iLine
            , int iColumn)
        {
            ErrorTask objErrorTask;

            //Microsoft.VisualStudio.Shell.Interop.IVsSolution objIVsSolution;
            //IVsHierarchy objVsHierarchy = null;

            try
            {
                //objIVsSolution = DirectCast(GetService(GetType(IVsSolution)), IVsSolution)

                //ErrorHandler.ThrowOnFailure(objIVsSolution.GetProjectOfUniqueName(objProject.UniqueName, objVsHierarchy))

                objErrorTask = new Microsoft.VisualStudio.Shell.ErrorTask();
                objErrorTask.ErrorCategory = eTaskErrorCategory;
                //objErrorTask.HierarchyItem = null;// objVsHierarchy;
                //objErrorTask.Document = objProjectItem.FileNames[0];
                //' VS uses indexes starting at 0 while the automation model uses indexes starting at 1
                objErrorTask.Line   = iLine - 1;
                objErrorTask.Column = iColumn;

                objErrorTask.Text = sErrorText;
                //AddHandler objErrorTask.Navigate, AddressOf ErrorTaskNavigate

                m_colErrorTasks.Add(objErrorTask);

                m_objErrorListProvider.Tasks.Add(objErrorTask);
            }
            catch (Exception objException)
            {
                MessageBox.Show(objException.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
예제 #26
0
        public void Log(Hint hint)
        {
            if (!tasksDictionary.ContainsKey(hint.Filename))
            {
                tasksDictionary.Add(hint.Filename, new List<ErrorTask>());
            }
            var tasks = tasksDictionary[hint.Filename];

            ErrorTask task = new ErrorTask
            {
                Document = hint.Filename,
                Line = hint.LineNumber - 1,
                Column = hint.ColumnNumber - 1,
                Text = hint.Message,
                ErrorCategory = TaskErrorCategory.Message,
                Category = TaskCategory.BuildCompile
            };
            task.Navigate += NavigateText;

            elp.Tasks.Add(task);
            tasks.Add(task);
        }
예제 #27
0
        /// <summary>
        /// Updates the error task list window with all the errors from the closure
        /// compiler.
        /// </summary>
        /// <param name="errors"></param>
        /// 
        public void AddErrors(List<jsCompiler.Core.Error> errors)
        {
            ErrorTask task = null;
            foreach (jsCompiler.Core.Error error in errors)
            {
                task = new ErrorTask();
                task.ErrorCategory = TaskErrorCategory.Error;
                task.Document = error.File;

                // The error list control uses 0 base, so we have to subtract one from
                // the actual values from the compiler
                task.Column = error.CharNo - 1;
                task.Line = error.LineNo - 1;
                task.Text = error.Description;
                task.Priority = TaskPriority.High;

                if ( task.Document != null )
                    task.Navigate += new EventHandler(error_Navigate);

                _ErrorListProvider.Tasks.Add(task);
            }

            _ErrorListProvider.BringToFront();
        }
        public static ErrorTask GetErrorWindowTask(this ISourceMappedItem item, IVsHierarchy hierarchy)
        {
            try
            {
                var task = new ErrorTask
                {
                    CanDelete = true,
                    Column = item.Column,
                    Document = item.Path,
                    ErrorCategory = TaskErrorCategory.Message,
                    Line = item.Line - 1, // Lines are indexed from 1
                    Text = GetErrorTaskMessage(GetName(item.Item), item.Item.RecommendedChanges, item.UnsupportedTargets),
                    HierarchyItem = hierarchy
                };

                task.Navigate += ApiPortVS.SourceMapping.CodeDocumentNavigator.Navigate;

                return task;
            }
            catch
            {
                return null;
            }
        }
예제 #29
0
        public void InternalReportErrorWarning(bool isError, string msg, string file, int column, int line)
        {
            var errorTask = new ErrorTask();
            errorTask.CanDelete = false;

            errorTask.ErrorCategory = isError ? TaskErrorCategory.Error : TaskErrorCategory.Warning;
            errorTask.Text = msg;
            errorTask.Document = file;
            errorTask.Line = line;
            errorTask.Column = column;
            errorTask.Navigate += new EventHandler(errorTask_Navigate);
            _taskProvider.Tasks.Add(errorTask);

            _taskProvider.Show();

            var taskList = serviceProvider.GetService(typeof(SVsTaskList))
                as IVsTaskList2;
            if (taskList == null)
            {
                return;
            }
            var guidProvider = typeof(SharpBuildTaskProvider).GUID;
            taskList.SetActiveProvider(ref guidProvider);
        }
예제 #30
0
        public void Write(
            TaskCategory category,
            TaskErrorCategory errorCategory,
            string text,
            string document,
            int line,
            int column)
        {
            _errorsSinceSuspend++;

            ErrorTask task = new ErrorTask();
            task.Text = text;
            task.ErrorCategory = errorCategory;
            //The task list does +1 before showing this numbers
            task.Line = line - 1;
            task.Column = column - 1;
            task.Document = document;
            task.Category = category;

            if (!string.IsNullOrEmpty(document))
            {
                //attach to the navigate event
                task.Navigate += NavigateDocument;
            }
            _errorProvider.Tasks.Add(task);
        }
예제 #31
0
 public void Show(Action<ErrorTask> exposer, Action<ErrorTask> navigator)
 {
     task = new ErrorTask
     {
         Document = LexicalInfo.FileName,
         ErrorCategory = ErrorCategory,
         Line = LexicalInfo.Line-1,
         Column = LexicalInfo.Column-1,
         Priority = TaskPriority.High,
         Text = Message,
         HierarchyItem = FileNode,
         Category = TaskCategory.CodeSense
     };
     task.Navigate +=
         (sender, e) =>
             {
                 var errortask = sender as ErrorTask;
                 if (errortask != null)
                     navigator(errortask);
             }
         ;
     exposer(task);
 }
예제 #32
0
        /// <summary>
        /// Adds a Error/Warning/Message to the Error List pane of Visual Studio.
        /// </summary>
        /// <param name="objProject">Project to reference. Can be null.</param>
        /// <param name="fileName">File name to reference. Can be null.</param>
        /// <param name="lineNumber">Line number to reference. Can be null.</param>
        /// <param name="columnNumber">Column number to reference. Can be null.</param>
        /// <param name="category">Category of the message.</param>
        /// <param name="text">Message text.</param>
        public static void AddToErrorList(TaskErrorCategory category, string text,
                                          Project objProject, string fileName, int?lineNumber, int?columnNumber)
        {
            try
            {
                // Create the Error Task
                var objErrorTask = new Microsoft.VisualStudio.Shell.ErrorTask();

                // Set category and text
                objErrorTask.ErrorCategory = category;
                objErrorTask.Text          = text;

                // If Project is not null then get the Hierarchy object to reference
                if (objProject != null)
                {
                    IVsHierarchy objVsHierarchy;

                    ErrorHandler.ThrowOnFailure(
                        VisualStudioHelper._solutionService.GetProjectOfUniqueName(objProject.UniqueName, out objVsHierarchy));

                    // Set HierarchyItem reference
                    objErrorTask.HierarchyItem = objVsHierarchy;

                    // Set Navigate event handler
                    objErrorTask.Navigate += VisualStudioHelper.ErrorTaskNavigate;
                }

                // If fileName is not null or whitespace then set the name of the Document
                if (string.IsNullOrWhiteSpace(fileName) == false)
                {
                    objErrorTask.Document = fileName;

                    // Can be obtained from a ProjectItem instance like shown below:
                    // objProjectItem.FileNames[0];
                }

                // Set Column if columnNumber has value
                if (columnNumber.HasValue)
                {
                    objErrorTask.Column = columnNumber.Value;
                }

                // Set Line if lineNumber has value
                if (lineNumber.HasValue)
                {
                    // VS uses indexes starting at 0 while the automation model uses indexes starting at 1
                    objErrorTask.Line = lineNumber.Value - 1;
                }

                // Add the ErrorTask to our collection
                VisualStudioHelper.ErrorTaskCollection.Add(objErrorTask);

                // Add the ErrorTask to the ErrorList pane of Visual Studio
                VisualStudioHelper._errorListProvider.Tasks.Add(objErrorTask);
            }
            catch (Exception ex)
            {
                // Show error message
                MessageBox.Show(ex.Message, Resources.Error_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }