Skip to content

Commit

Permalink
Bump tree-sitter to 0.22.2
Browse files Browse the repository at this point in the history
  • Loading branch information
the-mikedavis authored and archseer committed Mar 18, 2024
1 parent 476e6ba commit 38af99f
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 17 deletions.
5 changes: 3 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ package.helix-tui.opt-level = 2
package.helix-term.opt-level = 2

[workspace.dependencies]
tree-sitter = { version = "0.20", git = "https://github.com/helix-editor/tree-sitter", rev = "660481dbf71413eba5a928b0b0ab8da50c1109e0" }
tree-sitter = { version = "0.22" }
nucleo = "0.2.0"

[workspace.package]
Expand Down
20 changes: 7 additions & 13 deletions helix-core/src/syntax.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use std::{
collections::{HashMap, HashSet, VecDeque},
fmt::{self, Display},
hash::{Hash, Hasher},
mem::{replace, transmute},
mem::replace,
path::{Path, PathBuf},
str::FromStr,
sync::Arc,
Expand Down Expand Up @@ -805,7 +805,7 @@ impl LanguageConfiguration {
if query_text.is_empty() {
return None;
}
let lang = self.highlight_config.get()?.as_ref()?.language;
let lang = &self.highlight_config.get()?.as_ref()?.language;
Query::new(lang, &query_text)
.map_err(|e| {
log::error!(
Expand Down Expand Up @@ -1544,13 +1544,7 @@ impl PartialEq for LanguageLayer {
impl Hash for LanguageLayer {
fn hash<H: Hasher>(&self, state: &mut H) {
self.depth.hash(state);
// The transmute is necessary here because tree_sitter::Language does not derive Hash at the moment.
// However it does use #[repr] transparent so the transmute here is safe
// as `Language` (which `Grammar` is an alias for) is just a newtype wrapper around a (thin) pointer.
// This is also compatible with the PartialEq implementation of language
// as that is just a pointer comparison.
let language: *const () = unsafe { transmute(self.config.language) };
language.hash(state);
self.config.language.hash(state);
self.ranges.hash(state);
}
}
Expand All @@ -1567,7 +1561,7 @@ impl LanguageLayer {
.map_err(|_| Error::InvalidRanges)?;

parser
.set_language(self.config.language)
.set_language(&self.config.language)
.map_err(|_| Error::InvalidLanguage)?;

// unsafe { syntax.parser.set_cancellation_flag(cancellation_flag) };
Expand Down Expand Up @@ -1867,7 +1861,7 @@ impl HighlightConfiguration {

// Construct a single query by concatenating the three query strings, but record the
// range of pattern indices that belong to each individual string.
let query = Query::new(language, &query_source)?;
let query = Query::new(&language, &query_source)?;
let mut highlights_pattern_index = 0;
for i in 0..(query.pattern_count()) {
let pattern_offset = query.start_byte_for_pattern(i);
Expand All @@ -1876,7 +1870,7 @@ impl HighlightConfiguration {
}
}

let injections_query = Query::new(language, injection_query)?;
let injections_query = Query::new(&language, injection_query)?;
let combined_injections_patterns = (0..injections_query.pattern_count())
.filter(|&i| {
injections_query
Expand Down Expand Up @@ -2730,7 +2724,7 @@ mod test {
.unwrap();
let language = get_language("rust").unwrap();

let query = Query::new(language, query_str).unwrap();
let query = Query::new(&language, query_str).unwrap();
let textobject = TextObjectQuery { query };
let mut cursor = QueryCursor::new();

Expand Down
2 changes: 1 addition & 1 deletion xtask/src/querycheck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub fn query_check() -> Result<(), DynError> {
let query_text = read_query(language_name, query_file);
if let Ok(lang) = language {
if !query_text.is_empty() {
if let Err(reason) = Query::new(lang, &query_text) {
if let Err(reason) = Query::new(&lang, &query_text) {
return Err(format!(
"Failed to parse {} queries for {}: {}",
query_file, language_name, reason
Expand Down

0 comments on commit 38af99f

Please sign in to comment.