pub struct LanguageRegistry { /* private fields */ }Expand description
Ordered language registry with last-registration-wins extension and name lookup.
Implementations§
Source§impl LanguageRegistry
impl LanguageRegistry
Sourcepub fn register(&mut self, spec: LanguageSpec) -> LanguageId
pub fn register(&mut self, spec: LanguageSpec) -> LanguageId
Registers a language and returns its stable identifier.
When an extension or language name was already registered, this specification becomes the new lookup owner.
Sourcepub const fn generation(&self) -> u64
pub const fn generation(&self) -> u64
Returns the number of registry mutations observed so far.
Sourcepub fn for_path(&self, path: &Path) -> Option<LanguageId>
pub fn for_path(&self, path: &Path) -> Option<LanguageId>
Resolves a path by its final file extension.
Sourcepub fn get(&self, id: LanguageId) -> Option<&LanguageSpec>
pub fn get(&self, id: LanguageId) -> Option<&LanguageSpec>
Returns the specification for an identifier.
Sourcepub fn for_name(&self, name: &str) -> Option<LanguageId>
pub fn for_name(&self, name: &str) -> Option<LanguageId>
Resolves a registered language by its wire-stable name.
Sourcepub fn supports_symbols(&self, path: &Path) -> bool
pub fn supports_symbols(&self, path: &Path) -> bool
Returns whether the path has direct or injected symbol support.
Sourcepub fn supports_imports(&self, path: &Path) -> bool
pub fn supports_imports(&self, path: &Path) -> bool
Returns whether the path has a direct or injected import extractor.
Sourcepub fn iter(&self) -> impl ExactSizeIterator<Item = (LanguageId, &LanguageSpec)>
pub fn iter(&self) -> impl ExactSizeIterator<Item = (LanguageId, &LanguageSpec)>
Iterates over registered identifiers and specifications in registration order.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for LanguageRegistry
impl RefUnwindSafe for LanguageRegistry
impl Send for LanguageRegistry
impl Sync for LanguageRegistry
impl Unpin for LanguageRegistry
impl UnsafeUnpin for LanguageRegistry
impl UnwindSafe for LanguageRegistry
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