public ActiveSolutionBoundTracker(IHost host, IActiveSolutionTracker activeSolutionTracker,
                                          ISonarLintOutput sonarLintOutput)
        {
            if (host == null)
            {
                throw new ArgumentNullException(nameof(host));
            }
            if (activeSolutionTracker == null)
            {
                throw new ArgumentNullException(nameof(activeSolutionTracker));
            }
            if (sonarLintOutput == null)
            {
                throw new ArgumentNullException(nameof(sonarLintOutput));
            }

            this.extensionHost   = host;
            this.solutionTracker = activeSolutionTracker;
            this.sonarLintOutput = sonarLintOutput;

            this.solutionBindingInformationProvider = this.extensionHost.GetService <ISolutionBindingInformationProvider>();
            this.solutionBindingInformationProvider.AssertLocalServiceIsNotNull();

            this.errorListInfoBarController = this.extensionHost.GetService <IErrorListInfoBarController>();
            this.errorListInfoBarController.AssertLocalServiceIsNotNull();

            // The user changed the binding through the Team Explorer
            this.extensionHost.VisualStateManager.BindingStateChanged += this.OnBindingStateChanged;

            // The solution changed inside the IDE
            this.solutionTracker.ActiveSolutionChanged += this.OnActiveSolutionChanged;

            this.IsActiveSolutionBound = this.solutionBindingInformationProvider.IsSolutionBound();
            this.ProjectKey            = this.solutionBindingInformationProvider.GetProjectKey();
        }
        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 ActiveSolutionBoundTracker(IHost host, IActiveSolutionTracker activeSolutionTracker, ILogger logger)
        {
            if (host == null)
            {
                throw new ArgumentNullException(nameof(host));
            }
            if (activeSolutionTracker == null)
            {
                throw new ArgumentNullException(nameof(activeSolutionTracker));
            }
            if (logger == null)
            {
                throw new ArgumentNullException(nameof(logger));
            }

            this.extensionHost   = host;
            this.solutionTracker = activeSolutionTracker;
            this.logger          = logger;

            this.configurationProvider = this.extensionHost.GetService <IConfigurationProvider>();
            this.configurationProvider.AssertLocalServiceIsNotNull();

            this.errorListInfoBarController = this.extensionHost.GetService <IErrorListInfoBarController>();
            this.errorListInfoBarController.AssertLocalServiceIsNotNull();

            // The user changed the binding through the Team Explorer
            this.extensionHost.VisualStateManager.BindingStateChanged += this.OnBindingStateChanged;

            // The solution changed inside the IDE
            this.solutionTracker.ActiveSolutionChanged += this.OnActiveSolutionChanged;

            CurrentConfiguration = this.configurationProvider.GetConfiguration();
        }
        public ActiveSolutionBoundTracker(IHost host, IActiveSolutionTracker activeSolutionTracker, ILogger logger)
        {
            extensionHost   = host ?? throw new ArgumentNullException(nameof(host));
            solutionTracker = activeSolutionTracker ?? throw new ArgumentNullException(nameof(activeSolutionTracker));
            this.logger     = logger ?? throw new ArgumentNullException(nameof(logger));

            vsMonitorSelection = host.GetService <SVsShellMonitorSelection, IVsMonitorSelection>();
            vsMonitorSelection.GetCmdUIContextCookie(ref BoundSolutionUIContext.Guid, out boundSolutionContextCookie);

            configurationProvider = extensionHost.GetService <IConfigurationProviderService>();
            configurationProvider.AssertLocalServiceIsNotNull();

            errorListInfoBarController = extensionHost.GetService <IErrorListInfoBarController>();
            errorListInfoBarController.AssertLocalServiceIsNotNull();

            // The user changed the binding through the Team Explorer
            extensionHost.VisualStateManager.BindingStateChanged += OnBindingStateChanged;

            // The solution changed inside the IDE
            solutionTracker.ActiveSolutionChanged += OnActiveSolutionChanged;

            CurrentConfiguration = configurationProvider.GetConfiguration();

            SetBoundSolutionUIContext();
        }
        public ActiveSolutionBoundTracker(IHost host, IActiveSolutionTracker activeSolutionTracker)
        {
            if (host == null)
            {
                throw new ArgumentNullException(nameof(host));
            }

            if (activeSolutionTracker == null)
            {
                throw new ArgumentNullException(nameof(activeSolutionTracker));
            }

            this.extensionHost = host;
            this.solutionTracker = activeSolutionTracker;

            this.solutionBindingInformationProvider = this.extensionHost.GetService<ISolutionBindingInformationProvider>();
            this.solutionBindingInformationProvider.AssertLocalServiceIsNotNull();

            this.errorListInfoBarController = this.extensionHost.GetService<IErrorListInfoBarController>();
            this.errorListInfoBarController.AssertLocalServiceIsNotNull();
            this.errorListInfoBarController.Refresh();

            // The user changed the binding through the Team Explorer
            this.extensionHost.VisualStateManager.BindingStateChanged += this.OnBindingStateChanged;

            // The solution changed inside the IDE
            this.solutionTracker.ActiveSolutionChanged += this.OnActiveSolutionChanged;

            this.IsActiveSolutionBound = this.solutionBindingInformationProvider.IsSolutionBound();
        }
Example #6
0
 public EslintBridgeAnalyzerFactory(IActiveSolutionTracker activeSolutionTracker,
                                    IAnalysisConfigMonitor analysisConfigMonitor,
                                    ILogger logger)
 {
     this.activeSolutionTracker = activeSolutionTracker;
     this.analysisConfigMonitor = analysisConfigMonitor;
     this.logger = logger;
 }
        public EslintBridgeAnalyzer(
            IRulesProvider rulesProvider,
            IEslintBridgeClient eslintBridgeClient,
            IActiveSolutionTracker activeSolutionTracker,
            IAnalysisConfigMonitor analysisConfigMonitor,
            IEslintBridgeIssueConverter issueConverter,
            ILogger logger)
        {
            this.rulesProvider         = rulesProvider;
            this.eslintBridgeClient    = eslintBridgeClient;
            this.activeSolutionTracker = activeSolutionTracker;
            this.analysisConfigMonitor = analysisConfigMonitor;
            this.issueConverter        = issueConverter;
            this.logger = logger;

            activeSolutionTracker.ActiveSolutionChanged += ActiveSolutionTracker_ActiveSolutionChanged;
            analysisConfigMonitor.ConfigChanged         += AnalysisConfigMonitor_ConfigChanged;
        }
Example #8
0
        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();
        }
Example #9
0
        internal /* for testing purposes */ DeprecatedSonarRuleSetManager(IActiveSolutionBoundTracker activeSolutionBoundTracker,
                                                                          IActiveSolutionTracker activeSolutionTracker, IProjectSystemHelper projectSystemHelper,
                                                                          ISolutionRuleSetsInformationProvider ruleSetProvider, ILogger logger)
        {
            if (activeSolutionBoundTracker == null)
            {
                throw new ArgumentNullException(nameof(activeSolutionBoundTracker));
            }

            if (activeSolutionTracker == null)
            {
                throw new ArgumentNullException(nameof(activeSolutionTracker));
            }

            if (projectSystemHelper == null)
            {
                throw new ArgumentNullException(nameof(projectSystemHelper));
            }

            if (ruleSetProvider == null)
            {
                throw new ArgumentNullException(nameof(ruleSetProvider));
            }

            if (logger == null)
            {
                throw new ArgumentNullException(nameof(logger));
            }

            this.activeSolutionBoundTracker = activeSolutionBoundTracker;
            this.activeSolutionTracker      = activeSolutionTracker;
            this.projectSystemHelper        = projectSystemHelper;
            this.ruleSetProvider            = ruleSetProvider;
            this.logger = logger;

            this.activeSolutionBoundTracker.SolutionBindingChanged += OnSolutionBindingChanged;
            this.activeSolutionTracker.ActiveSolutionChanged       += OnActiveSolutionChanged;

            if (this.activeSolutionBoundTracker.CurrentConfiguration != null &&
                this.activeSolutionBoundTracker.CurrentConfiguration.Mode != NewConnectedMode.SonarLintMode.LegacyConnected)
            {
                WarnIfAnyProjectHasSonarRuleSet();
            }
        }
 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)
 {
 }
        private EslintBridgeAnalyzer CreateTestSubject(
            IEslintBridgeClient eslintBridgeClient       = null,
            IRulesProvider rulesProvider                 = null,
            IActiveSolutionTracker activeSolutionTracker = null,
            IAnalysisConfigMonitor analysisConfigMonitor = null,
            IEslintBridgeIssueConverter issueConverter   = null,
            ILogger logger = null)
        {
            eslintBridgeClient ??= SetupEslintBridgeClient().Object;
            rulesProvider ??= Mock.Of <IRulesProvider>();
            activeSolutionTracker ??= Mock.Of <IActiveSolutionTracker>();
            analysisConfigMonitor ??= Mock.Of <IAnalysisConfigMonitor>();
            issueConverter ??= Mock.Of <IEslintBridgeIssueConverter>();
            logger ??= Mock.Of <ILogger>();

            return(new EslintBridgeAnalyzer(rulesProvider,
                                            eslintBridgeClient,
                                            activeSolutionTracker,
                                            analysisConfigMonitor,
                                            issueConverter,
                                            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));
        }
Example #14
0
 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");
 }