Exemplo n.º 1
0
        public override UnitTestElementNamespace GetNamespace()
        {
#if R8
            return(new UnitTestNamespace(_testTypeName.GetNamespaceName()));
#elif R91
            return(UnitTestElementNamespace.Create(_testTypeName.FullName));
#endif
        }
        public void Execute(ISolution solution, ITextControl textControl)
        {
            var jetPopupMenus = solution.GetPsiServices().GetComponent <JetPopupMenus>();
            var cache         = solution.GetComponent <SpecflowStepsDefinitionsCache>();

            jetPopupMenus.ShowModal(JetPopupMenu.ShowWhen.AutoExecuteIfSingleEnabledItem,
                                    (lifetime, menu) =>
            {
                menu.Caption.Value = WindowlessControlAutomation.Create("Where to create the step ?");

                var availableSteps  = cache.GetBindingTypes(_reference.GetElement().GetPsiModule());
                var filesPerClasses = new OneToSetMap <string, SpecflowStepsDefinitionsCache.AvailableBindingClass>();
                foreach (var availableBindingClass in availableSteps)
                {
                    filesPerClasses.Add(availableBindingClass.ClassClrName, availableBindingClass);
                }

                menu.ItemKeys.AddRange(filesPerClasses);
                menu.DescribeItem.Advise(lifetime, e =>
                {
                    var(classClrFullName, _) = (KeyValuePair <string, ISet <SpecflowStepsDefinitionsCache.AvailableBindingClass> >)e.Key;

                    e.Descriptor.Icon  = PsiSymbolsThemedIcons.Class.Id;
                    e.Descriptor.Style = MenuItemStyle.Enabled;

                    var clrTypeName           = new ClrTypeName(classClrFullName);
                    e.Descriptor.Text         = new RichText(clrTypeName.ShortName, DeclaredElementPresenterTextStyles.ParameterInfo.GetStyle(DeclaredElementPresentationPartKind.Type));
                    e.Descriptor.ShortcutText = clrTypeName.GetNamespaceName();
                });
                menu.ItemClicked.Advise(lifetime, key =>
                {
                    var(_, availableBindingClasses) = (KeyValuePair <string, ISet <SpecflowStepsDefinitionsCache.AvailableBindingClass> >)key;
                    OpenFileSelectionModal(jetPopupMenus, textControl, availableBindingClasses, _reference.GetStepKind(), _reference.GetStepText());
                });
                menu.PopupWindowContextSource = textControl.PopupWindowContextFactory.ForCaret();
            });
        }