Search in sources :

Example 1 with SQLFormatterConfiguration

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);
}
Also used : SQLFormatter(org.jkiss.dbeaver.model.sql.format.SQLFormatter) SQLFormatterConfiguration(org.jkiss.dbeaver.model.sql.format.SQLFormatterConfiguration)

Example 2 with SQLFormatterConfiguration

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);
}
Also used : SQLTokenizedFormatter(org.jkiss.dbeaver.model.sql.format.tokenized.SQLTokenizedFormatter) SQLFormatterConfiguration(org.jkiss.dbeaver.model.sql.format.SQLFormatterConfiguration)

Example 3 with SQLFormatterConfiguration

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);
}
Also used : SQLFormatter(org.jkiss.dbeaver.model.sql.format.SQLFormatter) SQLFormatterConfiguration(org.jkiss.dbeaver.model.sql.format.SQLFormatterConfiguration)

Example 4 with SQLFormatterConfiguration

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);
}
Also used : SQLFormatter(org.jkiss.dbeaver.model.sql.format.SQLFormatter) SQLFormatterConfiguration(org.jkiss.dbeaver.model.sql.format.SQLFormatterConfiguration)

Aggregations

SQLFormatterConfiguration (org.jkiss.dbeaver.model.sql.format.SQLFormatterConfiguration)4 SQLFormatter (org.jkiss.dbeaver.model.sql.format.SQLFormatter)3 SQLTokenizedFormatter (org.jkiss.dbeaver.model.sql.format.tokenized.SQLTokenizedFormatter)1