Exemplo n.º 1
0
        internal DevSkimErrorsSnapshot(string filePath, int versionNumber)
        {
            _filePath      = filePath;
            _versionNumber = versionNumber;

            _project = VSPackage.GetProjectName(_filePath);
            _project = (_project != null) ? _project : string.Empty;
        }
        public void Invoke(CancellationToken cancellationToken)
        {
            if (cancellationToken.IsCancellationRequested)
            {
                return;
            }

            _span.TextBuffer.Replace(_span.GetSpan(_snapshot), _fixedCode);

            VSPackage.LogEvent(string.Format("Fix invoked on {0} {1} fix {2}", _rule.Id, _rule.Name, _fix.Name));
        }
Exemplo n.º 3
0
        private void Url_RequestNavigate(object sender, RequestNavigateEventArgs e)
        {
            IVsWindowFrame        ppFrame;
            IVsWebBrowsingService browserService;

            browserService = Package.GetGlobalService(typeof(SVsWebBrowsingService)) as IVsWebBrowsingService;

            browserService.Navigate(this.Url.NavigateUri.AbsoluteUri, 0, out ppFrame);

            VSPackage.LogEvent(string.Format("More info invoked on {0} {1}", _rule.Id, _rule.Name));
        }
Exemplo n.º 4
0
        public IEnumerable <SuggestedActionSet> GetSuggestedActions(ISuggestedActionCategorySet requestedActionCategories, SnapshotSpan range, CancellationToken cancellationToken)
        {
            DevSkimError error = GetErrorUnderCaret(range);

            if (error != null && error.Actionable)
            {
                List <ISuggestedAction> fixActions = new List <ISuggestedAction>();

                ITrackingSpan trackingSpan = range.Snapshot.CreateTrackingSpan(error.Span, SpanTrackingMode.EdgeInclusive);

                // Create list of fixes if the rule has them..
                if (error.Rule.Fixes != null)
                {
                    foreach (CodeFix fix in error.Rule.Fixes)
                    {
                        fixActions.Add(new FixSuggestedAction(trackingSpan, error.Rule, fix));
                    }
                }

                int suppressDays = Settings.GetSettings().SuppressDays;

                List <ISuggestedAction> suppActions = new List <ISuggestedAction>();
                var line = range.Snapshot.GetLineFromPosition(range.Start);
                trackingSpan = line.Snapshot.CreateTrackingSpan(line.Extent, SpanTrackingMode.EdgeInclusive);

                suppActions.Add(new SuppressSuggestedAction(trackingSpan, error.Rule, suppressDays));
                suppActions.Add(new SuppressSuggestedAction(trackingSpan, error.Rule));

                // If there is multiple issues on the line, offer "Suppress all"
                if (SkimShim.HasMultipleProblems(trackingSpan.GetText(range.Snapshot),
                                                 trackingSpan.TextBuffer.ContentType.TypeName))
                {
                    suppActions.Add(new SuppressSuggestedAction(trackingSpan, null, suppressDays));
                    suppActions.Add(new SuppressSuggestedAction(trackingSpan, null));
                }

                VSPackage.LogEvent(string.Format("Lightbulb invoked on {0} {1}", error.Rule.Id, error.Rule.Name));

                // We don't want empty group and spacer in the pop-up menu
                if (fixActions.Count > 0)
                {
                    return new SuggestedActionSet[] { new SuggestedActionSet(fixActions), new SuggestedActionSet(suppActions) }
                }
                ;
                else
                {
                    return new SuggestedActionSet[] { new SuggestedActionSet(suppActions) }
                };
            }

            return(Enumerable.Empty <SuggestedActionSet>());
        }