mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-01 22:31:47 +00:00
Pull in RustPython parser (#6099)
This commit is contained in:
parent
86539c1fc5
commit
40f54375cb
779 changed files with 108400 additions and 2078 deletions
33
crates/ruff_text_size/src/schemars_impls.rs
Normal file
33
crates/ruff_text_size/src/schemars_impls.rs
Normal file
|
@ -0,0 +1,33 @@
|
|||
//! This module implements the [`JsonSchema`] trait from the `schemars` crate for
|
||||
//! [`TextSize`] and [`TextRange`] if the `schemars` feature is enabled. This trait
|
||||
//! exposes meta-information on how a given type is serialized and deserialized
|
||||
//! using `serde`, and is currently used to generate autocomplete information
|
||||
//! for the `rome.json` configuration file and TypeScript types for the node.js
|
||||
//! bindings to the Workspace API
|
||||
|
||||
use crate::{TextRange, TextSize};
|
||||
use schemars::{gen::SchemaGenerator, schema::Schema, JsonSchema};
|
||||
|
||||
impl JsonSchema for TextSize {
|
||||
fn schema_name() -> String {
|
||||
String::from("TextSize")
|
||||
}
|
||||
|
||||
fn json_schema(gen: &mut SchemaGenerator) -> Schema {
|
||||
// TextSize is represented as a raw u32, see serde_impls.rs for the
|
||||
// actual implementation
|
||||
<u32>::json_schema(gen)
|
||||
}
|
||||
}
|
||||
|
||||
impl JsonSchema for TextRange {
|
||||
fn schema_name() -> String {
|
||||
String::from("TextRange")
|
||||
}
|
||||
|
||||
fn json_schema(gen: &mut SchemaGenerator) -> Schema {
|
||||
// TextSize is represented as (TextSize, TextSize), see serde_impls.rs
|
||||
// for the actual implementation
|
||||
<(TextSize, TextSize)>::json_schema(gen)
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue