private string Get_Label_Description(string label) { if (this.labelGraph_.Enabled) { StringBuilder sb = new StringBuilder(); SortedSet <uint> labelDefs = this.labelGraph_.Get_Label_Def_Linenumbers(label); if (labelDefs.Count > 1) { sb.AppendLine(string.Empty); } foreach (uint id in labelDefs) { int lineNumber = LabelGraph.Get_Linenumber(id); string filename = Path.GetFileName(this.labelGraph_.Get_Filename(id)); string lineContent = (LabelGraph.Is_From_Main_File(id)) ? " :" + this.textBuffer_.CurrentSnapshot.GetLineFromLineNumber(lineNumber).GetText() : string.Empty; sb.AppendLine(AsmDudeToolsStatic.Cleanup(string.Format(AsmDudeToolsStatic.CultureUI, "Defined at LINE {0} ({1}){2}", lineNumber + 1, filename, lineContent))); } string result = sb.ToString(); return(result.TrimEnd(Environment.NewLine.ToCharArray())); } else { return("Label analysis is disabled"); } }
private TextBlock Label_Clash_Tool_Tip_Content(string label) { TextBlock textBlock = new TextBlock(); try { textBlock.Inlines.Add(new Run("Label Clash:" + Environment.NewLine) { FontWeight = FontWeights.Bold, Foreground = this.foreground_, }); StringBuilder sb = new StringBuilder(); foreach (uint id in this.labelGraph_.Get_Label_Def_Linenumbers(label)) { int lineNumber = LabelGraph.Get_Linenumber(id); string filename = Path.GetFileName(this.labelGraph_.Get_Filename(id)); string lineContent; if (LabelGraph.Is_From_Main_File(id)) { lineContent = " :" + this.sourceBuffer_.CurrentSnapshot.GetLineFromLineNumber(lineNumber).GetText(); } else { lineContent = string.Empty; } sb.AppendLine(AsmDudeToolsStatic.Cleanup(string.Format(AsmDudeToolsStatic.CultureUI, "Defined at LINE {0} ({1}){2}", lineNumber + 1, filename, lineContent))); } string msg = sb.ToString().TrimEnd(Environment.NewLine.ToCharArray()); textBlock.Inlines.Add(new Run(msg) { Foreground = this.foreground_, }); } catch (Exception e) { AsmDudeToolsStatic.Output_ERROR(string.Format(AsmDudeToolsStatic.CultureUI, "{0}:labelClashToolTipContent; e={1}", this.ToString(), e.ToString())); } return(textBlock); }
private string Get_Label_Def_Description(string full_Qualified_Label, string label) { if (!this.labelGraph_.Enabled) { return("Label analysis is disabled"); } SortedSet <uint> usage = this.labelGraph_.Label_Used_At_Info(full_Qualified_Label, label); if (usage.Count > 0) { StringBuilder sb = new StringBuilder(); if (usage.Count > 1) { sb.AppendLine(string.Empty); // add a newline if multiple usage occurances exist } foreach (uint id in usage) { int lineNumber = LabelGraph.Get_Linenumber(id); string filename = Path.GetFileName(this.labelGraph_.Get_Filename(id)); string lineContent; if (LabelGraph.Is_From_Main_File(id)) { lineContent = " :" + this.textBuffer_.CurrentSnapshot.GetLineFromLineNumber(lineNumber).GetText(); } else { lineContent = string.Empty; } sb.AppendLine(AsmDudeToolsStatic.Cleanup(string.Format(AsmDudeToolsStatic.CultureUI, "Used at LINE {0} ({1}){2}", lineNumber + 1, filename, lineContent))); //AsmDudeToolsStatic.Output_INFO(string.Format(AsmDudeToolsStatic.CultureUI, "{0}:getLabelDefDescription; sb=\"{1}\"", this.ToString(), sb.ToString())); } string result = sb.ToString(); return(result.TrimEnd(Environment.NewLine.ToCharArray())); } else { return("Not used"); } }
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 = 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 = LabelGraph.Get_Linenumber(key), Column = 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 = 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 = 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 = 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(AsmDudeToolsStatic.CultureUI, "{0}:Update_Error_Tasks_Labels_Async; e={1}", this.ToString(), e.ToString())); } } }).ConfigureAwait(false); }