Esempio n. 1
0
        protected override async task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress)
        {
            await RemoveAllCommentsCommand.InitializeAsync(this);

            await RemoveRegionsCommand.InitializeAsync(this);

            await RemoveXmlDocComments.InitializeAsync(this);

            await RemoveAllExceptXmlDocComments.InitializeAsync(this);

            await RemoveTasksCommand.InitializeAsync(this);

            await RemoveAllExceptTaskComments.InitializeAsync(this);
        }
Esempio n. 2
0
        protected override void Initialize()
        {
            DTE = (DTE2)GetService(typeof(DTE));

            Logger.Initialize(this, Vsix.Name);
            Telemetry.Initialize(this, Vsix.Version, "4f961700-5d74-4a99-b346-571e5c82cb9b");

            RemoveAllCommentsCommand.Initialize(this);
            RemoveRegionsCommand.Initialize(this);
            RemoveXmlDocComments.Initialize(this);
            RemoveAllExceptXmlDocComments.Initialize(this);
            RemoveTasksCommand.Initialize(this);
            RemoveAllExceptTaskComments.Initialize(this);

            base.Initialize();
        }
Esempio n. 3
0
        private static void RemoveCommentSpansFromBuffer(IWpfTextView view, IEnumerable <IMappingSpan> mappingSpans, IList <int> affectedLines)
        {
            using (var edit = view.TextBuffer.CreateEdit())
            {
                foreach (var mappingSpan in mappingSpans)
                {
                    var start = mappingSpan.Start.GetPoint(view.TextBuffer, PositionAffinity.Predecessor).Value;
                    var end   = mappingSpan.End.GetPoint(view.TextBuffer, PositionAffinity.Successor).Value;

                    var  span  = new Span(start, end - start);
                    var  lines = view.TextBuffer.CurrentSnapshot.Lines.Where(l => l.Extent.IntersectsWith(span));
                    bool skip  = false;

                    foreach (var line in lines)
                    {
                        if (RemoveTasksCommand.ContainsTaskComment(line))
                        {
                            skip = true;
                        }
                        else
                        {
                            if (!affectedLines.Contains(line.LineNumber))
                            {
                                affectedLines.Add(line.LineNumber);
                            }
                        }
                    }

                    if (skip)
                    {
                        continue;
                    }

                    var    mappingText = view.TextBuffer.CurrentSnapshot.GetText(span.Start, span.Length);
                    string empty       = Regex.Replace(mappingText, "([\\S]+)", string.Empty);

                    edit.Replace(span.Start, span.Length, empty);
                }

                edit.Apply();
            }
        }