Rust/Ruby/Python: format code

This commit is contained in:
Paolo Tranquilli
2025-02-25 13:19:03 +01:00
parent e8799e346d
commit 6089a75262
11 changed files with 24 additions and 28 deletions

View File

@@ -7,17 +7,17 @@
use std::path::Path;
use anyhow::anyhow;
use anyhow::Context as _;
use anyhow::Result;
use clap::{Command, Arg, ArgAction};
use anyhow::anyhow;
use clap::{Arg, ArgAction, Command};
use tree_sitter::Parser;
use tree_sitter_graph::ast::File;
use tree_sitter_graph::functions::Functions;
use tree_sitter_graph::ExecutionConfig;
use tree_sitter_graph::Identifier;
use tree_sitter_graph::NoCancellation;
use tree_sitter_graph::Variables;
use tree_sitter_graph::ast::File;
use tree_sitter_graph::functions::Functions;
const BUILD_VERSION: &'static str = env!("CARGO_PKG_VERSION");
@@ -332,7 +332,7 @@ pub mod extra_functions {
return Err(ExecutionError::FunctionFailed(
"unnamed-child-index".into(),
format!("Cannot call child-index on the root node"),
))
));
}
};
let mut tree_cursor = parent.walk();
@@ -490,7 +490,7 @@ fn main() -> Result<()> {
.short('t')
.long("tsg")
.action(ArgAction::Set)
.required(false)
.required(false),
)
.arg(Arg::new("source").index(1).required(true))
.get_matches();

View File

@@ -4,9 +4,9 @@ use anyhow::Context;
use clap::Parser;
use codeql_extractor::trap;
use figment::{
Figment,
providers::{Env, Format, Serialized, Yaml},
value::Value,
Figment,
};
use itertools::Itertools;
use ra_ap_cfg::{CfgAtom, CfgDiff};

View File

@@ -1,5 +1,5 @@
use serde::de::{Error, Unexpected, Visitor};
use serde::Deserializer;
use serde::de::{Error, Unexpected, Visitor};
use std::collections::HashMap;
use std::fmt::Formatter;
use std::hash::BuildHasher;

View File

@@ -2,8 +2,8 @@ use crate::config::Config;
use anyhow::Context;
use chrono::{DateTime, Utc};
use ra_ap_project_model::ProjectManifest;
use serde::ser::SerializeMap;
use serde::Serialize;
use serde::ser::SerializeMap;
use std::collections::HashMap;
use std::fmt::Display;
use std::fs::File;

View File

@@ -1,11 +1,11 @@
use crate::diagnostics::{emit_extraction_diagnostics, ExtractionStep};
use crate::diagnostics::{ExtractionStep, emit_extraction_diagnostics};
use crate::rust_analyzer::path_to_file_id;
use crate::trap::TrapId;
use anyhow::Context;
use archive::Archiver;
use ra_ap_hir::Semantics;
use ra_ap_ide_db::line_index::{LineCol, LineIndex};
use ra_ap_ide_db::RootDatabase;
use ra_ap_ide_db::line_index::{LineCol, LineIndex};
use ra_ap_load_cargo::LoadCargoConfig;
use ra_ap_paths::{AbsPathBuf, Utf8PathBuf};
use ra_ap_project_model::{CargoConfig, ProjectManifest};

View File

@@ -2,7 +2,7 @@ use itertools::Itertools;
use ra_ap_base_db::SourceDatabase;
use ra_ap_hir::Semantics;
use ra_ap_ide_db::RootDatabase;
use ra_ap_load_cargo::{load_workspace_at, LoadCargoConfig};
use ra_ap_load_cargo::{LoadCargoConfig, load_workspace_at};
use ra_ap_paths::{AbsPath, Utf8PathBuf};
use ra_ap_project_model::ProjectManifest;
use ra_ap_project_model::{CargoConfig, ManifestPath};

View File

@@ -4,23 +4,23 @@ use crate::rust_analyzer::FileSemanticInformation;
use crate::trap::{DiagnosticSeverity, TrapFile, TrapId};
use crate::trap::{Label, TrapClass};
use itertools::Either;
use ra_ap_base_db::ra_salsa::InternKey;
use ra_ap_base_db::CrateOrigin;
use ra_ap_base_db::ra_salsa::InternKey;
use ra_ap_hir::db::ExpandDatabase;
use ra_ap_hir::{
Adt, Crate, ItemContainer, Module, ModuleDef, PathResolution, Semantics, Type, Variant,
};
use ra_ap_hir_def::type_ref::Mutability;
use ra_ap_hir_def::ModuleId;
use ra_ap_hir_def::type_ref::Mutability;
use ra_ap_hir_expand::ExpandTo;
use ra_ap_ide_db::line_index::{LineCol, LineIndex};
use ra_ap_ide_db::RootDatabase;
use ra_ap_ide_db::line_index::{LineCol, LineIndex};
use ra_ap_parser::SyntaxKind;
use ra_ap_span::{EditionedFileId, TextSize};
use ra_ap_syntax::ast::HasName;
use ra_ap_syntax::{
ast, AstNode, NodeOrToken, SyntaxElementChildren, SyntaxError, SyntaxNode, SyntaxToken,
TextRange,
AstNode, NodeOrToken, SyntaxElementChildren, SyntaxError, SyntaxNode, SyntaxToken, TextRange,
ast,
};
#[macro_export]

View File

@@ -1,6 +1,6 @@
use ra_ap_hir::{Enum, Function, HasContainer, Module, Semantics, Struct, Trait, Union};
use ra_ap_ide_db::RootDatabase;
use ra_ap_syntax::{ast, ast::RangeItem, AstNode};
use ra_ap_syntax::{AstNode, ast, ast::RangeItem};
pub(crate) trait TextValue {
fn try_get_text(&self) -> Option<String>;

View File

@@ -7,13 +7,13 @@ use std::collections::BTreeSet as Set;
use std::env;
use std::path::Path;
use tracing_subscriber::EnvFilter;
use tracing_subscriber::Layer;
use tracing_subscriber::filter::Filtered;
use tracing_subscriber::fmt::format::DefaultFields;
use tracing_subscriber::fmt::format::Format;
use tracing_subscriber::layer::SubscriberExt;
use tracing_subscriber::util::SubscriberInitExt;
use tracing_subscriber::EnvFilter;
use tracing_subscriber::Layer;
use tree_sitter::{Language, Node, Parser, Range, Tree};
pub mod simple;
@@ -591,11 +591,7 @@ impl<'a> Visitor<'a> {
}
}
}
if is_valid {
Some(args)
} else {
None
}
if is_valid { Some(args) } else { None }
}
fn type_matches(&self, tp: &TypeName, type_info: &node_types::FieldTypeInfo) -> bool {
@@ -615,7 +611,7 @@ impl<'a> Visitor<'a> {
}
node_types::FieldTypeInfo::ReservedWordInt(int_mapping) => {
return !tp.named && int_mapping.contains_key(&tp.kind)
return !tp.named && int_mapping.contains_key(&tp.kind);
}
}
false

View File

@@ -4,7 +4,7 @@ use codeql_extractor::trap;
use tree_sitter_ql;
mod common;
use common::{create_source_dir, expect_trap_file, SourceArchive};
use common::{SourceArchive, create_source_dir, expect_trap_file};
/// A very simple happy-path test.
/// We run the extractor using the tree-sitter-ql grammar and a single source file,

View File

@@ -3,7 +3,7 @@ use codeql_extractor::trap;
use tree_sitter_ql;
mod common;
use common::{create_source_dir, expect_trap_file, SourceArchive};
use common::{SourceArchive, create_source_dir, expect_trap_file};
/// Like the `simple_extractor` test but with multiple languages.
/// This is in a separate crate because the simple extractor API sets up a