private void GenerateButton_Click(object sender, EventArgs e) { if (HasNotParameter()) { MessageBox.Show(@"[Setting File Name]が正しい値ではありません。" , @"ERROR" , MessageBoxButtons.OK , MessageBoxIcon.Error); return; } Properties.Settings.Default.Save(); SqlAstParser sqlAstParser = new SqlAstParser(); SqlCompilationUnit unit = sqlAstParser.Parse(SqlTextBox.Text); SqlAstVisitor visitor = new SqlFormatVisitor(_entity); IList <ITransformer> transformers = new List <ITransformer>(); transformers.Add(new CaseTransform(_entity)); transformers.Add(new CommentTransform(_entity.IsDeleteComment)); if (_entity.IsReservedWordAsComplement) { transformers.Add(new AsWordCompletionTransform(_entity)); } unit.Accept(visitor, transformers); ResultTextBox.Text = visitor.ResultSql; }
public string SqlFormatter(string inputSql, ConfigEntity entity) { SqlAstParser sqlAstParser = new SqlAstParser(); SqlCompilationUnit unit = sqlAstParser.Parse(inputSql); SqlAstVisitor visitor = new SqlFormatVisitor(entity); IList <ITransformer> transformers = new List <ITransformer>(); transformers.Add(new CaseTransform(entity)); transformers.Add(new CommentTransform(entity.IsDeleteComment)); if (entity.IsReservedWordAsComplement) { transformers.Add(new AsWordCompletionTransform(entity)); } unit.Accept(visitor, transformers); return(visitor.ResultSql); }