public void RequestAnalysis(string path, string charset, IList <IContentType> contentTypes)
        {
            IssueTagger tracker;

            if (taggers.TryGetValue(path, out tracker))
            {
                foreach (IContentType type in contentTypes)
                {
                    if (type.IsOfType("JavaScript"))
                    {
                        daemon.RequestAnalysis(path, charset, "js", null, this);
                        return;
                    }
                    if (type.IsOfType("C/C++"))
                    {
                        string sqLanguage;
                        string json = CFamily.TryGetConfig(tracker.ProjectItem, path, out sqLanguage);
                        if (json != null && sqLanguage != null)
                        {
                            daemon.RequestAnalysis(path, charset, sqLanguage, json, this);
                        }
                        return;
                    }
                }
                VsShellUtils.WriteToSonarLintOutputPane(ServiceProvider.GlobalProvider, "Unsupported content type for " + path);
            }
        }
Example #2
0
        public void RequestAnalysis(string path, string charset, IEnumerable <SonarLanguage> detectedLanguages)
        {
            IssueTagger tracker;

            if (taggers.TryGetValue(path, out tracker))
            {
                foreach (var language in detectedLanguages)
                {
                    switch (language)
                    {
                    case SonarLanguage.Javascript:
                        daemon.RequestAnalysis(path, charset, "js", null, this);
                        break;

                    case SonarLanguage.CFamily:
                        string sqLanguage;
                        string json = CFamily.TryGetConfig(logger, tracker.ProjectItem, path, out sqLanguage);
                        if (json != null && sqLanguage != null)
                        {
                            daemon.RequestAnalysis(path, charset, sqLanguage, json, this);
                        }
                        break;

                    default:
                        break;
                    }
                }

                logger.WriteLine($"Unsupported content type for {path}");
            }
        }
        public void RequestAnalysis(string path, string charset, IEnumerable <SonarLanguage> detectedLanguages)
        {
            IssueTagger tracker;

            if (!taggers.TryGetValue(path, out tracker))
            {
                return;
            }

            bool handled = false;

            foreach (var language in detectedLanguages)
            {
                switch (language)
                {
                case SonarLanguage.Javascript:
                    handled = true;
                    daemon.RequestAnalysis(path, charset, "js", null, this);
                    break;

                case SonarLanguage.CFamily:
                    handled = true;
                    CFamily.ProcessFile(daemon, this, logger, tracker.ProjectItem, path, charset);
                    break;

                default:
                    break;
                }
            }

            if (!handled)
            {
                logger.WriteLine($"Unsupported content type for {path}");
            }
        }
Example #4
0
        private void UnsafeRequestAnalysis(string path, string charset, IEnumerable <SonarLanguage> detectedLanguages, IIssueConsumer issueConsumer, ProjectItem projectItem)
        {
            bool handled = false;

            foreach (var language in detectedLanguages)
            {
                switch (language)
                {
                case SonarLanguage.Javascript:
                    handled = true;
                    daemon.RequestAnalysis(path, charset, "js", null, issueConsumer);
                    break;

                case SonarLanguage.CFamily:
                    handled = true;
                    CFamily.ProcessFile(daemon, issueConsumer, logger, projectItem, path, charset);
                    break;

                default:
                    break;
                }
            }

            if (!handled)
            {
                logger.WriteLine($"Unsupported content type for {path}");
            }
        }
Example #5
0
        public static void ProcessFile(ISonarLintDaemon daemon, IIssueConsumer issueConsumer, ILogger logger,
                                       ProjectItem projectItem, string absoluteFilePath, string charset)
        {
            if (IsHeaderFile(absoluteFilePath))
            {
                // We can't analyze header files currently because we can't get all
                // of the required configuration information
                logger.WriteLine($"Cannot analyze header files. File: '{absoluteFilePath}'");
                return;
            }

            if (!IsFileInSolution(projectItem))
            {
                logger.WriteLine($"Unable to retrieve the configuration for file '{absoluteFilePath}'. Check the file is part of a project in the current solution.");
                return;
            }

            string sqLanguage;
            string json = TryGetConfig(logger, projectItem, absoluteFilePath, out sqLanguage);

            if (json != null && sqLanguage != null)
            {
                daemon.RequestAnalysis(absoluteFilePath, charset, sqLanguage, json, issueConsumer);
            }
        }
Example #6
0
 public void RequestAnalysis(string path, string charset)
 {
     daemon.RequestAnalysis(path, charset, this);
 }