-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
422 additions
and
148 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
pub mod javascript; | ||
pub mod language; | ||
pub mod python; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
use std::path::Path; | ||
|
||
use anyhow::Result; | ||
|
||
use ruff_python_parser::{lexer::lex, Mode}; | ||
|
||
use async_trait::async_trait; | ||
|
||
use super::language::{Language, Location}; | ||
|
||
/// List of scanned extensions | ||
const EXTENSIONS: [&str; 1] = ["py"]; | ||
|
||
pub struct Python; | ||
|
||
#[async_trait(?Send)] | ||
impl Language for Python { | ||
async fn check_file(path: &Path) -> Result<Option<Vec<(String, Location)>>> { | ||
let ext = path.extension().unwrap_or_default(); | ||
|
||
if !EXTENSIONS.contains(&ext.to_str().unwrap()) { | ||
return Ok(None); | ||
} | ||
|
||
let contents = std::fs::read_to_string(path)?; | ||
|
||
let lexer = lex(&contents, Mode::Module); | ||
|
||
let regexes = vec![]; | ||
|
||
for token in lexer { | ||
// TODO: support regexes | ||
println!("{:?}", token); | ||
} | ||
|
||
Ok(Some(regexes)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters