pub struct Grammar {
pub name: String,
pub scope_name: String,
pub scopes: Vec<String>,
pub kind: GrammarKind,
/* private fields */
}Expand description
Immutable compiled grammar data.
Fields§
§name: StringHuman-readable grammar name.
scope_name: StringRoot scope name.
scopes: Vec<String>Interned scope names used by this grammar.
kind: GrammarKindTokenization strategy used by this grammar.
Implementations§
Source§impl Grammar
impl Grammar
Sourcepub fn compile(raw: &RawGrammar) -> Result<Self, Error>
pub fn compile(raw: &RawGrammar) -> Result<Self, Error>
Compiles a raw grammar.
Sourcepub fn plain_text() -> Self
pub fn plain_text() -> Self
Builds a grammar with no patterns for plain text fallback.
Sourcepub fn json() -> Self
pub fn json() -> Self
Builds the dedicated fast JSON grammar.
This does not use the recursive TextMate tokenizer. It emits the same
kind of ScopeSpan values as compiled grammars while scanning each
line directly.
Sourcepub fn matches_name(&self, name: &str) -> bool
pub fn matches_name(&self, name: &str) -> bool
Returns true when this grammar matches a syntax name or alias.
Sourcepub fn matches_path(&self, path: &Path) -> bool
pub fn matches_path(&self, path: &Path) -> bool
Returns true when this grammar matches a file path.
Sourcepub fn matches_first_line(&self, line: &str) -> bool
pub fn matches_first_line(&self, line: &str) -> bool
Returns true when this grammar matches the first source line.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Grammar
impl RefUnwindSafe for Grammar
impl Send for Grammar
impl Sync for Grammar
impl Unpin for Grammar
impl UnsafeUnpin for Grammar
impl UnwindSafe for Grammar
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more