public void Rewrites_Insert_Into_Batched_Insert()
        {
            var script = @" delete from tablea;";

            var rewriter = new ChunkDeletesRewriter(script);

            var replacements = rewriter.GetReplacements(ScriptDom.ScriptDom.GetDeleteStatements(script));

            Assert.AreEqual(1, replacements.Count);
        }
        public override GlyphDefinition GetDefintions(string fragment, TSqlStatement statement, GlyphDefinition definition, List <DeleteSpecification> queries)
        {
            var nonSargableRewriter = new ChunkDeletesRewriter(fragment);
            var replacements        = nonSargableRewriter.GetReplacements(queries);

            if (replacements.Count > 0)
            {
                definition.Menu.Add(new MenuDefinition()
                {
                    Caption = "Run Delete Statement in Batches",
                    Action  = () => { },
                    Type    = MenuItemType.Header
                    ,
                    Glyph = definition
                });

                var offsettedReplacments = new List <Replacements>();
                foreach (var replacement in replacements)
                {
                    var replacement1 = replacement;
                    replacement1.OriginalOffset += statement.StartOffset;
                    offsettedReplacments.Add(replacement1);
                }

                if (replacements.Count > 1)
                {
                    var menu = new MenuDefinition();
                    menu.Operation = new ClippyReplacementOperations(offsettedReplacments);
                    menu.Action    = () => PerformAction(menu.Operation, menu.Glyph);

                    menu.Glyph   = definition;
                    menu.Caption = GetCaptionForAll(statement);
                    menu.Type    = MenuItemType.MenuItem;
                    definition.Menu.Add(menu);
                }


                foreach (var replacement in offsettedReplacments)
                {
                    var menu = new MenuDefinition();
                    menu.Action    = () => PerformAction(menu.Operation, menu.Glyph);
                    menu.Glyph     = definition;
                    menu.Caption   = string.Format("\t\"{0}\" into Chunked Delete", replacement.Original);
                    menu.Type      = MenuItemType.MenuItem;
                    menu.Operation = new ClippyReplacementOperation(replacement);
                    definition.Menu.Add(menu);
                }

                definition.GenerateKey();
            }

            return(definition);
        }