Beispiel #1
0
        private void OnActiveDocumentFocused(object sender, ActiveDocumentChangedEventArgs e)
        {
            if (e.ActiveTextDocument == null)
            {
                return;
            }

            var detectedLanguages = sonarLanguageRecognizer.Detect(e.ActiveTextDocument.FilePath, e.ActiveTextDocument.TextBuffer.ContentType);

            if (!detectedLanguages.Any() || !cFamilyAnalyzer.IsAnalysisSupported(detectedLanguages))
            {
                return;
            }

            var cFamilyAnalyzerOptions = new CFamilyAnalyzerOptions
            {
                CreatePreCompiledHeaders = true
            };

            scheduler.Schedule(PchJobId, token =>
            {
                cFamilyAnalyzer.ExecuteAnalysis(e.ActiveTextDocument.FilePath,
                                                detectedLanguages,
                                                null,
                                                cFamilyAnalyzerOptions,
                                                null,
                                                token);
            }, pchJobTimeoutInMilliseconds);
        }
        private void TriggerReproducer()
        {
            Debug.Assert(HasActiveCFamilyDoc(), "Expecting a document that can be analyzed by the CFamily analyzer to be active");

            var activeDoc = activeDocumentLocator.FindActiveDocument();

            if (activeDoc != null)
            {
                var options = new CFamilyAnalyzerOptions
                {
                    CreateReproducer = true
                };

                logger.WriteLine(CFamilyStrings.ReproCmd_ExecutingReproducer);
                analysisRequester.RequestAnalysis(options, activeDoc.FilePath);
            }
        }
Beispiel #3
0
        public void CreateRequest_PCHRequestDoesntLog()
        {
            // Arrange
            var loggerMock        = new Mock <ILogger>();
            var projectItemConfig = new ProjectItemConfig {
                IsVCCLCompilerTool = false
            };
            var projectItemMock = CreateMockProjectItem("c:\\foo\\xxx.vcxproj", projectItemConfig);
            var analyzerOption  = new CFamilyAnalyzerOptions {
                CreatePreCompiledHeaders = true
            };
            // Act
            var request = CFamilyHelper.CreateRequest(loggerMock.Object, projectItemMock.Object, "c:\\dummy\\file.cpp",
                                                      null, analyzerOption);

            // Assert
            loggerMock.Verify(x => x.WriteLine(It.IsAny <string>()), Times.Never);
            request.Should().BeNull();
        }