コード例 #1
0
 public CLangAnalyzer(ITelemetryManager telemetryManager, ISonarLintSettings settings, ICFamilyRulesConfigProvider cFamilyRulesConfigProvider, ILogger logger)
 {
     this.telemetryManager           = telemetryManager;
     this.settings                   = settings;
     this.cFamilyRulesConfigProvider = cFamilyRulesConfigProvider;
     this.logger = logger;
 }
コード例 #2
0
        public GeneralOptionsDialogControl(ISonarLintSettings settings, ISonarLintDaemon daemon, IDaemonInstaller installer, ICommand openSettingsFileCommand, ILogger logger)
        {
            if (settings == null)
            {
                throw new ArgumentNullException(nameof(settings));
            }
            if (daemon == null)
            {
                throw new ArgumentNullException(nameof(daemon));
            }
            if (installer == null)
            {
                throw new ArgumentNullException(nameof(installer));
            }
            if (logger == null)
            {
                throw new ArgumentNullException(nameof(logger));
            }
            if (openSettingsFileCommand == null)
            {
                throw new ArgumentNullException(nameof(openSettingsFileCommand));
            }

            this.settings  = settings;
            this.daemon    = daemon;
            this.installer = installer;
            this.logger    = logger;

            InitializeComponent();

            this.OpenSettingsButton.Command = openSettingsFileCommand;
        }
コード例 #3
0
        internal TaggerProvider(ITableManagerProvider provider,
                                ITextDocumentFactoryService textDocumentFactoryService,
                                IContentTypeRegistryService contentTypeRegistryService,
                                IFileExtensionRegistryService fileExtensionRegistryService,
                                ISonarLintDaemon daemon,
                                SVsServiceProvider serviceProvider,
                                ISonarLintSettings settings)
        {
            this.ErrorTableManager            = provider.GetTableManager(StandardTables.ErrorsTable);
            this.TextDocumentFactoryService   = textDocumentFactoryService;
            this.ContentTypeRegistryService   = contentTypeRegistryService;
            this.FileExtensionRegistryService = fileExtensionRegistryService;

            this.ErrorTableManager.AddSource(this, StandardTableColumnDefinitions.DetailsExpander,
                                             StandardTableColumnDefinitions.ErrorSeverity, StandardTableColumnDefinitions.ErrorCode,
                                             StandardTableColumnDefinitions.ErrorSource, StandardTableColumnDefinitions.BuildTool,
                                             StandardTableColumnDefinitions.ErrorSource, StandardTableColumnDefinitions.ErrorCategory,
                                             StandardTableColumnDefinitions.Text, StandardTableColumnDefinitions.DocumentName,
                                             StandardTableColumnDefinitions.Line, StandardTableColumnDefinitions.Column,
                                             StandardTableColumnDefinitions.ProjectName);

            this.daemon   = daemon;
            this.dte      = (_DTE)serviceProvider.GetService(typeof(_DTE));
            this.settings = settings;
        }
コード例 #4
0
        internal TaggerProvider(ITableManagerProvider tableManagerProvider,
                                ITextDocumentFactoryService textDocumentFactoryService,
                                ISonarLintDaemon daemon,
                                [Import(typeof(SVsServiceProvider))] IServiceProvider serviceProvider,
                                ISonarLintSettings settings,
                                ISonarLanguageRecognizer languageRecognizer,
                                ILogger logger)
        {
            this.errorTableManager          = tableManagerProvider.GetTableManager(StandardTables.ErrorsTable);
            this.textDocumentFactoryService = textDocumentFactoryService;

            this.errorTableManager.AddSource(this, StandardTableColumnDefinitions.DetailsExpander,
                                             StandardTableColumnDefinitions.ErrorSeverity, StandardTableColumnDefinitions.ErrorCode,
                                             StandardTableColumnDefinitions.ErrorSource, StandardTableColumnDefinitions.BuildTool,
                                             StandardTableColumnDefinitions.ErrorSource, StandardTableColumnDefinitions.ErrorCategory,
                                             StandardTableColumnDefinitions.Text, StandardTableColumnDefinitions.DocumentName,
                                             StandardTableColumnDefinitions.Line, StandardTableColumnDefinitions.Column,
                                             StandardTableColumnDefinitions.ProjectName);

            this.daemon             = daemon;
            this.dte                = serviceProvider.GetService <DTE>();
            this.settings           = settings;
            this.languageRecognizer = languageRecognizer;
            this.logger             = logger;
        }
コード例 #5
0
        private async System.Threading.Tasks.Task ListenForLogs()
        {
            ISonarLintSettings settings = ServiceProvider.GlobalProvider.GetMefService <ISonarLintSettings>();

            try
            {
                using (var streamLogs = daemonClient.StreamLogs(new Sonarlint.Void(), new CallOptions(null, null, channel.ShutdownToken).WithWaitForReady(true)))
                {
                    while (await streamLogs.ResponseStream.MoveNext())
                    {
                        var log = streamLogs.ResponseStream.Current;
                        if (ShouldLog(settings, log))
                        {
                            WritelnToPane($"{log.Level} {log.Log}");
                        }
                    }
                }
            }
            catch (RpcException e)
            {
                if (e.Status.StatusCode == StatusCode.Cancelled)
                {
                    return;
                }
                Debug.WriteLine("RPC failed: {0}", e);
                WritelnToPane("Unexpected error: " + e);
            }
        }
コード例 #6
0
        public SonarLintDaemon(ISonarLintSettings settings, IDaemonInstaller daemonInstaller, ILogger logger)
        {
            this.settings  = settings;
            this.logger    = logger;
            this.installer = daemonInstaller;

            this.WorkingDirectory = CreateTempDirectory();
        }
コード例 #7
0
 internal /* for testing */ SonarLintDaemon(ISonarLintSettings settings, ILogger logger, string version, string storagePath, string tmpPath)
 {
     this.settings         = settings;
     this.logger           = logger;
     this.version          = version;
     this.tmpPath          = tmpPath;
     this.storagePath      = storagePath;
     this.workingDirectory = CreateTempDirectory();
 }
コード例 #8
0
 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 SonarLintDaemonSplashscreen(ISonarLintSettings settings)
        {
            if (settings == null)
            {
                throw new ArgumentNullException(nameof(settings));
            }

            this.settings = settings;

            InitializeComponent();
        }
コード例 #10
0
 protected override void CallSubProcess(Action <Message> handleMessage, Request request,
                                        ISonarLintSettings settings, ILogger logger, CancellationToken cancellationToken)
 {
     if (onCallSubProcess == null)
     {
         base.CallSubProcess(handleMessage, request, settings, logger, cancellationToken);
     }
     else
     {
         onCallSubProcess(handleMessage, request, settings, logger, cancellationToken);
     }
 }
コード例 #11
0
        private static void ConfigureSiteMock(GeneralOptionsDialogPage testSubject, ISonarLintSettings settings, ISonarLintDaemon daemon)
        {
            var mefHostMock = new Mock <IComponentModel>();

            mefHostMock.Setup(m => m.GetExtensions <ISonarLintDaemon>()).Returns(() => new[] { daemon });
            mefHostMock.Setup(m => m.GetExtensions <ISonarLintSettings>()).Returns(() => new[] { settings });

            var siteMock = new Mock <ISite>();

            siteMock.As <IServiceProvider>().Setup(m => m.GetService(It.Is <Type>(t => t == typeof(SComponentModel)))).Returns(mefHostMock.Object);

            testSubject.Site = siteMock.Object;
        }
        public SonarLintDaemonInstaller(ISonarLintSettings settings, ISonarLintDaemon daemon)
        {
            if (settings == null)
            {
                throw new ArgumentNullException(nameof(settings));
            }
            if (daemon == null)
            {
                throw new ArgumentNullException(nameof(daemon));
            }

            this.settings = settings;
            this.daemon   = daemon;

            InitializeComponent();
        }
        public GeneralOptionsDialogControl(ISonarLintSettings settings, ISonarLintDaemon daemon)
        {
            if (settings == null)
            {
                throw new ArgumentNullException(nameof(settings));
            }
            if (daemon == null)
            {
                throw new ArgumentNullException(nameof(daemon));
            }

            this.settings = settings;
            this.daemon   = daemon;

            InitializeComponent();
        }
コード例 #14
0
        internal /*for testing purposes*/ ConnectionController(IHost host, IConnectionInformationProvider connectionProvider, IConnectionWorkflowExecutor workflowExecutor)
            : base(host)
        {
            if (host == null)
            {
                throw new ArgumentNullException(nameof(host));
            }

            this.host               = host;
            this.WorkflowExecutor   = workflowExecutor ?? this;
            this.connectionProvider = connectionProvider ?? this;
            this.settings           = this.host.GetMefService <ISonarLintSettings>();

            this.ConnectCommand       = new RelayCommand(this.OnConnect, this.OnConnectStatus);
            this.RefreshCommand       = new RelayCommand <ConnectionInformation>(this.OnRefresh, this.OnRefreshStatus);
            this.DontWarnAgainCommand = new RelayCommand(this.OnDontWarnAgain, this.OnDontWarnAgainStatus);
        }
コード例 #15
0
        private static void ConfigureSiteMock(GeneralOptionsDialogPage testSubject,
                                              ISonarLintSettings settings        = null,
                                              IVsBrowserService vsBrowserService = null)
        {
            settings ??= new ConfigurableSonarLintSettings();
            vsBrowserService ??= new Mock <IVsBrowserService>().Object;

            var mefHostMock = new Mock <IComponentModel>();

            mefHostMock.Setup(m => m.GetExtensions <ISonarLintSettings>()).Returns(() => new[] { settings });
            mefHostMock.Setup(m => m.GetExtensions <ILogger>()).Returns(() => new[] { new TestLogger() });
            mefHostMock.Setup(m => m.GetExtensions <IUserSettingsProvider>()).Returns(() => new[] { new Mock <IUserSettingsProvider>().Object });
            mefHostMock.Setup(m => m.GetExtensions <IVsBrowserService>()).Returns(() => new[] { vsBrowserService });

            var siteMock = new Mock <ISite>();

            siteMock.As <IServiceProvider>().Setup(m => m.GetService(It.Is <Type>(t => t == typeof(SComponentModel)))).Returns(mefHostMock.Object);

            testSubject.Site = siteMock.Object;
        }
コード例 #16
0
 private static bool ShouldLog(ISonarLintSettings settings, LogEvent log)
 {
     return(settings.DaemonLogLevel == DaemonLogLevel.Minimal && log.Level == "ERROR" ||
            settings.DaemonLogLevel == DaemonLogLevel.Info && new[] { "ERROR", "WARN", "INFO" }.Contains(log.Level) ||
            settings.DaemonLogLevel == DaemonLogLevel.Verbose);
 }
コード例 #17
0
 public ProcessRunner(ISonarLintSettings settings, ILogger logger)
 {
     this.logger   = logger ?? throw new ArgumentNullException(nameof(logger));
     this.settings = settings ?? throw new ArgumentNullException(nameof(settings));
 }
コード例 #18
0
        .Forget();         // fire and forget

        protected /* for testing */ virtual void CallSubProcess(Action <Message> handleMessage, Request request, ISonarLintSettings settings, ILogger logger, CancellationToken cancellationToken)
        {
            CFamilyHelper.CallClangAnalyzer(handleMessage, request, new ProcessRunner(settings, logger), logger, cancellationToken);
        }
コード例 #19
0
 public TestableCLangAnalyzer(ITelemetryManager telemetryManager, ISonarLintSettings settings, ICFamilyRulesConfigProvider cFamilyRulesConfigProvider,
                              IServiceProvider serviceProvider, IAnalysisStatusNotifier analysisStatusNotifier, ILogger logger, ICFamilyIssueToAnalysisIssueConverter cFamilyIssueConverter)
     : base(telemetryManager, settings, cFamilyRulesConfigProvider, serviceProvider, analysisStatusNotifier, logger, cFamilyIssueConverter)
 {
 }
コード例 #20
0
            public void CallSubProcess(Action <Message> handleMessage, Request request, ISonarLintSettings settings, ILogger logger, CancellationToken cancellationToken)
            {
                // When this method exits the analyzer will finish processing, so we need to
                // block until we we want that to happen.

                // Store the callback passed to us from the CLangAnalyzer
                handleMessageCallback = handleMessage;

                // Tell the calling test we're ready and the test can continue
                callbackFromCLangReceived.Set();

                // Block until the test tells us we can finish
                noMoreIssues.WaitOne();
            }
コード例 #21
0
 public SonarLintDaemon(ISonarLintSettings settings, ISonarLintOutput logger)
     : this(settings, logger, daemonVersion, Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), Path.GetTempPath())
 {
 }
コード例 #22
0
 public SonarLintDaemon(ISonarLintSettings settings, ILogger logger)
     : this(settings, logger, daemonVersion,
            Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "SonarLint for Visual Studio"),
            Path.GetTempPath())
 {
 }
コード例 #23
0
 public TestableSonarLintDaemon(ISonarLintSettings settings, ILogger logger, string version, string storagePath, string tmpPath)
     : base(settings, logger, version, storagePath, tmpPath)
 {
     this.Ready += (s, a) => WasReadyEventInvoked = true;
 }
コード例 #24
0
 public TestableSonarLintDaemon(ISonarLintSettings settings, ILogger logger, IDaemonInstaller installer)
     : base(settings, installer, logger)
 {
     this.Ready += (s, a) => WasReadyEventInvoked = true;
 }
コード例 #25
0
        private bool IsVerbose()
        {
            ISonarLintSettings settings = ServiceProvider.GlobalProvider.GetMefService <ISonarLintSettings>();

            return(settings.DaemonLogLevel == DaemonLogLevel.Verbose);
        }