chore(rust): make Query extra predicates state fully immutable
This commit is contained in:
parent
74e77b10c1
commit
52f7eaff31
6 changed files with 96 additions and 78 deletions
|
|
@ -828,8 +828,8 @@ impl<'a> LanguageConfiguration<'a> {
|
|||
let mut all_highlight_names = self.highlight_names.lock().unwrap();
|
||||
if self.use_all_highlight_names {
|
||||
for capture_name in result.query.capture_names() {
|
||||
if !all_highlight_names.contains(capture_name) {
|
||||
all_highlight_names.push(capture_name.clone());
|
||||
if !all_highlight_names.iter().any(|x| x == capture_name) {
|
||||
all_highlight_names.push(capture_name.to_string());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -353,7 +353,7 @@ fn format_captures<'a>(
|
|||
captures
|
||||
.map(|capture| {
|
||||
(
|
||||
query.capture_names()[capture.index as usize].as_str(),
|
||||
query.capture_names()[capture.index as usize],
|
||||
capture.node.utf8_text(source.as_bytes()).unwrap(),
|
||||
)
|
||||
})
|
||||
|
|
|
|||
|
|
@ -2269,7 +2269,7 @@ fn test_query_captures_within_byte_range_assigned_after_iterating() {
|
|||
for (mat, capture_ix) in captures.by_ref().take(5) {
|
||||
let capture = mat.captures[capture_ix as usize];
|
||||
results.push((
|
||||
query.capture_names()[capture.index as usize].as_str(),
|
||||
query.capture_names()[capture.index as usize],
|
||||
&source[capture.node.byte_range()],
|
||||
));
|
||||
}
|
||||
|
|
@ -2292,7 +2292,7 @@ fn test_query_captures_within_byte_range_assigned_after_iterating() {
|
|||
for (mat, capture_ix) in captures {
|
||||
let capture = mat.captures[capture_ix as usize];
|
||||
results.push((
|
||||
query.capture_names()[capture.index as usize].as_str(),
|
||||
query.capture_names()[capture.index as usize],
|
||||
&source[capture.node.byte_range()],
|
||||
));
|
||||
}
|
||||
|
|
@ -2533,7 +2533,7 @@ fn test_query_matches_with_captured_wildcard_at_root() {
|
|||
.iter()
|
||||
.map(|c| {
|
||||
(
|
||||
query.capture_names()[c.index as usize].as_str(),
|
||||
query.capture_names()[c.index as usize],
|
||||
c.node.kind(),
|
||||
c.node.start_position().row,
|
||||
)
|
||||
|
|
@ -2934,7 +2934,8 @@ fn test_query_captures_with_predicates() {
|
|||
args: vec![
|
||||
QueryPredicateArg::Capture(0),
|
||||
QueryPredicateArg::String("omg".to_string().into_boxed_str()),
|
||||
],
|
||||
]
|
||||
.into_boxed_slice(),
|
||||
},]
|
||||
);
|
||||
assert_eq!(query.property_settings(1), &[]);
|
||||
|
|
@ -3826,7 +3827,7 @@ fn test_query_random() {
|
|||
captures: mat
|
||||
.captures
|
||||
.iter()
|
||||
.map(|c| (query.capture_names()[c.index as usize].as_str(), c.node))
|
||||
.map(|c| (query.capture_names()[c.index as usize], c.node))
|
||||
.collect::<Vec<_>>(),
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue