public void ExecuteAnalysis(string path, IEnumerable <AnalysisLanguage> detectedLanguages, IIssueConsumer consumer, IAnalyzerOptions analyzerOptions, IAnalysisStatusNotifier statusNotifier, CancellationToken cancellationToken) { var projectItem = dte?.Solution?.FindProjectItem(path); if (projectItem == null) { return; } Debug.Assert(IsAnalysisSupported(detectedLanguages)); var request = CreateRequest(logger, projectItem, path, cFamilyRulesConfigProvider, analyzerOptions); if (request == null) { return; } TriggerAnalysis(request, consumer, statusNotifier, cancellationToken); }
private JavaScriptAnalyzer CreateTestSubject( IEslintBridgeAnalyzer eslintBridgeAnalyzer = null, IRulesProvider rulesProvider = null, ITelemetryManager telemetryManager = null, IAnalysisStatusNotifier statusNotifier = null) { telemetryManager ??= Mock.Of <ITelemetryManager>(); statusNotifier ??= Mock.Of <IAnalysisStatusNotifier>(); rulesProvider ??= Mock.Of <IRulesProvider>(); var rulesProviderFactory = new Mock <IRulesProviderFactory>(); rulesProviderFactory.Setup(x => x.Create("javascript")).Returns(rulesProvider); var eslintBridgeClient = Mock.Of <IJavaScriptEslintBridgeClient>(); var eslintBridgeAnalyzerFactory = new Mock <IEslintBridgeAnalyzerFactory>(); eslintBridgeAnalyzerFactory .Setup(x => x.Create(rulesProvider, eslintBridgeClient)) .Returns(eslintBridgeAnalyzer); return(new JavaScriptAnalyzer(eslintBridgeClient, rulesProviderFactory.Object, telemetryManager, statusNotifier, eslintBridgeAnalyzerFactory.Object)); }
private TypeScriptAnalyzer CreateTestSubject( IEslintBridgeAnalyzer eslintBridgeAnalyzer = null, ITsConfigProvider tsConfigProvider = null, IRulesProvider rulesProvider = null, IAnalysisStatusNotifier statusNotifier = null, ITelemetryManager telemetryManager = null, ILogger logger = null) { statusNotifier ??= Mock.Of <IAnalysisStatusNotifier>(); rulesProvider ??= Mock.Of <IRulesProvider>(); logger ??= Mock.Of <ILogger>(); tsConfigProvider ??= SetupTsConfigProvider(); eslintBridgeAnalyzer ??= Mock.Of <IEslintBridgeAnalyzer>(); telemetryManager ??= Mock.Of <ITelemetryManager>(); var rulesProviderFactory = new Mock <IRulesProviderFactory>(); rulesProviderFactory.Setup(x => x.Create("typescript")).Returns(rulesProvider); var eslintBridgeClient = Mock.Of <ITypeScriptEslintBridgeClient>(); var eslintBridgeAnalyzerFactory = new Mock <IEslintBridgeAnalyzerFactory>(); eslintBridgeAnalyzerFactory .Setup(x => x.Create(rulesProvider, eslintBridgeClient)) .Returns(eslintBridgeAnalyzer); return(new TypeScriptAnalyzer(eslintBridgeClient, rulesProviderFactory.Object, tsConfigProvider, statusNotifier, eslintBridgeAnalyzerFactory.Object, telemetryManager, logger)); }
private JavaScriptAnalyzer CreateTestSubject( IEslintBridgeProcess eslintBridgeProcess, IEslintBridgeClientFactory eslintBridgeClientFactory = null, IActiveJavaScriptRulesProvider activeRulesProvider = null, IEslintBridgeIssueConverter issueConverter = null, ITelemetryManager telemetryManager = null, IAnalysisStatusNotifier statusNotifier = null, IActiveSolutionTracker activeSolutionTracker = null, IAnalysisConfigMonitor analysisConfigMonitor = null, ILogger logger = null) { issueConverter ??= Mock.Of <IEslintBridgeIssueConverter>(); logger ??= Mock.Of <ILogger>(); telemetryManager ??= Mock.Of <ITelemetryManager>(); statusNotifier ??= Mock.Of <IAnalysisStatusNotifier>(); activeRulesProvider ??= Mock.Of <IActiveJavaScriptRulesProvider>(); activeSolutionTracker ??= Mock.Of <IActiveSolutionTracker>(); analysisConfigMonitor ??= Mock.Of <IAnalysisConfigMonitor>(); return(new JavaScriptAnalyzer(eslintBridgeClientFactory, eslintBridgeProcess, activeRulesProvider, issueConverter, telemetryManager, statusNotifier, activeSolutionTracker, analysisConfigMonitor, logger)); }
public CLangAnalyzer(ITelemetryManager telemetryManager, ISonarLintSettings settings, ICFamilyRulesConfigProvider cFamilyRulesConfigProvider, [Import(typeof(SVsServiceProvider))] IServiceProvider serviceProvider, IAnalysisStatusNotifier analysisStatusNotifier, ILogger logger, ICFamilyIssueToAnalysisIssueConverter issueConverter) { this.telemetryManager = telemetryManager; this.settings = settings; this.cFamilyRulesConfigProvider = cFamilyRulesConfigProvider; this.analysisStatusNotifier = analysisStatusNotifier; this.logger = logger; this.issueConverter = issueConverter; this.dte = serviceProvider.GetService <DTE>(); }
public JavaScriptAnalyzer(IJavaScriptEslintBridgeClient eslintBridgeClient, IRulesProviderFactory rulesProviderFactory, ITelemetryManager telemetryManager, IAnalysisStatusNotifier analysisStatusNotifier, IEslintBridgeAnalyzerFactory eslintBridgeAnalyzerFactory) { this.telemetryManager = telemetryManager; this.analysisStatusNotifier = analysisStatusNotifier; var rulesProvider = rulesProviderFactory.Create("javascript"); eslintBridgeAnalyzer = eslintBridgeAnalyzerFactory.Create(rulesProvider, eslintBridgeClient); }
public TypeScriptAnalyzer(ITypeScriptEslintBridgeClient eslintBridgeClient, IRulesProviderFactory rulesProviderFactory, ITsConfigProvider tsConfigProvider, IAnalysisStatusNotifier analysisStatusNotifier, IEslintBridgeAnalyzerFactory eslintBridgeAnalyzerFactory, ITelemetryManager telemetryManager, ILogger logger) { this.tsConfigProvider = tsConfigProvider; this.analysisStatusNotifier = analysisStatusNotifier; this.telemetryManager = telemetryManager; this.logger = logger; var rulesProvider = rulesProviderFactory.Create("typescript"); eslintBridgeAnalyzer = eslintBridgeAnalyzerFactory.Create(rulesProvider, eslintBridgeClient); }
public JavaScriptAnalyzer(IEslintBridgeClientFactory eslintBridgeClientFactory, IEslintBridgeProcess eslintBridgeProcess, IJavaScriptRuleKeyMapper keyMapper, IJavaScriptRuleDefinitionsProvider ruleDefinitionsProvider, IActiveJavaScriptRulesProvider activeRulesProvider, ITelemetryManager telemetryManager, IAnalysisStatusNotifier analysisStatusNotifier, IActiveSolutionTracker activeSolutionTracker, IAnalysisConfigMonitor analysisConfigMonitor, ILogger logger) : this(eslintBridgeClientFactory, eslintBridgeProcess, activeRulesProvider, new EslintBridgeIssueConverter(keyMapper.GetSonarRuleKey, ruleDefinitionsProvider.GetDefinitions), telemetryManager, analysisStatusNotifier, activeSolutionTracker, analysisConfigMonitor, logger) { }
internal JavaScriptAnalyzer(IEslintBridgeClientFactory eslintBridgeClientFactory, IEslintBridgeProcess eslintBridgeProcess, IActiveJavaScriptRulesProvider activeRulesProvider, IEslintBridgeIssueConverter issuesConverter, ITelemetryManager telemetryManager, IAnalysisStatusNotifier analysisStatusNotifier, IActiveSolutionTracker activeSolutionTracker, IAnalysisConfigMonitor analysisConfigMonitor, ILogger logger) { this.eslintBridgeClientFactory = eslintBridgeClientFactory; this.eslintBridgeProcess = eslintBridgeProcess; this.activeRulesProvider = activeRulesProvider; this.issuesConverter = issuesConverter; this.telemetryManager = telemetryManager; this.analysisStatusNotifier = analysisStatusNotifier; this.activeSolutionTracker = activeSolutionTracker; this.analysisConfigMonitor = analysisConfigMonitor; this.logger = logger; activeSolutionTracker.ActiveSolutionChanged += ActiveSolutionTracker_ActiveSolutionChanged; analysisConfigMonitor.ConfigChanged += AnalysisConfigMonitor_ConfigChanged; }
private JavaScriptAnalyzer CreateTestSubject(IEslintBridgeClient client = null, IEslintBridgeIssueConverter issueConverter = null, IActiveJavaScriptRulesProvider activeRulesProvider = null, ITelemetryManager telemetryManager = null, IAnalysisStatusNotifier statusNotifier = null, IActiveSolutionTracker activeSolutionTracker = null, IAnalysisConfigMonitor analysisConfigMonitor = null, ILogger logger = null) { client ??= SetupEslintBridgeClient(null).Object; var serverProcess = SetupServerProcess(123); var eslintBridgeClientFactory = SetupEslintBridgeClientFactory(123, client); return(CreateTestSubject(serverProcess.Object, eslintBridgeClientFactory.Object, activeRulesProvider, issueConverter, telemetryManager, statusNotifier, activeSolutionTracker, analysisConfigMonitor, logger)); }
internal /* for testing */ async Task TriggerAnalysisAsync(Request request, IIssueConsumer consumer, IAnalysisStatusNotifier statusNotifier, CancellationToken cancellationToken) { // For notes on VS threading, see https://github.com/microsoft/vs-threading/blob/master/doc/cookbook_vs.md // Note: we support multiple versions of VS which prevents us from using some threading helper methods // that are only available in newer versions of VS e.g. [Import] IThreadHandling. // Switch to a background thread await TaskScheduler.Default; var analysisStartTime = DateTime.Now; statusNotifier?.AnalysisStarted(request.File); int issueCount = 0; var handleMessage = consumer == null ? (Action <Message>)(message => { }) : message => HandleMessage(message, request, consumer, ref issueCount); try { // We're tying up a background thread waiting for out-of-process analysis. We could // change the process runner so it works asynchronously. Alternatively, we could change the // RequestAnalysis method to be asynchronous, rather than fire-and-forget. CallSubProcess(handleMessage, request, settings, logger, cancellationToken); if (cancellationToken.IsCancellationRequested) { statusNotifier?.AnalysisCancelled(request.File); } else { var analysisTime = DateTime.Now - analysisStartTime; statusNotifier?.AnalysisFinished(request.File, issueCount, analysisTime); } } catch (Exception ex) when(!ErrorHandler.IsCriticalException(ex)) { statusNotifier?.AnalysisFailed(request.File, ex); } telemetryManager.LanguageAnalyzed(request.CFamilyLanguage); // different keys for C and C++ }
protected /* for testing */ virtual void TriggerAnalysis(Request request, IIssueConsumer consumer, IAnalysisStatusNotifier statusNotifier, CancellationToken cancellationToken) => TriggerAnalysisAsync(request, consumer, statusNotifier, cancellationToken) .Forget(); // fire and forget
protected override void TriggerAnalysis(Request request, IIssueConsumer consumer, IAnalysisStatusNotifier analysisStatusNotifier, CancellationToken cancellationToken) { TriggerAnalysisCallCount++; }
public TestableCLangAnalyzer(ITelemetryManager telemetryManager, ISonarLintSettings settings, ICFamilyRulesConfigProvider cFamilyRulesConfigProvider, IServiceProvider serviceProvider, IAnalysisStatusNotifier analysisStatusNotifier, ILogger logger, ICFamilyIssueToAnalysisIssueConverter cFamilyIssueConverter) : base(telemetryManager, settings, cFamilyRulesConfigProvider, serviceProvider, analysisStatusNotifier, logger, cFamilyIssueConverter) { }