Skip to content

Commit

Permalink
[SQL] add boolean sub-scopes
Browse files Browse the repository at this point in the history
  • Loading branch information
Keith Hall committed Jul 14, 2024
1 parent 827b729 commit 1c49ea3
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 10 deletions.
4 changes: 4 additions & 0 deletions SQL/Cassandra.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,10 @@ contexts:

###[ LITERALS ]################################################################

constants:
- meta_prepend: true
- include: booleans

literals-and-variables:
- meta_prepend: true
- include: variables
Expand Down
1 change: 1 addition & 0 deletions SQL/MySQL.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -1520,6 +1520,7 @@ contexts:
scope: constant.language.sql

bool-constants:
- include: booleans
- match: \b(?i:yes|no)\b
scope: constant.language.boolean.sql

Expand Down
8 changes: 6 additions & 2 deletions SQL/SQL (basic).sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -1405,11 +1405,15 @@ contexts:
- include: strings

constants:
- match: \b(?i:true|false)\b
scope: constant.language.boolean.sql
- match: \b(?i:null)\b
scope: constant.language.null.sql

booleans:
- match: \b(?i:true)\b
scope: constant.language.boolean.true.sql
- match: \b(?i:false)\b
scope: constant.language.boolean.false.sql

numbers:
- match: \b\d+(\.)\d+\b
scope: meta.number.float.decimal.sql constant.numeric.value.sql
Expand Down
2 changes: 1 addition & 1 deletion SQL/tests/syntax/syntax_test_cassandra.cql
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ WITH HEADER=true;
-- ^ keyword.other
-- ^^^^^^ string.unquoted
-- ^ keyword.operator
-- ^^^^ constant.language.boolean
-- ^^^^ constant.language.boolean.true
-- ^ punctuation.terminator.statement

TRUNCATE table1;
Expand Down
16 changes: 9 additions & 7 deletions SQL/tests/syntax/syntax_test_mysql.sql
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@
-- ^ - constant
-- ^^^^ constant.language.null.sql
-- ^ - constant
-- ^^^^ constant.language.boolean.sql
-- ^^^^ constant.language.boolean.true.sql
-- ^ - constant
-- ^^^^^ constant.language.boolean.sql
-- ^^^^^ constant.language.boolean.false.sql
-- ^ - constant

all default maxvalue
Expand Down Expand Up @@ -791,14 +791,14 @@ BEGIN
-- ^^ keyword.control.conditional.sql
-- ^^^^ variable.other.sql
-- ^ keyword.operator.comparison.sql
-- ^^^^ constant.language.boolean.sql
-- ^^^^ constant.language.boolean.true.sql
-- ^^^^ keyword.control.conditional.sql

ELSEIF @var = FALSE THEN
-- ^^^^^^ keyword.control.conditional.sql
-- ^^^^ variable.other.sql
-- ^ keyword.operator.comparison.sql
-- ^^^^^ constant.language.boolean.sql
-- ^^^^^ constant.language.boolean.false.sql
-- ^^^^ keyword.control.conditional.sql

ELSE
Expand All @@ -821,7 +821,7 @@ BEGIN

WHILE TRUE
-- ^^^^^ keyword.control.loop.sql
-- ^^^^ constant.language.boolean.sql
-- ^^^^ constant.language.boolean.true.sql

END WHILE
-- ^^^^^^^^^ keyword.control.loop.sql
Expand Down Expand Up @@ -1275,7 +1275,7 @@ create table IF NOT EXISTS `testing123` (
`col` bool DEFAULT FALSE,
-- ^^^^ storage.type.sql
-- ^^^^^^^ storage.modifier.sql
-- ^^^^^ constant.language.boolean.sql
-- ^^^^^ constant.language.boolean.false.sql
-- ^ punctuation.separator.sequence
`fkey` INT UNSIGNED NULL REFERENCES test2(id),
-- ^^^^^^^^^^ storage.modifier.sql
Expand Down Expand Up @@ -1315,6 +1315,8 @@ create table fancy_table (
-- ^^^^^^^ storage.type.sql
myflag boolean DEFAULT false,
-- ^^^^^^^ storage.type.sql
-- ^^^^^^^ storage.modifier.sql
-- ^^^^^ constant.language.boolean.false.sql
mycount double precision DEFAULT 1,
-- ^^^^^^^^^^^^^^^^^ storage.type.sql
fancy_column character varying(42) DEFAULT 'nice'::character varying,
Expand Down Expand Up @@ -4167,7 +4169,7 @@ INNER JOIN {ON tbl_name LEFT OUTER JOIN other1 other2 ON TRUE}
-- ^^^^^^ meta.table-name.sql
-- ^^^^^^ meta.alias.table.sql
-- ^^ keyword.control.conditional.sql
-- ^^^^ constant.language.boolean.sql
-- ^^^^ constant.language.boolean.true.sql
-- ^ punctuation.section.braces.end.mysql

-- ----------------------------------------------------------------------------
Expand Down

0 comments on commit 1c49ea3

Please sign in to comment.