use of org.jkiss.dbeaver.model.sql.format.SQLFormatterConfiguration in project dbeaver by dbeaver.
the class SQLUtils method formatSQL.
public static String formatSQL(SQLDataSource dataSource, String query) {
SQLSyntaxManager syntaxManager = new SQLSyntaxManager();
syntaxManager.init(dataSource.getSQLDialect(), dataSource.getContainer().getPreferenceStore());
SQLFormatterConfiguration configuration = new SQLFormatterConfiguration(syntaxManager);
SQLFormatter formatter = dataSource.getDataSource().getContainer().getPlatform().getSQLFormatterRegistry().createFormatter(configuration);
if (formatter == null) {
return query;
}
return formatter.format(query, configuration);
}
use of org.jkiss.dbeaver.model.sql.format.SQLFormatterConfiguration in project dbeaver by serge-rider.
the class SQLUtils method formatSQL.
public static String formatSQL(SQLDataSource dataSource, String query) {
SQLSyntaxManager syntaxManager = new SQLSyntaxManager();
syntaxManager.init(dataSource.getSQLDialect(), dataSource.getContainer().getPreferenceStore());
SQLFormatterConfiguration configuration = new SQLFormatterConfiguration(syntaxManager);
return new SQLTokenizedFormatter().format(query, configuration);
}
use of org.jkiss.dbeaver.model.sql.format.SQLFormatterConfiguration in project dbeaver by serge-rider.
the class SQLFormattingStrategy method format.
@Override
public String format(String content, boolean isLineStart, String indentation, int[] positions) {
final String[] indentPrefixes = svConfig.getIndentPrefixes(sourceViewer, IDocument.DEFAULT_CONTENT_TYPE);
SQLFormatterConfiguration configuration = new SQLFormatterConfiguration(svConfig.getSQLEditor().getDataSource(), sqlSyntax);
configuration.setIndentString(indentPrefixes[0]);
SQLFormatter formatter = SQLFormatterConfigurationRegistry.getInstance().createFormatter(configuration);
if (formatter == null) {
return content;
}
return formatter.format(content, configuration);
}
use of org.jkiss.dbeaver.model.sql.format.SQLFormatterConfiguration in project dbeaver by dbeaver.
the class SQLFormattingStrategy method format.
@Override
public String format(String content, boolean isLineStart, String indentation, int[] positions) {
final String[] indentPrefixes = svConfig.getIndentPrefixes(sourceViewer, IDocument.DEFAULT_CONTENT_TYPE);
SQLFormatterConfiguration configuration = new SQLFormatterConfiguration(svConfig.getSQLEditor().getDataSource(), sqlSyntax);
configuration.setIndentString(indentPrefixes[0]);
SQLFormatter formatter = SQLFormatterConfigurationRegistry.getInstance().createFormatter(configuration);
if (formatter == null) {
return content;
}
return formatter.format(content, configuration);
}
Aggregations