internal static void FormatSql() { Gateway.SetCurrentLanguage(LangType.L_SQL); var text = GetCurrentText(); var options = new TSqlStandardFormatterOptions { BreakJoinOnSections = _settings.BreakJoinOnSections, ExpandBetweenConditions = _settings.ExpandBetweenConditions, ExpandBooleanExpressions = _settings.ExpandBooleanExpressions, ExpandCaseStatements = _settings.ExpandCaseStatements, ExpandCommaLists = _settings.ExpandCommaList, ExpandInLists = false, HTMLColoring = false, IndentString = _settings.IndentString, KeywordStandardization = _settings.KeywordStandardization, MaxLineWidth = _settings.MaxLineWidth, NewClauseLineBreaks = 0, NewStatementLineBreaks = 0, SpaceAfterExpandedComma = _settings.SpaceAfterExpandedComma, SpacesPerTab = _settings.SpacesPerTab, TrailingCommas = _settings.TrailingCommas, UppercaseKeywords = _settings.UppercaseKeywords }; var innerFormatter = new TSqlStandardFormatter(options); var tokenizer = new TSqlStandardTokenizer(); var parser = new TSqlStandardParser(); var parsedSql = parser.ParseSQL(tokenizer.TokenizeSQL(text)); Editor.SetText(innerFormatter.FormatSQLTree(parsedSql)); }
public string PrettyPrint(string sql) { var tokenizer = new TSqlStandardTokenizer(); var tokenized = tokenizer.TokenizeSQL(sql); var parser = new TSqlStandardParser(); var parsedSql = parser.ParseSQL(tokenized); return(_formatter.FormatSQLTree(parsedSql)?.TrimEnd()); }
internal SqlClassifier(ITagAggregator <StringTag> tagger, IClassificationTypeRegistryService classificationRegistry) { this.tagger = tagger; keywordType = classificationRegistry.GetClassificationType("sql-keyword"); operatorType = classificationRegistry.GetClassificationType("sql-operator"); stringType = classificationRegistry.GetClassificationType("sql-string"); functionType = classificationRegistry.GetClassificationType("sql-function"); numberType = classificationRegistry.GetClassificationType("sql-number"); parameterType = classificationRegistry.GetClassificationType("sql-parameter"); commentType = classificationRegistry.GetClassificationType("sql-comment"); formatter = new CustomFormatter(); tokenizer = new TSqlStandardTokenizer(); parser = new TSqlStandardParser(); }