Example #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));
            }
        }
Example #2
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()));
                    }
                }
            });
        }
Example #3
0
        private async System.Threading.Tasks.Task Update_Error_Tasks_AsmSim_Async()
        {
            if (!this._asmSimulator.Enabled)
            {
                return;
            }

            await System.Threading.Tasks.Task.Run(() =>
            {
                lock (this._updateLock)
                {
                    try
                    {
                        if (Settings.Default.AsmSim_Show_Syntax_Errors ||
                            Settings.Default.AsmSim_Show_Usage_Of_Undefined)
                        {
                            AsmDudeToolsStatic.Output_INFO("SquigglesTagger:Update_Error_Tasks_AsmSim_Async: going to update the error list");

                            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.USAGE_OF_UNDEFINED) ||
                                    (subCategory == AsmMessageEnum.SYNTAX_ERROR) ||
                                    (subCategory == AsmMessageEnum.REDUNDANT))
                                {
                                    errorTasks.RemoveAt(i);
                                    errorListNeedsRefresh = true;
                                }
                            }
                            #endregion

                            if (Settings.Default.AsmSim_Show_Syntax_Errors)
                            {
                                foreach ((int LineNumber, (string Message, Mnemonic Mnemonic)info) in this._asmSimulator.Syntax_Errors)
                                {
                                    this.AddErrorTask_Syntax_Error_Async(LineNumber, info.Mnemonic.ToString(), info.Message).ConfigureAwait(false);
                                    errorListNeedsRefresh = true;
                                }
                            }
                            if (Settings.Default.AsmSim_Show_Usage_Of_Undefined)
                            {
                                foreach ((int LineNumber, (string Message, Mnemonic Mnemonic)info) in this._asmSimulator.Usage_Undefined)
                                {
                                    this.AddErrorTask_Usage_Undefined_Async(LineNumber, info.Mnemonic.ToString(), info.Message).ConfigureAwait(false);
                                    errorListNeedsRefresh = true;
                                }
                            }
                            if (Settings.Default.AsmSim_Show_Redundant_Instructions)
                            {
                                foreach ((int LineNumber, (string Message, Mnemonic Mnemonic)info) in this._asmSimulator.Redundant_Instruction)
                                {
                                    this.AddErrorTask_Redundant_Instruction_Async(LineNumber, info.Mnemonic.ToString(), info.Message).ConfigureAwait(false);
                                    errorListNeedsRefresh = true;
                                }
                            }
                            if (Settings.Default.AsmSim_Show_Unreachable_Instructions)
                            {
                                foreach ((int LineNumber, (string Message, Mnemonic Mnemonic)info) in this._asmSimulator.Unreachable_Instruction)
                                {
                                    this.AddErrorTask_Unreachable_Instruction_Async(LineNumber, info.Mnemonic.ToString(), info.Message).ConfigureAwait(false);
                                    errorListNeedsRefresh = true;
                                }
                            }

                            if (errorListNeedsRefresh)
                            {
                                this._errorListProvider.Refresh();
                                //this._errorListProvider.Show(); // do not use BringToFront since that will select the error window.
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        AsmDudeToolsStatic.Output_ERROR(string.Format("{0}:Update_AsmSim_Error_Task_Async; e={1}", this.ToString(), e.ToString()));
                    }
                }
            });
        }
Example #4
0
        private async System.Threading.Tasks.Task Update_Error_Task_AsmSimAsync(int lineNumber, AsmMessageEnum error)
        {
            //NOTE: this method cannot be made async due to _errorListProvider

            if (!this._asmSimulator.Enabled)
            {
                return;
            }

            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)
            {
                Task task = errorTasks[i];
                if (((AsmMessageEnum)task.SubcategoryIndex == error) && (task.Line == lineNumber))
                {
                    errorTasks.RemoveAt(i);
                    errorListNeedsRefresh = true;
                }
            }
            #endregion

            switch (error)
            {
            case AsmMessageEnum.SYNTAX_ERROR:
            {
                if (Settings.Default.AsmSim_Show_Syntax_Errors)
                {
                    (string Message, Mnemonic Mnemonic)tup = this._asmSimulator.Get_Syntax_Error(lineNumber);
                    if (tup.Message.Length > 0)
                    {
                        await this.AddErrorTask_Syntax_Error_Async(lineNumber, tup.Mnemonic.ToString(), tup.Message);
                    }

                    errorListNeedsRefresh = true;
                }
                break;
            }

            case AsmMessageEnum.USAGE_OF_UNDEFINED:
            {
                if (Settings.Default.AsmSim_Show_Usage_Of_Undefined)
                {
                    (string Message, Mnemonic Mnemonic)tup = this._asmSimulator.Get_Usage_Undefined_Warning(lineNumber);
                    if (tup.Message.Length > 0)
                    {
                        await this.AddErrorTask_Usage_Undefined_Async(lineNumber, tup.Mnemonic.ToString(), tup.Message);
                    }

                    errorListNeedsRefresh = true;
                }
                break;
            }

            case AsmMessageEnum.REDUNDANT:
            {
                if (Settings.Default.AsmSim_Show_Redundant_Instructions)
                {
                    (string Message, Mnemonic Mnemonic)tup = this._asmSimulator.Get_Redundant_Instruction_Warning(lineNumber);
                    if (tup.Message.Length > 0)
                    {
                        await this.AddErrorTask_Redundant_Instruction_Async(lineNumber, tup.Mnemonic.ToString(), tup.Message);
                    }

                    errorListNeedsRefresh = true;
                }
                break;
            }

            case AsmMessageEnum.UNREACHABLE:
            {
                if (Settings.Default.AsmSim_Show_Unreachable_Instructions)
                {
                    (string Message, Mnemonic Mnemonic)tup = this._asmSimulator.Get_Unreachable_Instruction_Warning(lineNumber);
                    if (tup.Message.Length > 0)
                    {
                        await this.AddErrorTask_Unreachable_Instruction_Async(lineNumber, tup.Mnemonic.ToString(), tup.Message);
                    }

                    errorListNeedsRefresh = true;
                }
                break;
            }

            default: break;
            }

            if (errorListNeedsRefresh)
            {
                this._errorListProvider.Refresh();
                //this._errorListProvider.Show(); // do not use BringToFront since that will select the error window.
            }
        }