From 6c4e541cfc60092392bfd19ec0f795f6a301c754 Mon Sep 17 00:00:00 2001 From: Rita Gorokhod Date: Thu, 22 Sep 2022 13:51:59 +0200 Subject: [PATCH] Fix SC warning --- .../SonarLintTagger/TaggerProviderTests.cs | 4 ++-- .../TextBufferIssueTrackerTests.cs | 2 +- .../SonarLintTagger/TaggerProvider.cs | 15 +++++++++++++-- .../SonarLintTagger/TextBufferIssueTracker.cs | 13 ------------- 4 files changed, 16 insertions(+), 18 deletions(-) diff --git a/src/Integration.Vsix.UnitTests/SonarLintTagger/TaggerProviderTests.cs b/src/Integration.Vsix.UnitTests/SonarLintTagger/TaggerProviderTests.cs index c3028b7624..46f10574f5 100644 --- a/src/Integration.Vsix.UnitTests/SonarLintTagger/TaggerProviderTests.cs +++ b/src/Integration.Vsix.UnitTests/SonarLintTagger/TaggerProviderTests.cs @@ -34,7 +34,6 @@ using Moq; using SonarLint.VisualStudio.Core; using SonarLint.VisualStudio.Core.Analysis; -using SonarLint.VisualStudio.Core.Suppression; using SonarLint.VisualStudio.Integration.Vsix; using SonarLint.VisualStudio.Integration.Vsix.Analysis; using SonarLint.VisualStudio.Integration.Vsix.ErrorList; @@ -114,7 +113,7 @@ public void SetUp() .Returns(Mock.Of()); this.provider = new TaggerProvider(mockSonarErrorDataSource.Object, dummyDocumentFactoryService, mockAnalyzerController.Object, serviceProvider, - mockSonarLanguageRecognizer.Object, mockAnalysisRequester.Object, mockTaggableBufferIndicator.Object, issueConsumerFactory.Object, logger, mockAnalysisScheduler.Object); + mockSonarLanguageRecognizer.Object, mockAnalysisRequester.Object, mockTaggableBufferIndicator.Object, issueConsumerFactory.Object, logger, mockAnalysisScheduler.Object, new NoOpThreadHandler()); } [TestMethod] @@ -126,6 +125,7 @@ public void CreateTagger_should_create_tracker_when_analysis_is_supported() tagger.Should().NotBeNull(); VerifyCheckedAnalysisIsSupported(); + VerifyAnalysisWasRequested(); mockAnalyzerController.VerifyNoOtherCalls(); } diff --git a/src/Integration.Vsix.UnitTests/SonarLintTagger/TextBufferIssueTrackerTests.cs b/src/Integration.Vsix.UnitTests/SonarLintTagger/TextBufferIssueTrackerTests.cs index 034b4e1d2b..530d2a7bcd 100644 --- a/src/Integration.Vsix.UnitTests/SonarLintTagger/TextBufferIssueTrackerTests.cs +++ b/src/Integration.Vsix.UnitTests/SonarLintTagger/TextBufferIssueTrackerTests.cs @@ -439,7 +439,7 @@ private TaggerProvider CreateTaggerProvider() .Callback((string file, Action analyze, int timeout) => analyze(CancellationToken.None)); var provider = new TaggerProvider(mockSonarErrorDataSource.Object, textDocFactoryServiceMock.Object, mockAnalyzerController.Object, - serviceProvider, languageRecognizer, mockAnalysisRequester.Object, Mock.Of(), Mock.Of(), logger, mockAnalysisScheduler.Object); + serviceProvider, languageRecognizer, mockAnalysisRequester.Object, Mock.Of(), Mock.Of(), logger, mockAnalysisScheduler.Object, new NoOpThreadHandler()); return provider; } diff --git a/src/Integration.Vsix/SonarLintTagger/TaggerProvider.cs b/src/Integration.Vsix/SonarLintTagger/TaggerProvider.cs index 9e3e06ae8d..86af632a33 100644 --- a/src/Integration.Vsix/SonarLintTagger/TaggerProvider.cs +++ b/src/Integration.Vsix/SonarLintTagger/TaggerProvider.cs @@ -70,6 +70,7 @@ internal sealed class TaggerProvider : ITaggerProvider private readonly IScheduler scheduler; private readonly IVsSolution5 vsSolution; private readonly IIssueConsumerFactory issueConsumerFactory; + private readonly IThreadHandling threadHandling; [ImportingConstructor] internal TaggerProvider(ISonarErrorListDataSource sonarErrorDataSource, @@ -81,7 +82,8 @@ internal TaggerProvider(ISonarErrorListDataSource sonarErrorDataSource, ITaggableBufferIndicator taggableBufferIndicator, IIssueConsumerFactory issueConsumerFactory, ILogger logger, - IScheduler scheduler) + IScheduler scheduler, + IThreadHandling threadHandling) { this.sonarErrorDataSource = sonarErrorDataSource; this.textDocumentFactoryService = textDocumentFactoryService; @@ -93,6 +95,7 @@ internal TaggerProvider(ISonarErrorListDataSource sonarErrorDataSource, this.issueConsumerFactory = issueConsumerFactory; this.logger = logger; this.scheduler = scheduler; + this.threadHandling = threadHandling; vsStatusBar = serviceProvider.GetService(typeof(IVsStatusbar)) as IVsStatusbar; analysisRequester.AnalysisRequested += OnAnalysisRequested; @@ -182,7 +185,15 @@ public ITagger CreateTagger(ITextBuffer buffer) where T : ITag } private TextBufferIssueTracker InternalCreateTextBufferIssueTracker(ITextDocument textDocument, IEnumerable analysisLanguages) => - new TextBufferIssueTracker(dte, this, textDocument, analysisLanguages, sonarErrorDataSource, vsSolution, issueConsumerFactory, logger); + new TextBufferIssueTracker(dte, + this, + textDocument, + analysisLanguages, + sonarErrorDataSource, + vsSolution, + issueConsumerFactory, + logger, + threadHandling); #endregion IViewTaggerProvider members diff --git a/src/Integration.Vsix/SonarLintTagger/TextBufferIssueTracker.cs b/src/Integration.Vsix/SonarLintTagger/TextBufferIssueTracker.cs index ba03e792f2..6a43e6e55a 100644 --- a/src/Integration.Vsix/SonarLintTagger/TextBufferIssueTracker.cs +++ b/src/Integration.Vsix/SonarLintTagger/TextBufferIssueTracker.cs @@ -30,7 +30,6 @@ using Microsoft.VisualStudio.Threading; using SonarLint.VisualStudio.Core; using SonarLint.VisualStudio.Core.Analysis; -using SonarLint.VisualStudio.Infrastructure.VS; using SonarLint.VisualStudio.Integration.Helpers; using SonarLint.VisualStudio.Integration.Vsix.Analysis; using SonarLint.VisualStudio.Integration.Vsix.ErrorList; @@ -68,18 +67,6 @@ internal sealed class TextBufferIssueTracker : IIssueTracker, ITagger internal /* for testing */ IssuesSnapshotFactory Factory { get; } public TextBufferIssueTracker(DTE2 dte, - TaggerProvider provider, - ITextDocument document, - IEnumerable detectedLanguages, - ISonarErrorListDataSource sonarErrorDataSource, - IVsSolution5 vsSolution, - IIssueConsumerFactory issueConsumerFactory, - ILogger logger) - : this(dte, provider, document, detectedLanguages, sonarErrorDataSource, - vsSolution, issueConsumerFactory, logger, new ThreadHandling()) - { } - - internal /* for testing */ TextBufferIssueTracker(DTE2 dte, TaggerProvider provider, ITextDocument document, IEnumerable detectedLanguages,