use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "PascalCase")]
pub enum ClassificationKind {
PlainText,
Comment,
Punctuation,
Directive,
Literal,
StringLiteral,
Type,
Identifier,
Column,
Table,
Database,
ScalarFunction,
AggregateFunction,
Keyword,
Operator,
Variable,
Parameter,
CommandKeyword,
QueryOperator,
ScalarOperator,
MaterializedViewFunction,
Plugin,
Option,
ClientDirective,
QueryParameter,
Cluster,
}
impl ClassificationKind {
#[allow(dead_code)]
#[must_use]
pub fn parse(s: &str) -> Self {
match s {
"Comment" => Self::Comment,
"Punctuation" => Self::Punctuation,
"Directive" => Self::Directive,
"Literal" => Self::Literal,
"StringLiteral" => Self::StringLiteral,
"Type" => Self::Type,
"Identifier" => Self::Identifier,
"Column" => Self::Column,
"Table" => Self::Table,
"Database" => Self::Database,
"ScalarFunction" => Self::ScalarFunction,
"AggregateFunction" => Self::AggregateFunction,
"Keyword" => Self::Keyword,
"Operator" => Self::Operator,
"Variable" => Self::Variable,
"Parameter" => Self::Parameter,
"CommandKeyword" => Self::CommandKeyword,
"QueryOperator" => Self::QueryOperator,
"ScalarOperator" => Self::ScalarOperator,
"MaterializedViewFunction" => Self::MaterializedViewFunction,
"Plugin" => Self::Plugin,
"Option" => Self::Option,
"ClientDirective" => Self::ClientDirective,
"QueryParameter" => Self::QueryParameter,
"Cluster" => Self::Cluster,
_ => Self::PlainText,
}
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ClassifiedSpan {
pub start: usize,
pub length: usize,
pub kind: ClassificationKind,
}
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct ClassificationResult {
pub spans: Vec<ClassifiedSpan>,
}