Skip to content

Commit 1e6ff7e

Browse files
committed
Move Swift language into its own module
1 parent 0725b10 commit 1e6ff7e

2 files changed

Lines changed: 27 additions & 20 deletions

File tree

unified/extractor/src/extractor.rs

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ use std::path::PathBuf;
33

44
use codeql_extractor::extractor::simple;
55
use codeql_extractor::trap;
6-
use yeast::{rule, DesugaringConfig};
6+
7+
#[path = "languages/swift/swift.rs"]
8+
mod swift;
79

810
#[derive(Args)]
911
pub struct Options {
@@ -20,31 +22,13 @@ pub struct Options {
2022
file_list: PathBuf,
2123
}
2224

23-
fn swift_desugaring_rules() -> Vec<yeast::Rule> {
24-
vec![
25-
rule!(
26-
(additive_expression)
27-
=>
28-
(simple_identifier "blah")
29-
),
30-
]
31-
}
32-
3325
pub fn run(options: Options) -> std::io::Result<()> {
3426
codeql_extractor::extractor::set_tracing_level("ql");
3527

36-
let swift_desugar = DesugaringConfig::new(swift_desugaring_rules());
37-
3828
let extractor = simple::Extractor {
3929
prefix: "unified".to_string(),
4030
languages: vec![
41-
simple::LanguageSpec {
42-
prefix: "swift",
43-
ts_language: tree_sitter_swift::LANGUAGE.into(),
44-
node_types: tree_sitter_swift::NODE_TYPES,
45-
file_globs: vec!["*.swift".into(), "*.swiftinterface".into()],
46-
desugar: Some(swift_desugar),
47-
},
31+
swift::language_spec(),
4832
],
4933
trap_dir: options.output_dir,
5034
trap_compression: trap::Compression::from_env("CODEQL_QL_TRAP_COMPRESSION"),
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
use codeql_extractor::extractor::simple;
2+
use yeast::{rule, DesugaringConfig};
3+
4+
fn desugaring_rules() -> Vec<yeast::Rule> {
5+
vec![
6+
rule!(
7+
(additive_expression)
8+
=>
9+
(simple_identifier "blah")
10+
),
11+
]
12+
}
13+
14+
pub fn language_spec() -> simple::LanguageSpec {
15+
let desugar = DesugaringConfig::new(desugaring_rules());
16+
simple::LanguageSpec {
17+
prefix: "swift",
18+
ts_language: tree_sitter_swift::LANGUAGE.into(),
19+
node_types: tree_sitter_swift::NODE_TYPES,
20+
file_globs: vec!["*.swift".into(), "*.swiftinterface".into()],
21+
desugar: Some(desugar),
22+
}
23+
}

0 commit comments

Comments
 (0)