Skip to main content

ferroui_designer_language/
lib.rs

1//! Schema-aware XAML text editing, navigation, refactoring and stdio LSP.
2mod binding;
3mod design_support;
4mod formatting;
5mod line_index;
6pub mod lsp;
7mod references;
8mod schema;
9mod service;
10pub use formatting::FormattingOptions;
11pub use line_index::{LineIndex, Position, Range, TextChange, TextEdit};
12pub use references::{
13    identifier as is_xaml_identifier, name_occurrences, rewrite_names, scope_of as name_scope,
14    NameOccurrence,
15};
16pub use schema::{ExtensionInfo, PropertyInfo, Schema, TypeInfo};
17pub use service::*;
18use std::fmt;
19#[derive(Clone, Debug, PartialEq, Eq)]
20pub struct LanguageError(pub String);
21pub type Result<T> = std::result::Result<T, LanguageError>;
22impl fmt::Display for LanguageError {
23    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
24        f.write_str(&self.0)
25    }
26}
27impl std::error::Error for LanguageError {}
28impl From<ferroui_designer_core::DesignerError> for LanguageError {
29    fn from(e: ferroui_designer_core::DesignerError) -> Self {
30        Self(e.to_string())
31    }
32}
33impl From<ferroui_designer_project::ProjectError> for LanguageError {
34    fn from(e: ferroui_designer_project::ProjectError) -> Self {
35        Self(e.to_string())
36    }
37}
38fn require(value: bool, message: impl Into<String>) -> Result<()> {
39    if value {
40        Ok(())
41    } else {
42        Err(LanguageError(message.into()))
43    }
44}
45#[cfg(test)]
46mod component_schema_tests;
47#[cfg(test)]
48mod design_time_tests;
49#[cfg(test)]
50mod tests;
51#[cfg(test)]
52mod theme_resource_tests;