public SearchFilter(IVsSearchQuery searchQuery, IWpfTableControl control)
            {
                _searchTokens = SearchUtilities.ExtractSearchTokens(searchQuery);
                if (_searchTokens == null)
                {
                    _searchTokens = Array.Empty <IVsSearchToken>();
                }

                var newVisibleColumns = new List <ITableColumnDefinition>();

                foreach (var c in control.ColumnStates)
                {
                    if (c.IsVisible || ((c as ColumnState2)?.GroupingPriority > 0))
                    {
                        var definition = control.ColumnDefinitionManager.GetColumnDefinition(
                            c.Name
                            );
                        if (definition != null)
                        {
                            newVisibleColumns.Add(definition);
                        }
                    }
                }

                _visibleColumns = newVisibleColumns;
            }
        public VisualStudioSuppressionFixService(
            SVsServiceProvider serviceProvider,
            VisualStudioWorkspaceImpl workspace,
            IDiagnosticAnalyzerService diagnosticService,
            ExternalErrorDiagnosticUpdateSource buildErrorDiagnosticService,
            ICodeFixService codeFixService,
            ICodeActionEditHandlerService editHandlerService,
            IVisualStudioDiagnosticListSuppressionStateService suppressionStateService,
            IWaitIndicator waitIndicator,
            IVsHierarchyItemManager vsHierarchyItemManager)
        {
            _workspace                    = workspace;
            _diagnosticService            = diagnosticService;
            _buildErrorDiagnosticService  = buildErrorDiagnosticService;
            _codeFixService               = codeFixService;
            _suppressionStateService      = (VisualStudioDiagnosticListSuppressionStateService)suppressionStateService;
            _editHandlerService           = editHandlerService;
            _waitIndicator                = waitIndicator;
            _vsHierarchyItemManager       = vsHierarchyItemManager;
            _fixMultipleOccurencesService = workspace.Services.GetService <IFixMultipleOccurrencesService>();
            _projectMap                   = workspace.Services.GetService <IHierarchyItemToProjectIdMap>();

            var errorList = serviceProvider.GetService(typeof(SVsErrorList)) as IErrorList;

            _tableControl = errorList?.TableControl;
        }
        public VisualStudioSuppressionFixService(
            SVsServiceProvider serviceProvider,
            VisualStudioWorkspaceImpl workspace,
            IDiagnosticAnalyzerService diagnosticService,
            ICodeFixService codeFixService,
            ICodeActionEditHandlerService editHandlerService,
            IVisualStudioDiagnosticListSuppressionStateService suppressionStateService,
            IUIThreadOperationExecutor uiThreadOperationExecutor,
            IVsHierarchyItemManager vsHierarchyItemManager,
            IAsynchronousOperationListenerProvider listenerProvider)
        {
            _workspace                    = workspace;
            _diagnosticService            = diagnosticService;
            _buildErrorDiagnosticService  = workspace.ExternalErrorDiagnosticUpdateSource;
            _codeFixService               = codeFixService;
            _suppressionStateService      = (VisualStudioDiagnosticListSuppressionStateService)suppressionStateService;
            _editHandlerService           = editHandlerService;
            _uiThreadOperationExecutor    = uiThreadOperationExecutor;
            _vsHierarchyItemManager       = vsHierarchyItemManager;
            _fixMultipleOccurencesService = workspace.Services.GetService <IFixMultipleOccurrencesService>();
            _projectMap                   = workspace.Services.GetService <IHierarchyItemToProjectIdMap>();

            var errorList = serviceProvider.GetService(typeof(SVsErrorList)) as IErrorList;

            _tableControl = errorList?.TableControl;
            _listener     = listenerProvider.GetListener(FeatureAttribute.ErrorList);
        }
Example #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="FixSuggestedActionsSource"/> class.
        /// </summary>
        /// <param name="textView">
        /// The <see cref="ITextView"/> for which this source will offer fix suggestions.
        /// </param>
        /// <param name="textBuffer">
        /// The <see cref="ITextBuffer"/> associated with the <see cref="ITextView"/> for which this
        /// source will offer fix suggestions.
        /// </param>
        /// <param name="persistentSpanFactory">
        /// A factory for creating the persistent spans that specify the error locations and the
        /// replacement locations (which are not necessarily the same).
        /// </param>
        /// <param name="previewProvider">
        /// Creates the XAML UIControl that displays the preview.
        /// </param>
        public FixSuggestedActionsSource(
            ITextView textView,
            ITextBuffer textBuffer,
            IPersistentSpanFactory persistentSpanFactory,
            IPreviewProvider previewProvider)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            this.textView              = textView;
            this.textBuffer            = textBuffer;
            this.persistentSpanFactory = persistentSpanFactory;
            this.previewProvider       = previewProvider;

            // when text changed and sarif errors item changes, need to refresh errorInFile
            IErrorList errorList = ServiceProvider.GlobalProvider.GetService(typeof(SVsErrorList)) as IErrorList;

            this.errorListTableControl = errorList?.TableControl;
            this.errorListTableControl.EntriesChanged += this.ErrorListTableControl_EntriesChanged;
            this.RefreshPersistentSpans();

            // Keep track of which error is associated with each suggested action, so that when
            // the action is invoked, the associated error can be marked as fixed. When we mark
            // an error as fixed, we tell VS to recompute the list of suggested actions, so that
            // it doesn't suggest actions for errors that are already fixed.
            this.fixToErrorDictionary = new Dictionary <FixSuggestedAction, SarifErrorListItem>();
        }
Example #5
0
        public TableSearchFilter(IVsSearchQuery searchQuery, IWpfTableControl control)
        {
            this.tokens  = new List <string>();
            this.columns = new List <ITableColumnDefinition>(control.ColumnStates.Count);

            foreach (IVsSearchToken token in SearchUtilities.ExtractSearchTokens(searchQuery) ?? Array.Empty <IVsSearchToken>())
            {
                if (!string.IsNullOrEmpty(token.ParsedTokenText))
                {
                    this.tokens.Add(token.ParsedTokenText);
                }
            }

            foreach (ColumnState2 columnState in control.ColumnStates.OfType <ColumnState2>())
            {
                if (columnState.IsVisible || columnState.GroupingPriority > 0)
                {
                    ITableColumnDefinition definition = control.ColumnDefinitionManager.GetColumnDefinition(columnState.Name);
                    if (definition != null)
                    {
                        this.columns.Add(definition);
                    }
                }
            }
        }
Example #6
0
 public ITableControlEventProcessor GetAssociatedEventProcessor(IWpfTableControl tableControl)
 {
     return(new EventProcessor()
     {
         EditorAdaptersFactoryService = EditorAdaptersFactoryService
     });
 }
 public static void SetDefaultFilter(IWpfTableControl tableControl)
 {
     // We want only the active diagnostics to show up in the error list by default.
     if (tableControl.ColumnDefinitionManager.GetColumnDefinition(ColumnName) is SuppressionStateColumnDefinition suppressionStateColumn)
     {
         tableControl.SetFilter(ColumnName, new ColumnHashSetFilter(suppressionStateColumn, excluded: ServicesVSResources.Suppressed));
     }
 }
 public static void ClearSearch(IWpfTableControl control)
 {
     ThreadHelper.JoinableTaskFactory.RunAsync(async delegate
     {
         await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();
         control.SetFilter(nameof(TableSearchTask), null);
     }).FileAndForget(Constants.VsBindingPaneFeaturePrefix + nameof(TableSearchTask.ClearSearch));
 }
 public static void SetDefaultFilter(IWpfTableControl tableControl)
 {
     // We want only the active diagnostics to show up in the error list by default.
     var suppressionStateColumn = tableControl.ColumnDefinitionManager.GetColumnDefinition(ColumnName) as SuppressionStateColumnDefinition;
     if (suppressionStateColumn != null)
     {
         tableControl.SetFilter(ColumnName, new ColumnHashSetFilter(suppressionStateColumn, excluded: ServicesVSResources.SuppressionStateSuppressed));
     }
 }
Example #10
0
        public TableSearchFilter(IVsSearchQuery searchQuery, IWpfTableControl control)
        {
            _searchTokens = SearchUtilities.ExtractSearchTokens(searchQuery) ?? Array.Empty <IVsSearchToken>();

            var newVisibleColumns = control.ColumnStates
                                    .Where(c => c.IsVisible || (c as ColumnState2)?.GroupingPriority > 0)
                                    .Select(c => control.ColumnDefinitionManager.GetColumnDefinition(c.Name))
                                    .Where(definition => definition != null).ToList();

            _visibleColumns = newVisibleColumns;
        }
        public VisualStudioDiagnosticListSuppressionStateService(
            SVsServiceProvider serviceProvider,
            VisualStudioWorkspace workspace)
        {
            _workspace = workspace;
            _shellService = (IVsUIShell)serviceProvider.GetService(typeof(SVsUIShell));
            var errorList = serviceProvider.GetService(typeof(SVsErrorList)) as IErrorList;
            _tableControl = errorList?.TableControl;

            ClearState();
            InitializeFromTableControlIfNeeded();
        }
Example #12
0
        public IErrorListFilterHandler ReplaceFilter(IWpfTableControl tableControl, string filterIdentifier)
        {
            if (filterIdentifier == PredefinedScopeFilterNames.AllItemsScopeFilter)
            {
                return(new LoadedSolutionFilterHandler(ServicesVSResources.Loaded_items));
            }
            else if (filterIdentifier == PredefinedScopeFilterNames.EntireSolutionScopeFilter)
            {
                return(new LoadedSolutionFilterHandler(ServicesVSResources.Loaded_solution));
            }

            return(null); // Don't replace
        }
        public VisualStudioDiagnosticListSuppressionStateService(
            SVsServiceProvider serviceProvider,
            VisualStudioWorkspace workspace)
        {
            _workspace    = workspace;
            _shellService = (IVsUIShell)serviceProvider.GetService(typeof(SVsUIShell));
            var errorList = serviceProvider.GetService(typeof(SVsErrorList)) as IErrorList;

            _tableControl = errorList?.TableControl;

            ClearState();
            InitializeFromTableControlIfNeeded();
        }
        public VisualStudioSuppressionFixService(
            SVsServiceProvider serviceProvider,
            VisualStudioWorkspaceImpl workspace,
            IDiagnosticAnalyzerService diagnosticService,
            ICodeFixService codeFixService,
            IVisualStudioDiagnosticListSuppressionStateService suppressionStateService,
            IWaitIndicator waitIndicator)
        {
            _workspace = workspace;
            _diagnosticService = diagnosticService;
            _codeFixService = codeFixService;
            _suppressionStateService = (VisualStudioDiagnosticListSuppressionStateService)suppressionStateService;
            _waitIndicator = waitIndicator;
            _fixMultipleOccurencesService = workspace.Services.GetService<IFixMultipleOccurrencesService>();

            var errorList = serviceProvider.GetService(typeof(SVsErrorList)) as IErrorList;
            _tableControl = errorList?.TableControl;
        }
Example #15
0
        public BindingPaneControl(IServiceProvider serviceProvider, BindingPaneViewModel viewModel)
        {
            IComponentModel          componentModel       = serviceProvider.GetService <SComponentModel, IComponentModel>();
            ITableManagerProvider    tableManagerProvider = componentModel.GetService <ITableManagerProvider>();
            IWpfTableControlProvider tableControlProvider = componentModel.GetService <IWpfTableControlProvider>();

            this.ViewModel       = viewModel;
            this.tableDataSource = new TableDataSource(this.ViewModel.Entries);
            this.tableManager    = tableManagerProvider.GetTableManager(Constants.TableManagerString);
            this.tableManager.AddSource(this.tableDataSource, ColumnNames.DefaultSet.ToArray());
            this.TableControl = tableControlProvider.CreateControl(this.tableManager, true,
                                                                   ColumnNames.DefaultSet.Select(n => new ColumnState2(n, isVisible: true, width: 0)),
                                                                   ColumnNames.DefaultSet.ToArray());

            this.InitializeComponent();

            this.tableHolder.Child = this.TableControl.Control;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="FixSuggestedActionsSource"/> class.
        /// </summary>
        /// <param name="textView">
        /// The <see cref="ITextView"/> for which this source will offer fix suggestions.
        /// </param>
        /// <param name="textBuffer">
        /// The <see cref="ITextBuffer"/> associated with the <see cref="ITextView"/> for which this
        /// source will offer fix suggestions.
        /// </param>
        /// <param name="persistentSpanFactory">
        /// A factory for creating the persistent spans that specify the error locations and the
        /// replacement locations (which are not necessarily the same).
        /// </param>
        /// <param name="previewProvider">
        /// Creates the XAML UIControl that displays the preview.
        /// </param>
        public FixSuggestedActionsSource(
            ITextView textView,
            ITextBuffer textBuffer,
            IPersistentSpanFactory persistentSpanFactory,
            IPreviewProvider previewProvider)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            this.textView              = textView;
            this.textBuffer            = textBuffer;
            this.persistentSpanFactory = persistentSpanFactory;
            this.previewProvider       = previewProvider;

            if (this.previewProvider is EditActionPreviewProvider editActionPreviewProvider)
            {
                editActionPreviewProvider.ApplyFixesInDocument += this.PreviewProdiver_ApplyFixesInDocument;
            }

            // when text changed and sarif errors item changes, need to refresh errorInFile
            var errorList = ServiceProvider.GlobalProvider.GetService(typeof(SVsErrorList)) as IErrorList;

            this.errorListTableControl = errorList?.TableControl;
            if (this.errorListTableControl != null)
            {
                this.errorListTableControl.EntriesChanged += this.ErrorListTableControl_EntriesChanged;
            }

            var component = ServiceProvider.GlobalProvider.GetService(typeof(SComponentModel)) as IComponentModel;

            this.sarifErrorListEventSelectionService = component?.GetService <ISarifErrorListEventSelectionService>();
            if (this.sarifErrorListEventSelectionService != null)
            {
                this.sarifErrorListEventSelectionService.NavigatedItemChanged += this.SarifListErrorItemNavigated;
            }

            this.RefreshPersistentSpans();

            // Keep track of which error is associated with each suggested action, so that when
            // the action is invoked, the associated error can be marked as fixed. When we mark
            // an error as fixed, we tell VS to recompute the list of suggested actions, so that
            // it doesn't suggest actions for errors that are already fixed.
            this.fixToErrorDictionary = new Dictionary <FixSuggestedAction, SarifErrorListItem>();
        }
        public static bool SaveSettings(string window, IWpfTableControl control)
        {
            var columns = control.ColumnStates;

            using (var rootKey = VSRegistry.RegistryRoot(ProjectSystemToolsPackage.ServiceProvider, __VsLocalRegistryType.RegType_UserSettings, writable: true))
            {
                using (var columnsSubKey = rootKey.CreateSubKey(CreateColumnsKey(window)))
                {
                    if (columnsSubKey == null)
                    {
                        return(false);
                    }

                    for (var i = 0; i < columns.Count; i++)
                    {
                        var column = columns[i];

                        using (var columnSubKey = columnsSubKey.CreateSubKey(column.Name))
                        {
                            if (columnSubKey == null)
                            {
                                continue;
                            }

                            columnSubKey.SetValue(ColumnOrder, i, RegistryValueKind.DWord);
                            columnSubKey.SetValue(ColumnVisibility, column.IsVisible ? 1 : 0, RegistryValueKind.DWord);
                            columnSubKey.SetValue(ColumnWidth, (int)column.Width, RegistryValueKind.DWord);

                            columnSubKey.SetValue(ColumnSortDown, column.DescendingSort ? 1 : 0, RegistryValueKind.DWord);
                            columnSubKey.SetValue(ColumnSortPriority, column.SortPriority, RegistryValueKind.DWord);

                            if (column is ColumnState2 cs2)
                            {
                                columnSubKey.SetValue(ColumnGroupingPriority, cs2.GroupingPriority, RegistryValueKind.DWord);
                            }
                        }
                    }
                }
            }

            return(true);
        }
Example #18
0
        public VisualStudioDiagnosticListTableCommandHandler(
            SVsServiceProvider serviceProvider,
            VisualStudioWorkspace workspace,
            IVisualStudioSuppressionFixService suppressionFixService,
            IVisualStudioDiagnosticListSuppressionStateService suppressionStateService,
            IWaitIndicator waitIndicator,
            IDiagnosticAnalyzerService diagnosticService,
            ICodeActionEditHandlerService editHandlerService)
        {
            _workspace               = workspace;
            _suppressionFixService   = (VisualStudioSuppressionFixService)suppressionFixService;
            _suppressionStateService = (VisualStudioDiagnosticListSuppressionStateService)suppressionStateService;
            _waitIndicator           = waitIndicator;
            _diagnosticService       = diagnosticService;
            _editHandlerService      = editHandlerService;

            var errorList = serviceProvider.GetService(typeof(SVsErrorList)) as IErrorList;

            _tableControl = errorList?.TableControl;
        }
Example #19
0
        public VisualStudioSuppressionFixService(
            SVsServiceProvider serviceProvider,
            VisualStudioWorkspaceImpl workspace,
            IDiagnosticAnalyzerService diagnosticService,
            ICodeFixService codeFixService,
            ICodeActionEditHandlerService editHandlerService,
            IVisualStudioDiagnosticListSuppressionStateService suppressionStateService,
            IWaitIndicator waitIndicator)
        {
            _workspace                    = workspace;
            _diagnosticService            = diagnosticService;
            _codeFixService               = codeFixService;
            _suppressionStateService      = (VisualStudioDiagnosticListSuppressionStateService)suppressionStateService;
            _editHandlerService           = editHandlerService;
            _waitIndicator                = waitIndicator;
            _fixMultipleOccurencesService = workspace.Services.GetService <IFixMultipleOccurrencesService>();

            var errorList = serviceProvider.GetService(typeof(SVsErrorList)) as IErrorList;

            _tableControl = errorList?.TableControl;
        }
        public VisualStudioDiagnosticListTableCommandHandler(
            SVsServiceProvider serviceProvider,
            VisualStudioWorkspace workspace,
            IVisualStudioSuppressionFixService suppressionFixService,
            IVisualStudioDiagnosticListSuppressionStateService suppressionStateService,
            IUIThreadOperationExecutor uiThreadOperationExecutor,
            IDiagnosticAnalyzerService diagnosticService,
            ICodeActionEditHandlerService editHandlerService,
            IAsynchronousOperationListenerProvider listenerProvider)
        {
            _workspace                 = workspace;
            _suppressionFixService     = (VisualStudioSuppressionFixService)suppressionFixService;
            _suppressionStateService   = (VisualStudioDiagnosticListSuppressionStateService)suppressionStateService;
            _uiThreadOperationExecutor = uiThreadOperationExecutor;
            _diagnosticService         = diagnosticService;
            _editHandlerService        = editHandlerService;

            var errorList = serviceProvider.GetService(typeof(SVsErrorList)) as IErrorList;

            _tableControl = errorList?.TableControl;
            _listener     = listenerProvider.GetListener(FeatureAttribute.ErrorList);
        }
        public BindingPaneController(IServiceProvider serviceProvider, BindingPaneViewModel viewModel, IWpfTableControl table)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            this.serviceProvider            = serviceProvider;
            this.shell                      = this.serviceProvider.GetService <SVsUIShell, IVsUIShell>();
            this.viewModel                  = viewModel;
            this.viewModel.PropertyChanged += this.OnViewModelPropertyChanged;
            this.table                      = table;
            this.table.Control.Tag          = this;
            this.traceLevelDisplayNames     = Resource.TraceLevels.Split(',');

            this.traceLevels = new string[]
            {
                nameof(SourceLevels.Off),
                nameof(SourceLevels.Critical),
                nameof(SourceLevels.Error),
                nameof(SourceLevels.Warning),
                nameof(SourceLevels.Information),
                nameof(SourceLevels.Verbose),
                nameof(SourceLevels.ActivityTracing),
                nameof(SourceLevels.All),
            };
        }
Example #22
0
 public TableEventProcessor(IServiceProvider services, IWpfTableControl control)
 {
     this.services = services;
     this.control  = control;
 }
 public TableSearchTask(uint dwCookie, IVsSearchQuery pSearchQuery, IVsSearchCallback pSearchCallback, IWpfTableControl control)
     : base(dwCookie, pSearchQuery, pSearchCallback)
 {
     _control = control;
 }
 public ITableControlEventProcessor GetAssociatedEventProcessor(IWpfTableControl tableControl)
 {
     return(CreateEventProcessor());
 }
 private ErrorProcessor(IErrorList errorList)
 {
     _table = errorList.TableControl;
     errorList.TableControl.EntriesChanged += EntriesChanged;
 }
 public ITableControlEventProcessor GetAssociatedEventProcessor(IWpfTableControl tableControl)
 {
     return new EventProcessor() { EditorAdaptersFactoryService = EditorAdaptersFactoryService };
 }
 public ITableControlEventProcessor GetAssociatedEventProcessor(IWpfTableControl tableControl)
 => new TableControlEventProcessor(_operationExecutor, _listener);
Example #28
0
 public ITableControlEventProcessor GetAssociatedEventProcessor(IWpfTableControl tableControl)
 => CreateEventProcessor();
Example #29
0
 ITableControlEventProcessor ITableControlEventProcessorProvider.GetAssociatedEventProcessor(IWpfTableControl tableControl)
 {
     return(new TableEventProcessor(this.ServiceProvider, tableControl));
 }
 public ITableControlEventProcessor GetAssociatedEventProcessor(
     IWpfTableControl tableControl)
 {
     return new TableControlEventProcessor();
 }
 public IErrorListFilterHandler ReplaceFilter(IWpfTableControl tableControl, string filterIdentifier)
 {
     return(EntireSolutionWithoutMetadataFilterHandler.Instance);
 }
 public IErrorListFilterHandler?CreateFilter(IWpfTableControl tableControl)
 {
     // We're only replacing the "Entire Solution" filter, and not creating a new one.
     return(null);
 }
 public ITableControlEventProcessor GetAssociatedEventProcessor(IWpfTableControl tableControl)
 {
     return(new ErrorListPackageEventProcessor(_serviceProvider));
 }
Example #34
0
        ITableControlEventProcessor ITableControlEventProcessorProvider.GetAssociatedEventProcessor(IWpfTableControl tableControl)
        {
            if (tableControl == null)
            {
                return(null);
            }

            return(new EventProcessor(tableControl, selectionService));
        }
Example #35
0
 public EventProcessor(IWpfTableControl wpfTableControl, IIssueSelectionService selectionService)
 {
     this.wpfTableControl  = wpfTableControl;
     this.selectionService = selectionService;
 }