Skip to content

Commit

Permalink
feat(graphql_parser): separate binding and reference nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
vohoanglong0107 committed Jul 13, 2024
1 parent 48387f6 commit 3d0e70f
Show file tree
Hide file tree
Showing 86 changed files with 4,988 additions and 4,931 deletions.
150 changes: 90 additions & 60 deletions crates/biome_graphql_factory/src/generated/node_factory.rs

Large diffs are not rendered by default.

129 changes: 87 additions & 42 deletions crates/biome_graphql_factory/src/generated/syntax_factory.rs

Large diffs are not rendered by default.

208 changes: 172 additions & 36 deletions crates/biome_graphql_formatter/src/generated.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1160,83 +1160,123 @@ impl IntoFormat<GraphqlFormatContext> for biome_graphql_syntax::GraphqlListValue
)
}
}
impl FormatRule<biome_graphql_syntax::GraphqlName>
for crate::graphql::auxiliary::name::FormatGraphqlName
impl FormatRule<biome_graphql_syntax::GraphqlLiteralName>
for crate::graphql::auxiliary::literal_name::FormatGraphqlLiteralName
{
type Context = GraphqlFormatContext;
#[inline(always)]
fn fmt(
&self,
node: &biome_graphql_syntax::GraphqlName,
node: &biome_graphql_syntax::GraphqlLiteralName,
f: &mut GraphqlFormatter,
) -> FormatResult<()> {
FormatNodeRule::<biome_graphql_syntax::GraphqlName>::fmt(self, node, f)
FormatNodeRule::<biome_graphql_syntax::GraphqlLiteralName>::fmt(self, node, f)
}
}
impl AsFormat<GraphqlFormatContext> for biome_graphql_syntax::GraphqlName {
impl AsFormat<GraphqlFormatContext> for biome_graphql_syntax::GraphqlLiteralName {
type Format<'a> = FormatRefWithRule<
'a,
biome_graphql_syntax::GraphqlName,
crate::graphql::auxiliary::name::FormatGraphqlName,
biome_graphql_syntax::GraphqlLiteralName,
crate::graphql::auxiliary::literal_name::FormatGraphqlLiteralName,
>;
fn format(&self) -> Self::Format<'_> {
#![allow(clippy::default_constructed_unit_structs)]
FormatRefWithRule::new(
self,
crate::graphql::auxiliary::name::FormatGraphqlName::default(),
crate::graphql::auxiliary::literal_name::FormatGraphqlLiteralName::default(),
)
}
}
impl IntoFormat<GraphqlFormatContext> for biome_graphql_syntax::GraphqlName {
impl IntoFormat<GraphqlFormatContext> for biome_graphql_syntax::GraphqlLiteralName {
type Format = FormatOwnedWithRule<
biome_graphql_syntax::GraphqlName,
crate::graphql::auxiliary::name::FormatGraphqlName,
biome_graphql_syntax::GraphqlLiteralName,
crate::graphql::auxiliary::literal_name::FormatGraphqlLiteralName,
>;
fn into_format(self) -> Self::Format {
#![allow(clippy::default_constructed_unit_structs)]
FormatOwnedWithRule::new(
self,
crate::graphql::auxiliary::name::FormatGraphqlName::default(),
crate::graphql::auxiliary::literal_name::FormatGraphqlLiteralName::default(),
)
}
}
impl FormatRule<biome_graphql_syntax::GraphqlNamedType>
for crate::graphql::auxiliary::named_type::FormatGraphqlNamedType
impl FormatRule<biome_graphql_syntax::GraphqlNameBinding>
for crate::graphql::auxiliary::name_binding::FormatGraphqlNameBinding
{
type Context = GraphqlFormatContext;
#[inline(always)]
fn fmt(
&self,
node: &biome_graphql_syntax::GraphqlNamedType,
node: &biome_graphql_syntax::GraphqlNameBinding,
f: &mut GraphqlFormatter,
) -> FormatResult<()> {
FormatNodeRule::<biome_graphql_syntax::GraphqlNamedType>::fmt(self, node, f)
FormatNodeRule::<biome_graphql_syntax::GraphqlNameBinding>::fmt(self, node, f)
}
}
impl AsFormat<GraphqlFormatContext> for biome_graphql_syntax::GraphqlNamedType {
impl AsFormat<GraphqlFormatContext> for biome_graphql_syntax::GraphqlNameBinding {
type Format<'a> = FormatRefWithRule<
'a,
biome_graphql_syntax::GraphqlNamedType,
crate::graphql::auxiliary::named_type::FormatGraphqlNamedType,
biome_graphql_syntax::GraphqlNameBinding,
crate::graphql::auxiliary::name_binding::FormatGraphqlNameBinding,
>;
fn format(&self) -> Self::Format<'_> {
#![allow(clippy::default_constructed_unit_structs)]
FormatRefWithRule::new(
self,
crate::graphql::auxiliary::named_type::FormatGraphqlNamedType::default(),
crate::graphql::auxiliary::name_binding::FormatGraphqlNameBinding::default(),
)
}
}
impl IntoFormat<GraphqlFormatContext> for biome_graphql_syntax::GraphqlNamedType {
impl IntoFormat<GraphqlFormatContext> for biome_graphql_syntax::GraphqlNameBinding {
type Format = FormatOwnedWithRule<
biome_graphql_syntax::GraphqlNamedType,
crate::graphql::auxiliary::named_type::FormatGraphqlNamedType,
biome_graphql_syntax::GraphqlNameBinding,
crate::graphql::auxiliary::name_binding::FormatGraphqlNameBinding,
>;
fn into_format(self) -> Self::Format {
#![allow(clippy::default_constructed_unit_structs)]
FormatOwnedWithRule::new(
self,
crate::graphql::auxiliary::named_type::FormatGraphqlNamedType::default(),
crate::graphql::auxiliary::name_binding::FormatGraphqlNameBinding::default(),
)
}
}
impl FormatRule<biome_graphql_syntax::GraphqlNameReference>
for crate::graphql::auxiliary::name_reference::FormatGraphqlNameReference
{
type Context = GraphqlFormatContext;
#[inline(always)]
fn fmt(
&self,
node: &biome_graphql_syntax::GraphqlNameReference,
f: &mut GraphqlFormatter,
) -> FormatResult<()> {
FormatNodeRule::<biome_graphql_syntax::GraphqlNameReference>::fmt(self, node, f)
}
}
impl AsFormat<GraphqlFormatContext> for biome_graphql_syntax::GraphqlNameReference {
type Format<'a> = FormatRefWithRule<
'a,
biome_graphql_syntax::GraphqlNameReference,
crate::graphql::auxiliary::name_reference::FormatGraphqlNameReference,
>;
fn format(&self) -> Self::Format<'_> {
#![allow(clippy::default_constructed_unit_structs)]
FormatRefWithRule::new(
self,
crate::graphql::auxiliary::name_reference::FormatGraphqlNameReference::default(),
)
}
}
impl IntoFormat<GraphqlFormatContext> for biome_graphql_syntax::GraphqlNameReference {
type Format = FormatOwnedWithRule<
biome_graphql_syntax::GraphqlNameReference,
crate::graphql::auxiliary::name_reference::FormatGraphqlNameReference,
>;
fn into_format(self) -> Self::Format {
#![allow(clippy::default_constructed_unit_structs)]
FormatOwnedWithRule::new(
self,
crate::graphql::auxiliary::name_reference::FormatGraphqlNameReference::default(),
)
}
}
Expand Down Expand Up @@ -2009,43 +2049,43 @@ impl IntoFormat<GraphqlFormatContext> for biome_graphql_syntax::GraphqlUnionType
FormatOwnedWithRule :: new (self , crate :: graphql :: extensions :: union_type_extension :: FormatGraphqlUnionTypeExtension :: default ())
}
}
impl FormatRule<biome_graphql_syntax::GraphqlVariable>
for crate::graphql::auxiliary::variable::FormatGraphqlVariable
impl FormatRule<biome_graphql_syntax::GraphqlVariableBinding>
for crate::graphql::auxiliary::variable_binding::FormatGraphqlVariableBinding
{
type Context = GraphqlFormatContext;
#[inline(always)]
fn fmt(
&self,
node: &biome_graphql_syntax::GraphqlVariable,
node: &biome_graphql_syntax::GraphqlVariableBinding,
f: &mut GraphqlFormatter,
) -> FormatResult<()> {
FormatNodeRule::<biome_graphql_syntax::GraphqlVariable>::fmt(self, node, f)
FormatNodeRule::<biome_graphql_syntax::GraphqlVariableBinding>::fmt(self, node, f)
}
}
impl AsFormat<GraphqlFormatContext> for biome_graphql_syntax::GraphqlVariable {
impl AsFormat<GraphqlFormatContext> for biome_graphql_syntax::GraphqlVariableBinding {
type Format<'a> = FormatRefWithRule<
'a,
biome_graphql_syntax::GraphqlVariable,
crate::graphql::auxiliary::variable::FormatGraphqlVariable,
biome_graphql_syntax::GraphqlVariableBinding,
crate::graphql::auxiliary::variable_binding::FormatGraphqlVariableBinding,
>;
fn format(&self) -> Self::Format<'_> {
#![allow(clippy::default_constructed_unit_structs)]
FormatRefWithRule::new(
self,
crate::graphql::auxiliary::variable::FormatGraphqlVariable::default(),
crate::graphql::auxiliary::variable_binding::FormatGraphqlVariableBinding::default(),
)
}
}
impl IntoFormat<GraphqlFormatContext> for biome_graphql_syntax::GraphqlVariable {
impl IntoFormat<GraphqlFormatContext> for biome_graphql_syntax::GraphqlVariableBinding {
type Format = FormatOwnedWithRule<
biome_graphql_syntax::GraphqlVariable,
crate::graphql::auxiliary::variable::FormatGraphqlVariable,
biome_graphql_syntax::GraphqlVariableBinding,
crate::graphql::auxiliary::variable_binding::FormatGraphqlVariableBinding,
>;
fn into_format(self) -> Self::Format {
#![allow(clippy::default_constructed_unit_structs)]
FormatOwnedWithRule::new(
self,
crate::graphql::auxiliary::variable::FormatGraphqlVariable::default(),
crate::graphql::auxiliary::variable_binding::FormatGraphqlVariableBinding::default(),
)
}
}
Expand Down Expand Up @@ -2117,6 +2157,48 @@ impl IntoFormat<GraphqlFormatContext> for biome_graphql_syntax::GraphqlVariableD
FormatOwnedWithRule :: new (self , crate :: graphql :: auxiliary :: variable_definitions :: FormatGraphqlVariableDefinitions :: default ())
}
}
impl FormatRule<biome_graphql_syntax::GraphqlVariableReference>
for crate::graphql::auxiliary::variable_reference::FormatGraphqlVariableReference
{
type Context = GraphqlFormatContext;
#[inline(always)]
fn fmt(
&self,
node: &biome_graphql_syntax::GraphqlVariableReference,
f: &mut GraphqlFormatter,
) -> FormatResult<()> {
FormatNodeRule::<biome_graphql_syntax::GraphqlVariableReference>::fmt(self, node, f)
}
}
impl AsFormat<GraphqlFormatContext> for biome_graphql_syntax::GraphqlVariableReference {
type Format<'a> = FormatRefWithRule<
'a,
biome_graphql_syntax::GraphqlVariableReference,
crate::graphql::auxiliary::variable_reference::FormatGraphqlVariableReference,
>;
fn format(&self) -> Self::Format<'_> {
#![allow(clippy::default_constructed_unit_structs)]
FormatRefWithRule::new(
self,
crate::graphql::auxiliary::variable_reference::FormatGraphqlVariableReference::default(
),
)
}
}
impl IntoFormat<GraphqlFormatContext> for biome_graphql_syntax::GraphqlVariableReference {
type Format = FormatOwnedWithRule<
biome_graphql_syntax::GraphqlVariableReference,
crate::graphql::auxiliary::variable_reference::FormatGraphqlVariableReference,
>;
fn into_format(self) -> Self::Format {
#![allow(clippy::default_constructed_unit_structs)]
FormatOwnedWithRule::new(
self,
crate::graphql::auxiliary::variable_reference::FormatGraphqlVariableReference::default(
),
)
}
}
impl AsFormat<GraphqlFormatContext> for biome_graphql_syntax::GraphqlArgumentDefinitionList {
type Format<'a> = FormatRefWithRule<
'a,
Expand Down Expand Up @@ -2810,6 +2892,60 @@ impl IntoFormat<GraphqlFormatContext> for biome_graphql_syntax::AnyGraphqlType {
)
}
}
impl AsFormat<GraphqlFormatContext> for biome_graphql_syntax::AnyGraphqlTypeDefinition {
type Format<'a> = FormatRefWithRule<
'a,
biome_graphql_syntax::AnyGraphqlTypeDefinition,
crate::graphql::any::type_definition::FormatAnyGraphqlTypeDefinition,
>;
fn format(&self) -> Self::Format<'_> {
#![allow(clippy::default_constructed_unit_structs)]
FormatRefWithRule::new(
self,
crate::graphql::any::type_definition::FormatAnyGraphqlTypeDefinition::default(),
)
}
}
impl IntoFormat<GraphqlFormatContext> for biome_graphql_syntax::AnyGraphqlTypeDefinition {
type Format = FormatOwnedWithRule<
biome_graphql_syntax::AnyGraphqlTypeDefinition,
crate::graphql::any::type_definition::FormatAnyGraphqlTypeDefinition,
>;
fn into_format(self) -> Self::Format {
#![allow(clippy::default_constructed_unit_structs)]
FormatOwnedWithRule::new(
self,
crate::graphql::any::type_definition::FormatAnyGraphqlTypeDefinition::default(),
)
}
}
impl AsFormat<GraphqlFormatContext> for biome_graphql_syntax::AnyGraphqlTypeExtension {
type Format<'a> = FormatRefWithRule<
'a,
biome_graphql_syntax::AnyGraphqlTypeExtension,
crate::graphql::any::type_extension::FormatAnyGraphqlTypeExtension,
>;
fn format(&self) -> Self::Format<'_> {
#![allow(clippy::default_constructed_unit_structs)]
FormatRefWithRule::new(
self,
crate::graphql::any::type_extension::FormatAnyGraphqlTypeExtension::default(),
)
}
}
impl IntoFormat<GraphqlFormatContext> for biome_graphql_syntax::AnyGraphqlTypeExtension {
type Format = FormatOwnedWithRule<
biome_graphql_syntax::AnyGraphqlTypeExtension,
crate::graphql::any::type_extension::FormatAnyGraphqlTypeExtension,
>;
fn into_format(self) -> Self::Format {
#![allow(clippy::default_constructed_unit_structs)]
FormatOwnedWithRule::new(
self,
crate::graphql::any::type_extension::FormatAnyGraphqlTypeExtension::default(),
)
}
}
impl AsFormat<GraphqlFormatContext> for biome_graphql_syntax::AnyGraphqlValue {
type Format<'a> = FormatRefWithRule<
'a,
Expand Down
17 changes: 4 additions & 13 deletions crates/biome_graphql_formatter/src/graphql/any/definition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,15 @@ impl FormatRule<AnyGraphqlDefinition> for FormatAnyGraphqlDefinition {
type Context = GraphqlFormatContext;
fn fmt(&self, node: &AnyGraphqlDefinition, f: &mut GraphqlFormatter) -> FormatResult<()> {
match node {
AnyGraphqlDefinition::AnyGraphqlOperationDefinition(node) => node.format().fmt(f),
AnyGraphqlDefinition::AnyGraphqlTypeDefinition(node) => node.format().fmt(f),
AnyGraphqlDefinition::AnyGraphqlTypeExtension(node) => node.format().fmt(f),
AnyGraphqlDefinition::GraphqlBogusDefinition(node) => node.format().fmt(f),
AnyGraphqlDefinition::GraphqlDirectiveDefinition(node) => node.format().fmt(f),
AnyGraphqlDefinition::GraphqlEnumTypeDefinition(node) => node.format().fmt(f),
AnyGraphqlDefinition::GraphqlEnumTypeExtension(node) => node.format().fmt(f),
AnyGraphqlDefinition::GraphqlFragmentDefinition(node) => node.format().fmt(f),
AnyGraphqlDefinition::GraphqlInputObjectTypeDefinition(node) => node.format().fmt(f),
AnyGraphqlDefinition::GraphqlInputObjectTypeExtension(node) => node.format().fmt(f),
AnyGraphqlDefinition::GraphqlInterfaceTypeDefinition(node) => node.format().fmt(f),
AnyGraphqlDefinition::GraphqlInterfaceTypeExtension(node) => node.format().fmt(f),
AnyGraphqlDefinition::GraphqlObjectTypeDefinition(node) => node.format().fmt(f),
AnyGraphqlDefinition::GraphqlObjectTypeExtension(node) => node.format().fmt(f),
AnyGraphqlDefinition::GraphqlScalarTypeDefinition(node) => node.format().fmt(f),
AnyGraphqlDefinition::GraphqlScalarTypeExtension(node) => node.format().fmt(f),
AnyGraphqlDefinition::GraphqlOperationDefinition(node) => node.format().fmt(f),
AnyGraphqlDefinition::GraphqlSchemaDefinition(node) => node.format().fmt(f),
AnyGraphqlDefinition::GraphqlSchemaExtension(node) => node.format().fmt(f),
AnyGraphqlDefinition::GraphqlUnionTypeDefinition(node) => node.format().fmt(f),
AnyGraphqlDefinition::GraphqlUnionTypeExtension(node) => node.format().fmt(f),
AnyGraphqlDefinition::GraphqlSelectionSet(node) => node.format().fmt(f),
}
}
}
2 changes: 2 additions & 0 deletions crates/biome_graphql_formatter/src/graphql/any/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@ pub(crate) mod operation_definition;
pub(crate) mod primitive_type;
pub(crate) mod selection;
pub(crate) mod ts_type;
pub(crate) mod type_definition;
pub(crate) mod type_extension;
pub(crate) mod value;
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ impl FormatRule<AnyGraphqlPrimitiveType> for FormatAnyGraphqlPrimitiveType {
fn fmt(&self, node: &AnyGraphqlPrimitiveType, f: &mut GraphqlFormatter) -> FormatResult<()> {
match node {
AnyGraphqlPrimitiveType::GraphqlListType(node) => node.format().fmt(f),
AnyGraphqlPrimitiveType::GraphqlNamedType(node) => node.format().fmt(f),
AnyGraphqlPrimitiveType::GraphqlNameReference(node) => node.format().fmt(f),
}
}
}
21 changes: 21 additions & 0 deletions crates/biome_graphql_formatter/src/graphql/any/type_definition.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//! This is a generated file. Don't modify it by hand! Run 'cargo codegen formatter' to re-generate the file.

use crate::prelude::*;
use biome_graphql_syntax::AnyGraphqlTypeDefinition;
#[derive(Debug, Clone, Default)]
pub(crate) struct FormatAnyGraphqlTypeDefinition;
impl FormatRule<AnyGraphqlTypeDefinition> for FormatAnyGraphqlTypeDefinition {
type Context = GraphqlFormatContext;
fn fmt(&self, node: &AnyGraphqlTypeDefinition, f: &mut GraphqlFormatter) -> FormatResult<()> {
match node {
AnyGraphqlTypeDefinition::GraphqlEnumTypeDefinition(node) => node.format().fmt(f),
AnyGraphqlTypeDefinition::GraphqlInputObjectTypeDefinition(node) => {
node.format().fmt(f)
}
AnyGraphqlTypeDefinition::GraphqlInterfaceTypeDefinition(node) => node.format().fmt(f),
AnyGraphqlTypeDefinition::GraphqlObjectTypeDefinition(node) => node.format().fmt(f),
AnyGraphqlTypeDefinition::GraphqlScalarTypeDefinition(node) => node.format().fmt(f),
AnyGraphqlTypeDefinition::GraphqlUnionTypeDefinition(node) => node.format().fmt(f),
}
}
}
Loading

0 comments on commit 3d0e70f

Please sign in to comment.