public SonarQubeIssuesProvider(ISonarQubeService sonarQubeService, IActiveSolutionBoundTracker solutionBoundTracker, ITimerFactory timerFactory) { if (sonarQubeService == null) { throw new ArgumentNullException(nameof(sonarQubeService)); } if (solutionBoundTracker == null) { throw new ArgumentNullException(nameof(solutionBoundTracker)); } if (timerFactory == null) { throw new ArgumentNullException(nameof(timerFactory)); } this.sonarQubeService = sonarQubeService; this.solutionBoundTacker = solutionBoundTracker; this.solutionBoundTacker.SolutionBindingChanged += OnSolutionBoundChanged; refreshTimer = timerFactory.Create(); refreshTimer.AutoReset = true; refreshTimer.Interval = MillisecondsToWaitBetweenRefresh; refreshTimer.Elapsed += OnRefreshTimerElapsed; if (this.solutionBoundTacker.IsActiveSolutionBound) { SynchronizeSuppressedIssues(); refreshTimer.Start(); } }
public async Task UpdateHashesAsync(IEnumerable <SonarQubeIssue> issues, ISonarQubeService sonarQubeService, CancellationToken cancellationToken) { var secondaryLocations = GetSecondaryLocations(issues); if (!secondaryLocations.Any()) { // This will be the normal case: most issues don't have secondary locations return; } var uniqueKeys = GetUniqueSecondaryLocationKeys(secondaryLocations); var map = new ModuleKeyToSourceMap(); foreach (var key in uniqueKeys) { var sourceCode = await sonarQubeService.GetSourceCodeAsync(key, cancellationToken); Debug.Assert(sourceCode != null, "Not expecting the file contents to be null"); map.AddSourceCode(key, sourceCode); } foreach (var location in GetSecondaryLocations(issues)) { SetLineHash(map, location); } }
public SonarQubeIssuesProvider(ISonarQubeService sonarQubeService, string sonarQubeProjectKey, ITimerFactory timerFactory, ILogger logger) { if (sonarQubeService == null) { throw new ArgumentNullException(nameof(sonarQubeService)); } if (string.IsNullOrWhiteSpace(sonarQubeProjectKey)) { throw new ArgumentNullException(nameof(sonarQubeProjectKey)); } if (timerFactory == null) { throw new ArgumentNullException(nameof(timerFactory)); } if (logger == null) { throw new ArgumentNullException(nameof(logger)); } this.sonarQubeService = sonarQubeService; this.sonarQubeProjectKey = sonarQubeProjectKey; this.logger = logger; refreshTimer = timerFactory.Create(); refreshTimer.AutoReset = true; refreshTimer.Interval = MillisecondsToWaitBetweenRefresh; refreshTimer.Elapsed += OnRefreshTimerElapsed; initialFetchCancellationTokenSource = new CancellationTokenSource(); this.initialFetch = Task.Factory.StartNew(DoInitialFetchAsync, initialFetchCancellationTokenSource.Token); refreshTimer.Start(); }
public SonarQubeIssuesProvider(ISonarQubeService sonarQubeService, string sonarQubeProjectKey, ITimerFactory timerFactory) { if (sonarQubeService == null) { throw new ArgumentNullException(nameof(sonarQubeService)); } if (string.IsNullOrWhiteSpace(sonarQubeProjectKey)) { throw new ArgumentNullException(nameof(sonarQubeProjectKey)); } if (timerFactory == null) { throw new ArgumentNullException(nameof(timerFactory)); } this.sonarQubeService = sonarQubeService; this.sonarQubeProjectKey = sonarQubeProjectKey; refreshTimer = timerFactory.Create(); refreshTimer.AutoReset = true; refreshTimer.Interval = MillisecondsToWaitBetweenRefresh; refreshTimer.Elapsed += OnRefreshTimerElapsed; this.initialFetch = Task.Factory.StartNew(SynchronizeSuppressedIssues); refreshTimer.Start(); }
public OpenInIDERequestHandler( IIDEWindowService ideWindowService, IToolWindowService toolWindowService, IOpenInIDEStateValidator ideStateValidator, ISonarQubeService sonarQubeService, IHotspotToIssueVisualizationConverter converter, ILocationNavigator navigator, IHotspotsStore hotspotsStore, IOpenInIDEFailureInfoBar failureInfoBar, IIssueSelectionService issueSelectionService, ITelemetryManager telemetryManager, ILogger logger) { // MEF-created so the arguments should never be null this.ideWindowService = ideWindowService; this.toolWindowService = toolWindowService; this.ideStateValidator = ideStateValidator; this.sonarQubeService = sonarQubeService; this.converter = converter; this.navigator = navigator; this.hotspotsStore = hotspotsStore; this.failureInfoBar = failureInfoBar; this.issueSelectionService = issueSelectionService; this.telemetryManager = telemetryManager; this.logger = logger; }
private async Task UpdateConnection() { ISonarQubeService sqService = this.extensionHost.SonarQubeService; if (sqService.IsConnected) { sqService.Disconnect(); if (this.extensionHost.ActiveSection?.DisconnectCommand.CanExecute(null) == true) { this.extensionHost.ActiveSection.DisconnectCommand.Execute(null); } } bool isSolutionCurrentlyBound = this.solutionBindingInformationProvider.IsSolutionBound(); if (isSolutionCurrentlyBound) { var solutionBinding = this.extensionHost.GetService <ISolutionBindingSerializer>(); solutionBinding.AssertLocalServiceIsNotNull(); BoundSonarQubeProject boundProject = solutionBinding.ReadSolutionBinding(); var connectionInformation = boundProject.CreateConnectionInformation(); // TODO: handle connection failure // TODO: block until the connection is complete await this.extensionHost.SonarQubeService.ConnectAsync(connectionInformation, CancellationToken.None); } }
private static TaintIssuesSynchronizer CreateTestSubject(ITaintStore taintStore = null, ITaintIssueToIssueVisualizationConverter converter = null, ILogger logger = null, SonarLintMode mode = SonarLintMode.Connected, ISonarQubeService sonarService = null, IVsMonitorSelection vsMonitor = null, IToolWindowService toolWindowService = null) { taintStore ??= Mock.Of <ITaintStore>(); converter ??= Mock.Of <ITaintIssueToIssueVisualizationConverter>(); var serviceProvider = CreateServiceProvider(vsMonitor); var configurationProvider = new Mock <IConfigurationProvider>(); configurationProvider .Setup(x => x.GetConfiguration()) .Returns(new BindingConfiguration(new BoundSonarQubeProject { ProjectKey = SharedProjectKey }, mode, "")); sonarService ??= CreateSonarService().Object; toolWindowService ??= Mock.Of <IToolWindowService>(); logger ??= Mock.Of <ILogger>(); return(new TaintIssuesSynchronizer(taintStore, sonarService, converter, configurationProvider.Object, toolWindowService, serviceProvider, logger)); }
private async Task UpdateConnectionAsync() { ISonarQubeService sonarQubeService = this.extensionHost.SonarQubeService; if (sonarQubeService.IsConnected) { if (this.extensionHost.ActiveSection?.DisconnectCommand.CanExecute(null) == true) { this.extensionHost.ActiveSection.DisconnectCommand.Execute(null); } else { sonarQubeService.Disconnect(); } } Debug.Assert(!sonarQubeService.IsConnected, "SonarQube service should always be disconnected at this point"); var boundProject = this.configurationProvider.GetConfiguration().Project; if (boundProject != null) { var connectionInformation = boundProject.CreateConnectionInformation(); await WebServiceHelper.SafeServiceCallAsync(() => sonarQubeService.ConnectAsync(connectionInformation, CancellationToken.None), this.logger); } Debug.Assert((boundProject != null) == sonarQubeService.IsConnected, $"Inconsistent connection state: Solution bound={boundProject != null}, service connected={sonarQubeService.IsConnected}"); }
private async Task UpdateConnection() { ISonarQubeService sonarQubeService = this.extensionHost.SonarQubeService; if (sonarQubeService.IsConnected) { if (this.extensionHost.ActiveSection?.DisconnectCommand.CanExecute(null) == true) { this.extensionHost.ActiveSection.DisconnectCommand.Execute(null); } else { sonarQubeService.Disconnect(); } } Debug.Assert(!sonarQubeService.IsConnected, "SonarQube service should always be disconnected at this point"); bool isSolutionCurrentlyBound = this.solutionBindingInformationProvider.IsSolutionBound(); if (isSolutionCurrentlyBound) { var connectionInformation = GetConnectionInformation(); await SafeServiceCall(async() => await sonarQubeService.ConnectAsync(connectionInformation, CancellationToken.None)); } Debug.Assert(isSolutionCurrentlyBound == sonarQubeService.IsConnected, $"Inconsistent connection state: Solution bound={isSolutionCurrentlyBound}, service connected={sonarQubeService.IsConnected}"); }
public DotNetBindingConfigProvider(ISonarQubeService sonarQubeService, INuGetBindingOperation nuGetBindingOperation, string serverUrl, string projectName, ILogger logger) { this.sonarQubeService = sonarQubeService; this.nuGetBindingOperation = nuGetBindingOperation; this.serverUrl = serverUrl; this.projectName = projectName; this.logger = logger; }
private static CreateProviderFunc GetCreateProviderFunc(ISonarQubeService sonarQubeService, ILogger logger) { return(bindingConfiguration => new SonarQubeIssuesProvider( sonarQubeService, bindingConfiguration.Project.ProjectKey, new TimerFactory(), logger)); }
public ConfigurableConnectionWorkflow(ISonarQubeService sonarQubeService) { if (sonarQubeService == null) { throw new ArgumentNullException(nameof(sonarQubeService)); } this.sonarQubeService = sonarQubeService; }
internal ShowInBrowserService(ISonarQubeService sonarQubeService, IConfigurationProvider configurationProvider, IVsBrowserService vsBrowserService, IRuleHelpLinkProvider ruleHelpLinkProvider) { this.sonarQubeService = sonarQubeService; this.configurationProvider = configurationProvider; this.vsBrowserService = vsBrowserService; this.ruleHelpLinkProvider = ruleHelpLinkProvider; }
public SonarQubeNotificationService(ISonarQubeService sonarQubeService, INotificationIndicatorViewModel model, ITimer timer, ILogger logger) { this.sonarQubeService = sonarQubeService; this.timer = timer; this.timer.Elapsed += OnTimerElapsed; this.logger = logger; Model = model; }
public SonarQubeNotificationService(ISonarQubeService sonarQubeService, INotificationIndicatorViewModel model, ITimer timer, ISonarLintOutput sonarLintOutput) { this.sonarQubeService = sonarQubeService; this.timer = timer; this.timer.Elapsed += OnTimerElapsed; this.sonarLintOutput = sonarLintOutput; Model = model; }
internal /* for testing */ CSharpVBBindingConfigProvider(ISonarQubeService sonarQubeService, INuGetBindingOperation nuGetBindingOperation, ILogger logger, IRuleSetGenerator ruleSetGenerator, INuGetPackageInfoGenerator nuGetPackageInfoGenerator, ISonarLintConfigGenerator sonarLintConfigGenerator) { this.sonarQubeService = sonarQubeService; this.nuGetBindingOperation = nuGetBindingOperation; this.logger = logger; this.ruleSetGenerator = ruleSetGenerator; this.nuGetPackageInfoGenerator = nuGetPackageInfoGenerator; this.sonarLintConfigGenerator = sonarLintConfigGenerator; }
private ShowInBrowserService CreateTestSubject(ISonarQubeService sonarQubeService = null, IConfigurationProvider configurationProvider = null, IVsBrowserService browserService = null, IRuleHelpLinkProvider helpLinkProvider = null) { sonarQubeService ??= Mock.Of <ISonarQubeService>(); configurationProvider ??= Mock.Of <IConfigurationProvider>(); browserService ??= Mock.Of <IVsBrowserService>(); helpLinkProvider ??= Mock.Of <IRuleHelpLinkProvider>(); return(new ShowInBrowserService(sonarQubeService, configurationProvider, browserService, helpLinkProvider)); }
public SuppressionManager(IServiceProvider serviceProvider, ITimerFactory timerFactory) { this.serviceProvider = serviceProvider; this.activeSolutionBoundTracker = serviceProvider.GetMefService <IActiveSolutionBoundTracker>(); this.activeSolutionBoundTracker.SolutionBindingChanged += OnSolutionBindingChanged; this.sonarQubeService = serviceProvider.GetMefService <ISonarQubeService>(); this.timerFactory = timerFactory; RefreshSuppresionHandling(); }
/// <summary> /// Fetch all rules in the specified quality, both active and inactive /// </summary> public static async Task <IList <SonarQubeRule> > GetAllRulesAsync(this ISonarQubeService sonarQubeService, string qualityProfileKey, CancellationToken token) { var activeRules = await sonarQubeService.GetRulesAsync(true, qualityProfileKey, token); token.ThrowIfCancellationRequested(); var inactiveRules = await sonarQubeService.GetRulesAsync(false, qualityProfileKey, token); var allRules = (activeRules ?? Enumerable.Empty <SonarQubeRule>()) .Union(inactiveRules ?? Enumerable.Empty <SonarQubeRule>()) .ToList(); return(allRules); }
public SonarQubeQualityProfileProvider(ISonarQubeService sonarQubeService, ILogger logger) { if (sonarQubeService == null) { throw new ArgumentNullException(nameof(sonarQubeService)); } if (logger == null) { throw new ArgumentNullException(nameof(logger)); } this.sonarQubeService = sonarQubeService; this.logger = logger; }
public SonarAnalyzerManager(IActiveSolutionBoundTracker activeSolutionBoundTracker, ISonarQubeService sonarQubeService, Workspace workspace, IVsSolution vsSolution, ILogger logger) { if (activeSolutionBoundTracker == null) { throw new ArgumentNullException(nameof(activeSolutionBoundTracker)); } if (sonarQubeService == null) { throw new ArgumentNullException(nameof(sonarQubeService)); } if (workspace == null) { throw new ArgumentNullException(nameof(workspace)); } if (vsSolution == null) { throw new ArgumentNullException(nameof(vsSolution)); } if (logger == null) { throw new ArgumentNullException(nameof(logger)); } this.activeSolutionBoundTracker = activeSolutionBoundTracker; this.sonarQubeService = sonarQubeService; this.workspace = workspace; this.vsSolution = vsSolution; this.logger = logger; this.activeSolutionBoundTracker = activeSolutionBoundTracker; // Saving previous state so that SonarLint doesn't have to know what's the default state in SonarAnalyzer this.previousShouldRegisterContextAction = SonarAnalysisContext.ShouldRegisterContextAction; this.previousShouldExecuteRegisteredAction = SonarAnalysisContext.ShouldExecuteRegisteredAction; this.previousShouldDiagnosticBeReported = SonarAnalysisContext.ShouldDiagnosticBeReported; this.previousReportDiagnostic = SonarAnalysisContext.ReportDiagnostic; activeSolutionBoundTracker.SolutionBindingChanged += OnSolutionBindingChanged; activeSolutionBoundTracker.SolutionBindingUpdated += OnSolutionBindingUpdated; RefreshWorkflow(this.activeSolutionBoundTracker.CurrentConfiguration); }
internal /*for test purposes*/ VsSessionHost(IServiceProvider serviceProvider, IStateManager state, IProgressStepRunnerWrapper progressStepRunner, ISonarQubeService sonarQubeService, IActiveSolutionTracker solutionTacker, ILogger logger, Dispatcher uiDispatcher) { if (serviceProvider == null) { throw new ArgumentNullException(nameof(serviceProvider)); } if (sonarQubeService == null) { throw new ArgumentNullException(nameof(sonarQubeService)); } if (solutionTacker == null) { throw new ArgumentNullException(nameof(solutionTacker)); } if (logger == null) { throw new ArgumentNullException(nameof(logger)); } if (uiDispatcher == null) { throw new ArgumentNullException(nameof(uiDispatcher)); } this.serviceProvider = serviceProvider; this.VisualStateManager = state ?? new StateManager(this, new TransferableVisualState()); this.progressStepRunner = progressStepRunner ?? this; this.UIDispatcher = uiDispatcher; this.SonarQubeService = sonarQubeService; this.solutionTracker = solutionTacker; this.solutionTracker.ActiveSolutionChanged += this.OnActiveSolutionChanged; this.Logger = logger; this.RegisterLocalServices(); }
public TaintIssuesSynchronizer(ITaintStore taintStore, ISonarQubeService sonarQubeService, ITaintIssueToIssueVisualizationConverter converter, IConfigurationProvider configurationProvider, IToolWindowService toolWindowService, [Import(typeof(VSShell.SVsServiceProvider))] IServiceProvider serviceProvider, ILogger logger) { this.taintStore = taintStore; this.sonarQubeService = sonarQubeService; this.converter = converter; this.configurationProvider = configurationProvider; this.toolWindowService = toolWindowService; this.logger = logger; vsMonitorSelection = (VSShellInterop.IVsMonitorSelection)serviceProvider.GetService(typeof(VSShellInterop.SVsShellMonitorSelection)); Guid localGuid = TaintIssuesExistUIContext.Guid; vsMonitorSelection.GetCmdUIContextCookie(ref localGuid, out contextCookie); }
public QualityProfileProviderCachingDecorator(IQualityProfileProvider wrappedProvider, BoundSonarQubeProject boundProject, ISonarQubeService sonarQubeService, ITimerFactory timerFactory) { if (wrappedProvider == null) { throw new ArgumentNullException(nameof(wrappedProvider)); } if (boundProject == null) { throw new ArgumentNullException(nameof(boundProject)); } if (sonarQubeService == null) { throw new ArgumentNullException(nameof(sonarQubeService)); } if (timerFactory == null) { throw new ArgumentNullException(nameof(timerFactory)); } this.wrappedProvider = wrappedProvider; this.boundProject = boundProject; this.sonarQubeService = sonarQubeService; this.refreshTimer = timerFactory.Create(); this.refreshTimer.AutoReset = true; this.refreshTimer.Interval = MillisecondsToWaitBetweenRefresh; this.refreshTimer.Elapsed += OnRefreshTimerElapsed; initialFetchCancellationTokenSource = new CancellationTokenSource(); this.initialFetch = Task.Factory.StartNew(DoInitialFetch, initialFetchCancellationTokenSource.Token); refreshTimer.Start(); }
public CFamilyBindingConfigProvider(ISonarQubeService sonarQubeService, ILogger logger) { this.sonarQubeService = sonarQubeService ?? throw new ArgumentNullException(nameof(sonarQubeService)); this.logger = logger ?? throw new ArgumentNullException(nameof(logger)); }
public ShowInBrowserService(ISonarQubeService sonarQubeService, IConfigurationProvider configurationProvider, IVsBrowserService vsBrowserService) : this(sonarQubeService, configurationProvider, vsBrowserService, new RuleHelpLinkProvider()) { }
public CSharpVBBindingConfigProvider(ISonarQubeService sonarQubeService, INuGetBindingOperation nuGetBindingOperation, ILogger logger) : this(sonarQubeService, nuGetBindingOperation, logger, new RuleSetGenerator(), new NuGetPackageInfoGenerator(), new SonarLintConfigGenerator()) { }
public TestableCachingDecorator(IQualityProfileProvider wrappedProvider, BoundSonarQubeProject boundProject, ISonarQubeService sonarQubeService, ITimerFactory timerFactory) : base(wrappedProvider, boundProject, sonarQubeService, timerFactory) { }
public VsSessionHost([Import(typeof(SVsServiceProvider))] IServiceProvider serviceProvider, ISonarQubeService sonarQubeService, IActiveSolutionTracker solutionTacker, ILogger logger) : this(serviceProvider, null, null, sonarQubeService, solutionTacker, logger, Dispatcher.CurrentDispatcher) { Debug.Assert(ThreadHelper.CheckAccess(), "Expected to be created on the UI thread"); }
public SuppressedIssuesProvider(IActiveSolutionBoundTracker activeSolutionBoundTracker, ISonarQubeService sonarQubeService, ILogger logger) : this(activeSolutionBoundTracker, GetCreateProviderFunc(sonarQubeService, logger)) { }