Skip to content

Commit

Permalink
[Mixed] Use detailed scope for true/false/null (#4009)
Browse files Browse the repository at this point in the history
* [Python] Use detailed scope for True/False

Signed-off-by: Jack Cherng <[email protected]>

* [Bash] Use detailed scope for true/false

Signed-off-by: Jack Cherng <[email protected]>

* [PHP] Use detailed scope for true/false

Signed-off-by: Jack Cherng <[email protected]>

* [JSON] Use detailed scope for true/false

Signed-off-by: Jack Cherng <[email protected]>

* [YAML] Use detailed scope for true/false (y/n etc)

Signed-off-by: Jack Cherng <[email protected]>

* [Rust] Use detailed scope for true/false

Signed-off-by: Jack Cherng <[email protected]>

* [SQL] Use detailed scope for true/false

Signed-off-by: Jack Cherng <[email protected]>

* [Scala] Use detailed scope for true/false

Signed-off-by: Jack Cherng <[email protected]>

* [Matlab] Use detailed scope for true/false

Signed-off-by: Jack Cherng <[email protected]>

* [Ruby] Use detailed scope for true/false

Signed-off-by: Jack Cherng <[email protected]>

* [Lua] Use detailed scope for true/false

Signed-off-by: Jack Cherng <[email protected]>

* [Go] Use detailed scope for true/false/nil

Signed-off-by: Jack Cherng <[email protected]>

* [R] Use detailed scope for true/false/null

Signed-off-by: Jack Cherng <[email protected]>

* [OCaml] Use detailed scope for true/false

Signed-off-by: Jack Cherng <[email protected]>

* [Lisp] Use detailed scope for true/false

Signed-off-by: Jack Cherng <[email protected]>

* [Java/JSP] Use detailed scope for true/false

Signed-off-by: Jack Cherng <[email protected]>

* [Groovy] Use detailed scope for true/false/null

Signed-off-by: Jack Cherng <[email protected]>

* [Erlang] Use detailed scope for true/false

Signed-off-by: Jack Cherng <[email protected]>

* [C/C++] Use detailed scope for true/false/NULL

Signed-off-by: Jack Cherng <[email protected]>

* [C#] Use detailed scope for true/false/null

Signed-off-by: Jack Cherng <[email protected]>

* [ActionScript] Use detailed scope for true/false/null

Signed-off-by: Jack Cherng <[email protected]>

---------

Signed-off-by: Jack Cherng <[email protected]>
  • Loading branch information
jfcherng authored Jul 13, 2024
1 parent 634bebb commit 4a51942
Show file tree
Hide file tree
Showing 39 changed files with 262 additions and 169 deletions.
8 changes: 7 additions & 1 deletion ActionScript/ActionScript.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,13 @@ contexts:
scope: keyword.control.actionscript.2
- match: \b(Boolean|Number|String|Void)\b
scope: storage.type.actionscript.2
- match: \b(null|undefined|true|false)\b
- match: \bfalse\b
scope: constant.language.boolean.false.actionscript.2
- match: \btrue\b
scope: constant.language.boolean.true.actionscript.2
- match: \bnull\b
scope: constant.language.null.actionscript.2
- match: \bundefined\b
scope: constant.language.actionscript.2
- match: '\b((0(x|X)[0-9a-fA-F]*)|(([0-9]+\.?[0-9]*)|(\.[0-9]+))((e|E)(\+|-)?[0-9]+)?)(L|l|UL|ul|u|U|F|f)?\b'
scope: constant.numeric.actionscript.2
Expand Down
8 changes: 6 additions & 2 deletions C#/C#.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -1634,8 +1634,12 @@ contexts:
# bools, numbers, chars, simple strings
literals:
# language constants
- match: \b(true|false|null)\b
scope: constant.language.cs
- match: \bfalse\b
scope: constant.language.boolean.false.cs
- match: \btrue\b
scope: constant.language.boolean.true.cs
- match: \bnull\b
scope: constant.language.null.cs
# characters
- match: '''\'''
scope: invalid.illegal.lone-escape.cs
Expand Down
8 changes: 7 additions & 1 deletion C++/C.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,13 @@ contexts:
scope: variable.other.readwrite.static.mac-classic.c

constants:
- match: \b(__func__|NULL|true|false|TRUE|FALSE)\b
- match: \b(false|FALSE)\b
scope: constant.language.boolean.false.c
- match: \b(true|TRUE)\b
scope: constant.language.boolean.true.c
- match: \bNULL\b
scope: constant.language.null.c
- match: \b__func__\b
scope: constant.language.c
- match: \b(__FILE__|__FUNCTION__|__LINE__)\b
scope: support.constant.c
Expand Down
6 changes: 4 additions & 2 deletions Erlang/Erlang.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -1386,8 +1386,10 @@ contexts:

constant:
# https://www.erlang.org/doc/reference_manual/data_types.html#boolean
- match: (false|true){{ident_break}}
scope: constant.language.boolean.erlang
- match: false{{ident_break}}
scope: constant.language.boolean.false.erlang
- match: true{{ident_break}}
scope: constant.language.boolean.true.erlang
# https://www.erlang.org/doc/reference_manual/errors.html#exceptions
- match: (error|exit|ok|throw){{ident_break}}
scope: constant.language.exception.type.erlang
Expand Down
16 changes: 8 additions & 8 deletions Erlang/syntax_test_erlang.erl
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ atom_tests() -> .
% Special atom tests

true
% ^^^^ constant.language.boolean.erlang
% ^^^^ constant.language.boolean.true.erlang

false
% ^^^^^ constant.language.boolean.erlang
% ^^^^^ constant.language.boolean.false.erlang

error
% ^^^^^ constant.language.exception.type.erlang
Expand Down Expand Up @@ -473,7 +473,7 @@ list_tests() -> .
% ^ punctuation.section.sequence.begin.erlang
% ^ meta.number.integer.decimal.erlang constant.numeric.value.erlang
% ^^ keyword.operator.comprehension.erlang
% ^^^^ constant.language.boolean.erlang
% ^^^^ constant.language.boolean.true.erlang
% ^ punctuation.section.sequence.end.erlang

[2 || is_integer(2)]
Expand Down Expand Up @@ -4137,7 +4137,7 @@ func_name ( ) when true ->
% ^ punctuation.section.parameters.begin.erlang
% ^ punctuation.section.parameters.end.erlang
% ^^^^ keyword.control.conditional.when.erlang
% ^^^^ constant.language.boolean.erlang
% ^^^^ constant.language.boolean.true.erlang
% ^^ punctuation.separator.clause-head-body.erlang
.
% ^ meta.function.erlang punctuation.terminator.clause.erlang
Expand Down Expand Up @@ -4389,7 +4389,7 @@ case_tests() ->
% ^ punctuation.separator.clauses.erlang
% ^^^ variable.other.readwrite.erlang
% ^^ keyword.operator.comparison.erlang
% ^^^^^ constant.language.boolean.erlang
% ^^^^^ constant.language.boolean.false.erlang
% ^^ punctuation.separator.clause-head-body.erlang
print("ok");
% ^^^^^^^^^^^^ meta.case.erlang
Expand Down Expand Up @@ -4446,7 +4446,7 @@ if_tests() ->
% ^ punctuation.separator.clauses.erlang
% ^^^ variable.other.readwrite.erlang
% ^^ keyword.operator.comparison.erlang
% ^^^^^ constant.language.boolean.erlang
% ^^^^^ constant.language.boolean.false.erlang
% ^^ punctuation.separator.clause-head-body.erlang
print("ok");
% ^^^^^^^^^^^^ meta.if.erlang
Expand Down Expand Up @@ -4496,7 +4496,7 @@ maybe_tests() ->
% ^ punctuation.separator.expressions.erlang
true = A >= 0,
% ^^^^^^^^^^^^^^^^^^^^^^^ meta.maybe.erlang meta.maybe.erlang
% ^^^^ constant.language.boolean.erlang
% ^^^^ constant.language.boolean.true.erlang
% ^ keyword.operator.assignment.erlang
% ^ variable.other.readwrite.erlang
% ^^ keyword.operator.comparison.erlang
Expand Down Expand Up @@ -5243,7 +5243,7 @@ fun_expression_tests() ->
% ^^^^ keyword.control.conditional.when.erlang
% ^ variable.other.readwrite.erlang
% ^^ keyword.operator.comparison.erlang
% ^^^^ constant.language.boolean.erlang
% ^^^^ constant.language.boolean.true.erlang
% ^ punctuation.separator.clauses.erlang
% ^^^^^^^^ support.function.erlang
% ^ punctuation.section.arguments.begin.erlang
Expand Down
8 changes: 6 additions & 2 deletions Go/Go.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -344,8 +344,12 @@ contexts:
# would be ideal, but is beyond the scope of this syntax engine; we simply
# expect it to be very rare.
match-predeclared-constants:
- match: \b(?:true|false|nil)\b
scope: constant.language.go
- match: \bfalse\b
scope: constant.language.boolean.false.go
- match: \btrue\b
scope: constant.language.boolean.true.go
- match: \bnil\b
scope: constant.language.null.go

# Reference: https://golang.org/ref/spec#Predeclared_identifiers
#
Expand Down
6 changes: 3 additions & 3 deletions Go/tests/syntax_test_go.go
Original file line number Diff line number Diff line change
Expand Up @@ -5082,9 +5082,9 @@ by accident, but if necessary, such support could be sacrificed.
/* # Predeclared Constants */

true false nil
// ^^^^ constant.language.go
// ^^^^^ constant.language.go
// ^^^ constant.language.go
// ^^^^ constant.language.boolean.true.go
// ^^^^^ constant.language.boolean.false.go
// ^^^ constant.language.null.go


/* # Built-in Types */
Expand Down
8 changes: 6 additions & 2 deletions Groovy/Groovy.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,12 @@ contexts:
constants:
- match: '\b([A-Z][A-Z0-9_]+)\b'
scope: constant.other.groovy
- match: \b(true|false|null)\b
scope: constant.language.groovy
- match: \bfalse\b
scope: constant.language.boolean.false.groovy
- match: \btrue\b
scope: constant.language.boolean.true.groovy
- match: \bnull\b
scope: constant.language.null.groovy
groovy:
- include: classes
- include: methods
Expand Down
6 changes: 4 additions & 2 deletions JSON/JSON.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,10 @@ contexts:
###[ LITERALS ]################################################################

constants:
- match: \b(?:false|true)\b
scope: constant.language.boolean.json
- match: \bfalse\b
scope: constant.language.boolean.false.json
- match: \btrue\b
scope: constant.language.boolean.true.json
- match: \bnull\b
scope: constant.language.null.json

Expand Down
2 changes: 1 addition & 1 deletion JSON/syntax_test_json.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"bool": false,
//^^^^^^ meta.mapping.key.json
//^^^^^^^^^^^^^^ - meta.mapping meta.mapping
// ^^^^^ constant.language.boolean.json
// ^^^^^ constant.language.boolean.false.json

"null": null,
//^^^^^^ meta.mapping.key.json
Expand Down
13 changes: 9 additions & 4 deletions Java/HTML (JSP).sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -640,14 +640,19 @@ contexts:
- include: jstl-expressions

jstl-constants:
- match: (?:false|true){{break}}
scope: constant.language.boolean.jstl
- match: false{{break}}
scope: constant.language.boolean.false.jstl
- match: true{{break}}
scope: constant.language.boolean.true.jstl
- match: null{{break}}
scope: constant.language.null.jstl

jstl-constant:
- match: (?:false|true){{break}}
scope: constant.language.boolean.jstl
- match: false{{break}}
scope: constant.language.boolean.false.jstl
pop: 1
- match: true{{break}}
scope: constant.language.boolean.true.jstl
pop: 1
- match: null{{break}}
scope: constant.language.null.jstl
Expand Down
13 changes: 9 additions & 4 deletions Java/Java.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -2346,16 +2346,21 @@ contexts:

literal-constants:
# https://docs.oracle.com/javase/specs/jls/se13/html/jls-3.html#jls-3.10.3
- match: (?:false|true){{break}}
scope: constant.language.boolean.java
- match: false{{break}}
scope: constant.language.boolean.false.java
- match: true{{break}}
scope: constant.language.boolean.true.java
# https://docs.oracle.com/javase/specs/jls/se13/html/jls-3.html#jls-3.10.7
- match: null{{break}}
scope: constant.language.null.java

literal-constant:
# https://docs.oracle.com/javase/specs/jls/se13/html/jls-3.html#jls-3.10.3
- match: (?:false|true){{break}}
scope: constant.language.boolean.java
- match: false{{break}}
scope: constant.language.boolean.false.java
pop: 1
- match: true{{break}}
scope: constant.language.boolean.true.java
pop: 1
# https://docs.oracle.com/javase/specs/jls/se13/html/jls-3.html#jls-3.10.7
- match: null{{break}}
Expand Down
Loading

0 comments on commit 4a51942

Please sign in to comment.