コード例 #1
0
        private async Task ShowHotspotAsync(IShowHotspotRequest request)
        {
            logger.WriteLine(OpenInIDEResources.ApiHandler_ProcessingRequest, request.ServerUrl, request.ProjectKey,
                             request.OrganizationKey ?? OpenInIDEResources.ApiHandler_NullOrganization, request.HotspotKey);

            // Always show the Hotspots tool window. If we can't successfully process the
            // request we'll show a gold bar in the window
            telemetryManager.ShowHotspotRequested();
            ideWindowService.BringToFront();
            toolWindowService.Show(HotspotsToolWindow.ToolWindowId);
            await failureInfoBar.ClearAsync();

            if (!ideStateValidator.CanHandleOpenInIDERequest(request.ServerUrl, request.ProjectKey, request.OrganizationKey))
            {
                // We're assuming the validator will have output an explanantion of why the IDE
                // isn't in the correct state
                await failureInfoBar.ShowAsync(HotspotsToolWindow.ToolWindowId);

                return;
            }

            var hotspot = await TryGetHotspotData(request.HotspotKey);

            if (hotspot == null)
            {
                await failureInfoBar.ShowAsync(HotspotsToolWindow.ToolWindowId);

                return;
            }

            var hotspotViz = TryCreateIssueViz(hotspot);

            if (hotspotViz == null)
            {
                await failureInfoBar.ShowAsync(HotspotsToolWindow.ToolWindowId);

                return;
            }

            if (!navigator.TryNavigate(hotspotViz))
            {
                logger.WriteLine(OpenInIDEResources.ApiHandler_FailedToNavigateToHotspot, hotspotViz.FilePath, hotspotViz.StartLine);
            }

            // Add to store and select regardless of whether navigation succeeded
            var addedHotspot = hotspotsStore.GetOrAdd(hotspotViz);

            issueSelectionService.SelectedIssue = addedHotspot;
        }