Skip to content

Commit 55bcccd

Browse files
committed
[#15] Fix extra chars appended to settings/function names.
1 parent 8438819 commit 55bcccd

3 files changed

Lines changed: 59 additions & 7 deletions

File tree

Syntax/Just.sublime-syntax

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ file_extensions:
1919
variables:
2020
valid_name: "[a-zA-Z_][a-zA-Z0-9_-]*"
2121
built_in_functions: |
22-
(?x) # ignore whitespace in this regex
22+
(?x)(?: # ignore whitespace in this regex
2323
2424
absolute_path | arch | capitalize | clean | env_var_or_default | env_var |
2525
error | extension | file_name | file_stem | invocation_directory_native |
@@ -31,17 +31,20 @@ variables:
3131
trim_end_matches | trim_end_match | trim_end | trim_start_matches |
3232
trim_start_match | trim_start | trim | uppercase | uppercamelcase |
3333
uuid | without_extension
34-
34+
)
3535
boolean_settings: |
36-
(?x)
36+
(?x)(?:
3737
allow-duplicate-recipes | dotenv-load | export | fallback | ignore-comments |
3838
positional-arguments | windows-powershell
39+
)
3940
string_settings: |
40-
(?x)
41+
(?x)(?:
4142
tempdir
43+
)
4244
shell_settings: |
43-
(?x)
45+
(?x)(?:
4446
shell | windows-shell
47+
)
4548
recipe_attributes: |
4649
(?x)
4750
linux | macos | no-cd | no-exit-message | private | unix | windows
@@ -274,6 +277,11 @@ contexts:
274277
###[ VARIABLES ]###############################################################
275278

276279
operands-variables:
280+
# First check for an invalid function
281+
- match: '\b({{valid_name}})\b\s*(\()'
282+
captures:
283+
1: source.just
284+
2: invalid.illegal.just
277285
- match: \b(?:{{valid_name}})\b
278286
scope: variable.other.just
279287

@@ -503,10 +511,17 @@ contexts:
503511
- match: '^set(?=\s+)'
504512
scope: storage.modifier.definition.just
505513
push:
514+
- settings-invalid
506515
- settings-boolean
507516
- settings-shell
508517
- settings-string
509518

519+
settings-invalid:
520+
- match: '\b({{valid_name}})\b\s*:='
521+
captures:
522+
1: invalid.illegal.just
523+
- include: else-pop
524+
510525
settings-boolean:
511526
- match: '\b{{boolean_settings}}\b'
512527
scope: entity.name.definition.just
@@ -532,8 +547,9 @@ contexts:
532547
- include: else-pop
533548

534549
constant-boolean:
535-
- match: "(true|false)"
536-
scope: constant.language.boolean.just
550+
- match: '\b(true|false)\b'
551+
captures:
552+
1: constant.language.boolean.just
537553
pop: 1
538554
- include: else-pop
539555

Syntax/tests/syntax_test_just.functions.just

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,3 +216,11 @@ upper := uppercase("test-me")
216216
# ^^^^^^^^^ string.quoted.double.just
217217
# ^ meta.function-call.arguments.just punctuation.section.group.end.just
218218

219+
220+
#
221+
# Invalid cases
222+
#
223+
224+
t2 := titlecased("test me thanks" + lowercase("blah"))
225+
# ^^^^^^^^^^ - meta.function-call.identifier.just - support.function.builtin.just - variable.other.just
226+
# ^ invalid.illegal.just

Syntax/tests/syntax_test_just.settings.just

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,3 +75,31 @@ set ignore-comments # Comment
7575
# ^^^^^^^^^^^^^^^ entity.name.definition.just
7676
# ^^ comment.line.number-sign.just punctuation.definition.comment.begin.just
7777
# ^^^^^^^^ comment.line.number-sign.just
78+
79+
80+
#
81+
# Invalid cases
82+
#
83+
84+
# Extra characters for boolean setting
85+
set exported
86+
#^^ storage.modifier.definition.just
87+
# ^^^^^^^^^ - entity.name.definition.just - variable.other.just
88+
89+
# Extra characters for string setting
90+
set tempdirectory := '/tmp'
91+
# ^^^^^^^^^^^^^ invalid.illegal.just - entity.name.definition.just - variable.other.just
92+
93+
set shellac := ["sh", "-c"]
94+
# ^^^^^^^ invalid.illegal.just - entity.name.definition.just - variable.other.just
95+
96+
# Wrong character case
97+
set tempDir
98+
#^^ storage.modifier.definition.just
99+
# ^^^^^^^^ - entity.name.definition.just - variable.other.just
100+
101+
set export := trued
102+
# ^^^^^ - constant.language.boolean.just
103+
104+
set dotenv-load := falsey
105+
# ^^^^^^ - constant.language.boolean.just

0 commit comments

Comments
 (0)