コード例 #1
0
        public NavigateToSearcher(
            Solution solution,
            IAsynchronousOperationListener asyncListener,
            INavigateToSearchCallback callback,
            string searchPattern,
            bool searchCurrentDocument,
            IImmutableSet <string> kinds,
            CancellationToken cancellationToken)
        {
            _solution              = solution;
            _asyncListener         = asyncListener;
            _callback              = callback;
            _searchPattern         = searchPattern;
            _searchCurrentDocument = searchCurrentDocument;
            _kinds             = kinds;
            _cancellationToken = cancellationToken;
            _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;
            }
        }
コード例 #2
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);
        }
コード例 #3
0
 public static NavigateToSearcher Create(
     Solution solution,
     IAsynchronousOperationListener asyncListener,
     INavigateToSearchCallback callback,
     string searchPattern,
     IImmutableSet <string> kinds,
     CancellationToken disposalToken,
     INavigateToSearcherHost?host = null)
 {
     host ??= new DefaultNavigateToSearchHost(solution, asyncListener, disposalToken);
     return(new NavigateToSearcher(host, solution, callback, searchPattern, kinds));
 }
コード例 #4
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);
        }