Exemple #1
0
            public void Execute(IDataContext context, DelegateExecute nextExecute)
            {
                var solution = context.GetData(ProjectModel.DataContext.DataConstants.SOLUTION);

                if (solution == null)
                {
                    return;
                }

                var textControl = context.GetData(TextControl.DataContext.DataConstants.TEXT_CONTROL);

                if (textControl == null)
                {
                    return;
                }

                if (myLookupWindowManager.CurrentLookup != null)
                {
                    return;
                }

                const string commandName  = "Expanding postfix template with [Tab]";
                var          updateCookie = myChangeUnitFactory.CreateChangeUnit(textControl, commandName);

                try
                {
                    using (myCommandProcessor.UsingCommand(commandName))
                    {
                        var postfixItem = GetTemplateFromTextControl(solution, textControl);
                        if (postfixItem != null)
                        {
                            TipsManager.Instance.FeatureIsUsed(
                                "Plugin.ControlFlow.PostfixTemplates.<tab>", textControl.Document, solution);

                            var nameLength = postfixItem.Identity.Length;
                            var offset     = textControl.Caret.Offset() - nameLength;

                            postfixItem.Accept(
                                textControl, TextRange.FromLength(offset, nameLength),
                                LookupItemInsertType.Insert, Suffix.Empty, solution, keepCaretStill: false);

                            return;
                        }

                        updateCookie.Dispose();
                    }
                }
                catch
                {
                    updateCookie.Dispose();
                    throw;
                }

                nextExecute();
            }
Exemple #2
0
            public void Execute(IDataContext context, DelegateExecute nextExecute)
            {
                var solution = context.GetData(ProjectModel.DataContext.DataConstants.SOLUTION);

                if (solution != null)
                {
                    var textControl = context.GetData(TextControl.DataContext.DataConstants.TEXT_CONTROL);
                    if (textControl != null)
                    {
                        var lookupWindowManager = solution.TryGetComponent <ILookupWindowManager>();
                        if (lookupWindowManager == null || lookupWindowManager.CurrentLookup == null)
                        {
                            const string commandName = "Expanding postfix template with [Tab]";

                            var updateCookie = myChangeUnitFactory.CreateChangeUnit(textControl, commandName);

                            try
                            {
                                using (myCommandProcessor.UsingCommand(commandName))
                                {
                                    IsAvailableOrExecuteEww(solution, textControl, execute: true);
                                }
                            }
                            catch
                            {
                                updateCookie.Dispose();
                                throw;
                            }

                            return;
                        }
                    }
                }

                nextExecute();
            }