Move Swift language into its own module

This commit is contained in:
Asger F
2026-05-07 09:47:27 +02:00
parent 4e12a8c8d2
commit cd457a7d6b
2 changed files with 27 additions and 20 deletions

View File

@@ -3,7 +3,9 @@ use std::path::PathBuf;
use codeql_extractor::extractor::simple;
use codeql_extractor::trap;
use yeast::{rule, DesugaringConfig};
#[path = "languages/swift/swift.rs"]
mod swift;
#[derive(Args)]
pub struct Options {
@@ -20,31 +22,13 @@ pub struct Options {
file_list: PathBuf,
}
fn swift_desugaring_rules() -> Vec<yeast::Rule> {
vec![
rule!(
(additive_expression)
=>
(simple_identifier "blah")
),
]
}
pub fn run(options: Options) -> std::io::Result<()> {
codeql_extractor::extractor::set_tracing_level("ql");
let swift_desugar = DesugaringConfig::new(swift_desugaring_rules());
let extractor = simple::Extractor {
prefix: "unified".to_string(),
languages: vec![
simple::LanguageSpec {
prefix: "swift",
ts_language: tree_sitter_swift::LANGUAGE.into(),
node_types: tree_sitter_swift::NODE_TYPES,
file_globs: vec!["*.swift".into(), "*.swiftinterface".into()],
desugar: Some(swift_desugar),
},
swift::language_spec(),
],
trap_dir: options.output_dir,
trap_compression: trap::Compression::from_env("CODEQL_QL_TRAP_COMPRESSION"),

View File

@@ -0,0 +1,23 @@
use codeql_extractor::extractor::simple;
use yeast::{rule, DesugaringConfig};
fn desugaring_rules() -> Vec<yeast::Rule> {
vec![
rule!(
(additive_expression)
=>
(simple_identifier "blah")
),
]
}
pub fn language_spec() -> simple::LanguageSpec {
let desugar = DesugaringConfig::new(desugaring_rules());
simple::LanguageSpec {
prefix: "swift",
ts_language: tree_sitter_swift::LANGUAGE.into(),
node_types: tree_sitter_swift::NODE_TYPES,
file_globs: vec!["*.swift".into(), "*.swiftinterface".into()],
desugar: Some(desugar),
}
}