Добавьте файлы проекта.
This commit is contained in:
62
SQLLinter/Linter.cs
Normal file
62
SQLLinter/Linter.cs
Normal file
@@ -0,0 +1,62 @@
|
||||
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<string> filePaths)
|
||||
{
|
||||
_reporter.Report($"Запуск SQL Linter...");
|
||||
|
||||
List<string> files = FileHelpers.FindFilesWithMask(filePaths);
|
||||
files.ForEach(file => _reporter.Report($@"Найден файл ""{file}"""));
|
||||
|
||||
_fileProcessor.ProcessList(filePaths);
|
||||
}
|
||||
|
||||
public void Run(string fileName, Stream fileReader)
|
||||
{
|
||||
Run(new Dictionary<string, Stream> { [fileName] = fileReader });
|
||||
}
|
||||
|
||||
public void Run(Dictionary<string, Stream> files)
|
||||
{
|
||||
_reporter.Report($"Запуск SQL Linter...");
|
||||
|
||||
_fileProcessor.ProcessList(files);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user