From 2242ce0a3e912351fc49cc381d01953c7f552fc0 Mon Sep 17 00:00:00 2001 From: Keith Hall Date: Sun, 14 Jul 2024 06:21:08 +0300 Subject: [PATCH] [SQL] add boolean sub-scopes --- SQL/Cassandra.sublime-syntax | 4 ++++ SQL/MySQL.sublime-syntax | 1 + SQL/SQL (basic).sublime-syntax | 8 ++++++-- SQL/tests/syntax/syntax_test_cassandra.cql | 2 +- SQL/tests/syntax/syntax_test_mysql.sql | 6 ++++-- 5 files changed, 16 insertions(+), 5 deletions(-) diff --git a/SQL/Cassandra.sublime-syntax b/SQL/Cassandra.sublime-syntax index ead24f0fd8d..01aa50387eb 100644 --- a/SQL/Cassandra.sublime-syntax +++ b/SQL/Cassandra.sublime-syntax @@ -215,6 +215,10 @@ contexts: ###[ LITERALS ]################################################################ + constants: + - meta_prepend: true + - include: booleans + literals-and-variables: - meta_prepend: true - include: variables diff --git a/SQL/MySQL.sublime-syntax b/SQL/MySQL.sublime-syntax index 0d25fa53bb6..f283776fdb3 100644 --- a/SQL/MySQL.sublime-syntax +++ b/SQL/MySQL.sublime-syntax @@ -1520,6 +1520,7 @@ contexts: scope: constant.language.sql bool-constants: + - include: booleans - match: \b(?i:yes|no)\b scope: constant.language.boolean.sql diff --git a/SQL/SQL (basic).sublime-syntax b/SQL/SQL (basic).sublime-syntax index e47d144994f..73bff36c7aa 100644 --- a/SQL/SQL (basic).sublime-syntax +++ b/SQL/SQL (basic).sublime-syntax @@ -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 diff --git a/SQL/tests/syntax/syntax_test_cassandra.cql b/SQL/tests/syntax/syntax_test_cassandra.cql index 868b3d09ca3..1944904a9bf 100644 --- a/SQL/tests/syntax/syntax_test_cassandra.cql +++ b/SQL/tests/syntax/syntax_test_cassandra.cql @@ -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; diff --git a/SQL/tests/syntax/syntax_test_mysql.sql b/SQL/tests/syntax/syntax_test_mysql.sql index 61c2a2dad1e..e18a1bef4e1 100644 --- a/SQL/tests/syntax/syntax_test_mysql.sql +++ b/SQL/tests/syntax/syntax_test_mysql.sql @@ -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 @@ -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,