예제 #1
0
        private void ShowErrors(string activeFile, IVsHierarchy hierarchy, CompilerError[] errors)
        {
            if (ConfigurationPage.ShouldShowCompilerErrors == false)
            {
                return;
            }

            ErrorTask item;

            TaskProvider.TaskCollection list = _errorList.Tasks;

            int nErrors = list.Count;

            for (int i = 0; i < nErrors; i++)
            {
                item = (ErrorTask)list[i];
                if (Helper.AreSame(item.Document, activeFile))
                {
                    item.Navigate -= GotoLine;
                    list.RemoveAt(i);
                    nErrors--; i--;
                }
            }

            nErrors = errors.Length;
            for (int i = 0; i < nErrors; i++)
            {
                list.Add(ToTask(errors[i], hierarchy));
            }
        }
        public void SetEntries(ICollection <ResourceTableEntry> entries, ICollection <CultureKey> cultures, int errorCategory)
        {
            _errorListProvider.SuspendRefresh();

            try
            {
                _tasks.Clear();

                var errorCount = 0;

                foreach (var entry in entries)
                {
                    foreach (var culture in cultures)
                    {
                        if (!entry.GetError(culture, out var error))
                        {
                            continue;
                        }

                        if (++errorCount >= 200)
                        {
                            return;
                        }

                        // Bug in VS2022: : this is the call that is responsible for the exception: 'Could not load type 'Microsoft.VisualStudio.Shell.Task' from assembly 'Microsoft.VisualStudio.Shell.15.0, Version=17.0.0.0
                        var task = new ResourceErrorTask(entry)
                        {
                            ErrorCategory = (TaskErrorCategory)errorCategory,
                            Category      = TaskCategory.BuildCompile,
                            Text          = error,
                            Document      = entry.Container.UniqueName,
                        };

                        task.Navigate += Task_Navigate;
                        _tasks.Add(task);
                    }
                }
            }
            finally
            {
                _errorListProvider.ResumeRefresh();
            }
        }
예제 #3
0
        private async System.Threading.Tasks.Task Update_Error_Tasks_Labels_Async()
        {
            if (!this._labelGraph.Enabled)
            {
                return;
            }

            await System.Threading.Tasks.Task.Run(() =>
            {
                lock (this._updateLock)
                {
                    try
                    {
                        #region Update Error Tasks
                        if (Settings.Default.IntelliSense_Show_Clashing_Labels ||
                            Settings.Default.IntelliSense_Show_Undefined_Labels ||
                            Settings.Default.IntelliSense_Show_Undefined_Includes)
                        {
                            TaskProvider.TaskCollection errorTasks = this._errorListProvider.Tasks;
                            bool errorListNeedsRefresh             = false;

                            #region Remove stale error tasks from the error list
                            for (int i = errorTasks.Count - 1; i >= 0; --i)
                            {
                                AsmMessageEnum subCategory = (AsmMessageEnum)errorTasks[i].SubcategoryIndex;
                                if ((subCategory == AsmMessageEnum.LABEL_UNDEFINED) ||
                                    (subCategory == AsmMessageEnum.LABEL_CLASH) ||
                                    (subCategory == AsmMessageEnum.INCLUDE_UNDEFINED))
                                {
                                    errorTasks.RemoveAt(i);
                                    errorListNeedsRefresh = true;
                                }
                            }
                            #endregion

                            if (Settings.Default.IntelliSense_Show_Clashing_Labels)
                            {
                                foreach ((uint Key, string Value) in this._labelGraph.Label_Clashes) // TODO Label_Clashes does not return the classes in any particular order,
                                {
                                    string label   = Value;
                                    int lineNumber = this._labelGraph.Get_Linenumber(Key);
                                    //TODO retrieve the lineContent of the correct buffer!
                                    string lineContent = this._sourceBuffer.CurrentSnapshot.GetLineFromLineNumber(lineNumber).GetText();

                                    ErrorTask errorTask = new ErrorTask()
                                    {
                                        SubcategoryIndex = (int)AsmMessageEnum.LABEL_CLASH,
                                        Line             = this._labelGraph.Get_Linenumber(Key),
                                        Column           = this.Get_Keyword_Begin_End(lineContent, label),
                                        Text             = "Label Clash: \"" + label + "\"",
                                        ErrorCategory    = TaskErrorCategory.Warning,
                                        Document         = this._labelGraph.Get_Filename(Key)
                                    };
                                    errorTask.Navigate += AsmDudeToolsStatic.Error_Task_Navigate_Handler;
                                    errorTasks.Add(errorTask);
                                    errorListNeedsRefresh = true;
                                }
                            }
                            if (Settings.Default.IntelliSense_Show_Undefined_Labels)
                            {
                                foreach ((uint Key, string Value) in this._labelGraph.Undefined_Labels)
                                {
                                    string label   = Value;
                                    int lineNumber = this._labelGraph.Get_Linenumber(Key);
                                    //TODO retrieve the lineContent of the correct buffer!
                                    string lineContent = this._sourceBuffer.CurrentSnapshot.GetLineFromLineNumber(lineNumber).GetText();

                                    ErrorTask errorTask = new ErrorTask()
                                    {
                                        SubcategoryIndex = (int)AsmMessageEnum.LABEL_UNDEFINED,
                                        Line             = lineNumber,
                                        Column           = this.Get_Keyword_Begin_End(lineContent, label),
                                        Text             = "Undefined Label: \"" + label + "\"",
                                        ErrorCategory    = TaskErrorCategory.Warning,
                                        Document         = this._labelGraph.Get_Filename(Key)
                                    };
                                    errorTask.Navigate += AsmDudeToolsStatic.Error_Task_Navigate_Handler;
                                    errorTasks.Add(errorTask);
                                    errorListNeedsRefresh = true;
                                }
                            }
                            if (Settings.Default.IntelliSense_Show_Undefined_Includes)
                            {
                                foreach ((string Include_Filename, string Path, string Source_Filename, int LineNumber)entry in this._labelGraph.Undefined_Includes)
                                {
                                    string include = entry.Include_Filename;
                                    int lineNumber = entry.LineNumber;
                                    //TODO retrieve the lineContent of the correct buffer!
                                    string lineContent = this._sourceBuffer.CurrentSnapshot.GetLineFromLineNumber(lineNumber).GetText();

                                    ErrorTask errorTask = new ErrorTask()
                                    {
                                        SubcategoryIndex = (int)AsmMessageEnum.INCLUDE_UNDEFINED,
                                        Line             = lineNumber,
                                        Column           = this.Get_Keyword_Begin_End(lineContent, include),
                                        Text             = "Could not resolve include \"" + include + "\" at line " + (lineNumber + 1) + " in file \"" + entry.Source_Filename + "\"",
                                        ErrorCategory    = TaskErrorCategory.Warning,
                                        Document         = entry.Source_Filename
                                    };
                                    errorTask.Navigate += AsmDudeToolsStatic.Error_Task_Navigate_Handler;
                                    errorTasks.Add(errorTask);
                                    errorListNeedsRefresh = true;
                                }
                            }
                            if (errorListNeedsRefresh)
                            {
                                this._errorListProvider.Refresh();
                                //this._errorListProvider.Show(); // do not use BringToFront since that will select the error window.
                            }
                        }
                        #endregion Update Error Tasks
                    }
                    catch (Exception e)
                    {
                        AsmDudeToolsStatic.Output_ERROR(string.Format("{0}:Update_Error_Tasks_Labels_Async; e={1}", this.ToString(), e.ToString()));
                    }
                }
            });
        }