mirror of
https://github.com/github/codeql.git
synced 2026-04-26 01:05:15 +02:00
Apply suggestions from code review
Co-authored-by: Nick Rolfe <nickrolfe@github.com>
This commit is contained in:
@@ -166,15 +166,15 @@ fn main() -> std::io::Result<()> {
|
||||
let mut trap_file = BufWriter::new(trap_file);
|
||||
match trap_compression {
|
||||
TrapCompression::None => {
|
||||
if erb_trap.is_some() {
|
||||
write!(trap_file, "{}", erb_trap.unwrap())?;
|
||||
if let Some(erb_trap) = erb_trap {
|
||||
write!(trap_file, "{}", erb_trap)?;
|
||||
}
|
||||
write!(trap_file, "{}", trap)
|
||||
}
|
||||
TrapCompression::Gzip => {
|
||||
let mut compressed_writer = GzEncoder::new(trap_file, flate2::Compression::fast());
|
||||
if erb_trap.is_some() {
|
||||
write!(compressed_writer, "{}", erb_trap.unwrap())?;
|
||||
if let Some(erb_trap) = erb_trap {
|
||||
write!(compressed_writer, "{}", erb_trap)?;
|
||||
}
|
||||
write!(compressed_writer, "{}", trap)
|
||||
}
|
||||
|
||||
@@ -136,6 +136,12 @@ fn add_field_for_column_storage<'a>(
|
||||
}
|
||||
|
||||
/// Converts the given tree-sitter node types into CodeQL dbscheme entries.
|
||||
/// Returns a tuple containing:
|
||||
///
|
||||
/// 1. A vector of dbscheme entries.
|
||||
/// 2. A set of names of the members of the `<lang>_ast_node` union.
|
||||
/// 3. A map where the keys are the dbscheme names for token kinds, and the
|
||||
/// values are their integer representations.
|
||||
fn convert_nodes<'a>(
|
||||
nodes: &'a node_types::NodeTypeMap,
|
||||
) -> (Vec<dbscheme::Entry<'a>>, Set<&'a str>, Map<&'a str, usize>) {
|
||||
@@ -244,6 +250,12 @@ fn convert_nodes<'a>(
|
||||
|
||||
(entries, ast_node_members, token_kinds)
|
||||
}
|
||||
|
||||
/// Creates a dbscheme table entry representing the parent relation for AST nodes.
|
||||
///
|
||||
/// # Arguments
|
||||
/// - `name` - the name of both the table to create and the node parent type.
|
||||
/// - `ast_node_name` - the name of the node child type.
|
||||
fn create_ast_node_parent_table<'a>(name: &'a str, ast_node_name: &'a str) -> dbscheme::Table<'a> {
|
||||
dbscheme::Table {
|
||||
name,
|
||||
|
||||
@@ -249,7 +249,7 @@ impl<'a> fmt::Display for FormalParameter<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
/// Generates a QL library by writing the given `classes` to the `file`.
|
||||
/// Generates a QL library by writing the given `elements` to the `file`.
|
||||
pub fn write<'a>(file: &mut dyn std::io::Write, elements: &'a [TopLevel]) -> std::io::Result<()> {
|
||||
for element in elements {
|
||||
write!(file, "{}\n\n", &element)?;
|
||||
|
||||
Reference in New Issue
Block a user