-
Notifications
You must be signed in to change notification settings - Fork 590
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Rust] Refactor path matching (#3854)
* [Rust] Scope accessor punctuation in attributes * [Rust] Scope accessor punctuation in nested attribute call * [Rust] Introduce `declarations` scope * [Rust] Restructure definition file Move some context to related ones and add section headers. This commit does not claim to be an accurate grouping, but some grouping for now is better than none. Additionally, the `statements-block` context was replaced with a `block` context that pops after matching, following the plural vs singular naming convention. * [Rust] Rewrite identifier matching Rewrite type and identifier matching to fix problems with properly highlighting function calls. Not all cases are implemented yet, but this is a significant improvement over the previous situation. - The generics meta scope doesn't cover the preceding identifier anymore. - `meta.path` now spans the entire path, including the last segment. - The explicit `types` context is used in a couple more newly introduced contexts, i.e. for variable type declarations and `type` variables. A test file concerning identifier paths and function calls has been added. Some plural-vs-singular renaming has also been done, but not to all contexts. * [Rust] Add test for `union` as an identifier * [Rust] Optimize some contexts according to review
- Loading branch information
1 parent
9ba6b93
commit 1fe0b24
Showing
15 changed files
with
680 additions
and
423 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
// SYNTAX TEST "Packages/Rust/Rust.sublime-syntax" | ||
|
||
let line = Cow::from(x); | ||
// ^^^^^^^^^ meta.path | ||
// ^^^ storage.type | ||
// ^^ punctuation.accessor | ||
// ^^^^ variable.function | ||
// ^^^ meta.group | ||
// ^ punctuation.section.group.begin | ||
|
||
|
||
buffer.rope.char(); | ||
//^^^^^^^^^^^^^^ meta.path | ||
// ^ punctuation.accessor.dot | ||
// ^ punctuation.accessor.dot | ||
// ^^^^ variable.function | ||
// ^^ 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 | ||
// ^^^^^^^^^^^ variable.function | ||
|
||
let file_bytes = fs::read(&path_buf)?; | ||
// ^^^^^^^^ meta.path | ||
// ^^ punctuation.accessor | ||
// ^^^^ variable.function | ||
// ^^^^^^^^^^^ meta.group | ||
// ^ keyword.operator | ||
// ^ punctuation.terminator | ||
|
||
u8::try_from(), f64 :: from () | ||
// <- meta.path storage.type | ||
// <- meta.path storage.type | ||
//^^^^^^^^^^ meta.path | ||
// ^^^^^^^^ variable.function | ||
// ^^^^ -meta.path | ||
// ^ punctuation.separator | ||
// ^^^^^^^^^^^ meta.path | ||
// ^^^ storage.type | ||
// ^^ punctuation.accessor | ||
// ^^^^ variable.function | ||
|
||
Vec::with_capacity() | ||
//^^^^^^^^^^^^^^^^ meta.path | ||
//^ support.type | ||
// ^^ punctuation.accessor | ||
|
||
for x in a.union(&b) { | ||
// ^^^^^^^ meta.path | ||
// ^ punctuation.accessor.dot | ||
// ^^^^^ variable.function | ||
println!("{}", x); | ||
} | ||
|
||
// The following should eventually recognize `parse` as the function name | ||
input.parse::<SnailNum>() | ||
// ^^^^^^^^^^ meta.generic.rust | ||
// ^ punctuation.definition.generic.begin.rust | ||
// ^^^^^^^^ storage.type.rust | ||
// ^ punctuation.definition.generic.end.rust | ||
// ^^ meta.group.rust | ||
// ^ punctuation.section.group.begin.rust | ||
// ^ punctuation.section.group.end.rust |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.