Exemple #1
0
        public override void DoOperation(GlyphDefinition glyph)
        {
            foreach (var replacement in _replacements)
            {
                try
                {
                    var span = _snapshot.CreateTrackingSpan(replacement.OriginalOffset, replacement.OriginalLength, SpanTrackingMode.EdgeNegative).GetSpan(_snapshot);

                    if (span.GetText() != replacement.Original)
                    {
                        return;
                    }

                    var newSpan = span.Snapshot.CreateTrackingSpan(span.Start, replacement.OriginalLength, SpanTrackingMode.EdgeNegative);

                    _snapshot.TextBuffer.Replace(newSpan.GetSpan(newSpan.TextBuffer.CurrentSnapshot), replacement.Replacement);
                }
                catch (Exception e)
                {
                    OutputPane.WriteMessage("error unable to do replacement : {0}", e);
                }
            }

            glyph.Tag.Tagger.Reset();
        }
Exemple #2
0
        public List <GlyphDefinition> Get(int max)
        {
            List <GlyphDefinition> tags = new List <GlyphDefinition>();

            for (int i = 1; i < max; i++)
            {
                if (i % 2 == 0)
                {
                    continue;
                }

                var definition = new GlyphDefinition();
                definition.Line      = i;
                definition.LineCount = 1;
                definition.Menu.Add(new MenuDefinition()
                {
                    Caption = "why hello there", Type = MenuItemType.Header, Glyph = definition
                });


                tags.Add(definition);
            }

            return(tags);
        }
        private List <GlyphDefinition> GetClippyMenuItems()
        {
            var d = new GlyphDefinition();

            d.Line      = 1;
            d.LineCount = 1;
            d.Menu.Add(new MenuDefinition()
            {
                Action = () => { MessageBox.Show("Now"); }, Caption = "When is it beer time?", Type = MenuItemType.MenuItem, Glyph = d
            });
            d.Menu.Add(new MenuDefinition()
            {
                Action = () => { MessageBox.Show("Now"); }, Caption = "When is it lunch time?", Type = MenuItemType.MenuItem, Glyph = d
            });

            return(new List <GlyphDefinition>()
            {
                d
            });
        }
        public override void DoOperation(GlyphDefinition glyph)
        {
            try
            {
                var span = _snapshot.CreateTrackingSpan(_replacement.OriginalOffset, _replacement.OriginalLength, SpanTrackingMode.EdgeNegative).GetSpan(_snapshot);

                if (span.GetText() != _replacement.Original)
                    return;

                var newSpan = span.Snapshot.CreateTrackingSpan(span.Start, _replacement.OriginalLength, SpanTrackingMode.EdgeNegative);
                
                _snapshot.TextBuffer.Replace(newSpan.GetSpan(newSpan.TextBuffer.CurrentSnapshot), _replacement.Replacement);

                glyph.Tag.Tagger.Reset();
            }
            catch (Exception e)
            {
                OutputPane.WriteMessage("error unable to do replacement : {0}", e);
            }
        }
Exemple #5
0
        private List <GlyphDefinition> GetGlyphDefinitions(List <TSqlStatement> statements, string script)
        {
            var definitions = new List <GlyphDefinition>();

            foreach (var statement in statements)
            {
                var definition = new GlyphDefinition();
                definition.Line            = statement.StartLine;
                definition.StatementOffset = statement.StartOffset;
                definition.Type            = GlyphDefinitonType.Normal;
                definition.LineCount       = statement.ScriptTokenStream.LastOrDefault().Line - definition.Line;
                definition.StatementLength = statement.FragmentLength;

                var fragment           = script.Substring(statement.StartOffset, statement.FragmentLength);
                var queriesInStatement = ScriptDom.GetQuerySpecifications(fragment);
                var deletes            = ScriptDom.GetDeleteStatements(fragment);

                foreach (var operation in _operations)
                {
                    try
                    {
                        definition = operation.GetDefintions(fragment, statement, definition, queriesInStatement);
                        definition = operation.GetDefintions(fragment, statement, definition, deletes);

                        definition = operation.GetDefinitions(fragment, statement, definition, new List <TSqlStatement>()
                        {
                            statement
                        });
                    }
                    catch (Exception e)
                    {
                    }
                }


                definitions.Add(definition);
            }

            return(definitions);
        }
Exemple #6
0
        private List<GlyphDefinition> GetGlyphDefinitions(List<TSqlStatement> statements, string script)
        {
            var definitions = new List<GlyphDefinition>();

            foreach (var statement in statements)
            {
                var definition = new GlyphDefinition();
                definition.Line = statement.StartLine;
                definition.StatementOffset = statement.StartOffset;
                definition.Type = GlyphDefinitonType.Normal;
                definition.LineCount = statement.ScriptTokenStream.LastOrDefault().Line - definition.Line;
                definition.StatementLength = statement.FragmentLength;

                var fragment = script.Substring(statement.StartOffset, statement.FragmentLength);
                var queriesInStatement = ScriptDom.GetQuerySpecifications(fragment);
                var deletes = ScriptDom.GetDeleteStatements(fragment);
                
                foreach (var operation in _operations)
                {
                    try
                    {
                        definition = operation.GetDefintions(fragment, statement, definition, queriesInStatement);
                        definition = operation.GetDefintions(fragment, statement, definition, deletes);

                        definition = operation.GetDefinitions(fragment, statement, definition, new List<TSqlStatement>() {statement});
                    }
                    catch (Exception e)
                    {
                        
                    }
                }
                

                definitions.Add(definition);
            }

            return definitions;
        }
Exemple #7
0
 public ClippyTag(GlyphDefinition definition)
 {
     _definition = definition;
 }
        private List<GlyphDefinition> GetClippyMenuItems()
        {
            var d = new GlyphDefinition();
            d.Line = 1;
            d.LineCount = 1;
            d.Menu.Add(new MenuDefinition(){Action = () => { MessageBox.Show("Now"); }, Caption = "When is it beer time?", Type = MenuItemType.MenuItem, Glyph =  d});
            d.Menu.Add(new MenuDefinition() { Action = () => { MessageBox.Show("Now"); }, Caption = "When is it lunch time?", Type = MenuItemType.MenuItem, Glyph = d });

            return new List<GlyphDefinition>(){d};
        }
Exemple #9
0
 public ClippyTag(GlyphDefinition definition)
 {
     _definition = definition;
     
 }