/// <summary> /// Handler which enumerates issues for a Sonar project /// </summary> /// <param name="project">SonarQube project to query</param> /// <returns>Awaitable task which enumerates associated errors</returns> private async Task OnItemSelectAsync(SonarQubeProject project) { _projectPathsManager.TryGetValue(project.Key, out string projectLocalPath); IEnumerable <ErrorListItem> errors; try { errors = await _errorListProvider.GetErrorsAsync(project.Key, projectLocalPath); } catch { TeamExplorer.ShowNotification($"Failed to download issues for \"{project.Name}\".", NotificationType.Error, NotificationFlags.None, null, SonarErrorsNotificationId); return; } TeamExplorer.HideNotification(SonarErrorsNotificationId); if (errors.Any()) { if (!Path.IsPathRooted(errors.First().FileName)) { TeamExplorer.ShowNotification("Unable to resolve local file path for issues. Make sure project local path is correctly configured.", NotificationType.Warning, NotificationFlags.None, null, FilePathResolutionNotificationId); } else { TeamExplorer.HideNotification(FilePathResolutionNotificationId); } } ErrorTable.CleanAllErrors(); ErrorTable.AddErrors(project.Name, errors); _projectIssuesInView = project.Key; }
/// <summary> /// Refreshes the Sonar projects /// </summary> /// <returns>Awaitable task which completes when all projects are loaded</returns> public async System.Threading.Tasks.Task RefreshAsync() { try { IsBusy = true; await ViewModel.RefreshAsync(); TeamExplorer.HideNotification(ProjectLoadNotificationId); } catch { // Await until we are in the main thread context to be able // to access the View's ViewModel without issues await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); TeamExplorer.ShowNotification("Failed to load projects.", NotificationType.Error, NotificationFlags.None, null, ProjectLoadNotificationId); } finally { IsBusy = false; } }