コード例 #1
0
        private async Task EnsureEslintBridgeClientIsInitialized(CancellationToken cancellationToken)
        {
            var port = await eslintBridgeProcess.Start();

            try
            {
                serverInitLocker.WaitOne();

                if (port != javascriptServerPort)
                {
                    javascriptServerPort = port;
                    shouldInitLinter     = true;
                    eslintBridgeClient?.Dispose();
                    eslintBridgeClient = eslintBridgeClientFactory.Create(javascriptServerPort);
                }

                if (shouldInitLinter)
                {
                    await eslintBridgeClient.InitLinter(activeRulesProvider.Get(), cancellationToken);

                    shouldInitLinter = false;
                }
            }
            finally
            {
                serverInitLocker.Set();
            }
        }
コード例 #2
0
 public IEslintBridgeAnalyzer Create(IRulesProvider rulesProvider, IEslintBridgeClient eslintBridgeClient)
 {
     return(new EslintBridgeAnalyzer(rulesProvider,
                                     eslintBridgeClient,
                                     activeSolutionTracker,
                                     analysisConfigMonitor,
                                     new EslintBridgeIssueConverter(rulesProvider),
                                     logger));
 }
コード例 #3
0
        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;
        }
コード例 #4
0
        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));
        }
コード例 #5
0
        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));
        }
コード例 #6
0
        private Mock <IEslintBridgeClientFactory> SetupEslintBridgeClientFactory(int port, IEslintBridgeClient client)
        {
            var factory = new Mock <IEslintBridgeClientFactory>();

            factory.Setup(x => x.Create(port)).Returns(client);

            return(factory);
        }