Skip to content

Commit

Permalink
[Rust] Add punctuation.accessor scopes
Browse files Browse the repository at this point in the history
  • Loading branch information
wbond committed Apr 5, 2017
1 parent fa30dac commit b506d85
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
20 changes: 13 additions & 7 deletions Rust/Rust.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -498,14 +498,17 @@ contexts:
- include: type-any-identifier
- match: '''{{identifier}}(?!\'')\b'
scope: storage.modifier.lifetime.rust
- match: '\b([[:upper:]]|_*[[:upper:]][[:alnum:]_]*[[:lower:]][[:alnum:]_]*)\b::'
- match: '\b([[:upper:]]|_*[[:upper:]][[:alnum:]_]*[[:lower:]][[:alnum:]_]*)\b(::)'
scope: meta.path.rust storage.type.rust
captures:
1: storage.type.rust
- match: '{{identifier}}::'
scope: meta.path.rust
- match: '::(?={{identifier}})'
2: punctuation.accessor.rust
- match: '{{identifier}}(::)'
scope: meta.path.rust
captures:
1: punctuation.accessor.rust
- match: '(::)(?={{identifier}})'
scope: meta.path.rust punctuation.accessor.rust
- match: '(?=<)'
push: generic-angles
- match: '\('
Expand Down Expand Up @@ -1060,12 +1063,15 @@ contexts:
- meta_scope: meta.path.rust
- include: no-path-identifiers
- match: '::'
scope: punctuation.accessor.rust
set: no-type-names
- match: '{{identifier}}::'
- match: '{{identifier}}(::)'
scope: meta.path.rust
captures:
1: punctuation.accessor.rust
push: no-type-names
- match: '::(?={{identifier}})'
scope: meta.path.rust
- match: '(::)(?={{identifier}})'
scope: meta.path.rust punctuation.accessor.rust
push: no-type-names
- include: no-path-identifiers

Expand Down
12 changes: 10 additions & 2 deletions Rust/syntax_test_rust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,18 +151,23 @@ pub use self::trafile::*;
// <- storage.modifier
// ^ keyword.other
// ^^^^^^^^^^^^^^^ meta.path
// ^^ punctuation.accessor

use std::fmt;
// <- keyword.other
// ^^^^^ meta.path
// ^^ punctuation.accessor
// ^^^ - meta.path
use foo::i32;
// ^^^^^ meta.path
// ^^ punctuation.accessor
// ^^^ - meta.path storage.type
use foo::Bar;
// ^^^^^ meta.path
// ^^ punctuation.accessor
use foo::{Baz, QUX, quux};
// ^^^^^ meta.path
// ^^ punctuation.accessor
// ^^^^^^^^^^^^^^^^ meta.block
// ^^^ constant.other

Expand Down Expand Up @@ -221,6 +226,7 @@ impl fmt::Display for PrintableStruct {
// <- storage.type.impl
//^^ storage.type.impl
// ^^^^^ meta.path
// ^^ punctuation.accessor
// ^^^ keyword.other
// ^^^^^^^^^^^^^^^ entity.name.impl
// ^ meta.block punctuation.section.block.begin
Expand All @@ -241,6 +247,7 @@ impl fmt::Display for PrintableStruct {
// ^ punctuation.section.parameters.end
// ^^ punctuation.separator
// ^^^^^ meta.path
// ^^ punctuation.accessor
// ^ meta.block punctuation.section.block.begin
write!(f, "{}", self.0)
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function
Expand Down Expand Up @@ -626,6 +633,7 @@ fn factory() -> Box<Fn(i32) -> i32> {
// ^^ storage.type
// ^^ punctuation.separator
Box::new(|x| x + 1)
// ^^ punctuation.accessor
}

let inferred_closure = |i, j: u32| i + 1;
Expand Down Expand Up @@ -829,7 +837,7 @@ macro_rules! forward_ref_binop [
// ^ meta.macro meta.group meta.block meta.impl meta.block punctuation.section.block.begin
type Output = <$t as $imp<$u>>::Output;
// ^^^^^^^^^^^^^^^^ meta.generic
// ^^ meta.path
// ^^ meta.path punctuation.accessor

#[inline]
// ^^^^^^^^^ meta.annotation
Expand All @@ -845,7 +853,7 @@ macro_rules! forward_ref_binop [
// ^^ variable.other
// ^^ punctuation.separator
// ^^^^^^^^^^^^^^^^ meta.generic
// ^^ meta.path
// ^^ meta.path punctuation.accessor
// ^ meta.macro meta.group meta.block meta.impl meta.block meta.block punctuation.section.block.begin
#![cfg(all(unix, target_pointer_width = "32"))]
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.annotation
Expand Down

0 comments on commit b506d85

Please sign in to comment.