use super::node::NodeId;
use super::token::Span;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum SyntaxKind {
TypeSpecScript,
ImportStatement,
Identifier,
MemberExpression,
StringLiteral,
NumericLiteral,
BooleanLiteral,
ModelStatement,
ModelExpression,
ModelProperty,
ModelSpreadProperty,
ScalarStatement,
ScalarConstructor,
InterfaceStatement,
UnionStatement,
UnionVariant,
EnumStatement,
EnumMember,
EnumSpreadMember,
NamespaceStatement,
UsingStatement,
OperationStatement,
OperationSignatureDeclaration,
OperationSignatureReference,
AliasStatement,
ConstStatement,
DecoratorDeclarationStatement,
DecoratorExpression,
AugmentDecoratorStatement,
ArrayExpression,
TupleExpression,
UnionExpression,
IntersectionExpression,
TypeReference,
CallExpression,
ValueOfExpression,
TypeOfExpression,
StringTemplateExpression,
StringTemplateHead,
StringTemplateMiddle,
StringTemplateTail,
StringTemplateSpan,
ObjectLiteral,
ObjectLiteralProperty,
ObjectLiteralSpreadProperty,
ArrayLiteral,
ExternKeyword,
InternalKeyword,
VoidKeyword,
NeverKeyword,
UnknownKeyword,
TemplateParameterDeclaration,
TemplateArgument,
FunctionDeclarationStatement,
FunctionParameter,
FunctionTypeExpression,
DirectiveExpression,
Doc,
DocText,
EmptyStatement,
InvalidStatement,
LineComment,
BlockComment,
}
#[derive(Debug, Clone)]
pub struct Identifier {
pub id: NodeId,
pub span: Span,
pub value: String,
}
#[derive(Debug, Clone)]
pub struct MemberExpression {
pub id: NodeId,
pub span: Span,
pub object: NodeId, pub property: NodeId, pub selector: MemberSelector,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum MemberSelector {
Dot, DoubleColon, }
#[derive(Debug, Clone)]
pub struct StringLiteral {
pub id: NodeId,
pub span: Span,
pub value: String,
}
#[derive(Debug, Clone)]
pub struct NumericLiteral {
pub id: NodeId,
pub span: Span,
pub value: f64,
pub value_as_string: String,
}
#[derive(Debug, Clone)]
pub struct BooleanLiteral {
pub id: NodeId,
pub span: Span,
pub value: bool,
}
#[derive(Debug, Clone)]
pub struct ArrayExpression {
pub id: NodeId,
pub span: Span,
pub element_type: NodeId,
}
#[derive(Debug, Clone)]
pub struct TupleExpression {
pub id: NodeId,
pub span: Span,
pub values: Vec<NodeId>,
}
#[derive(Debug, Clone)]
pub struct UnionExpression {
pub id: NodeId,
pub span: Span,
pub options: Vec<NodeId>,
}
#[derive(Debug, Clone)]
pub struct IntersectionExpression {
pub id: NodeId,
pub span: Span,
pub options: Vec<NodeId>,
}
#[derive(Debug, Clone)]
pub struct TypeReference {
pub id: NodeId,
pub span: Span,
pub name: NodeId, pub arguments: Vec<NodeId>,
}
#[derive(Debug, Clone)]
pub struct CallExpression {
pub id: NodeId,
pub span: Span,
pub target: NodeId, pub arguments: Vec<NodeId>,
}
#[derive(Debug, Clone)]
pub struct ValueOfExpression {
pub id: NodeId,
pub span: Span,
pub target: NodeId,
}
#[derive(Debug, Clone)]
pub struct TypeOfExpression {
pub id: NodeId,
pub span: Span,
pub target: NodeId,
}
#[derive(Debug, Clone)]
pub struct StringTemplateExpression {
pub id: NodeId,
pub span: Span,
pub head: NodeId,
pub spans: Vec<NodeId>,
}
#[derive(Debug, Clone)]
pub struct StringTemplateHead {
pub id: NodeId,
pub span: Span,
pub value: String,
}
#[derive(Debug, Clone)]
pub struct StringTemplateMiddle {
pub id: NodeId,
pub span: Span,
pub value: String,
}
#[derive(Debug, Clone)]
pub struct StringTemplateTail {
pub id: NodeId,
pub span: Span,
pub value: String,
}
#[derive(Debug, Clone)]
pub struct StringTemplateSpan {
pub id: NodeId,
pub span: Span,
pub expression: NodeId,
pub literal: NodeId, }
#[derive(Debug, Clone)]
pub struct ObjectLiteral {
pub id: NodeId,
pub span: Span,
pub properties: Vec<NodeId>,
}
#[derive(Debug, Clone)]
pub struct ObjectLiteralProperty {
pub id: NodeId,
pub span: Span,
pub key: NodeId,
pub value: NodeId,
}
#[derive(Debug, Clone)]
pub struct ObjectLiteralSpreadProperty {
pub id: NodeId,
pub span: Span,
pub target: NodeId,
}
#[derive(Debug, Clone)]
pub struct ArrayLiteral {
pub id: NodeId,
pub span: Span,
pub values: Vec<NodeId>,
}
#[derive(Debug, Clone)]
pub struct ExternKeyword {
pub id: NodeId,
pub span: Span,
}
#[derive(Debug, Clone)]
pub struct InternalKeyword {
pub id: NodeId,
pub span: Span,
}
#[derive(Debug, Clone)]
pub struct VoidKeyword {
pub id: NodeId,
pub span: Span,
}
#[derive(Debug, Clone)]
pub struct NeverKeyword {
pub id: NodeId,
pub span: Span,
}
#[derive(Debug, Clone)]
pub struct UnknownKeyword {
pub id: NodeId,
pub span: Span,
}
#[derive(Debug, Clone)]
pub struct ModelDeclaration {
pub id: NodeId,
pub span: Span,
pub name: NodeId,
pub properties: Vec<NodeId>,
pub extends: Option<NodeId>, pub is: Option<NodeId>, pub decorators: Vec<NodeId>,
pub template_parameters: Vec<NodeId>,
pub body_range: Span,
pub modifiers: Vec<NodeId>,
}
#[derive(Debug, Clone)]
pub struct ModelExpression {
pub id: NodeId,
pub span: Span,
pub properties: Vec<NodeId>,
pub body_range: Span,
}
#[derive(Debug, Clone)]
pub struct ModelProperty {
pub id: NodeId,
pub span: Span,
pub name: NodeId,
pub value: NodeId, pub decorators: Vec<NodeId>,
pub optional: bool,
pub default: Option<NodeId>, }
#[derive(Debug, Clone)]
pub struct ModelSpreadProperty {
pub id: NodeId,
pub span: Span,
pub target: NodeId,
}
#[derive(Debug, Clone)]
pub struct ScalarDeclaration {
pub id: NodeId,
pub span: Span,
pub name: NodeId,
pub extends: Option<NodeId>,
pub decorators: Vec<NodeId>,
pub constructors: Vec<NodeId>,
pub template_parameters: Vec<NodeId>,
pub body_range: Span,
pub modifiers: Vec<NodeId>,
}
#[derive(Debug, Clone)]
pub struct ScalarConstructor {
pub id: NodeId,
pub span: Span,
pub name: NodeId,
pub parameters: Vec<NodeId>,
}
#[derive(Debug, Clone)]
pub struct InterfaceDeclaration {
pub id: NodeId,
pub span: Span,
pub name: NodeId,
pub operations: Vec<NodeId>,
pub extends: Vec<NodeId>,
pub decorators: Vec<NodeId>,
pub template_parameters: Vec<NodeId>,
pub body_range: Span,
pub modifiers: Vec<NodeId>,
}
#[derive(Debug, Clone)]
pub struct UnionDeclaration {
pub id: NodeId,
pub span: Span,
pub name: NodeId,
pub variants: Vec<NodeId>,
pub decorators: Vec<NodeId>,
pub template_parameters: Vec<NodeId>,
pub modifiers: Vec<NodeId>,
}
#[derive(Debug, Clone)]
pub struct UnionVariant {
pub id: NodeId,
pub span: Span,
pub name: Option<NodeId>,
pub value: NodeId,
pub decorators: Vec<NodeId>,
}
#[derive(Debug, Clone)]
pub struct EnumDeclaration {
pub id: NodeId,
pub span: Span,
pub name: NodeId,
pub members: Vec<NodeId>,
pub decorators: Vec<NodeId>,
pub modifiers: Vec<NodeId>,
}
#[derive(Debug, Clone)]
pub struct EnumMember {
pub id: NodeId,
pub span: Span,
pub name: NodeId,
pub value: Option<NodeId>, pub decorators: Vec<NodeId>,
}
#[derive(Debug, Clone)]
pub struct EnumSpreadMember {
pub id: NodeId,
pub span: Span,
pub target: NodeId,
}
#[derive(Debug, Clone)]
pub struct NamespaceDeclaration {
pub id: NodeId,
pub span: Span,
pub name: NodeId,
pub statements: Vec<NodeId>,
pub decorators: Vec<NodeId>,
pub modifiers: Vec<NodeId>,
}
#[derive(Debug, Clone)]
pub struct UsingDeclaration {
pub id: NodeId,
pub span: Span,
pub name: NodeId, }
#[derive(Debug, Clone)]
pub struct OperationDeclaration {
pub id: NodeId,
pub span: Span,
pub name: NodeId,
pub signature: NodeId, pub decorators: Vec<NodeId>,
pub template_parameters: Vec<NodeId>,
pub modifiers: Vec<NodeId>,
}
#[derive(Debug, Clone)]
pub struct OperationSignatureDeclaration {
pub id: NodeId,
pub span: Span,
pub parameters: NodeId, pub return_type: NodeId,
}
#[derive(Debug, Clone)]
pub struct OperationSignatureReference {
pub id: NodeId,
pub span: Span,
pub base_operation: NodeId, }
#[derive(Debug, Clone)]
pub struct AliasStatement {
pub id: NodeId,
pub span: Span,
pub name: NodeId,
pub value: NodeId,
pub template_parameters: Vec<NodeId>,
pub modifiers: Vec<NodeId>,
}
#[derive(Debug, Clone)]
pub struct ConstStatement {
pub id: NodeId,
pub span: Span,
pub name: NodeId,
pub value: NodeId,
pub type_annotation: Option<NodeId>,
pub modifiers: Vec<NodeId>,
}
#[derive(Debug, Clone)]
pub struct DecoratorDeclaration {
pub id: NodeId,
pub span: Span,
pub name: NodeId,
pub target: NodeId, pub parameters: Vec<NodeId>, pub modifiers: Vec<NodeId>,
}
#[derive(Debug, Clone)]
pub struct DecoratorExpression {
pub id: NodeId,
pub span: Span,
pub target: NodeId, pub arguments: Vec<NodeId>,
}
#[derive(Debug, Clone)]
pub struct AugmentDecoratorStatement {
pub id: NodeId,
pub span: Span,
pub target: NodeId, pub target_type: NodeId, pub arguments: Vec<NodeId>,
}
#[derive(Debug, Clone)]
pub struct FunctionDeclaration {
pub id: NodeId,
pub span: Span,
pub name: NodeId,
pub parameters: Vec<NodeId>,
pub return_type: Option<NodeId>,
pub modifiers: Vec<NodeId>,
}
#[derive(Debug, Clone)]
pub struct FunctionParameter {
pub id: NodeId,
pub span: Span,
pub name: NodeId,
pub type_annotation: Option<NodeId>,
pub optional: bool,
pub rest: bool,
}
#[derive(Debug, Clone)]
pub struct FunctionTypeExpression {
pub id: NodeId,
pub span: Span,
pub parameters: Vec<NodeId>,
pub return_type: Option<NodeId>,
}
#[derive(Debug, Clone)]
pub struct TemplateParameterDeclaration {
pub id: NodeId,
pub span: Span,
pub name: NodeId,
pub constraint: Option<NodeId>,
pub default: Option<NodeId>,
}
#[derive(Debug, Clone)]
pub struct TemplateArgument {
pub id: NodeId,
pub span: Span,
pub name: Option<NodeId>, pub argument: NodeId,
}
#[derive(Debug, Clone)]
pub struct ImportStatement {
pub id: NodeId,
pub span: Span,
pub path: NodeId, }
#[derive(Debug, Clone)]
pub struct DirectiveExpression {
pub id: NodeId,
pub span: Span,
pub target: NodeId, pub arguments: Vec<NodeId>,
}
#[derive(Debug, Clone)]
pub struct Doc {
pub id: NodeId,
pub span: Span,
pub content: Vec<NodeId>,
pub tags: Vec<NodeId>,
}
#[derive(Debug, Clone)]
pub struct DocText {
pub id: NodeId,
pub span: Span,
pub text: String,
}
#[derive(Debug, Clone)]
pub struct LineComment {
pub id: NodeId,
pub span: Span,
}
#[derive(Debug, Clone)]
pub struct BlockComment {
pub id: NodeId,
pub span: Span,
pub parsed_as_docs: bool,
}
#[derive(Debug, Clone)]
pub struct EmptyStatement {
pub id: NodeId,
pub span: Span,
}
#[derive(Debug, Clone)]
pub struct InvalidStatement {
pub id: NodeId,
pub span: Span,
pub decorators: Vec<NodeId>,
}
#[derive(Debug, Clone)]
pub struct TypeSpecScript {
pub id: NodeId,
pub span: Span,
pub statements: Vec<NodeId>,
pub comments: Vec<NodeId>,
pub parse_diagnostics: Vec<NodeId>,
}
#[derive(Debug, Clone)]
pub struct Modifier {
pub id: NodeId,
pub span: Span,
pub kind: ModifierKind,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum ModifierKind {
Extern,
Internal,
}