Skip to content

Commit

Permalink
[#15] Fix extra chars appended to settings/function names.
Browse files Browse the repository at this point in the history
  • Loading branch information
nk9 committed Apr 26, 2023
1 parent 8438819 commit 8bfec6f
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 7 deletions.
30 changes: 23 additions & 7 deletions Syntax/Just.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ file_extensions:
variables:
valid_name: "[a-zA-Z_][a-zA-Z0-9_-]*"
built_in_functions: |
(?x) # ignore whitespace in this regex
(?x)(?: # ignore whitespace in this regex
absolute_path | arch | capitalize | clean | env_var_or_default | env_var |
error | extension | file_name | file_stem | invocation_directory_native |
Expand All @@ -31,17 +31,20 @@ variables:
trim_end_matches | trim_end_match | trim_end | trim_start_matches |
trim_start_match | trim_start | trim | uppercase | uppercamelcase |
uuid | without_extension
)
boolean_settings: |
(?x)
(?x)(?:
allow-duplicate-recipes | dotenv-load | export | fallback | ignore-comments |
positional-arguments | windows-powershell
)
string_settings: |
(?x)
(?x)(?:
tempdir
)
shell_settings: |
(?x)
(?x)(?:
shell | windows-shell
)
recipe_attributes: |
(?x)
linux | macos | no-cd | no-exit-message | private | unix | windows
Expand Down Expand Up @@ -274,6 +277,11 @@ contexts:
###[ VARIABLES ]###############################################################

operands-variables:
# First check for an invalid function
- match: '\b({{valid_name}})\b\s*(\()'
captures:
1: source.just
2: invalid.illegal.just
- match: \b(?:{{valid_name}})\b
scope: variable.other.just

Expand Down Expand Up @@ -503,10 +511,17 @@ contexts:
- match: '^set(?=\s+)'
scope: storage.modifier.definition.just
push:
- settings-invalid
- settings-boolean
- settings-shell
- settings-string

settings-invalid:
- match: '\b({{valid_name}})\b\s*:='
captures:
1: invalid.illegal.just
- include: else-pop

settings-boolean:
- match: '\b{{boolean_settings}}\b'
scope: entity.name.definition.just
Expand All @@ -532,8 +547,9 @@ contexts:
- include: else-pop

constant-boolean:
- match: "(true|false)"
scope: constant.language.boolean.just
- match: '\b(true|false)\b'
captures:
1: constant.language.boolean.just
pop: 1
- include: else-pop

Expand Down
8 changes: 8 additions & 0 deletions Syntax/tests/syntax_test_just.functions.just
Original file line number Diff line number Diff line change
Expand Up @@ -216,3 +216,11 @@ upper := uppercase("test-me")
# ^^^^^^^^^ string.quoted.double.just
# ^ meta.function-call.arguments.just punctuation.section.group.end.just


#
# Invalid cases
#

t2 := titlecased("test me thanks" + lowercase("blah"))
# ^^^^^^^^^^ - meta.function-call.identifier.just - support.function.builtin.just - variable.other.just
# ^ invalid.illegal.just
28 changes: 28 additions & 0 deletions Syntax/tests/syntax_test_just.settings.just
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,31 @@ set ignore-comments # Comment
# ^^^^^^^^^^^^^^^ entity.name.definition.just
# ^^ comment.line.number-sign.just punctuation.definition.comment.begin.just
# ^^^^^^^^ comment.line.number-sign.just


#
# Invalid cases
#

# Extra characters for boolean setting
set exported
#^^ storage.modifier.definition.just
# ^^^^^^^^^ - entity.name.definition.just - variable.other.just

# Extra characters for string setting
set tempdirectory := '/tmp'
# ^^^^^^^^^^^^^ invalid.illegal.just - entity.name.definition.just - variable.other.just

set shellac := ["sh", "-c"]
# ^^^^^^^ invalid.illegal.just - entity.name.definition.just - variable.other.just

# Wrong character case
set tempDir
#^^ storage.modifier.definition.just
# ^^^^^^^^ - entity.name.definition.just - variable.other.just

set export := trued
# ^^^^^ - constant.language.boolean.just

set dotenv-load := falsey
# ^^^^^^ - constant.language.boolean.just

0 comments on commit 8bfec6f

Please sign in to comment.