private string GetText(string text, string actionId) { switch (actionId) { case "TextControl.Enter": return(null); // TODO: "Insert Live Template" // We only get this when someone uses Tab to insert a live template. // It would be nice to recognise that. We can't assume it, as any other // tab handler could be mis-recognised case "TextControl.Tab": return("Tab"); case "Synthetic.NextHotspot": return("Next Hotspot"); case "Synthetic.PreviousHotspot": return("Previous Hotspot"); case "Synthetic.CompleteItem.Enter": return(GetEnterCompleteItemText()); case "Synthetic.CompleteItem.Tab": return(GetTabCompleteItemText()); } var trim = MnemonicStore.RemoveMnemonicMark(text).Trim(TrimCharacters); return(string.IsNullOrEmpty(trim) ? actionId : trim); }
private IList <Mnemonic> getAllowedMnemonics(ISet <Arch> selectedArchitectures) { MnemonicStore store = this._asmDudeTools.mnemonicStore; IList <Mnemonic> list = new List <Mnemonic>(); foreach (Mnemonic mnemonic in Enum.GetValues(typeof(Mnemonic))) { foreach (Arch a in store.getArch(mnemonic)) { if (selectedArchitectures.Contains(a)) { list.Add(mnemonic); break; } } } return(list); }
public CommandBarActionDef(VsShortcutFinder vsShortcutFinder, DTE dte, string actionId, CommandID commandId, CommandBarControl control, CommandBarPopup[] parentPopups) { ActionId = actionId; // Lazily initialise. Talking to the command bar objects is SLOOOOOOOWWWWWW. backingFields = Lazy.Of(() => { Assertion.AssertNotNull(control, "control != null"); var sb = new StringBuilder(); foreach (var popup in parentPopups) { sb.AppendFormat("{0} \u2192 ", popup.Caption); } var fields = new BackingFields { Text = MnemonicStore.RemoveMnemonicMark(control.Caption), Path = MnemonicStore.RemoveMnemonicMark(sb.ToString()) }; var command = VsCommandHelpers.TryGetVsCommandAutomationObject(commandId, dte); var vsShortcut = vsShortcutFinder.GetVsShortcut(command); if (vsShortcut != null) { var details = new ShortcutDetails[vsShortcut.KeyboardShortcuts.Length]; for (int i = 0; i < vsShortcut.KeyboardShortcuts.Length; i++) { var keyboardShortcut = vsShortcut.KeyboardShortcuts[i]; details[i] = new ShortcutDetails(KeyConverter.Convert(keyboardShortcut.Key), keyboardShortcut.Modifiers); } fields.VsShortcut = new ShortcutSequence(details); } return(fields); }, true); }
/// <summary> /// Singleton pattern: use AsmDudeTools.Instance for the instance of this class /// </summary> private AsmDudeTools() { //AsmDudeToolsStatic.Output_INFO("AsmDudeTools constructor"); ThreadHelper.ThrowIfNotOnUIThread(); #region Initialize ErrorListProvider IServiceProvider serviceProvider = new ServiceProvider(Package.GetGlobalService(typeof(Microsoft.VisualStudio.OLE.Interop.IServiceProvider)) as Microsoft.VisualStudio.OLE.Interop.IServiceProvider); this._errorListProvider = new ErrorListProvider(serviceProvider) { ProviderName = "Asm Errors", ProviderGuid = new Guid(EnvDTE.Constants.vsViewKindCode), }; #endregion this._threadPool = new SmartThreadPool(); #region load Signature Store and Performance Store string path = AsmDudeToolsStatic.Get_Install_Path() + "Resources" + Path.DirectorySeparatorChar; { string filename_Regular = path + "signature-may2019.txt"; string filename_Hand = path + "signature-hand-1.txt"; this._mnemonicStore = new MnemonicStore(filename_Regular, filename_Hand); } { this._performanceStore = new PerformanceStore(path + "Performance" + Path.DirectorySeparatorChar); } #endregion this.Init_Data(); this._mnemonics_switched_on = new HashSet <Mnemonic>(); this.UpdateMnemonicSwitchedOn(); this._register_switched_on = new HashSet <Rn>(); this.UpdateRegisterSwitchedOn(); #region Experiments if (false) { string filename2 = AsmDudeToolsStatic.Get_Install_Path() + "Resources" + Path.DirectorySeparatorChar + "mnemonics-nasm.txt"; MnemonicStore store2 = new MnemonicStore(filename2, null); ISet <string> archs = new SortedSet <string>(); IDictionary <string, string> signaturesIntel = new Dictionary <string, string>(); IDictionary <string, string> signaturesNasm = new Dictionary <string, string>(); foreach (Mnemonic mnemonic in Enum.GetValues(typeof(Mnemonic))) { IEnumerable <AsmSignatureElement> intel = this._mnemonicStore.GetSignatures(mnemonic); IEnumerable <AsmSignatureElement> nasm = store2.GetSignatures(mnemonic); signaturesIntel.Clear(); signaturesNasm.Clear(); int intelCount = 0; foreach (AsmSignatureElement e in intel) { intelCount++; string instruction = e.Mnemonic.ToString() + " " + e.Operands_Str; if (signaturesIntel.ContainsKey(instruction)) { AsmDudeToolsStatic.Output_WARNING("Intel " + instruction + ": is already present with arch " + signaturesIntel[instruction] + "; new arch " + e.Arch_Str); } else { signaturesIntel.Add(instruction, e.Arch_Str); } } int nasmCount = 0; foreach (AsmSignatureElement e in nasm) { nasmCount++; string instruction = e.Mnemonic.ToString() + " " + e.Operands_Str; if (signaturesNasm.ContainsKey(instruction)) { // AsmDudeToolsStatic.Output_WARNING("Nasm " + instruction + ": is already present with arch " + signaturesNasm[instruction] + "; new arch " + e.archStr); } else { signaturesNasm.Add(instruction, e.Arch_Str); } } foreach (AsmSignatureElement e in intel) { string instruction = e.Mnemonic.ToString() + " " + e.Operands_Str; //AsmDudeToolsStatic.Output_INFO("Intel " + instruction + ": arch" + e.archStr); if ((e.Arch_Str == null) || (e.Arch_Str.Length == 0)) { if (signaturesNasm.ContainsKey(instruction)) { AsmDudeToolsStatic.Output_INFO("Intel " + instruction + " has no arch, but NASM has \"" + signaturesNasm[instruction] + "\"."); } else { if (signaturesNasm.Count == 1) { AsmDudeToolsStatic.Output_INFO("Intel " + instruction + " has no arch, but NASM has \"" + signaturesNasm.GetEnumerator().Current + "\"."); } else { AsmDudeToolsStatic.Output_INFO("Intel " + instruction + " has no arch:"); foreach (KeyValuePair <string, string> pair in signaturesNasm) { AsmDudeToolsStatic.Output_INFO("\tNASM has " + pair.Key + ": \"" + pair.Value + "\"."); } AsmDudeToolsStatic.Output_INFO(" ----"); } } } } if (false) { if (intelCount != nasmCount) { foreach (AsmSignatureElement e in intel) { AsmDudeToolsStatic.Output_INFO("INTEL " + mnemonic + ": " + e); } foreach (AsmSignatureElement e in nasm) { AsmDudeToolsStatic.Output_INFO("NASM " + mnemonic + ": " + e); } } } } foreach (string str in archs) { AsmDudeToolsStatic.Output_INFO("INTEL arch " + str); } } if (false) { foreach (Arch arch in Enum.GetValues(typeof(Arch))) { int counter = 0; ISet <Mnemonic> usedMnemonics = new HashSet <Mnemonic>(); foreach (Mnemonic mnemonic in Enum.GetValues(typeof(Mnemonic))) { if (this.Mnemonic_Store.GetArch(mnemonic).Contains(arch)) { //AsmDudeToolsStatic.Output_INFO("AsmDudeTools constructor: arch="+arch+"; mnemonic=" + mnemonic); counter++; usedMnemonics.Add(mnemonic); } } string str = string.Empty; foreach (Mnemonic mnemonic in usedMnemonics) { str += mnemonic.ToString() + ","; } AsmDudeToolsStatic.Output_INFO("AsmDudeTools constructor: Architecture Option " + arch + " enables mnemonics " + str); } } if (false) { foreach (Mnemonic mnemonic in Enum.GetValues(typeof(Mnemonic))) { string keyword = mnemonic.ToString().ToUpper(); if (this._description.ContainsKey(keyword)) { string description = this._description[keyword]; string reference = this.Get_Url(mnemonic); this.Mnemonic_Store.SetHtmlRef(mnemonic, reference); } } AsmDudeToolsStatic.Output_INFO(this.Mnemonic_Store.ToString()); } if (false) { ISet <string> archs = new HashSet <string>(); foreach (Mnemonic mnemonic in Enum.GetValues(typeof(Mnemonic))) { if (!this._mnemonicStore.HasElement(mnemonic)) { AsmDudeToolsStatic.Output_INFO("AsmDudeTools constructor: mnemonic " + mnemonic + " is not present"); } foreach (AsmSignatureElement e in this._mnemonicStore.GetSignatures(mnemonic)) { foreach (string s in e.Arch_Str.Split(',')) { archs.Add(s.Trim()); } } } foreach (string s in archs) { AsmDudeToolsStatic.Output_INFO(s + ","); } } #endregion }
private string GetPath(IActionDefWithId def) { var path = actionPresentationHelper.GetPathPresentationToRoot(def); return(!string.IsNullOrEmpty(path) ? MnemonicStore.RemoveMnemonicMark(path) + " \u2192 " : string.Empty); }
public AsmSignatureHelpSource(ITextBuffer buffer) { //AsmDudeToolsStatic.Output_INFO("AsmSignatureHelpSource:constructor"); this._buffer = buffer; this._store = AsmDudeTools.Instance.Mnemonic_Store; }
public AsmSignatureHelpSource(ITextBuffer buffer) { //AsmDudeToolsStatic.Output_INFO("AsmSignatureHelpSource:constructor"); this._buffer = buffer ?? throw new ArgumentNullException(nameof(buffer)); this._store = AsmDudeTools.Instance.Mnemonic_Store; }
/// <summary> /// Singleton pattern: use AsmDudeTools.Instance for the instance of this class /// </summary> private AsmDudeTools() { //AsmDudeToolsStatic.Output(string.Format("INFO: AsmDudeTools constructor")); #region Initialize ErrorListProvider IServiceProvider serviceProvider = new ServiceProvider(Package.GetGlobalService(typeof(Microsoft.VisualStudio.OLE.Interop.IServiceProvider)) as Microsoft.VisualStudio.OLE.Interop.IServiceProvider); this._errorListProvider = new ErrorListProvider(serviceProvider); this._errorListProvider.ProviderName = "Asm Errors"; this._errorListProvider.ProviderGuid = new Guid(EnvDTE.Constants.vsViewKindCode); #endregion this._smartThreadPool = new SmartThreadPool(); //this._smartThreadPool.Start(); #region load signature store string path = AsmDudeToolsStatic.getInstallPath() + "Resources" + Path.DirectorySeparatorChar; //string filename = path + "mnemonics-nasm.txt"; string filename_Regular = path + "signature-june2016.txt"; string filename_Hand = path + "signature-hand-1.txt"; this._mnemonicStore = new MnemonicStore(filename_Regular, filename_Hand); #endregion this.initData(); #region Experiments if (false) { string filename2 = AsmDudeToolsStatic.getInstallPath() + "Resources" + Path.DirectorySeparatorChar + "mnemonics-nasm.txt"; MnemonicStore store2 = new MnemonicStore(filename2, null); ISet <String> archs = new SortedSet <String>(); IDictionary <string, string> signaturesIntel = new Dictionary <string, string>(); IDictionary <string, string> signaturesNasm = new Dictionary <string, string>(); foreach (Mnemonic mnemonic in Enum.GetValues(typeof(Mnemonic))) { IList <AsmSignatureElement> intel = this._mnemonicStore.getSignatures(mnemonic); IList <AsmSignatureElement> nasm = store2.getSignatures(mnemonic); signaturesIntel.Clear(); signaturesNasm.Clear(); foreach (AsmSignatureElement e in intel) { string instruction = e.mnemonic.ToString() + " " + e.operandsStr; if (signaturesIntel.ContainsKey(instruction)) { AsmDudeToolsStatic.Output("WARNING: Intel " + instruction + ": is already present with arch " + signaturesIntel[instruction] + "; new arch " + e.archStr); } else { signaturesIntel.Add(instruction, e.archStr); } } foreach (AsmSignatureElement e in nasm) { string instruction = e.mnemonic.ToString() + " " + e.operandsStr; if (signaturesNasm.ContainsKey(instruction)) { // AsmDudeToolsStatic.Output("WARNING: Nasm " + instruction + ": is already present with arch " + signaturesNasm[instruction] + "; new arch " + e.archStr); } else { signaturesNasm.Add(instruction, e.archStr); } } foreach (AsmSignatureElement e in intel) { string instruction = e.mnemonic.ToString() + " " + e.operandsStr; //AsmDudeToolsStatic.Output("Intel " + instruction + ": arch" + e.archStr); if ((e.archStr == null) || (e.archStr.Length == 0)) { if (signaturesNasm.ContainsKey(instruction)) { AsmDudeToolsStatic.Output("Intel " + instruction + " has no arch, but NASM has \"" + signaturesNasm[instruction] + "\"."); } else { if (signaturesNasm.Count == 1) { AsmDudeToolsStatic.Output("Intel " + instruction + " has no arch, but NASM has \"" + signaturesNasm.GetEnumerator().Current + "\"."); } else { AsmDudeToolsStatic.Output("Intel " + instruction + " has no arch:"); foreach (KeyValuePair <string, string> pair in signaturesNasm) { AsmDudeToolsStatic.Output("\tNASM has " + pair.Key + ": \"" + pair.Value + "\"."); } AsmDudeToolsStatic.Output(" ----"); } } } } if (false) { if (intel.Count != nasm.Count) { foreach (AsmSignatureElement e in intel) { AsmDudeToolsStatic.Output("INTEL " + mnemonic + ": " + e); } foreach (AsmSignatureElement e in nasm) { AsmDudeToolsStatic.Output("NASM " + mnemonic + ": " + e); } } } } foreach (String str in archs) { AsmDudeToolsStatic.Output("INTEL arch " + str); } } if (false) { foreach (Arch arch in Enum.GetValues(typeof(Arch))) { int counter = 0; ISet <Mnemonic> usedMnemonics = new HashSet <Mnemonic>(); foreach (Mnemonic mnemonic in Enum.GetValues(typeof(Mnemonic))) { if (this.mnemonicStore.getArch(mnemonic).Contains(arch)) { //AsmDudeToolsStatic.Output("INFO: AsmDudeTools constructor: arch="+arch+"; mnemonic=" + mnemonic); counter++; usedMnemonics.Add(mnemonic); } } string str = ""; foreach (Mnemonic mnemonic in usedMnemonics) { str += mnemonic.ToString() + ","; } AsmDudeToolsStatic.Output("INFO: AsmDudeTools constructor: Architecture Option " + arch + " enables mnemonics " + str); } } if (false) { foreach (Mnemonic mnemonic in Enum.GetValues(typeof(Mnemonic))) { string keyword = mnemonic.ToString().ToUpper(); if (this._description.ContainsKey(keyword)) { string description = this._description[keyword]; string reference = this.getUrl(keyword); this.mnemonicStore.setHtmlRef(mnemonic, reference); } } AsmDudeToolsStatic.Output(this.mnemonicStore.ToString()); } if (false) { ISet <string> archs = new HashSet <string>(); foreach (Mnemonic mnemonic in Enum.GetValues(typeof(Mnemonic))) { if (!this._mnemonicStore.hasElement(mnemonic)) { AsmDudeToolsStatic.Output("INFO: AsmDudeTools constructor: mnemonic " + mnemonic + " is not present"); } foreach (AsmSignatureElement e in this._mnemonicStore.getSignatures(mnemonic)) { foreach (string s in e.archStr.Split(',')) { archs.Add(s.Trim()); } } } foreach (string s in archs) { AsmDudeToolsStatic.Output(s + ","); } } #endregion }