pub(super) const MAX_COMPLETION_ITEMS: usize = 100;
pub(super) const MAX_BRANCH_COUNT: usize = 20;
pub(super) const MAX_DESCRIPTION_LEN: usize = 200;
pub(super) const MAX_ENUM_LABEL_LEN: usize = 50;
#[cfg(test)]
pub(super) mod test_fixtures {
use tower_lsp::lsp_types::{CompletionItem, Position};
use crate::schema::{JsonSchema, SchemaType};
pub fn pos(line: u32, character: u32) -> Position {
Position::new(line, character)
}
pub fn labels(items: &[CompletionItem]) -> Vec<&str> {
items.iter().map(|i| i.label.as_str()).collect()
}
pub fn string_schema() -> JsonSchema {
JsonSchema {
schema_type: Some(SchemaType::Single("string".to_string())),
..JsonSchema::default()
}
}
pub fn integer_schema() -> JsonSchema {
JsonSchema {
schema_type: Some(SchemaType::Single("integer".to_string())),
..JsonSchema::default()
}
}
pub fn boolean_schema() -> JsonSchema {
JsonSchema {
schema_type: Some(SchemaType::Single("boolean".to_string())),
..JsonSchema::default()
}
}
pub fn object_schema(props: Vec<(&str, JsonSchema)>) -> JsonSchema {
JsonSchema {
schema_type: Some(SchemaType::Single("object".to_string())),
properties: Some(props.into_iter().map(|(k, v)| (k.to_string(), v)).collect()),
..JsonSchema::default()
}
}
}