示例#1
0
        private NavigateToSearcher(
            INavigateToSearcherHost host,
            Solution solution,
            INavigateToSearchCallback callback,
            string searchPattern,
            IImmutableSet <string> kinds)
        {
            _host          = host;
            _solution      = solution;
            _callback      = callback;
            _searchPattern = searchPattern;
            _kinds         = kinds;
            _progress_doNotAccessDirectly = new StreamingProgressTracker((current, maximum, ct) =>
            {
                callback.ReportProgress(current, maximum);
                return(new ValueTask());
            });

            var docTrackingService = _solution.Workspace.Services.GetRequiredService <IDocumentTrackingService>();

            // If the workspace is tracking documents, use that to prioritize our search
            // order.  That way we provide results for the documents the user is working
            // on faster than the rest of the solution.
            _activeDocument   = docTrackingService.GetActiveDocument(_solution);
            _visibleDocuments = docTrackingService.GetVisibleDocuments(_solution)
                                .WhereAsArray(d => d != _activeDocument);
        }
示例#2
0
        private NavigateToSearcher(
            INavigateToSearcherHost host,
            Solution solution,
            IAsynchronousOperationListener asyncListener,
            INavigateToSearchCallback callback,
            string searchPattern,
            bool searchCurrentDocument,
            IImmutableSet <string> kinds
            )
        {
            _host                  = host;
            _solution              = solution;
            _asyncListener         = asyncListener;
            _callback              = callback;
            _searchPattern         = searchPattern;
            _searchCurrentDocument = searchCurrentDocument;
            _kinds                 = kinds;
            _progress              = new StreamingProgressTracker(
                (current, maximum) =>
            {
                callback.ReportProgress(current, maximum);
                return(new ValueTask());
            }
                );

            if (_searchCurrentDocument)
            {
                var documentService =
                    _solution.Workspace.Services.GetRequiredService <IDocumentTrackingService>();
                var activeId = documentService.TryGetActiveDocument();
                _currentDocument = activeId != null?_solution.GetDocument(activeId) : null;
            }

            var docTrackingService =
                _solution.Workspace.Services.GetService <IDocumentTrackingService>()
                ?? NoOpDocumentTrackingService.Instance;

            // If the workspace is tracking documents, use that to prioritize our search
            // order.  That way we provide results for the documents the user is working
            // on faster than the rest of the solution.
            _activeDocument   = docTrackingService.GetActiveDocument(_solution);
            _visibleDocuments = docTrackingService
                                .GetVisibleDocuments(_solution)
                                .WhereAsArray(d => d != _activeDocument);
        }