Auto-fix clippy::collapsible_if violations (#36428)
Release Notes: - N/A
This commit is contained in:
parent
9e8ec72bd5
commit
8f567383e4
281 changed files with 6628 additions and 7089 deletions
|
@ -40,20 +40,20 @@ fn migrate_context_server_settings(
|
|||
// Parse the server settings to check what keys it contains
|
||||
let mut cursor = server_settings.walk();
|
||||
for child in server_settings.children(&mut cursor) {
|
||||
if child.kind() == "pair" {
|
||||
if let Some(key_node) = child.child_by_field_name("key") {
|
||||
if let (None, Some(quote_content)) = (column, key_node.child(0)) {
|
||||
column = Some(quote_content.start_position().column);
|
||||
}
|
||||
if let Some(string_content) = key_node.child(1) {
|
||||
let key = &contents[string_content.byte_range()];
|
||||
match key {
|
||||
// If it already has a source key, don't modify it
|
||||
"source" => return None,
|
||||
"command" => has_command = true,
|
||||
"settings" => has_settings = true,
|
||||
_ => other_keys += 1,
|
||||
}
|
||||
if child.kind() == "pair"
|
||||
&& let Some(key_node) = child.child_by_field_name("key")
|
||||
{
|
||||
if let (None, Some(quote_content)) = (column, key_node.child(0)) {
|
||||
column = Some(quote_content.start_position().column);
|
||||
}
|
||||
if let Some(string_content) = key_node.child(1) {
|
||||
let key = &contents[string_content.byte_range()];
|
||||
match key {
|
||||
// If it already has a source key, don't modify it
|
||||
"source" => return None,
|
||||
"command" => has_command = true,
|
||||
"settings" => has_settings = true,
|
||||
_ => other_keys += 1,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -84,10 +84,10 @@ fn remove_pair_with_whitespace(
|
|||
}
|
||||
} else {
|
||||
// If no next sibling, check if there's a comma before
|
||||
if let Some(prev_sibling) = pair_node.prev_sibling() {
|
||||
if prev_sibling.kind() == "," {
|
||||
range_to_remove.start = prev_sibling.start_byte();
|
||||
}
|
||||
if let Some(prev_sibling) = pair_node.prev_sibling()
|
||||
&& prev_sibling.kind() == ","
|
||||
{
|
||||
range_to_remove.start = prev_sibling.start_byte();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -123,10 +123,10 @@ fn remove_pair_with_whitespace(
|
|||
|
||||
// Also check if we need to include trailing whitespace up to the next line
|
||||
let text_after = &contents[range_to_remove.end..];
|
||||
if let Some(newline_pos) = text_after.find('\n') {
|
||||
if text_after[..newline_pos].chars().all(|c| c.is_whitespace()) {
|
||||
range_to_remove.end += newline_pos + 1;
|
||||
}
|
||||
if let Some(newline_pos) = text_after.find('\n')
|
||||
&& text_after[..newline_pos].chars().all(|c| c.is_whitespace())
|
||||
{
|
||||
range_to_remove.end += newline_pos + 1;
|
||||
}
|
||||
|
||||
Some((range_to_remove, String::new()))
|
||||
|
|
|
@ -56,19 +56,18 @@ fn flatten_context_server_command(
|
|||
|
||||
let mut cursor = command_object.walk();
|
||||
for child in command_object.children(&mut cursor) {
|
||||
if child.kind() == "pair" {
|
||||
if let Some(key_node) = child.child_by_field_name("key") {
|
||||
if let Some(string_content) = key_node.child(1) {
|
||||
let key = &contents[string_content.byte_range()];
|
||||
if let Some(value_node) = child.child_by_field_name("value") {
|
||||
let value_range = value_node.byte_range();
|
||||
match key {
|
||||
"path" => path_value = Some(&contents[value_range]),
|
||||
"args" => args_value = Some(&contents[value_range]),
|
||||
"env" => env_value = Some(&contents[value_range]),
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
if child.kind() == "pair"
|
||||
&& let Some(key_node) = child.child_by_field_name("key")
|
||||
&& let Some(string_content) = key_node.child(1)
|
||||
{
|
||||
let key = &contents[string_content.byte_range()];
|
||||
if let Some(value_node) = child.child_by_field_name("value") {
|
||||
let value_range = value_node.byte_range();
|
||||
match key {
|
||||
"path" => path_value = Some(&contents[value_range]),
|
||||
"args" => args_value = Some(&contents[value_range]),
|
||||
"env" => env_value = Some(&contents[value_range]),
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue