Skip to content

Commit

Permalink
[Rust] Optimize some contexts according to review
Browse files Browse the repository at this point in the history
  • Loading branch information
FichteFoll committed Oct 29, 2023
1 parent f6e04ed commit 20ff4fa
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 15 deletions.
23 changes: 12 additions & 11 deletions Rust/Rust.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ contexts:
- include: keywords
- include: numbers

- match: '(?=\{)'
push: block
- include: blocks

- match: '(?=\()'
push: group
Expand Down Expand Up @@ -155,7 +154,7 @@ contexts:
push: generic-angles
- match: '=(?!=)'
scope: keyword.operator.assignment.rust
push: type-declaration-body
set: type-declaration-body
- include: else-pop

- match: '\b(trait)\s+({{identifier}})\b'
Expand Down Expand Up @@ -1540,26 +1539,29 @@ contexts:
identifier-path:
- meta_scope: meta.path.rust
- include: comments
- match: \.
scope: punctuation.accessor.dot.rust
- match: \s*(\.)
captures:
1: punctuation.accessor.dot.rust
push: [identifier-path-second, path-after-accessor]
- include: identifier-names
- include: immediately-pop

identifier-path-second:
- meta_scope: meta.path.rust
- include: comments
- match: \.
scope: punctuation.accessor.dot.rust
- match: \s*(\.)
captures:
1: punctuation.accessor.dot.rust
push: path-after-accessor
- include: in-path-identifier-names
- include: immediately-pop

static-identifier-path:
- meta_scope: meta.path.rust
- include: comments
- match: '::'
scope: punctuation.accessor.rust
- match: \s*(::)
captures:
1: punctuation.accessor.rust
set: [static-identifier-path-second, path-after-accessor]
- include: type-names
- include: identifier-names
Expand All @@ -1580,8 +1582,7 @@ contexts:

path-after-accessor:
- include: comments
- match: \s+
- include: immediately-pop
- include: else-pop

identifier-names:
- include: no-path-identifier-names
Expand Down
22 changes: 18 additions & 4 deletions Rust/tests/syntax_test_identifiers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,20 @@ buffer.rope.char();
// ^^ meta.group
// ^ punctuation.terminator


buffer . rope . char ();
//^^^^^^^^^^^^^^^^^^ meta.path
// ^ punctuation.accessor.dot
// ^ punctuation.accessor.dot
// ^^^^ variable.function
// ^^ meta.group
// ^ punctuation.terminator

path . with_a_break s.path ();
//^^^^^^^^^^^^^^^^^ meta.path
// ^ -meta.path
// ^^^^^^ meta.path

env::current_dir()
//^^^^^^^^^^^^^^ meta.path
// ^^ punctuation.accessor
Expand All @@ -30,17 +44,17 @@ let file_bytes = fs::read(&path_buf)?;
// ^ keyword.operator
// ^ punctuation.terminator

u8::try_from(), f64::from()
u8::try_from(), f64 :: from ()
// <- meta.path storage.type
// <- meta.path storage.type
//^^^^^^^^^^ meta.path
// ^^^^^^^^ variable.function
// ^^^^ -meta.path
// ^ punctuation.separator
// ^^^^^^^^^ meta.path
// ^^^^^^^^^^^ meta.path
// ^^^ storage.type
// ^^ punctuation.accessor
// ^^^^ variable.function
// ^^ punctuation.accessor
// ^^^^ variable.function

Vec::with_capacity()
//^^^^^^^^^^^^^^^^ meta.path
Expand Down

0 comments on commit 20ff4fa

Please sign in to comment.