public void SetDescription(Rn reg, AsmDudeTools asmDudeTools) { string regStr = reg.ToString(); this.Description.Inlines.Add(new Run("Register ") { FontWeight = FontWeights.Bold, Foreground = this._foreground }); this.Description.Inlines.Add(new Run(regStr) { FontWeight = FontWeights.Bold, Foreground = new SolidColorBrush(AsmDudeToolsStatic.ConvertColor(Settings.Default.SyntaxHighlighting_Register)) }); Arch arch = RegisterTools.GetArch(reg); string archStr = (arch == Arch.ARCH_NONE) ? "" : " [" + ArchTools.ToString(arch) + "] "; string descr = asmDudeTools.Get_Description(regStr); if (regStr.Length > (AsmDudePackage.maxNumberOfCharsInToolTips / 2)) { descr = "\n" + descr; } string full_Descr = AsmSourceTools.Linewrap(":" + archStr + descr, AsmDudePackage.maxNumberOfCharsInToolTips); this.Description.Inlines.Add(new Run(full_Descr) { Foreground = this._foreground }); }
public void SetDescription(Mnemonic mnemonic, AsmDudeTools asmDudeTools) { string mnemonicStr = mnemonic.ToString(); this.Description.Inlines.Add(new Run("Mnemonic ") { FontWeight = FontWeights.Bold, Foreground = this._foreground }); this.Description.Inlines.Add(new Run(mnemonicStr) { FontWeight = FontWeights.Bold, Foreground = new SolidColorBrush(AsmDudeToolsStatic.ConvertColor((AsmSourceTools.IsJump(mnemonic) ? Settings.Default.SyntaxHighlighting_Jump : Settings.Default.SyntaxHighlighting_Opcode))) }); string archStr = ":" + ArchTools.ToString(asmDudeTools.Mnemonic_Store.GetArch(mnemonic)) + " "; string descr = asmDudeTools.Mnemonic_Store.GetDescription(mnemonic); string full_Descr = AsmSourceTools.Linewrap(archStr + descr, AsmDudePackage.maxNumberOfCharsInToolTips); this.Description.Inlines.Add(new Run(full_Descr) { Foreground = this._foreground }); }
private void Handle(IQuickInfoSession session, IList <object> quickInfoContent, out ITrackingSpan applicableToSpan) { applicableToSpan = null; DateTime time1 = DateTime.Now; ITextSnapshot snapshot = this._sourceBuffer.CurrentSnapshot; var triggerPoint = (SnapshotPoint)session.GetTriggerPoint(snapshot); if (triggerPoint == null) { AsmDudeToolsStatic.Output_WARNING("AsmQuickInfoSource:AugmentQuickInfoSession: trigger point is null"); return; } Brush foreground = AsmDudeToolsStatic.Get_Font_Color(); var enumerator = this._aggregator.GetTags(new SnapshotSpan(triggerPoint, triggerPoint)).GetEnumerator(); if (enumerator.MoveNext()) { var asmTokenTag = enumerator.Current; var enumerator2 = asmTokenTag.Span.GetSpans(this._sourceBuffer).GetEnumerator(); if (enumerator2.MoveNext()) { SnapshotSpan tagSpan = enumerator2.Current; string keyword = tagSpan.GetText(); string keywordUpper = keyword.ToUpper(); #region Tests // TODO: multiple tags at the provided triggerPoint is most likely the result of a bug in AsmTokenTagger, but it seems harmless... if (false) { if (enumerator.MoveNext()) { var asmTokenTagX = enumerator.Current; var enumeratorX = asmTokenTagX.Span.GetSpans(this._sourceBuffer).GetEnumerator(); enumeratorX.MoveNext(); AsmDudeToolsStatic.Output_WARNING(string.Format("{0}:AugmentQuickInfoSession. current keyword " + keyword + ": but span has more than one tag! next tag=\"{1}\"", ToString(), enumeratorX.Current.GetText())); } } #endregion //AsmDudeToolsStatic.Output_INFO("AsmQuickInfoSource:AugmentQuickInfoSession: keyword=\""+ keyword + "\"; type=" + asmTokenTag.Tag.type +"; file="+AsmDudeToolsStatic.GetFileName(session.TextView.TextBuffer)); applicableToSpan = snapshot.CreateTrackingSpan(tagSpan, SpanTrackingMode.EdgeInclusive); TextBlock description = null; AsmTokenType type = asmTokenTag.Tag.Type; switch (type) { case AsmTokenType.Misc: { description = new TextBlock(); description.Inlines.Add(Make_Run1("Keyword ", foreground)); description.Inlines.Add(Make_Run2(keyword, new SolidColorBrush(AsmDudeToolsStatic.ConvertColor(Settings.Default.SyntaxHighlighting_Misc)))); string descr = this._asmDudeTools.Get_Description(keywordUpper); if (descr.Length > 0) { if (keyword.Length > (AsmDudePackage.maxNumberOfCharsInToolTips / 2)) { descr = "\n" + descr; } description.Inlines.Add(new Run(AsmSourceTools.Linewrap(": " + descr, AsmDudePackage.maxNumberOfCharsInToolTips)) { Foreground = foreground }); } break; } case AsmTokenType.Directive: { description = new TextBlock(); description.Inlines.Add(Make_Run1("Directive ", foreground)); description.Inlines.Add(Make_Run2(keyword, new SolidColorBrush(AsmDudeToolsStatic.ConvertColor(Settings.Default.SyntaxHighlighting_Directive)))); string descr = this._asmDudeTools.Get_Description(keywordUpper); if (descr.Length > 0) { if (keyword.Length > (AsmDudePackage.maxNumberOfCharsInToolTips / 2)) { descr = "\n" + descr; } description.Inlines.Add(new Run(AsmSourceTools.Linewrap(": " + descr, AsmDudePackage.maxNumberOfCharsInToolTips)) { Foreground = foreground }); } break; } case AsmTokenType.Register: { int lineNumber = AsmDudeToolsStatic.Get_LineNumber(tagSpan); if (keywordUpper.StartsWith("%")) { keywordUpper = keywordUpper.Substring(1); // remove the preceding % in AT&T syntax } Rn reg = RegisterTools.ParseRn(keywordUpper, true); if (this._asmDudeTools.RegisterSwitchedOn(reg)) { var registerTooltipWindow = new RegisterTooltipWindow(foreground); registerTooltipWindow.SetDescription(reg, this._asmDudeTools); registerTooltipWindow.SetAsmSim(this._asmSimulator, reg, lineNumber, true); quickInfoContent.Add(registerTooltipWindow); } break; } case AsmTokenType.Mnemonic: case AsmTokenType.Jump: { int lineNumber = AsmDudeToolsStatic.Get_LineNumber(tagSpan); Mnemonic mnemonic = AsmSourceTools.ParseMnemonic_Att(keywordUpper, true); if (this._asmDudeTools.MnemonicSwitchedOn(mnemonic)) { var instructionTooltipWindow = new InstructionTooltipWindow(foreground) { Session = session // set the owner of this windows such that we can manually close this window }; instructionTooltipWindow.SetDescription(mnemonic, this._asmDudeTools); instructionTooltipWindow.SetPerformanceInfo(mnemonic, this._asmDudeTools, false); instructionTooltipWindow.SetAsmSim(this._asmSimulator, lineNumber, true); quickInfoContent.Add(instructionTooltipWindow); } break; } case AsmTokenType.Label: { string label = keyword; string labelPrefix = asmTokenTag.Tag.Misc; string full_Qualified_Label = AsmDudeToolsStatic.Make_Full_Qualified_Label(labelPrefix, label, AsmDudeToolsStatic.Used_Assembler); description = new TextBlock(); description.Inlines.Add(Make_Run1("Label ", foreground)); description.Inlines.Add(Make_Run2(full_Qualified_Label, new SolidColorBrush(AsmDudeToolsStatic.ConvertColor(Settings.Default.SyntaxHighlighting_Label)))); string descr = Get_Label_Description(full_Qualified_Label); if (descr.Length == 0) { descr = Get_Label_Description(label); } if (descr.Length > 0) { if (keyword.Length > (AsmDudePackage.maxNumberOfCharsInToolTips / 2)) { descr = "\n" + descr; } description.Inlines.Add(new Run(AsmSourceTools.Linewrap(": " + descr, AsmDudePackage.maxNumberOfCharsInToolTips)) { Foreground = foreground }); } break; } case AsmTokenType.LabelDef: { string label = keyword; string extra_Tag_Info = asmTokenTag.Tag.Misc; string full_Qualified_Label; if ((extra_Tag_Info != null) && extra_Tag_Info.Equals(AsmTokenTag.MISC_KEYWORD_PROTO)) { full_Qualified_Label = label; } else { full_Qualified_Label = AsmDudeToolsStatic.Make_Full_Qualified_Label(extra_Tag_Info, label, AsmDudeToolsStatic.Used_Assembler); } AsmDudeToolsStatic.Output_INFO("AsmQuickInfoSource:AugmentQuickInfoSession: found label def " + full_Qualified_Label); description = new TextBlock(); description.Inlines.Add(Make_Run1("Label ", foreground)); description.Inlines.Add(Make_Run2(full_Qualified_Label, new SolidColorBrush(AsmDudeToolsStatic.ConvertColor(Settings.Default.SyntaxHighlighting_Label)))); string descr = Get_Label_Def_Description(full_Qualified_Label, label); if (descr.Length > 0) { if (keyword.Length > (AsmDudePackage.maxNumberOfCharsInToolTips / 2)) { descr = "\n" + descr; } description.Inlines.Add(new Run(AsmSourceTools.Linewrap(": " + descr, AsmDudePackage.maxNumberOfCharsInToolTips)) { Foreground = foreground }); } break; } case AsmTokenType.Constant: { description = new TextBlock(); description.Inlines.Add(Make_Run1("Constant ", foreground)); var(Valid, Value, NBits) = AsmSourceTools.Evaluate_Constant(keyword); string constantStr = (Valid) ? Value + "d = " + Value.ToString("X") + "h = " + AsmSourceTools.ToStringBin(Value, NBits) + "b" : keyword; description.Inlines.Add(Make_Run2(constantStr, new SolidColorBrush(AsmDudeToolsStatic.ConvertColor(Settings.Default.SyntaxHighlighting_Constant)))); break; } case AsmTokenType.UserDefined1: { description = new TextBlock(); description.Inlines.Add(Make_Run1("User defined 1: ", foreground)); description.Inlines.Add(Make_Run2(keyword, new SolidColorBrush(AsmDudeToolsStatic.ConvertColor(Settings.Default.SyntaxHighlighting_Userdefined1)))); string descr = this._asmDudeTools.Get_Description(keywordUpper); if (descr.Length > 0) { if (keyword.Length > (AsmDudePackage.maxNumberOfCharsInToolTips / 2)) { descr = "\n" + descr; } description.Inlines.Add(new Run(AsmSourceTools.Linewrap(": " + descr, AsmDudePackage.maxNumberOfCharsInToolTips)) { Foreground = foreground }); } break; } case AsmTokenType.UserDefined2: { description = new TextBlock(); description.Inlines.Add(Make_Run1("User defined 2: ", foreground)); description.Inlines.Add(Make_Run2(keyword, new SolidColorBrush(AsmDudeToolsStatic.ConvertColor(Settings.Default.SyntaxHighlighting_Userdefined2)))); string descr = this._asmDudeTools.Get_Description(keywordUpper); if (descr.Length > 0) { if (keyword.Length > (AsmDudePackage.maxNumberOfCharsInToolTips / 2)) { descr = "\n" + descr; } description.Inlines.Add(new Run(AsmSourceTools.Linewrap(": " + descr, AsmDudePackage.maxNumberOfCharsInToolTips)) { Foreground = foreground }); } break; } case AsmTokenType.UserDefined3: { description = new TextBlock(); description.Inlines.Add(Make_Run1("User defined 3: ", foreground)); description.Inlines.Add(Make_Run2(keyword, new SolidColorBrush(AsmDudeToolsStatic.ConvertColor(Settings.Default.SyntaxHighlighting_Userdefined3)))); string descr = this._asmDudeTools.Get_Description(keywordUpper); if (descr.Length > 0) { if (keyword.Length > (AsmDudePackage.maxNumberOfCharsInToolTips / 2)) { descr = "\n" + descr; } description.Inlines.Add(new Run(AsmSourceTools.Linewrap(": " + descr, AsmDudePackage.maxNumberOfCharsInToolTips)) { Foreground = foreground }); } break; } default: //description = new TextBlock(); //description.Inlines.Add(makeRun1("Unused tagType " + asmTokenTag.Tag.type)); break; } if (description != null) { description.FontSize = AsmDudeToolsStatic.Get_Font_Size() + 2; description.FontFamily = AsmDudeToolsStatic.Get_Font_Type(); //AsmDudeToolsStatic.Output_INFO(string.Format("{0}:AugmentQuickInfoSession; setting description fontSize={1}; fontFamily={2}", this.ToString(), description.FontSize, description.FontFamily)); quickInfoContent.Add(description); } } } //AsmDudeToolsStatic.Output_INFO("AsmQuickInfoSource:AugmentQuickInfoSession: applicableToSpan=\"" + applicableToSpan + "\"; quickInfoContent,Count=" + quickInfoContent.Count); AsmDudeToolsStatic.Print_Speed_Warning(time1, "QuickInfo"); }
private void Handle(IQuickInfoSession session, IList <object> quickInfoContent, out ITrackingSpan applicableToSpan) { applicableToSpan = null; DateTime time1 = DateTime.Now; ITextSnapshot snapshot = this.textBuffer_.CurrentSnapshot; SnapshotPoint?triggerPoint = session.GetTriggerPoint(snapshot); if (!triggerPoint.HasValue) { AsmDudeToolsStatic.Output_WARNING(string.Format(AsmDudeToolsStatic.CultureUI, "{0}:Handle: trigger point is null", this.ToString())); return; } Brush foreground = AsmDudeToolsStatic.GetFontColor(); (AsmTokenTag tag, SnapshotSpan? keywordSpan) = AsmDudeToolsStatic.GetAsmTokenTag(this.aggregator_, triggerPoint.Value); if (keywordSpan.HasValue) { SnapshotSpan tagSpan = keywordSpan.Value; string keyword = tagSpan.GetText(); string keyword_upcase = keyword.ToUpperInvariant(); AsmDudeToolsStatic.Output_INFO(string.Format(AsmDudeToolsStatic.CultureUI, "{0}:Handle: keyword=\"{1}\"; type={2}; file=\"{3}\"", this.ToString(), keyword, tag.Type, AsmDudeToolsStatic.GetFilename(session.TextView.TextBuffer))); applicableToSpan = snapshot.CreateTrackingSpan(tagSpan, SpanTrackingMode.EdgeInclusive); TextBlock description = null; switch (tag.Type) { case AsmTokenType.Misc: { description = new TextBlock(); description.Inlines.Add(Make_Run1("Keyword ", foreground)); description.Inlines.Add(Make_Run2(keyword, new SolidColorBrush(AsmDudeToolsStatic.ConvertColor(Settings.Default.SyntaxHighlighting_Misc)))); string descr = this.asmDudeTools_.Get_Description(keyword_upcase); if (descr.Length > 0) { if (keyword.Length > (AsmDudePackage.MaxNumberOfCharsInToolTips / 2)) { descr = "\n" + descr; } description.Inlines.Add(new Run(AsmSourceTools.Linewrap(": " + descr, AsmDudePackage.MaxNumberOfCharsInToolTips)) { Foreground = foreground, }); } break; } case AsmTokenType.Directive: { description = new TextBlock(); description.Inlines.Add(Make_Run1("Directive ", foreground)); description.Inlines.Add(Make_Run2(keyword, new SolidColorBrush(AsmDudeToolsStatic.ConvertColor(Settings.Default.SyntaxHighlighting_Directive)))); string descr = this.asmDudeTools_.Get_Description(keyword_upcase); if (descr.Length > 0) { if (keyword.Length > (AsmDudePackage.MaxNumberOfCharsInToolTips / 2)) { descr = "\n" + descr; } description.Inlines.Add(new Run(AsmSourceTools.Linewrap(": " + descr, AsmDudePackage.MaxNumberOfCharsInToolTips)) { Foreground = foreground, }); } break; } case AsmTokenType.Register: { int lineNumber = AsmDudeToolsStatic.Get_LineNumber(tagSpan); if (keyword_upcase.StartsWith("%", StringComparison.Ordinal)) { keyword_upcase = keyword_upcase.Substring(1); // remove the preceding % in AT&T syntax } Rn reg = RegisterTools.ParseRn(keyword_upcase, true); if (this.asmDudeTools_.RegisterSwitchedOn(reg)) { RegisterTooltipWindow registerTooltipWindow = new RegisterTooltipWindow(foreground); registerTooltipWindow.SetDescription(reg, this.asmDudeTools_); registerTooltipWindow.SetAsmSim(this.asmSimulator_, reg, lineNumber, true); quickInfoContent.Add(registerTooltipWindow); } break; } case AsmTokenType.Mnemonic: // intentional fall through case AsmTokenType.MnemonicOff: // intentional fall through case AsmTokenType.Jump: { (Mnemonic mnemonic, _) = AsmSourceTools.ParseMnemonic_Att(keyword_upcase, true); InstructionTooltipWindow instructionTooltipWindow = new InstructionTooltipWindow(foreground) { Session = session, // set the owner of this windows such that we can manually close this window }; instructionTooltipWindow.SetDescription(mnemonic, this.asmDudeTools_); instructionTooltipWindow.SetPerformanceInfo(mnemonic, this.asmDudeTools_); int lineNumber = AsmDudeToolsStatic.Get_LineNumber(tagSpan); instructionTooltipWindow.SetAsmSim(this.asmSimulator_, lineNumber, true); quickInfoContent.Add(instructionTooltipWindow); break; } case AsmTokenType.Label: { string label = keyword; string labelPrefix = tag.Misc; string full_Qualified_Label = AsmDudeToolsStatic.Make_Full_Qualified_Label(labelPrefix, label, AsmDudeToolsStatic.Used_Assembler); description = new TextBlock(); description.Inlines.Add(Make_Run1("Label ", foreground)); description.Inlines.Add(Make_Run2(full_Qualified_Label, new SolidColorBrush(AsmDudeToolsStatic.ConvertColor(Settings.Default.SyntaxHighlighting_Label)))); string descr = this.Get_Label_Description(full_Qualified_Label); if (descr.Length == 0) { descr = this.Get_Label_Description(label); } if (descr.Length > 0) { if (keyword.Length > (AsmDudePackage.MaxNumberOfCharsInToolTips / 2)) { descr = "\n" + descr; } description.Inlines.Add(new Run(AsmSourceTools.Linewrap(": " + descr, AsmDudePackage.MaxNumberOfCharsInToolTips)) { Foreground = foreground, }); } break; } case AsmTokenType.LabelDef: { string label = keyword; string extra_Tag_Info = tag.Misc; string full_Qualified_Label; if ((extra_Tag_Info != null) && extra_Tag_Info.Equals(AsmTokenTag.MISC_KEYWORD_PROTO, StringComparison.Ordinal)) { full_Qualified_Label = label; } else { full_Qualified_Label = AsmDudeToolsStatic.Make_Full_Qualified_Label(extra_Tag_Info, label, AsmDudeToolsStatic.Used_Assembler); } AsmDudeToolsStatic.Output_INFO("AsmQuickInfoSource:AugmentQuickInfoSession: found label def " + full_Qualified_Label); description = new TextBlock(); description.Inlines.Add(Make_Run1("Label ", foreground)); description.Inlines.Add(Make_Run2(full_Qualified_Label, new SolidColorBrush(AsmDudeToolsStatic.ConvertColor(Settings.Default.SyntaxHighlighting_Label)))); string descr = this.Get_Label_Def_Description(full_Qualified_Label, label); if (descr.Length > 0) { if (keyword.Length > (AsmDudePackage.MaxNumberOfCharsInToolTips / 2)) { descr = "\n" + descr; } description.Inlines.Add(new Run(AsmSourceTools.Linewrap(": " + descr, AsmDudePackage.MaxNumberOfCharsInToolTips)) { Foreground = foreground, }); } break; } case AsmTokenType.Constant: { (bool valid, ulong value, int nBits) = AsmSourceTools.Evaluate_Constant(keyword); string constantStr = valid ? value + "d = " + value.ToString("X", AsmDudeToolsStatic.CultureUI) + "h = " + AsmSourceTools.ToStringBin(value, nBits) + "b" : keyword; if (false) // experiment to get text selectable { TextBoxWindow myWindow = new TextBoxWindow(); myWindow.MouseRightButtonUp += this.MyWindow_MouseRightButtonUp; myWindow.MyContent.Text = "Constant X: " + constantStr; myWindow.MyContent.Foreground = foreground; myWindow.MyContent.MouseRightButtonUp += this.MyContent_MouseRightButtonUp; quickInfoContent.Add(myWindow); } else { description = new SelectableTextBlock(); description.Inlines.Add(Make_Run1("Constant ", foreground)); description.Inlines.Add(Make_Run2(constantStr, new SolidColorBrush(AsmDudeToolsStatic.ConvertColor(Settings.Default.SyntaxHighlighting_Constant)))); } break; } case AsmTokenType.UserDefined1: { description = new TextBlock(); description.Inlines.Add(Make_Run1("User defined 1: ", foreground)); description.Inlines.Add(Make_Run2(keyword, new SolidColorBrush(AsmDudeToolsStatic.ConvertColor(Settings.Default.SyntaxHighlighting_Userdefined1)))); string descr = this.asmDudeTools_.Get_Description(keyword_upcase); if (descr.Length > 0) { if (keyword.Length > (AsmDudePackage.MaxNumberOfCharsInToolTips / 2)) { descr = "\n" + descr; } description.Inlines.Add(new Run(AsmSourceTools.Linewrap(": " + descr, AsmDudePackage.MaxNumberOfCharsInToolTips)) { Foreground = foreground, }); } break; } case AsmTokenType.UserDefined2: { description = new TextBlock(); description.Inlines.Add(Make_Run1("User defined 2: ", foreground)); description.Inlines.Add(Make_Run2(keyword, new SolidColorBrush(AsmDudeToolsStatic.ConvertColor(Settings.Default.SyntaxHighlighting_Userdefined2)))); string descr = this.asmDudeTools_.Get_Description(keyword_upcase); if (descr.Length > 0) { if (keyword.Length > (AsmDudePackage.MaxNumberOfCharsInToolTips / 2)) { descr = "\n" + descr; } description.Inlines.Add(new Run(AsmSourceTools.Linewrap(": " + descr, AsmDudePackage.MaxNumberOfCharsInToolTips)) { Foreground = foreground, }); } break; } case AsmTokenType.UserDefined3: { description = new TextBlock(); description.Inlines.Add(Make_Run1("User defined 3: ", foreground)); description.Inlines.Add(Make_Run2(keyword, new SolidColorBrush(AsmDudeToolsStatic.ConvertColor(Settings.Default.SyntaxHighlighting_Userdefined3)))); string descr = this.asmDudeTools_.Get_Description(keyword_upcase); if (descr.Length > 0) { if (keyword.Length > (AsmDudePackage.MaxNumberOfCharsInToolTips / 2)) { descr = "\n" + descr; } description.Inlines.Add(new Run(AsmSourceTools.Linewrap(": " + descr, AsmDudePackage.MaxNumberOfCharsInToolTips)) { Foreground = foreground, }); } break; } default: //description = new TextBlock(); //description.Inlines.Add(makeRun1("Unused tagType " + asmTokenTag.Tag.type)); break; } if (description != null) { description.Focusable = true; description.FontSize = AsmDudeToolsStatic.GetFontSize() + 2; description.FontFamily = AsmDudeToolsStatic.GetFontType(); //AsmDudeToolsStatic.Output_INFO(string.Format(AsmDudeToolsStatic.CultureUI, "{0}:AugmentQuickInfoSession; setting description fontSize={1}; fontFamily={2}", this.ToString(), description.FontSize, description.FontFamily)); quickInfoContent.Add(description); } } //AsmDudeToolsStatic.Output_INFO("AsmQuickInfoSource:AugmentQuickInfoSession: applicableToSpan=\"" + applicableToSpan + "\"; quickInfoContent,Count=" + quickInfoContent.Count); AsmDudeToolsStatic.Print_Speed_Warning(time1, "QuickInfo"); }
public IEnumerable <ITagSpan <IErrorTag> > GetTags(NormalizedSnapshotSpanCollection spans) { if (spans.Count == 0) { // there is no content in the buffer yield break; } bool labelGraph_Enabled = this._labelGraph.Enabled; bool asmSimulator_Enabled = this._asmSimulator.Enabled; if (!labelGraph_Enabled && !asmSimulator_Enabled) { // nothing to decorate yield break; } DateTime time1 = DateTime.Now; //TODO move the followign boolean to constructor bool Decorate_Undefined_Labels = labelGraph_Enabled && Settings.Default.IntelliSense_Decorate_Undefined_Labels; bool Decorate_Clashing_Labels = labelGraph_Enabled && Settings.Default.IntelliSense_Decorate_Clashing_Labels; bool Decorate_Undefined_Includes = labelGraph_Enabled && Settings.Default.IntelliSense_Show_Undefined_Includes; bool Decorate_Registers_Known_Register_Values = asmSimulator_Enabled && Settings.Default.AsmSim_Decorate_Registers; bool Decorate_Syntax_Errors = asmSimulator_Enabled && Settings.Default.AsmSim_Decorate_Syntax_Errors; bool Decorate_Unimplemented = asmSimulator_Enabled && Settings.Default.AsmSim_Decorate_Unimplemented; bool Decorate_Usage_Of_Undefined = asmSimulator_Enabled && Settings.Default.AsmSim_Decorate_Usage_Of_Undefined; bool Decorate_Redundant_Instructions = asmSimulator_Enabled && Settings.Default.AsmSim_Decorate_Redundant_Instructions; bool Decorate_Unreachable_Instructions = asmSimulator_Enabled && Settings.Default.AsmSim_Decorate_Unreachable_Instructions; bool Show_Syntax_Error_Error_List = asmSimulator_Enabled && Settings.Default.AsmSim_Show_Syntax_Errors; bool Show_Usage_Of_Undefined = asmSimulator_Enabled && Settings.Default.AsmSim_Show_Usage_Of_Undefined; AssemblerEnum usedAssember = AsmDudeToolsStatic.Used_Assembler; foreach (IMappingTagSpan <AsmTokenTag> asmTokenTag in this._aggregator.GetTags(spans)) { SnapshotSpan tagSpan = asmTokenTag.Span.GetSpans(this._sourceBuffer)[0]; //AsmDudeToolsStatic.Output_INFO(string.Format("SquigglesTagger:GetTags: found keyword \"{0}\"", tagSpan.GetText())); int lineNumber = AsmDudeToolsStatic.Get_LineNumber(tagSpan); switch (asmTokenTag.Tag.Type) { case AsmTokenType.Label: { if (Decorate_Undefined_Labels) { string label = tagSpan.GetText(); string full_Qualified_Label = AsmDudeToolsStatic.Make_Full_Qualified_Label(asmTokenTag.Tag.Misc, label, usedAssember); if (this._labelGraph.Has_Label(full_Qualified_Label)) { // Nothing to report } else { //AsmDudeToolsStatic.Output_INFO(string.Format("SquigglesTagger:GetTags: found label \"{0}\"; full-label \"{1}\"", label, full_Qualified_Label)); if (usedAssember == AssemblerEnum.MASM) { if (this._labelGraph.Has_Label(label)) { // TODO: is this always a valid label? Nothing to report } else { TextBlock toolTipContent = this.Undefined_Label_Tool_Tip_Content(); yield return(new TagSpan <IErrorTag>(tagSpan, new ErrorTag(PredefinedErrorTypeNames.SyntaxError, toolTipContent))); } } else { TextBlock toolTipContent = this.Undefined_Label_Tool_Tip_Content(); yield return(new TagSpan <IErrorTag>(tagSpan, new ErrorTag(PredefinedErrorTypeNames.SyntaxError, toolTipContent))); } } } break; } case AsmTokenType.LabelDef: { if (Decorate_Clashing_Labels) { string label = tagSpan.GetText(); string full_Qualified_Label = AsmDudeToolsStatic.Make_Full_Qualified_Label(asmTokenTag.Tag.Misc, label, usedAssember); if (this._labelGraph.Has_Label_Clash(full_Qualified_Label)) { TextBlock toolTipContent = this.Label_Clash_Tool_Tip_Content(full_Qualified_Label); //PredefinedErrorTypeNames.Warning is green //PredefinedErrorTypeNames.SyntaxError is red //PredefinedErrorTypeNames.CompilerError is blue //PredefinedErrorTypeNames.Suggestion is NOTHING //PredefinedErrorTypeNames.OtherError is purple yield return(new TagSpan <IErrorTag>(tagSpan, new ErrorTag(PredefinedErrorTypeNames.SyntaxError, toolTipContent))); } } break; } case AsmTokenType.Register: { if (Decorate_Registers_Known_Register_Values) { Rn regName = RegisterTools.ParseRn(tagSpan.GetText()); //AsmDudeToolsStatic.Output_INFO("SquigglesTagger:GetTags: found register " + regName + " at line " + lineNumber); bool preCompute = false; (bool HasValue1, bool Bussy1) = this._asmSimulator.Has_Register_Value(regName, lineNumber, true, preCompute); if (!Bussy1) { (bool HasValue2, bool Bussy2) = this._asmSimulator.Has_Register_Value(regName, lineNumber, false, preCompute); if (!Bussy2) { if (HasValue1 || HasValue2) { // only show squiggles to indicate that information is available //AsmDudeToolsStatic.Output_INFO("SquigglesTagger:GetTags: adding squiggles for register " + regName + " at line " + lineNumber); yield return(new TagSpan <IErrorTag>(tagSpan, new ErrorTag(PredefinedErrorTypeNames.Warning))); } } } } break; } case AsmTokenType.Mnemonic: { if (Decorate_Syntax_Errors || Decorate_Unimplemented) { if (this._asmSimulator.Is_Implemented(lineNumber)) { if (Decorate_Syntax_Errors && this._asmSimulator.Has_Syntax_Error(lineNumber)) { string message = AsmSourceTools.Linewrap("Syntax Error: " + this._asmSimulator.Get_Syntax_Error(lineNumber).Message, AsmDudePackage.maxNumberOfCharsInToolTips); yield return(new TagSpan <IErrorTag>(tagSpan, new ErrorTag(PredefinedErrorTypeNames.SyntaxError, message))); } } else if (Decorate_Unimplemented) { string message = AsmSourceTools.Linewrap("Info: Instruction " + tagSpan.GetText() + " is not (yet) supported by the simulator.", AsmDudePackage.maxNumberOfCharsInToolTips); yield return(new TagSpan <IErrorTag>(tagSpan, new ErrorTag(PredefinedErrorTypeNames.CompilerError, message))); } } if (Decorate_Usage_Of_Undefined) { if (this._asmSimulator.Has_Usage_Undefined_Warning(lineNumber)) { string message = AsmSourceTools.Linewrap("Semantic Warning: " + this._asmSimulator.Get_Usage_Undefined_Warning(lineNumber).Message, AsmDudePackage.maxNumberOfCharsInToolTips); yield return(new TagSpan <IErrorTag>(tagSpan, new ErrorTag(PredefinedErrorTypeNames.OtherError, message))); } } if (Decorate_Redundant_Instructions) { if (this._asmSimulator.Has_Redundant_Instruction_Warning(lineNumber)) { string message = AsmSourceTools.Linewrap("Semantic Warning: " + this._asmSimulator.Get_Redundant_Instruction_Warning(lineNumber).Message, AsmDudePackage.maxNumberOfCharsInToolTips); yield return(new TagSpan <IErrorTag>(tagSpan, new ErrorTag(PredefinedErrorTypeNames.OtherError, message))); } } if (Decorate_Unreachable_Instructions) { if (this._asmSimulator.Has_Unreachable_Instruction_Warning(lineNumber)) { string message = AsmSourceTools.Linewrap("Semantic Warning: " + this._asmSimulator.Get_Unreachable_Instruction_Warning(lineNumber).Message, AsmDudePackage.maxNumberOfCharsInToolTips); yield return(new TagSpan <IErrorTag>(tagSpan, new ErrorTag(PredefinedErrorTypeNames.OtherError, message))); } } break; } case AsmTokenType.Constant: { if (Decorate_Undefined_Includes) { foreach ((string Include_Filename, string Path, string Source_Filename, int LineNumber)tup in this._labelGraph.Undefined_Includes) { if (tup.LineNumber == lineNumber) //TODO this is inefficient! { string toolTipContent = "Could not resolve include \"" + tagSpan.GetText() + "\""; yield return(new TagSpan <IErrorTag>(tagSpan, new ErrorTag(PredefinedErrorTypeNames.SyntaxError, toolTipContent))); break; // leave the foreach loop } } } break; } default: break; } } AsmDudeToolsStatic.Print_Speed_Warning(time1, "SquiggleTagger"); }
/// <summary> /// Determine which pieces of Quickinfo content should be displayed /// </summary> public void AugmentQuickInfoSession(IQuickInfoSession session, IList <object> quickInfoContent, out ITrackingSpan applicableToSpan) { //AsmDudeToolsStatic.Output_INFO("AsmQuickInfoSource:AugmentQuickInfoSession"); applicableToSpan = null; try { DateTime time1 = DateTime.Now; ITextSnapshot snapshot = this._sourceBuffer.CurrentSnapshot; var triggerPoint = (SnapshotPoint)session.GetTriggerPoint(snapshot); if (triggerPoint == null) { AsmDudeToolsStatic.Output_INFO("AsmQuickInfoSource:AugmentQuickInfoSession: trigger point is null"); return; } string keyword = ""; IEnumerable <IMappingTagSpan <AsmTokenTag> > enumerator = this._aggregator.GetTags(new SnapshotSpan(triggerPoint, triggerPoint)); //AsmDudeToolsStatic.Output("INFO: AsmQuickInfoSource:AugmentQuickInfoSession: enumerator.Count="+ enumerator.Count()); if (enumerator.Count() > 0) { if (false) { // TODO: multiple tags at the provided triggerPoint is most likely the result of a bug in AsmTokenTagger, but it seems harmless... if (enumerator.Count() > 1) { foreach (IMappingTagSpan <AsmTokenTag> v in enumerator) { AsmDudeToolsStatic.Output(string.Format("WARNING: {0}:AugmentQuickInfoSession. more than one tag! \"{1}\"", ToString(), v.Span.GetSpans(this._sourceBuffer).First().GetText())); } } } IMappingTagSpan <AsmTokenTag> asmTokenTag = enumerator.First(); SnapshotSpan tagSpan = asmTokenTag.Span.GetSpans(this._sourceBuffer).First(); keyword = tagSpan.GetText(); int lineNumber = tagSpan.Snapshot.GetLineNumberFromPosition(tagSpan.Start); //AsmDudeToolsStatic.Output("INFO: AsmQuickInfoSource:AugmentQuickInfoSession: keyword=\""+ keyword + "\"; type=" + asmTokenTag.Tag.type +"; file="+AsmDudeToolsStatic.GetFileName(session.TextView.TextBuffer)); string keywordUpper = keyword.ToUpper(); applicableToSpan = snapshot.CreateTrackingSpan(tagSpan, SpanTrackingMode.EdgeExclusive); TextBlock description = null; switch (asmTokenTag.Tag.Type) { case AsmTokenType.Misc: { description = new TextBlock(); description.Inlines.Add(Make_Run1("Keyword ", this._foreground)); description.Inlines.Add(Make_Run2(keyword, new SolidColorBrush(AsmDudeToolsStatic.ConvertColor(Settings.Default.SyntaxHighlighting_Misc)))); string descr = this._asmDudeTools.Get_Description(keywordUpper); if (descr.Length > 0) { description.Inlines.Add(new Run(AsmSourceTools.Linewrap(": " + descr, AsmDudePackage.maxNumberOfCharsInToolTips)) { Foreground = this._foreground }); } break; } case AsmTokenType.Directive: { description = new TextBlock(); description.Inlines.Add(Make_Run1("Directive ", this._foreground)); description.Inlines.Add(Make_Run2(keyword, new SolidColorBrush(AsmDudeToolsStatic.ConvertColor(Settings.Default.SyntaxHighlighting_Directive)))); string descr = this._asmDudeTools.Get_Description(keywordUpper); if (descr.Length > 0) { description.Inlines.Add(new Run(AsmSourceTools.Linewrap(": " + descr, AsmDudePackage.maxNumberOfCharsInToolTips)) { Foreground = this._foreground }); } break; } case AsmTokenType.Register: { description = new TextBlock(); description.Inlines.Add(Make_Run1("Register ", this._foreground)); description.Inlines.Add(Make_Run2(keyword, new SolidColorBrush(AsmDudeToolsStatic.ConvertColor(Settings.Default.SyntaxHighlighting_Register)))); string register_Descr = this._asmDudeTools.Get_Description(keywordUpper); if (register_Descr.Length > 0) { description.Inlines.Add(new Run(AsmSourceTools.Linewrap(": " + register_Descr, AsmDudePackage.maxNumberOfCharsInToolTips)) { Foreground = this._foreground }); } if (this._asmSimulator.Is_Enabled) { IState_R state = this._asmSimulator.GetState(lineNumber, true); string msg = this._asmSimulator.GetRegisterValue(RegisterTools.ParseRn(keyword), state); if (msg.Length == 0) { msg = "Calculating register content"; } description.Inlines.Add(new Run(AsmSourceTools.Linewrap("\n" + msg, AsmDudePackage.maxNumberOfCharsInToolTips)) { Foreground = this._foreground }); } break; } case AsmTokenType.Mnemonic: case AsmTokenType.Jump: { description = new TextBlock(); description.Inlines.Add(Make_Run1("Mnemonic ", this._foreground)); description.Inlines.Add(Make_Run2(keyword, new SolidColorBrush(AsmDudeToolsStatic.ConvertColor(Settings.Default.SyntaxHighlighting_Opcode)))); Mnemonic mmemonic = AsmSourceTools.ParseMnemonic(keywordUpper); { string archStr = ":" + ArchTools.ToString(this._asmDudeTools.Mnemonic_Store.GetArch(mmemonic)) + " "; string descr = this._asmDudeTools.Mnemonic_Store.GetDescription(mmemonic); description.Inlines.Add(new Run(AsmSourceTools.Linewrap(archStr + descr, AsmDudePackage.maxNumberOfCharsInToolTips)) { Foreground = this._foreground }); } { // show performance information MicroArch selectedMicroarchitures = AsmDudeToolsStatic.Get_MicroArch_Switched_On(); IReadOnlyList <PerformanceItem> performanceData = this._asmDudeTools.Performance_Store.GetPerformance(mmemonic, selectedMicroarchitures); if (performanceData.Count > 0) { FontFamily family = new FontFamily("Consolas"); IList <Run> list = new List <Run>(); description.Inlines.Add(new Run(string.Format("\n\n{0,-15}{1,-24}{2,-10}{3,-10}\n", "Architecture", "Instruction", "Latency", "Throughput")) { FontFamily = family, FontStyle = FontStyles.Italic, FontWeight = FontWeights.Bold, Foreground = this._foreground }); foreach (PerformanceItem item in performanceData) { description.Inlines.Add(new Run(string.Format("{0,-15}{1,-24}{2,-10}{3,-10}{4,-10}\n", item._microArch, item._instr + " " + item._args, item._latency, item._throughput, item._remark)) { FontFamily = family, Foreground = this._foreground }); } } } break; } case AsmTokenType.Label: { string label = keyword; string labelPrefix = asmTokenTag.Tag.Misc; string full_Qualified_Label = AsmDudeToolsStatic.Make_Full_Qualified_Label(labelPrefix, label, AsmDudeToolsStatic.Used_Assembler); description = new TextBlock(); description.Inlines.Add(Make_Run1("Label ", this._foreground)); description.Inlines.Add(Make_Run2(full_Qualified_Label, new SolidColorBrush(AsmDudeToolsStatic.ConvertColor(Settings.Default.SyntaxHighlighting_Label)))); string descr = Get_Label_Description(full_Qualified_Label); if (descr.Length == 0) { descr = Get_Label_Description(label); } if (descr.Length > 0) { description.Inlines.Add(new Run(AsmSourceTools.Linewrap(": " + descr, AsmDudePackage.maxNumberOfCharsInToolTips)) { Foreground = this._foreground }); } break; } case AsmTokenType.LabelDef: { string label = keyword; string extra_Tag_Info = asmTokenTag.Tag.Misc; string full_Qualified_Label; if ((extra_Tag_Info != null) && extra_Tag_Info.Equals(AsmTokenTag.MISC_KEYWORD_PROTO)) { full_Qualified_Label = label; } else { full_Qualified_Label = AsmDudeToolsStatic.Make_Full_Qualified_Label(extra_Tag_Info, label, AsmDudeToolsStatic.Used_Assembler); } AsmDudeToolsStatic.Output_INFO("AsmQuickInfoSource:AugmentQuickInfoSession: found label def " + full_Qualified_Label); description = new TextBlock(); description.Inlines.Add(Make_Run1("Label ", this._foreground)); description.Inlines.Add(Make_Run2(full_Qualified_Label, new SolidColorBrush(AsmDudeToolsStatic.ConvertColor(Settings.Default.SyntaxHighlighting_Label)))); string descr = Get_Label_Def_Description(full_Qualified_Label, label); if (descr.Length > 0) { description.Inlines.Add(new Run(AsmSourceTools.Linewrap(": " + descr, AsmDudePackage.maxNumberOfCharsInToolTips)) { Foreground = this._foreground }); } break; } case AsmTokenType.Constant: { description = new TextBlock(); description.Inlines.Add(Make_Run1("Constant ", this._foreground)); description.Inlines.Add(Make_Run2(keyword, new SolidColorBrush(AsmDudeToolsStatic.ConvertColor(Settings.Default.SyntaxHighlighting_Constant)))); break; } default: //description = new TextBlock(); //description.Inlines.Add(makeRun1("Unused tagType " + asmTokenTag.Tag.type)); break; } if (description != null) { description.FontSize = AsmDudeToolsStatic.Get_Font_Size() + 2; description.FontFamily = AsmDudeToolsStatic.Get_Font_Type(); //AsmDudeToolsStatic.Output(string.Format("INFO: {0}:AugmentQuickInfoSession; setting description fontSize={1}; fontFamily={2}", this.ToString(), description.FontSize, description.FontFamily)); quickInfoContent.Add(description); } } //AsmDudeToolsStatic.Output("INFO: AsmQuickInfoSource:AugmentQuickInfoSession: applicableToSpan=\"" + applicableToSpan + "\"; quickInfoContent,Count=" + quickInfoContent.Count); AsmDudeToolsStatic.Print_Speed_Warning(time1, "QuickInfo"); } catch (Exception e) { AsmDudeToolsStatic.Output(string.Format("ERROR: {0}:AugmentQuickInfoSession; e={1}", ToString(), e.ToString())); } }