Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#34371 Add color for functions in sql editor #34384

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
'org.jkiss.dbeaver.sql.editor.color.disabled.background=0,0,0'
'org.jkiss.dbeaver.sql.editor.color.keyword.foreground=115,158,202'
'org.jkiss.dbeaver.sql.editor.color.datatype.foreground=193,170,108'
'org.jkiss.dbeaver.sql.editor.color.function.foreground=193,170,108'
'org.jkiss.dbeaver.sql.editor.color.string.foreground=202,197,128'
'org.jkiss.dbeaver.sql.editor.color.number.foreground=192,192,192'
'org.jkiss.dbeaver.sql.editor.color.comment.foreground=102,151,104'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ public void loadRules(@Nullable DBPDataSource dataSource, boolean minimalRules)

final TPToken keywordToken = new TPTokenDefault(SQLTokenType.T_KEYWORD);
final TPToken typeToken = new TPTokenDefault(SQLTokenType.T_TYPE);
final TPToken functionToken = new TPTokenDefault(SQLTokenType.T_FUNCTION);
final TPToken stringToken = new TPTokenDefault(SQLTokenType.T_STRING);
final TPToken quotedToken = new TPTokenDefault(SQLTokenType.T_QUOTED);
final TPToken numberToken = new TPTokenDefault(SQLTokenType.T_NUMBER);
Expand Down Expand Up @@ -227,7 +228,7 @@ public void loadRules(@Nullable DBPDataSource dataSource, boolean minimalRules)

if (!minimalRules) {
// Add word rule for keywords, functions, types, and constants.
SQLWordRule wordRule = new SQLWordRule(delimRule, typeToken, otherToken, dialect);
SQLWordRule wordRule = new SQLWordRule(delimRule, functionToken, otherToken, dialect);
for (String reservedWord : dialect.getReservedWords()) {
DBPKeywordType keywordType = dialect.getKeywordType(reservedWord);
// Functions without parentheses has type 'DBPKeywordType.OTHER' (#8710)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public enum SQLTokenType implements TPTokenType {
T_SCHEMA(509),
T_COMPOSITE_FIELD(510),
T_SQL_VARIABLE(511),
T_FUNCTION(512),
T_SEMANTIC_ERROR(900),

T_UNKNOWN(1000),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -676,6 +676,7 @@ public class SQLConstants {
public static final char STRUCT_SEPARATOR = '.'; //$NON-NLS-1$
public static final String CONFIG_COLOR_KEYWORD = "org.jkiss.dbeaver.sql.editor.color.keyword.foreground";
public static final String CONFIG_COLOR_DATATYPE = "org.jkiss.dbeaver.sql.editor.color.datatype.foreground";
public static final String CONFIG_COLOR_FUNCTION = "org.jkiss.dbeaver.sql.editor.color.function.foreground";
public static final String CONFIG_COLOR_STRING = "org.jkiss.dbeaver.sql.editor.color.string.foreground";
public static final String CONFIG_COLOR_TABLE = "org.jkiss.dbeaver.sql.editor.color.table.foreground";
public static final String CONFIG_COLOR_TABLE_ALIAS = "org.jkiss.dbeaver.sql.editor.color.table.alias.foreground";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,8 @@ colorDefinition.org.jkiss.dbeaver.sql.editor.color.keyword.foreground.label = SQ
colorDefinition.org.jkiss.dbeaver.sql.editor.color.keyword.foreground.description = SQL keyword color
colorDefinition.org.jkiss.dbeaver.sql.editor.color.datatype.foreground.label = SQL datatype color
colorDefinition.org.jkiss.dbeaver.sql.editor.color.datatype.foreground.description = SQL datatype color
colorDefinition.org.jkiss.dbeaver.sql.editor.color.function.foreground.label = SQL function color
colorDefinition.org.jkiss.dbeaver.sql.editor.color.function.foreground.description = SQL function color
colorDefinition.org.jkiss.dbeaver.sql.editor.color.string.foreground.label = SQL string color
colorDefinition.org.jkiss.dbeaver.sql.editor.color.string.foreground.description = SQL string color
colorDefinition.org.jkiss.dbeaver.sql.editor.color.number.foreground.label = SQL number color
Expand Down
7 changes: 7 additions & 0 deletions plugins/org.jkiss.dbeaver.ui.editors.sql/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1245,6 +1245,13 @@
value="COLOR_DARK_BLUE">
<description>%colorDefinition.org.jkiss.dbeaver.sql.editor.color.datatype.foreground.description</description>
</colorDefinition>
<colorDefinition
label="%colorDefinition.org.jkiss.dbeaver.sql.editor.color.function.foreground.label"
categoryId="org.jkiss.dbeaver.ui.presentation.sql"
id="org.jkiss.dbeaver.sql.editor.color.function.foreground"
value="COLOR_DARK_BLUE">
<description>%colorDefinition.org.jkiss.dbeaver.sql.editor.color.function.foreground.description</description>
</colorDefinition>
<colorDefinition
label="%colorDefinition.org.jkiss.dbeaver.sql.editor.color.string.foreground.label"
categoryId="org.jkiss.dbeaver.ui.presentation.sql"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ public StyledString getStyledDisplayString() {
StyledString.createColorRegistryStyler(SQLConstants.CONFIG_COLOR_KEYWORD, null));
} else if (getProposalType() == DBPKeywordType.FUNCTION) {
return new StyledString(getDisplayString(),
StyledString.createColorRegistryStyler(SQLConstants.CONFIG_COLOR_DATATYPE, null));
StyledString.createColorRegistryStyler(SQLConstants.CONFIG_COLOR_FUNCTION, null));
} else {
return new StyledString(getDisplayString());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ private static TextAttribute makeTextAttribute(TPToken token, SQLRuleScanner sca
colorKey = SQLConstants.CONFIG_COLOR_DATATYPE;
style = scanner.getKeywordStyle();
break;
case T_FUNCTION:
colorKey = SQLConstants.CONFIG_COLOR_FUNCTION;
style = scanner.getKeywordStyle();
break;
case T_NUMBER:
colorKey = SQLConstants.CONFIG_COLOR_NUMBER;
style = SWT.NORMAL;
Expand Down
Loading