Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
jackdotink authored Oct 8, 2024
2 parents 7914ecb + 81a9fc3 commit 9cc3534
Show file tree
Hide file tree
Showing 12 changed files with 523 additions and 183 deletions.
6 changes: 3 additions & 3 deletions full-moon/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ keywords = ["lua", "parser", "lua51", "lua52", "luau"]
edition = "2021"

[package.metadata.docs.rs]
# Build Locally: RUSTDOCFLAGS="--cfg doc_cfg" cargo +nightly doc --features luau,lua52,lua53,lua54,luajit --no-deps --open
# Build Locally: RUSTDOCFLAGS="--cfg docsrs" cargo +nightly doc --features luau,lua52,lua53,lua54,luajit --no-deps --open
features = ["luau", "lua52", "lua53", "lua54", "luajit"]
rustdoc-args = ["--cfg", "doc_cfg"]
rustdoc-args = ["--cfg", "docsrs"]

[features]
default = ["serde"]
Expand All @@ -28,7 +28,7 @@ no-source-tests = []
[dependencies]
bytecount = "0.6"
cfg-if = "1.0"
derive_more = "0.99"
derive_more = { version = "1.0", features = ["display"] }
full_moon_derive = { path = "../full-moon-derive", version = "=0.11.0" }
paste = "1.0"
serde = { version = "1.0", features = ["derive", "rc"], optional = true }
Expand Down
4 changes: 2 additions & 2 deletions full-moon/src/ast/lua52.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use serde::{Deserialize, Serialize};
/// A goto statement, such as `goto label`.
#[derive(Clone, Debug, Display, PartialEq, Eq, Node, Visit)]
#[cfg_attr(feature = "serde", derive(Deserialize, Serialize))]
#[display(fmt = "{goto_token}{label_name}")]
#[display("{goto_token}{label_name}")]
pub struct Goto {
pub(crate) goto_token: TokenReference,
pub(crate) label_name: TokenReference,
Expand Down Expand Up @@ -50,7 +50,7 @@ impl Goto {
/// A label, such as `::label::`.
#[derive(Clone, Debug, Display, PartialEq, Eq, Node, Visit)]
#[cfg_attr(feature = "serde", derive(Deserialize, Serialize))]
#[display(fmt = "{left_colons}{name}{right_colons}")]
#[display("{left_colons}{name}{right_colons}")]
pub struct Label {
pub(crate) left_colons: TokenReference,
pub(crate) name: TokenReference,
Expand Down
2 changes: 1 addition & 1 deletion full-moon/src/ast/lua54.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use serde::{Deserialize, Serialize};
/// An attribute on a local variable, `<const>` in `local x <const>`
#[derive(Clone, Debug, Display, PartialEq, Eq, Node, Visit)]
#[cfg_attr(feature = "serde", derive(Deserialize, Serialize))]
#[display(fmt = "{}{}{}", "brackets.tokens().0", "name", "brackets.tokens().1")]
#[display("{}{}{}", brackets.tokens().0, name, brackets.tokens().1)]
pub struct Attribute {
#[node(full_range)]
#[visit(contains = "name")]
Expand Down
128 changes: 64 additions & 64 deletions full-moon/src/ast/luau.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,23 @@ pub enum TypeInfo {
},

/// A standalone type, such as `string` or `Foo`.
#[display(fmt = "{_0}")]
#[display("{_0}")]
Basic(TokenReference),

/// A singleton string type, such as `"hello"`
#[display(fmt = "{_0}")]
#[display("{_0}")]
String(TokenReference),

/// A singleton boolean type, such as `true`
#[display(fmt = "{_0}")]
#[display("{_0}")]
Boolean(TokenReference),

/// A callback type, such as `(string, number) => boolean`.
#[display(
fmt = "{}{}{arguments}{}{arrow}{return_type}",
"display_option(generics)",
"parentheses.tokens().0",
"parentheses.tokens().1"
"{}{}{arguments}{}{arrow}{return_type}",
display_option(generics),
parentheses.tokens().0,
parentheses.tokens().1
)]
Callback {
/// Optional generics provided for the arguments, such as in `<T>(T) -> string`
Expand All @@ -65,11 +65,11 @@ pub enum TypeInfo {

/// A type using generics, such as `map<number, string>`.
#[display(
fmt = "{}{}{}{}",
"base",
"arrows.tokens().0",
"generics",
"arrows.tokens().1"
"{}{}{}{}",
base,
arrows.tokens().0,
generics,
arrows.tokens().1
)]
Generic {
/// The type that has generics: `map`.
Expand All @@ -82,7 +82,7 @@ pub enum TypeInfo {

/// A generic pack: `T...`.
/// Note, these are only available as return types, when annotating a vararg (`...`) in a function parameter, or as a generic type argument.
#[display(fmt = "{name}{ellipsis}")]
#[display("{name}{ellipsis}")]
GenericPack {
/// The name of the type that is generic: `T`.
name: TokenReference,
Expand All @@ -91,11 +91,11 @@ pub enum TypeInfo {
},

/// An intersection type, such as `string & number`.
#[display(fmt = "{_0}")]
#[display("{_0}")]
Intersection(TypeIntersection),

/// A type coming from a module, such as `module.Foo`
#[display(fmt = "{module}{punctuation}{type_info}")]
#[display("{module}{punctuation}{type_info}")]
Module {
/// The module the type is coming from: `module`.
module: TokenReference,
Expand All @@ -106,7 +106,7 @@ pub enum TypeInfo {
},

/// An optional type, such as `string?`.
#[display(fmt = "{base}{question_mark}")]
#[display("{base}{question_mark}")]
Optional {
/// The type that is optional: `string`.
base: Box<TypeInfo>,
Expand All @@ -115,7 +115,7 @@ pub enum TypeInfo {
},

/// A type annotating the structure of a table: { foo: number, bar: string }
#[display(fmt = "{}{}{}", "braces.tokens().0", "fields", "braces.tokens().1")]
#[display("{}{}{}", braces.tokens().0, fields, braces.tokens().1)]
Table {
/// The braces (`{}`) containing the fields.
braces: ContainedSpan,
Expand All @@ -125,11 +125,11 @@ pub enum TypeInfo {

/// A type in the form of `typeof(foo)`.
#[display(
fmt = "{}{}{}{}",
"typeof_token",
"parentheses.tokens().0",
"inner",
"parentheses.tokens().1"
"{}{}{}{}",
typeof_token,
parentheses.tokens().0,
inner,
parentheses.tokens().1
)]
Typeof {
/// The token `typeof`.
Expand All @@ -142,10 +142,10 @@ pub enum TypeInfo {

/// A tuple expression: `(string, number)`.
#[display(
fmt = "{}{}{}",
"parentheses.tokens().0",
"types",
"parentheses.tokens().1"
"{}{}{}",
parentheses.tokens().0,
types,
parentheses.tokens().1
)]
Tuple {
/// The parentheses used to contain the types
Expand All @@ -155,11 +155,11 @@ pub enum TypeInfo {
},

/// A union type, such as `string | number`.
#[display(fmt = "{_0}")]
#[display("{_0}")]
Union(TypeUnion),

/// A variadic type: `...number`.
#[display(fmt = "{ellipsis}{type_info}")]
#[display("{ellipsis}{type_info}")]
Variadic {
/// The ellipsis: `...`.
ellipsis: TokenReference,
Expand All @@ -168,7 +168,7 @@ pub enum TypeInfo {
},

/// A variadic type pack: `...T` in `Function<...T>`
#[display(fmt = "{ellipsis}{name}")]
#[display("{ellipsis}{name}")]
VariadicPack {
/// The ellipsis: `...`
ellipsis: TokenReference,
Expand All @@ -180,7 +180,7 @@ pub enum TypeInfo {
/// A union type, such as `string | number`.
#[derive(Clone, Debug, Display, PartialEq, Node)]
#[cfg_attr(feature = "serde", derive(Deserialize, Serialize))]
#[display(fmt = "{}{types}", "display_option(leading)")]
#[display("{}{types}", display_option(leading))]
pub struct TypeUnion {
pub(crate) leading: Option<TokenReference>,
pub(crate) types: Punctuated<TypeInfo>,
Expand Down Expand Up @@ -216,7 +216,7 @@ impl TypeUnion {
/// An intersection type, such as `string & number`.
#[derive(Clone, Debug, Display, PartialEq, Node)]
#[cfg_attr(feature = "serde", derive(Deserialize, Serialize))]
#[display(fmt = "{}{types}", "display_option(leading)")]
#[display("{}{types}", display_option(leading))]
pub struct TypeIntersection {
pub(crate) leading: Option<TokenReference>,
pub(crate) types: Punctuated<TypeInfo>,
Expand Down Expand Up @@ -255,11 +255,11 @@ impl TypeIntersection {
#[non_exhaustive]
pub enum IndexedTypeInfo {
/// A standalone type, such as `string` or `Foo`.
#[display(fmt = "{_0}")]
#[display("{_0}")]
Basic(TokenReference),

/// A type using generics, such as `map<number, string>`.
#[display(fmt = "{base}{}{generics}{}", "arrows.tokens().0", "arrows.tokens().1")]
#[display("{base}{}{generics}{}", arrows.tokens().0, arrows.tokens().1)]
Generic {
/// The type that has generics: `map`.
base: TokenReference,
Expand Down Expand Up @@ -343,11 +343,11 @@ impl TypeField {
#[non_exhaustive]
pub enum TypeFieldKey {
/// A name, such as `foo`.
#[display(fmt = "{_0}")]
#[display("{_0}")]
Name(TokenReference),

/// An index signature, such as `[number]`.
#[display(fmt = "{}{}{}", "brackets.tokens().0", "inner", "brackets.tokens().1")]
#[display("{}{}{}", brackets.tokens().0, inner, brackets.tokens().1)]
IndexSignature {
/// The brackets (`[]`) used to contain the type.
brackets: ContainedSpan,
Expand All @@ -360,7 +360,7 @@ pub enum TypeFieldKey {
/// A type assertion using `::`, such as `:: number`.
#[derive(Clone, Debug, Display, PartialEq, Node, Visit)]
#[cfg_attr(feature = "serde", derive(Deserialize, Serialize))]
#[display(fmt = "{assertion_op}{cast_to}")]
#[display("{assertion_op}{cast_to}")]
pub struct TypeAssertion {
pub(crate) assertion_op: TokenReference,
pub(crate) cast_to: TypeInfo,
Expand Down Expand Up @@ -403,12 +403,12 @@ impl TypeAssertion {
#[derive(Clone, Debug, Display, PartialEq, Node, Visit)]
#[cfg_attr(feature = "serde", derive(Deserialize, Serialize))]
#[display(
fmt = "{}{}{}{}{}",
"type_token",
"base",
"display_option(generics)",
"equal_token",
"declare_as"
"{}{}{}{}{}",
type_token,
base,
display_option(generics),
equal_token,
declare_as
)]
pub struct TypeDeclaration {
pub(crate) type_token: TokenReference,
Expand Down Expand Up @@ -502,11 +502,11 @@ impl TypeDeclaration {
#[non_exhaustive]
pub enum GenericParameterInfo {
/// A name, such as `foo`.
#[display(fmt = "{_0}")]
#[display("{_0}")]
Name(TokenReference),

/// A variadic type pack: `T...`.
#[display(fmt = "{name}{ellipsis}")]
#[display("{name}{ellipsis}")]
Variadic {
/// The name of the type that is variadic: `T`.
name: TokenReference,
Expand All @@ -518,10 +518,10 @@ pub enum GenericParameterInfo {
#[derive(Clone, Debug, Display, PartialEq, Node, Visit)]
#[cfg_attr(feature = "serde", derive(Deserialize, Serialize))]
#[display(
fmt = "{}{}{}",
"parameter",
"display_option(self.equals())",
"display_option(self.default_type())"
"{}{}{}",
parameter,
display_option(self.equals()),
display_option(self.default_type())
)]
pub struct GenericDeclarationParameter {
pub(crate) parameter: GenericParameterInfo,
Expand Down Expand Up @@ -566,7 +566,7 @@ impl GenericDeclarationParameter {
/// The generics used in a [`TypeDeclaration`].
#[derive(Clone, Debug, Display, PartialEq, Node, Visit)]
#[cfg_attr(feature = "serde", derive(Deserialize, Serialize))]
#[display(fmt = "{}{}{}", "arrows.tokens().0", "generics", "arrows.tokens().1")]
#[display("{}{}{}", arrows.tokens().0, generics, arrows.tokens().1)]
pub struct GenericDeclaration {
#[visit(contains = "generics")]
pub(crate) arrows: ContainedSpan,
Expand Down Expand Up @@ -615,7 +615,7 @@ impl Default for GenericDeclaration {
/// A type specifier, the `: number` in `local foo: number`
#[derive(Clone, Debug, Display, PartialEq, Node, Visit)]
#[cfg_attr(feature = "serde", derive(Deserialize, Serialize))]
#[display(fmt = "{punctuation}{type_info}")]
#[display("{punctuation}{type_info}")]
pub struct TypeSpecifier {
pub(crate) punctuation: TokenReference,
pub(crate) type_info: TypeInfo,
Expand Down Expand Up @@ -706,7 +706,7 @@ impl fmt::Display for TypeArgument {
/// An exported type declaration, such as `export type Meters = number`
#[derive(Clone, Debug, Display, PartialEq, Node, Visit)]
#[cfg_attr(feature = "serde", derive(Deserialize, Serialize))]
#[display(fmt = "{export_token}{type_declaration}")]
#[display("{export_token}{type_declaration}")]
pub struct ExportedTypeDeclaration {
pub(crate) export_token: TokenReference,
pub(crate) type_declaration: TypeDeclaration,
Expand Down Expand Up @@ -758,7 +758,7 @@ impl ExportedTypeDeclaration {
#[cfg_attr(feature = "serde", derive(Deserialize, Serialize))]
#[non_exhaustive]
#[allow(missing_docs)]
#[display(fmt = "{}")]
#[display("{_0}")]
/// Compound operators, such as X += Y or X -= Y
pub enum CompoundOp {
PlusEqual(TokenReference),
Expand Down Expand Up @@ -812,7 +812,7 @@ impl CompoundOp {
/// A Compound Assignment statement, such as `x += 1` or `x -= 1`
#[derive(Clone, Debug, Display, PartialEq, Node, Visit)]
#[cfg_attr(feature = "serde", derive(Deserialize, Serialize))]
#[display(fmt = "{lhs}{compound_operator}{rhs}")]
#[display("{lhs}{compound_operator}{rhs}")]
pub struct CompoundAssignment {
pub(crate) lhs: Var,
pub(crate) compound_operator: CompoundOp,
Expand Down Expand Up @@ -867,14 +867,14 @@ impl CompoundAssignment {
#[derive(Clone, Debug, Display, PartialEq, Node, Visit)]
#[cfg_attr(feature = "serde", derive(Deserialize, Serialize))]
#[display(
fmt = "{}{}{}{}{}{}{}",
"if_token",
"condition",
"then_token",
"if_expression",
"display_option(else_if_expressions.as_ref().map(join_vec))",
"else_token",
"else_expression"
"{}{}{}{}{}{}{}",
if_token,
condition,
then_token,
if_expression,
display_option(else_if_expressions.as_ref().map(join_vec)),
else_token,
else_expression
)]
pub struct IfExpression {
pub(crate) if_token: TokenReference,
Expand Down Expand Up @@ -991,7 +991,7 @@ impl IfExpression {
/// An elseif expression in a bigger [`IfExpression`] expression
#[derive(Clone, Debug, Display, PartialEq, Node, Visit)]
#[cfg_attr(feature = "serde", derive(Deserialize, Serialize))]
#[display(fmt = "{else_if_token}{condition}{then_token}{expression}")]
#[display("{else_if_token}{condition}{then_token}{expression}")]
pub struct ElseIfExpression {
pub(crate) else_if_token: TokenReference,
pub(crate) condition: Expression,
Expand Down Expand Up @@ -1064,7 +1064,7 @@ impl ElseIfExpression {
/// The `last_string` would be the literal 3, with a backtick afterwards.
#[derive(Clone, Debug, Display, PartialEq, Node, Visit)]
#[cfg_attr(feature = "serde", derive(Deserialize, Serialize))]
#[display(fmt = "{}{}", "join_vec(segments)", "last_string")]
#[display("{}{}", join_vec(segments), last_string)]
pub struct InterpolatedString {
pub(crate) segments: Vec<InterpolatedStringSegment>,
pub(crate) last_string: TokenReference,
Expand Down Expand Up @@ -1115,7 +1115,7 @@ impl InterpolatedString {
/// Read the documentation for [`InterpolatedString`] for more information.
#[derive(Clone, Debug, Display, PartialEq, Node)]
#[cfg_attr(feature = "serde", derive(Deserialize, Serialize))]
#[display(fmt = "{literal}{expression}")]
#[display("{literal}{expression}")]
pub struct InterpolatedStringSegment {
/// The literal part of the segment. Guaranteed to be of TokenType::InterpolatedString
pub literal: TokenReference,
Expand Down
Loading

0 comments on commit 9cc3534

Please sign in to comment.