mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-28 04:45:01 +00:00
Rename ruff
crate to ruff_linter
(#7529)
This commit is contained in:
parent
dcbd8eacd8
commit
5849a75223
4397 changed files with 93921 additions and 93915 deletions
31
crates/ruff_linter/src/source_kind.rs
Normal file
31
crates/ruff_linter/src/source_kind.rs
Normal file
|
@ -0,0 +1,31 @@
|
|||
use ruff_diagnostics::SourceMap;
|
||||
use ruff_notebook::Notebook;
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, is_macro::Is)]
|
||||
pub enum SourceKind {
|
||||
/// The source contains Python source code.
|
||||
Python(String),
|
||||
/// The source contains a Jupyter notebook.
|
||||
IpyNotebook(Notebook),
|
||||
}
|
||||
|
||||
impl SourceKind {
|
||||
#[must_use]
|
||||
pub(crate) fn updated(&self, new_source: String, source_map: &SourceMap) -> Self {
|
||||
match self {
|
||||
SourceKind::IpyNotebook(notebook) => {
|
||||
let mut cloned = notebook.clone();
|
||||
cloned.update(source_map, new_source);
|
||||
SourceKind::IpyNotebook(cloned)
|
||||
}
|
||||
SourceKind::Python(_) => SourceKind::Python(new_source),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn source_code(&self) -> &str {
|
||||
match self {
|
||||
SourceKind::Python(source) => source,
|
||||
SourceKind::IpyNotebook(notebook) => notebook.source_code(),
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue