using SQLLinter.Common; using SQLLinter.Common.Helpers; using SQLLinter.Core.Interfaces; using SQLLinter.Infrastructure.Parser; using SQLLinter.Infrastructure.Plugins; namespace SQLLinter; public class Linter { private readonly IReporter _reporter; private readonly IConfig _config; private IPluginHandler _pluginHandler; private ISqlFileProcessor _fileProcessor; public Linter(IConfig config, IReporter reporter) { this._config = config; this._reporter = reporter; this._pluginHandler = new PluginHandler(reporter, config); _reporter.Report($"Загрузка SQL Linter..."); var fragmentBuilder = new FragmentBuilder(reporter, _config.CompatibilityLevel); _pluginHandler = new PluginHandler(_reporter, _config); var ruleVisitor = new SqlRuleVisitor(_pluginHandler, fragmentBuilder, _reporter); _fileProcessor = new SqlFileProcessor(ruleVisitor, _pluginHandler, reporter); _reporter.Report($"SQL Linter загружен..."); } public void Run(string filePath) { this.Run([filePath]); } public void Run(List filePaths) { _reporter.Report($"Запуск SQL Linter..."); List files = FileHelpers.FindFilesWithMask(filePaths); files.ForEach(file => _reporter.Report($@"Найден файл ""{file}""")); _fileProcessor.ProcessList(filePaths); } public void Run(string fileName, Stream fileReader) { Run(new Dictionary { [fileName] = fileReader }); } public void Run(Dictionary files) { _reporter.Report($"Запуск SQL Linter..."); _fileProcessor.ProcessList(files); } }