Skip to main content

SchemaProvider

Struct SchemaProvider 

Source
pub struct SchemaProvider { /* private fields */ }
Expand description

Schema 提供者

管理配置 Schema,提供配置项元数据查询

Implementations§

Source§

impl SchemaProvider

Source

pub fn new() -> Self

创建新的 Schema 提供者(使用空 Schema)

Source

pub async fn load() -> Result<Self>

从 URL 加载 Schema

如果加载失败,使用内置的备用 Schema

Source

pub async fn load_with_workspace(workspace_path: &Path) -> Result<Self>

从 URL 加载 Schema 并合并本地 Schema 文件

§Arguments
  • workspace_path - 工作空间路径,用于查找本地 Schema 文件
§Returns

返回合并了远程和本地 Schema 的 SchemaProvider

§本地 Schema 文件

支持以下文件(按优先级):

  1. target/*/summer-lsp.schema.json - build.rs 生成的 Schema 文件
  2. .summer-lsp.schema.json - 手动生成的 Schema 文件(兼容旧版本)
  3. 扫描 Rust 代码生成 Schema(fallback)
Source

pub fn has_plugin(&self, prefix: &str) -> bool

获取插件 Schema

检查指定的配置前缀是否在 Schema 中定义

Source

pub fn get_all_prefixes(&self) -> Vec<String>

获取所有配置前缀

返回所有已注册插件的配置前缀列表

Source

pub fn get_plugin_schema(&self, prefix: &str) -> Option<&Value>

获取插件的 Schema

返回指定插件的 JSON Schema

Source

pub fn has_property(&self, prefix: &str, property: &str) -> bool

检查配置属性是否存在

查询指定插件的指定属性是否在 Schema 中定义

Source

pub fn get_plugin(&self, prefix: &str) -> Option<PluginSchema>

获取插件的结构化 Schema

将 JSON Schema 解析为 PluginSchema 结构

Source§

impl SchemaProvider

Source

pub fn from_schema(schema: ConfigSchema) -> Self

从给定的 ConfigSchema 创建 SchemaProvider(用于测试)

这个方法主要用于属性测试,允许使用自定义的 Schema 创建提供者

Trait Implementations§

Source§

impl Clone for SchemaProvider

Source§

fn clone(&self) -> SchemaProvider

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Default for SchemaProvider

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more