mirror of
https://github.com/github/codeql.git
synced 2026-05-14 11:19:27 +02:00
Move Swift language into its own module
This commit is contained in:
@@ -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"),
|
||||
|
||||
23
unified/extractor/src/languages/swift/swift.rs
Normal file
23
unified/extractor/src/languages/swift/swift.rs
Normal 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),
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user