Exemplo n.º 1
0
        private static void AddTask(Message message, TaskErrorCategory category, string docName)
        {
            if (ErrorListProvider == null)
            {
                return;
            }

            var error = new ErrorTask
            {
                Category      = TaskCategory.CodeSense,
                ErrorCategory = category,
                Text          = message.From.MessageCodeToString(message.Code) +
                                ((!string.IsNullOrWhiteSpace(message.Text)) ? "\"" + message.Text + "\"" : string.Empty) +
                                ((message.AssociatedException != null) ? message.AssociatedException.ToMessageWithType() : string.Empty),

                Column   = message.Position.ColNumber - 1,
                Line     = message.Position.LineNumber - 1,
                Document = docName
            };

            if (message.Token != null)
            {
                error.Column = message.Token.StartPosition.ColNumber - 1;
                error.Line   = message.Token.StartPosition.LineNumber - 1;
            }
            if (docName.IsNotNullOrEmpty())
            {
                error.Navigate += NavigateDocument;
            }

            ErrorListProvider.Tasks.Add(error);
            ErrorListProvider.Show();
        }
        public void Write(
            TaskCategory category,
            TaskErrorCategory errorCategory,
            string context, //used as an indicator when removing
            string text,
            string document,
            int line,
            int column)
        {
            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;
            }
            GetErrorListProvider().Tasks.Add(task);//add it to the errorlistprovider
        }
Exemplo n.º 3
0
        private void AddError(TaskErrorCategory category, string projectFileName, string filePath, string text, int line, int column)
        {
            var          ivsSolution = (IVsSolution)Package.GetGlobalService(typeof(IVsSolution));
            IVsHierarchy hierarchyItem;

            ivsSolution.GetProjectOfUniqueName(projectFileName, out hierarchyItem);

            var error = new ErrorTask();

            error.Line          = line - 1;
            error.Column        = column;
            error.Text          = text;
            error.ErrorCategory = category;
            error.Category      = TaskCategory.BuildCompile;
            error.Document      = filePath;
            error.HierarchyItem = hierarchyItem;

            error.Navigate += (sender, e) =>
            {
                error.Line++;
                ErrorList.Navigate(error, new Guid(EnvDTE.Constants.vsViewKindCode));
                error.Line--;
            };
            ErrorList.Tasks.Add(error);
        }
Exemplo n.º 4
0
 public CompilerMessage(LexicalInfo lexicalInfo, string code, string message, TaskErrorCategory errorCategory)
 {
     LexicalInfo   = lexicalInfo;
     Code          = code;
     Message       = message;
     ErrorCategory = errorCategory;
 }
        internal static ErrorTask CreateErrorTask(
            string document, string errorMessage, TextSpan textSpan, TaskErrorCategory taskErrorCategory, IVsHierarchy hierarchy,
            uint itemID, MARKERTYPE markerType)
        {
            ErrorTask errorTask = null;

            IOleServiceProvider oleSp = null;

            hierarchy.GetSite(out oleSp);
            IServiceProvider sp = new ServiceProvider(oleSp);

            // see if Document is open
            IVsTextLines buffer  = null;
            var          docData = VSHelpers.GetDocData(sp, document);

            if (docData != null)
            {
                buffer = VSHelpers.GetVsTextLinesFromDocData(docData);
            }

            if (buffer != null)
            {
                errorTask = new EFModelDocumentTask(sp, buffer, markerType, textSpan, document, itemID, errorMessage, hierarchy);
                errorTask.ErrorCategory = taskErrorCategory;
            }
            else
            {
                errorTask = new EFModelErrorTask(
                    document, errorMessage, textSpan.iStartLine, textSpan.iEndLine, taskErrorCategory, hierarchy, itemID);
            }

            return(errorTask);
        }
        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);
              }
              }
        }
Exemplo n.º 7
0
 public CompilerMessage(LexicalInfo lexicalInfo, string code, string message, TaskErrorCategory errorCategory)
 {
     LexicalInfo = lexicalInfo;
     Code = code;
     Message = message;
     ErrorCategory = errorCategory;
 }
Exemplo n.º 8
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);
        }
        private void LogErrorTask(IVsHierarchy project, string document, TaskErrorCategory errorCategory, string text)
        {
            var task = new ErrorTask
            {
                Category      = TaskCategory.BuildCompile,
                ErrorCategory = errorCategory,
                Text          = "AutoRunCustomTool: " + text,
                Document      = document,
                HierarchyItem = project,
                Line          = -1,
                Column        = -1
            };

            _errorListProvider.Tasks.Add(task);
            string prefix = "";

            switch (errorCategory)
            {
            case TaskErrorCategory.Error:
                prefix = "Error: ";
                break;

            case TaskErrorCategory.Warning:
                prefix = "Warning: ";
                break;
            }
            _outputPane.OutputString(prefix + text + Environment.NewLine);
        }
Exemplo n.º 10
0
        public void Build()
        {
            var    groups             = mMatchResult.Groups;
            string messageDescription = groups[10].Value;

            if (string.IsNullOrWhiteSpace(messageDescription))
            {
                return;
            }

            string path = groups[1].Value;

            int.TryParse(groups[4].Value, out int line);
            int.TryParse(groups[6].Value, out int column);

            string            categoryAsString = groups[8].Value;
            TaskErrorCategory category         = FindErrorCategory(ref categoryAsString);

            string fullMessage = CreateFullErrorMessage(path, line, categoryAsString, messageDescription);

            // Add clang prefix for error list
            messageDescription = messageDescription.Insert(0, ErrorParserConstants.kClangTag);

            mError = new TaskErrorModel()
            {
                FilePath      = path,
                Line          = line,
                Column        = column,
                Category      = category,
                Description   = messageDescription,
                FullMessage   = fullMessage,
                HierarchyItem = mHierarchy
            };
        }
Exemplo n.º 11
0
        protected XmlModelErrorTask(
            string document, string errorMessage, int lineNumber, int columnNumber, TaskErrorCategory category, IVsHierarchy hierarchy,
            uint itemID)
        {
            ErrorCategory = category;
            HierarchyItem = hierarchy;
            _itemID       = itemID;

            IOleServiceProvider oleSP = null;
            var hr = hierarchy.GetSite(out oleSP);

            if (NativeMethods.Succeeded(hr))
            {
                _serviceProvider = new ServiceProvider(oleSP);
            }

            Debug.Assert(!String.IsNullOrEmpty(document), "document is null or empty");
            Debug.Assert(!String.IsNullOrEmpty(errorMessage), "errorMessage is null or empty");
            Debug.Assert(hierarchy != null, "hierarchy is null");

            Document = document;
            Text     = errorMessage;
            Line     = lineNumber;
            Column   = columnNumber;
        }
        private void LogErrorTask(IVsHierarchy project, string document, TaskErrorCategory errorCategory, string text)
        {
            var task = new ErrorTask
            {
                Category      = TaskCategory.BuildCompile,
                ErrorCategory = errorCategory,
                Text          = $" {DateTime.Now.ToString("M/d/y h:mm:ss.FFF", CultureInfo.InvariantCulture)}] {text}",
                Document      = document,
                HierarchyItem = project,
                Line          = -1,
                Column        = -1
            };

            _errorListProvider.Tasks.Add(task);
            string prefix = "";

            switch (errorCategory)
            {
            case TaskErrorCategory.Error:
                prefix = "[!";
                break;

            case TaskErrorCategory.Warning:
                prefix = "[*: ";
                break;
            }
            _outputPane.OutputString(prefix + text + Environment.NewLine);
        }
Exemplo n.º 13
0
        protected void task(string msg, TaskErrorCategory type = TaskErrorCategory.Message)
        {
            // prevents possible bug from `Process.ErrorDataReceived` because of NLog

#if VSSDK_15_AND_NEW
            ThreadHelper.JoinableTaskFactory.RunAsync(async() =>
            {
                await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken);
#else
            Task.Factory.StartNew(() =>
            {
#endif
                provider.Tasks.Add(new ErrorTask()
                {
                    Text              = msg,
                    Document          = Settings.APP_NAME_SHORT,
                    Category          = TaskCategory.User,
                    Checked           = true,
                    IsCheckedEditable = true,
                    ErrorCategory     = type,
                });

#if VSSDK_15_AND_NEW
            });
#else
            },
                                                      CancellationToken.None,
                                                      TaskCreationOptions.None,
                                                      TaskScheduler.Default);
#endif
        }
Exemplo n.º 14
0
        public static IEnumerable <ErrorReportEntry> GetErrors(ITextBuffer buffer, ITextDocument document)
        {
            var report = GhcMod.GhcMod.Check(document.FilePath).Split(new[] { '\n' }, StringSplitOptions.RemoveEmptyEntries).Select(err => err.Replace('\0', '\n')).ToList();

            foreach (var errorString in report)
            {
                var regex  = new Regex(@"((\w:)?[^:]*):([0-9]*):([0-9]*):(.*)");
                var match  = regex.Match(errorString);
                var path   = match.Groups[1].Value;
                var line   = Int32.Parse(match.Groups[3].Value) - 1;
                var column = Int32.Parse(match.Groups[4].Value) - 1;
                var err    = match.Groups[5].Value;
                TaskErrorCategory severity = TaskErrorCategory.Error;
                if (err.StartsWith("Warning:"))
                {
                    err      = err.Substring("Warning:".Length);
                    severity = TaskErrorCategory.Warning;
                }
                var fullPath = FullPathRelativeTo(Path.GetDirectoryName(document.FilePath), path);
                yield return(new ErrorReportEntry
                {
                    FileName = fullPath,
                    Column = column,
                    Line = line,
                    Message = err,
                    Severity = severity
                });
            }
        }
Exemplo n.º 15
0
 internal EFModelErrorTask(
     string document, string errorMessage, int lineNumber, int columnNumber, TaskErrorCategory category, IVsHierarchy hierarchy,
     uint itemID)
     : base(document, errorMessage, lineNumber, columnNumber, category, hierarchy, itemID)
 {
     Navigate += EFModelErrorTaskNavigator.NavigateTo;
 }
Exemplo n.º 16
0
 internal EFModelErrorTask(
     string document, string errorMessage, int lineNumber, int columnNumber, TaskErrorCategory category, IVsHierarchy hierarchy,
     uint itemID)
     : base(document, errorMessage, lineNumber, columnNumber, category, hierarchy, itemID)
 {
     Navigate += EFModelErrorTaskNavigator.NavigateTo;
 }
Exemplo n.º 17
0
        private static void AddTask(string message, TaskErrorCategory category, string document, int line, int column, string key = null, string project = null)
        {
            IVsHierarchy h = null;

            if (project != null && solutions.GetProjectOfUniqueName(project, out h) == 0)
            {
                ;
            }

            var image = (int)category;
            var err   = new ErrorTask {
                Category      = TaskCategory.BuildCompile,
                ErrorCategory = category,
                Text          = message,
                Document      = document,
                Column        = column,
                Line          = line,
                ImageIndex    = image
            };

            if (key != null)
            {
                err.HelpKeyword = key;
            }
            if (h != null)
            {
                err.HierarchyItem = h;
            }

            /* TODO
             * err.Navigate += (sender, args) => {
             *      var e = (ErrorTask)sender;
             * } */
            provider.Tasks.Add(err);
        }
        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);
                }
            }
        }
        internal static ErrorTask CreateErrorTask(
            string document, string errorMessage, TextSpan textSpan, TaskErrorCategory taskErrorCategory, IVsHierarchy hierarchy,
            uint itemID, MARKERTYPE markerType)
        {
            ErrorTask errorTask = null;

            IOleServiceProvider oleSp = null;
            hierarchy.GetSite(out oleSp);
            IServiceProvider sp = new ServiceProvider(oleSp);

            // see if Document is open
            IVsTextLines buffer = null;
            var docData = VSHelpers.GetDocData(sp, document);
            if (docData != null)
            {
                buffer = VSHelpers.GetVsTextLinesFromDocData(docData);
            }

            if (buffer != null)
            {
                errorTask = new EFModelDocumentTask(sp, buffer, markerType, textSpan, document, itemID, errorMessage, hierarchy);
                errorTask.ErrorCategory = taskErrorCategory;
            }
            else
            {
                errorTask = new EFModelErrorTask(
                    document, errorMessage, textSpan.iStartLine, textSpan.iEndLine, taskErrorCategory, hierarchy, itemID);
            }

            return errorTask;
        }
Exemplo n.º 20
0
 public static void AddTask(string message, TaskErrorCategory category)
 {
     _errorListProvider.Tasks.Add(new ErrorTask
     {
         Category      = TaskCategory.User,
         ErrorCategory = category,
         Text          = message
     });
 }
Exemplo n.º 21
0
 public TaskError(string aFilePath, string aFullMessage,
                  string aMessage, int aLine, TaskErrorCategory aCategory)
 {
     FilePath    = aFilePath;
     FullMessage = aFullMessage;
     Message     = aMessage;
     Line        = aLine;
     Category    = aCategory;
 }
Exemplo n.º 22
0
 public TaskError(string aFilePath, int aLine,
                  TaskErrorCategory aCategory, string aDescription, string aFullMessage)
 {
     FilePath    = aFilePath;
     Line        = aLine;
     Category    = aCategory;
     Description = aDescription;
     FullMessage = aFullMessage;
 }
Exemplo n.º 23
0
 /// <summary>
 /// Initializes a new instance of the <see cref="JSLintErrorTask" /> class.
 /// </summary>
 /// <param name="document">The document.</param>
 /// <param name="jsLintWarning">The JSLint error.</param>
 /// <param name="category">The category.</param>
 /// <param name="hierarchy">The hierarchy.</param>
 public JSLintErrorTask(string document, IJSLintWarning jsLintWarning, TaskErrorCategory category, IVsHierarchy hierarchy)
 {
     this.Document      = document;
     this.Category      = TaskCategory.BuildCompile;
     this.ErrorCategory = category;
     this.Line          = jsLintWarning.Line;
     this.Column        = jsLintWarning.Column;
     this.Text          = GetText(jsLintWarning);
     this.HierarchyItem = hierarchy;
 }
Exemplo n.º 24
0
 /// <summary>
 /// Initializes a new instance of the <see cref="JSLintErrorTask" /> class.
 /// </summary>
 /// <param name="document">The document.</param>
 /// <param name="jsLintError">The JSLint error.</param>
 /// <param name="category">The category.</param>
 /// <param name="hierarchy">The hierarchy.</param>
 public JSLintErrorTask(string document, IJSLintError jsLintError, TaskErrorCategory category, IVsHierarchy hierarchy)
 {
     this.Document = document;
     this.Category = TaskCategory.BuildCompile;
     this.ErrorCategory = category;
     this.Line = jsLintError.Line - 1;
     this.Column = jsLintError.Character - 1;
     this.Text = GetText(jsLintError);
     this.HierarchyItem = hierarchy;
 }
Exemplo n.º 25
0
 /// <summary>
 /// Initializes a new instance of the <see cref="JSLintErrorTask" /> class.
 /// </summary>
 /// <param name="document">The document.</param>
 /// <param name="jsLintError">The JSLint error.</param>
 /// <param name="category">The category.</param>
 /// <param name="hierarchy">The hierarchy.</param>
 public JSLintErrorTask(string document, IJSLintError jsLintError, TaskErrorCategory category, IVsHierarchy hierarchy)
 {
     this.Document      = document;
     this.Category      = TaskCategory.BuildCompile;
     this.ErrorCategory = category;
     this.Line          = jsLintError.Line - 1;
     this.Column        = jsLintError.Character - 1;
     this.Text          = GetText(jsLintError);
     this.HierarchyItem = hierarchy;
 }
Exemplo n.º 26
0
 /// <summary>
 /// Initializes a new instance of the <see cref="JSLintErrorTask" /> class.
 /// </summary>
 /// <param name="document">The document.</param>
 /// <param name="jsLintWarning">The JSLint error.</param>
 /// <param name="category">The category.</param>
 /// <param name="hierarchy">The hierarchy.</param>
 public JSLintErrorTask(string document, IJSLintWarning jsLintWarning, TaskErrorCategory category, IVsHierarchy hierarchy)
 {
     this.Document = document;
     this.Category = TaskCategory.BuildCompile;
     this.ErrorCategory = category;
     this.Line = jsLintWarning.Line;
     this.Column = jsLintWarning.Column;
     this.Text = GetText(jsLintWarning);
     this.HierarchyItem = hierarchy;
 }
 /// <summary>
 /// Adds an item to VS error list
 /// </summary>
 /// <param name="message">Message describing the item and presented within the list</param>
 /// <param name="category">Type of the item (Error, Warning, Message)</param>
 private void ErrorListAddTask(string message, TaskErrorCategory category)
 {
     ErrorListProvider.Tasks.Add(new ErrorTask
     {
         Category      = TaskCategory.User,
         ErrorCategory = category,
         Text          = message,
         Document      = "RAD Projects Extension",
         CanDelete     = true
     });
 }
Exemplo n.º 28
0
 private void AddTask(TaskErrorCategory category, string message, int line, int column)
 {
     _errorListProvider.Tasks.Add(
         new ErrorTask
     {
         Category      = TaskCategory.User,
         ErrorCategory = category,
         Line          = line,
         Column        = column,
         Text          = message
     });
 }
Exemplo n.º 29
0
 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);
 }
Exemplo n.º 30
0
 private static ErrorTask CreateTask(string text, int line, string document, TaskErrorCategory errorCategory)
 {
     return(new ErrorTask
     {
         Category = TaskCategory.BuildCompile,
         Text = text,
         Line = line,
         Column = 1,
         Document = document,
         ErrorCategory = errorCategory,
     });
 }
Exemplo n.º 31
0
        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);
        }
Exemplo n.º 32
0
 /// <summary>
 /// This Method writes errors to visual studio
 /// </summary>
 /// <param name="message"></param>
 /// <param name="category"></param>
 /// <param name="filedetails"></param>
 /// <param name="hierarchyItem"></param>
 private static void AddTask(ErrorResultSet message, TaskErrorCategory category, string filedetails, IVsHierarchy hierarchyItem)
 {
     ErrorListProvider.Tasks.Add(new ErrorTask
     {
         Category      = TaskCategory.User,
         ErrorCategory = category,
         Text          = message.ErrorDescription + " (" + message.Referencelink + ")",
         HierarchyItem = hierarchyItem,
         Column        = string.IsNullOrEmpty(message.Column) ? 0 : Int32.Parse(message.Column, CultureInfo.InvariantCulture),
         Line          = string.IsNullOrEmpty(message.Line) ? 0 : Int32.Parse(message.Line, CultureInfo.InvariantCulture),
         Document      = filedetails
     });
 }
        public static void ShowError(ErrorListProvider errorListProvider, TaskErrorCategory errorCategory, TaskPriority priority, string errorText, IVsHierarchy hierarchyItem)
        {
            ErrorTask errorTask = new ErrorTask();

            errorTask.Text          = errorText;
            errorTask.ErrorCategory = errorCategory;
            errorTask.Category      = TaskCategory.BuildCompile;
            errorTask.Priority      = priority;
            errorTask.HierarchyItem = hierarchyItem;
            errorListProvider.Tasks.Add(errorTask);
            errorListProvider.BringToFront();
            errorListProvider.ForceShowErrors();
        }
Exemplo n.º 34
0
        private static void AddTask(GCCErrorListItem item, TaskErrorCategory category)
        {
            try
            {
                // Visual studio has a bug of showing each gcc message twice. Make sure this error list item doesn't exist already
                if (item == null || CurrentListItems.Contains(item))
                {
                    return;
                }

                var task = new ErrorTask
                {
                    Category      = TaskCategory.BuildCompile,
                    ErrorCategory = category,
                    Text          = item.Text
                };

                switch (item.ErrorType)
                {
                case GCCErrorType.Full:
                    task.Navigate     += TaskOnNavigate;
                    task.Line          = item.Line - 1;   // Visual studio starts counting from 0
                    task.Column        = item.Column - 1; // Visual studio starts counting from 0
                    task.Document      = GetFileByProjectNumber(item.ProjectNumber, item.Filename);
                    task.HierarchyItem = GetItemHierarchy(task.Document);
                    break;

                case GCCErrorType.GCCOnly:
                    task.Document = item.Filename;
                    var project = GetProjectByNumber(item.ProjectNumber);
                    task.HierarchyItem = GetProjectHierarchy(project);

                    break;

                case GCCErrorType.NoDetails:
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }

                _errorListProvider.Tasks.Add(task);
                CurrentListItems.Add(item);
            }
            catch (Exception e)
            {
                // eat it
                Log.LogError(e.ToString());
            }
        }
Exemplo n.º 35
0
 protected void task(string msg, TaskErrorCategory type = TaskErrorCategory.Message)
 {
     ThreadTask.Factory.StartNew(() => // to prevent bug from `Process.ErrorDataReceived`
     {
         provider.Tasks.Add(new ErrorTask()
         {
             Text              = msg,
             Document          = Settings.APP_NAME_SHORT,
             Category          = TaskCategory.User,
             Checked           = true,
             IsCheckedEditable = true,
             ErrorCategory     = type,
         });
     });
 }
Exemplo n.º 36
0
        int TaskCount(TaskErrorCategory type)
        {
            int count = 0;

            foreach (object task in _taskProvider.Tasks)
            {
                ErrorTask err = task as ErrorTask;

                if (err != null && err.ErrorCategory == type)
                {
                    count++;
                }
            }

            return(count);
        }
        private void ShowError(ErrorTask newError, TaskErrorCategory errorCategory, string text, string file, int lineNumber, int linePosition)
        {
            newError.Category      = TaskCategory.Misc;
            newError.ErrorCategory = errorCategory;
            newError.Text          = text;
            newError.Document      = file;
            newError.Line          = lineNumber;
            newError.Column        = linePosition;

            newError.Navigate += (sender, e) =>
            {
                this.errorListProvider.Navigate(newError, new Guid(EnvDTE.Constants.vsViewKindCode));
            };

            this.errorListProvider.Tasks.Add(newError);
            this.errorListProvider.Show();
        }
        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;
 }
Exemplo n.º 40
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);
    }
Exemplo n.º 41
0
        private static void AddTask(ProjectItem projectItem, string message, TaskErrorCategory category, int line)
        {
            if (_initialized == false) return;

            try
            {
                var project = projectItem.ContainingProject.FileName;
                var filename = projectItem.FileNames[0];

                IVsHierarchy hierarchyItem;
                _ivsSolution.GetProjectOfUniqueName(project, out hierarchyItem);

                var errorTask = new ErrorTask
                {
                    Category = TaskCategory.BuildCompile,
                    ErrorCategory = category,
                    Text = message,
                    Document = filename,
                    Line = line,
                    HierarchyItem = hierarchyItem
                };

                errorTask.Navigate += (sender, e) =>
                {
                    //there are two Bugs in the errorListProvider.Navigate method:
                    //    Line number needs adjusting
                    //    Column is not shown
                    errorTask.Line++;
                    var guid = new Guid(EnvDTE.Constants.vsViewKindCode);
                    _errorListProvider.Navigate(errorTask, guid);
                    errorTask.Line--;
                };

                _errorListProvider.Tasks.Add(errorTask);
            }
            catch (Exception exception)
            {
                Log.Error($"Failed to add task to Error List. {exception.Message}");
            }
        }
Exemplo n.º 42
0
        protected XmlModelErrorTask(
            string document, string errorMessage, int lineNumber, int columnNumber, TaskErrorCategory category, IVsHierarchy hierarchy,
            uint itemID)
        {
            ErrorCategory = category;
            HierarchyItem = hierarchy;
            _itemID = itemID;

            IOleServiceProvider oleSP = null;
            var hr = hierarchy.GetSite(out oleSP);
            if (NativeMethods.Succeeded(hr))
            {
                _serviceProvider = new ServiceProvider(oleSP);
            }

            Debug.Assert(!String.IsNullOrEmpty(document), "document is null or empty");
            Debug.Assert(!String.IsNullOrEmpty(errorMessage), "errorMessage is null or empty");
            Debug.Assert(hierarchy != null, "hierarchy is null");

            Document = document;
            Text = errorMessage;
            Line = lineNumber;
            Column = columnNumber;
        }
Exemplo n.º 43
0
        // helper methods.
        /// <include file='doc\Source.uex' path='docs/doc[@for="Source.CreateErrorTaskItem"]/*' />
        public virtual DocumentTask CreateErrorTaskItem(TextSpan span, string filename, string message, TaskPriority priority, TaskCategory category, MARKERTYPE markerType, TaskErrorCategory errorCategory)
        {
            // create task item

            //TODO this src obj may not be the one matching filename.
            //find the src for the filename only then call ValidSpan.
            //Debug.Assert(TextSpanHelper.ValidSpan(this, span));

            DocumentTask taskItem = CreateErrorTaskItem(span, markerType, filename);
            taskItem.Priority = priority;
            taskItem.Category = category;
            taskItem.ErrorCategory = errorCategory;
            taskItem.Text = message;
            taskItem.IsTextEditable = false;
            taskItem.IsCheckedEditable = false;
            return taskItem;
        }
Exemplo n.º 44
0
 /// <include file='doc\Task.uex' path='docs/doc[@for="ErrorTask.ErrorTask"]/*' />
 public ErrorTask()
 {
     category = TaskErrorCategory.Error;
 }
Exemplo n.º 45
0
        private void ShowRetargetingErrorTask(IEnumerable<string> packagesToBeReinstalled, IVsHierarchy projectHierarchy, TaskErrorCategory errorCategory, TaskPriority priority)
        {
            Debug.Assert(packagesToBeReinstalled != null && !packagesToBeReinstalled.IsEmpty());

            var errorText = String.Format(CultureInfo.CurrentCulture, Resources.ProjectUpgradeAndRetargetErrorMessage,
                    String.Join(", ", packagesToBeReinstalled));
            VsUtility.ShowError(_errorListProvider, errorCategory, priority, errorText, projectHierarchy);
        }
Exemplo n.º 46
0
        protected void task(string msg, TaskErrorCategory type = TaskErrorCategory.Message)
        {
            ThreadTask.Factory.StartNew(() => // to prevent bug from `Process.ErrorDataReceived`
            {
                provider.Tasks.Add(new ErrorTask()
                {
                    Text                = msg,
                    Document            = Settings.APP_NAME_SHORT,
                    Category            = TaskCategory.User,
                    Checked             = true,
                    IsCheckedEditable   = true,
                    ErrorCategory       = type,
                });

            });
        }
Exemplo n.º 47
0
    /// <summary>
    ///     Adds an entry to the error list
    /// </summary>
    /// <param name="document">Complete path of the document in which the error was found</param>
    /// <param name="text">Errormessage</param>
    /// <param name="line">the line, counting from one</param>
    /// <param name="category">is this an error or a warning?</param>
    internal static void AddErrorToErrorList(string document, string text, int line, TaskErrorCategory category)
    {
      var errorTask = new ErrorTask
                              {
                                ErrorCategory = category,
                                Document = document,
                                Text = text,
                                Line = line - 1,
                                Column = 0
                              };
      errorTask.Navigate += errorTask_Navigate;
      errorListProvider.Tasks.Add(errorTask);

      List<Tuple<int, string>> errorLinesInDocument;
      if (!ErrorLines.TryGetValue(document, out errorLinesInDocument))
      {
        errorLinesInDocument = new List<Tuple<int, string>>();
        ErrorLines.Add(document, errorLinesInDocument);
      }

      errorLinesInDocument.Add(Tuple.Create(line, text));
      if (!text.StartsWith("(related")) linesWithModels.Add(Tuple.Create(document.ToUpperInvariant(), line));
      OnErrorLinesChanged(document);
    }
Exemplo n.º 48
0
        // helper methods.
        public DocumentTask CreateErrorTaskItem(TextSpan span, string filename, string subcategory, string message, TaskPriority priority, TaskCategory category, MARKERTYPE markerType, TaskErrorCategory errorCategory)
        {
            // create task item

            //TODO this src obj may not be the one matching filename.
            //find the src for the filename only then call ValidSpan.
            //Debug.Assert(TextSpanHelper.ValidSpan(this, span)); 

            DocumentTask taskItem = new DocumentTask(this.service.Site, this.textLines, markerType, span, filename, subcategory);
            taskItem.Priority = priority;
            taskItem.Category = category;
            taskItem.ErrorCategory = errorCategory;
            message = NewlineifyErrorString(message);
            taskItem.Text = message;
            taskItem.IsTextEditable = false;
            taskItem.IsCheckedEditable = false;
            return taskItem;
        }
Exemplo n.º 49
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);
            }
        }
 private void LogErrorTask(IVsHierarchy project, string document, TaskErrorCategory errorCategory, string text)
 {
     var task = new ErrorTask
     {
         Category = TaskCategory.BuildCompile,
         ErrorCategory = errorCategory,
         Text = "AutoRunCustomTool: " + text,
         Document = document,
         HierarchyItem = project,
         Line = -1,
         Column = -1
     };
     _errorListProvider.Tasks.Add(task);
     string prefix = "";
     switch (errorCategory)
     {
         case TaskErrorCategory.Error:
             prefix = "Error: ";
             break;
         case TaskErrorCategory.Warning:
             prefix = "Warning: ";
             break;
     }
     _outputPane.OutputString(prefix + text + Environment.NewLine);
 }
Exemplo n.º 51
0
 ErrorTask CreateErrorTask(BuildEventArgs errorEvent, TextSpan span, string file, MARKERTYPE marker, TaskErrorCategory category, IVsTextLines buffer)
 {
     if(buffer != null)
         return new DocumentTask(serviceProvider, buffer, marker, span, file);
     else
         return new ErrorTask();
 }
        public void Write(
            TaskCategory category,
            TaskErrorCategory errorCategory,
            string context, //used as an indicator when removing
            string text,
            string document,
            int line,
            int column)
        {
            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;
            }

            //add it to the errorlistprovider
            errorListProvider.Tasks.Add(task);

            errorListProvider.BringToFront();
        }
Exemplo n.º 53
0
 int TaskCount(TaskErrorCategory type)
 {
     return
         _taskProvider.Tasks.OfType<ErrorTask>()
             .Count(task => task.ErrorCategory == type);
 }
        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);
      }

      }
Exemplo n.º 55
0
        //
        // Add an error to slice builder error list provider.
        //
        public void addError(Project project, string file, TaskErrorCategory category, int line, int column,
                              string text)
        {
            IVsHierarchy hierarchy = getProjectHierarchy(project);

            ErrorTask errorTask = new ErrorTask();
            errorTask.ErrorCategory = category;
            // Visual Studio uses indexes starting at 0
            // while the automation model uses indexes starting at 1
            errorTask.Line = line - 1;
            errorTask.Column = column - 1;
            if(hierarchy != null)
            {
                errorTask.HierarchyItem = hierarchy;
            }
            errorTask.Navigate += new EventHandler(errorTaskNavigate);
            errorTask.Document = file;
            errorTask.Category = TaskCategory.BuildCompile;
            errorTask.Text = text;
            _errors.Add(errorTask);
            _errorListProvider.Tasks.Add(errorTask);
            if(category == TaskErrorCategory.Error)
            {
                ++_errorCount;
            }
        }
Exemplo n.º 56
0
 private void AddTask(TaskErrorCategory category, string message, int line, int column)
 {
     _errorListProvider.Tasks.Add(
         new ErrorTask
         {
             Category = TaskCategory.User,
             ErrorCategory = category,
             Line = line,
             Column = column,
             Text = message
         });
 }
Exemplo n.º 57
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);
        }
 internal static ErrorTask CreateErrorTask(
     string document, string errorMessage, TextSpan textSpan, TaskErrorCategory taskErrorCategory, IVsHierarchy hierarchy,
     uint itemID)
 {
     return CreateErrorTask(document, errorMessage, textSpan, taskErrorCategory, hierarchy, itemID, MARKERTYPE.MARKER_COMPILE_ERROR);
 }