예제 #1
0
        private void UpdateAnalyzers()
        {
            if (_analyzerItems == null)
            {
                // The set of AnalyzerItems hasn't been realized yet. Just signal that HasItems
                // may have changed.

                NotifyPropertyChanged(nameof(HasItems));
                return;
            }

            var project = _analyzersFolder.Workspace.CurrentSolution.GetProject(
                _analyzersFolder.ProjectId
                );

            if (project != null && project.AnalyzerReferences != _analyzerReferences)
            {
                _analyzerReferences = project.AnalyzerReferences;

                _analyzerItems.BeginBulkOperation();

                var itemsToRemove = _analyzerItems
                                    .Where(item => !_analyzerReferences.Contains(item.AnalyzerReference))
                                    .ToArray();

                var referencesToAdd = GetFilteredAnalyzers(_analyzerReferences, project)
                                      .Where(r => !_analyzerItems.Any(item => item.AnalyzerReference == r))
                                      .ToArray();

                foreach (var item in itemsToRemove)
                {
                    _analyzerItems.Remove(item);
                }

                foreach (var reference in referencesToAdd)
                {
                    _analyzerItems.Add(
                        new AnalyzerItem(
                            _analyzersFolder,
                            reference,
                            _commandHandler.AnalyzerContextMenuController
                            )
                        );
                }

                var sorted = _analyzerItems
                             .OrderBy(item => item.AnalyzerReference.Display)
                             .ToArray();
                for (var i = 0; i < sorted.Length; i++)
                {
                    _analyzerItems.Move(_analyzerItems.IndexOf(sorted[i]), i);
                }

                _analyzerItems.EndBulkOperation();

                NotifyPropertyChanged(nameof(HasItems));
            }
        }
예제 #2
0
        private void AddNewLog(string fullName)
        {
            if (logs.Any(x => x.FileInfo.FullName == fullName))
            {
                return;
            }

            if (!LogCache.TryGetLogData(fullName, out var log))
            {
                log = new LogData(new FileInfo(fullName));
            }

            if (log.ParsingStatus != ParsingStatus.Parsed)
            {
                LogDataProcessor.Schedule(log);
            }

            logs.Add(log);
        }
예제 #3
0
        /// <summary>
        /// Initializes a new instance with the specified properties.
        /// </summary>
        /// <param name="moniker">The unique, non-localized identifier for the
        /// completion set.</param>
        /// <param name="displayName">The localized name of the completion set.
        /// </param>
        /// <param name="applicableTo">The tracking span to which the
        /// completions apply.</param>
        /// <param name="completions">The list of completions.</param>
        /// <param name="options">The options to use for filtering and
        /// selecting items.</param>
        /// <param name="comparer">The comparer to use to order the provided
        /// completions.</param>
        /// <param name="matchInsertionText">If true, matches user input against
        /// the insertion text; otherwise, uses the display text.</param>
        public FuzzyCompletionSet(
            string moniker,
            string displayName,
            ITrackingSpan applicableTo,
            IEnumerable <DynamicallyVisibleCompletion> completions,
            CompletionOptions options,
            IComparer <Completion> comparer,
            bool matchInsertionText = false
            ) :
            base(moniker, displayName, applicableTo, null, null)
        {
            _matchInsertionText = matchInsertionText;
            _completions        = new BulkObservableCollection <Completion>();
            _completions.AddRange(completions
                                  .Where(c => c != null && !string.IsNullOrWhiteSpace(c.DisplayText))
                                  .OrderBy(c => c, comparer)
                                  );
            _comparer = new FuzzyStringMatcher(options.SearchMode);

            _shouldFilter       = options.FilterCompletions;
            _shouldHideAdvanced = options.HideAdvancedMembers && !_completions.All(IsAdvanced);

            if (!_completions.Any())
            {
                _completions = null;
            }

            if (_completions != null && _shouldFilter | _shouldHideAdvanced)
            {
                _filteredCompletions = new FilteredObservableCollection <Completion>(_completions);

                foreach (var c in _completions.Cast <DynamicallyVisibleCompletion>())
                {
                    c.Visible = !_shouldHideAdvanced || !IsAdvanced(c);
                }
                _filteredCompletions.Filter(IsVisible);
            }

            CommitByDefault = DefaultCommitByDefault;
        }
예제 #4
0
        /// <summary>
        /// Initializes a new instance with the specified properties.
        /// </summary>
        /// <param name="moniker">The unique, non-localized identifier for the
        /// completion set.</param>
        /// <param name="displayName">The localized name of the completion set.
        /// </param>
        /// <param name="applicableTo">The tracking span to which the
        /// completions apply.</param>
        /// <param name="completions">The list of completions.</param>
        /// <param name="options">The options to use for filtering and
        /// selecting items.</param>
        /// <param name="comparer">The comparer to use to order the provided
        /// completions.</param>
        /// <param name="matchInsertionText">If true, matches user input against
        /// the insertion text; otherwise, uses the display text.</param>
        public FuzzyCompletionSet(
            string moniker,
            string displayName,
            ITrackingSpan applicableTo,
            IEnumerable<DynamicallyVisibleCompletion> completions,
            CompletionOptions options,
            IComparer<Completion> comparer,
            bool matchInsertionText = false
        ) :
            base(moniker, displayName, applicableTo, null, null) {
            _matchInsertionText = matchInsertionText;
            _completions = new BulkObservableCollection<Completion>();
            _completions.AddRange(completions
                .Where(c => c != null && !string.IsNullOrWhiteSpace(c.DisplayText))
                .OrderBy(c => c, comparer)
            );
            _comparer = new FuzzyStringMatcher(options.SearchMode);

            _shouldFilter = options.FilterCompletions;
            _shouldHideAdvanced = options.HideAdvancedMembers && !_completions.All(IsAdvanced);

            if (!_completions.Any()) {
                _completions = null;
            }

            if (_completions != null && _shouldFilter | _shouldHideAdvanced) {
                _filteredCompletions = new FilteredObservableCollection<Completion>(_completions);

                foreach (var c in _completions.Cast<DynamicallyVisibleCompletion>()) {
                    c.Visible = !_shouldHideAdvanced || !IsAdvanced(c);
                }
                _filteredCompletions.Filter(IsVisible);
            }

            CommitByDefault = DefaultCommitByDefault;
        }