Start work on handling combined injections in SyntaxMap
This commit is contained in:
parent
be6ee3cbff
commit
5efe2ed6d3
5 changed files with 288 additions and 82 deletions
|
@ -28,6 +28,7 @@ use std::{
|
|||
any::Any,
|
||||
cell::RefCell,
|
||||
fmt::Debug,
|
||||
hash::Hash,
|
||||
mem,
|
||||
ops::Range,
|
||||
path::{Path, PathBuf},
|
||||
|
@ -643,6 +644,10 @@ impl Language {
|
|||
self.adapter.clone()
|
||||
}
|
||||
|
||||
pub fn id(&self) -> Option<usize> {
|
||||
self.grammar.as_ref().map(|g| g.id)
|
||||
}
|
||||
|
||||
pub fn with_highlights_query(mut self, source: &str) -> Result<Self> {
|
||||
let grammar = self.grammar_mut();
|
||||
grammar.highlights_query = Some(Query::new(grammar.ts_language, source)?);
|
||||
|
@ -895,6 +900,20 @@ impl Language {
|
|||
}
|
||||
}
|
||||
|
||||
impl Hash for Language {
|
||||
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
|
||||
self.id().hash(state)
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialEq for Language {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
self.id().eq(&other.id())
|
||||
}
|
||||
}
|
||||
|
||||
impl Eq for Language {}
|
||||
|
||||
impl Debug for Language {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
f.debug_struct("Language")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue