Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions crates/oxc_ast/src/ast_kind_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,7 @@ impl AstKind<'_> {
Self::TSConstructSignatureDeclaration(_) => "TSConstructSignatureDeclaration".into(),
Self::TSExportAssignment(_) => "TSExportAssignment".into(),
Self::TSConstructorType(_) => "TSConstructorType".into(),
Self::TSIndexSignature(_) => "TSIndexSignature".into(),
Self::V8IntrinsicExpression(_) => "V8IntrinsicExpression".into(),

Self::JSDocNullableType(_) => "JSDocNullableType".into(),
Expand Down
65 changes: 37 additions & 28 deletions crates/oxc_ast/src/generated/ast_kind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,34 +171,35 @@ pub enum AstType {
TSClassImplements = 154,
TSInterfaceDeclaration = 155,
TSPropertySignature = 156,
TSCallSignatureDeclaration = 157,
TSMethodSignature = 158,
TSConstructSignatureDeclaration = 159,
TSIndexSignatureName = 160,
TSInterfaceHeritage = 161,
TSTypePredicate = 162,
TSModuleDeclaration = 163,
TSModuleBlock = 164,
TSTypeLiteral = 165,
TSInferType = 166,
TSTypeQuery = 167,
TSImportType = 168,
TSConstructorType = 169,
TSMappedType = 170,
TSTemplateLiteralType = 171,
TSAsExpression = 172,
TSSatisfiesExpression = 173,
TSTypeAssertion = 174,
TSImportEqualsDeclaration = 175,
TSExternalModuleReference = 176,
TSNonNullExpression = 177,
Decorator = 178,
TSExportAssignment = 179,
TSNamespaceExportDeclaration = 180,
TSInstantiationExpression = 181,
JSDocNullableType = 182,
JSDocNonNullableType = 183,
JSDocUnknownType = 184,
TSIndexSignature = 157,
TSCallSignatureDeclaration = 158,
TSMethodSignature = 159,
TSConstructSignatureDeclaration = 160,
TSIndexSignatureName = 161,
TSInterfaceHeritage = 162,
TSTypePredicate = 163,
TSModuleDeclaration = 164,
TSModuleBlock = 165,
TSTypeLiteral = 166,
TSInferType = 167,
TSTypeQuery = 168,
TSImportType = 169,
TSConstructorType = 170,
TSMappedType = 171,
TSTemplateLiteralType = 172,
TSAsExpression = 173,
TSSatisfiesExpression = 174,
TSTypeAssertion = 175,
TSImportEqualsDeclaration = 176,
TSExternalModuleReference = 177,
TSNonNullExpression = 178,
Decorator = 179,
TSExportAssignment = 180,
TSNamespaceExportDeclaration = 181,
TSInstantiationExpression = 182,
JSDocNullableType = 183,
JSDocNonNullableType = 184,
JSDocUnknownType = 185,
}

/// Untyped AST Node Kind
Expand Down Expand Up @@ -372,6 +373,7 @@ pub enum AstKind<'a> {
TSClassImplements(&'a TSClassImplements<'a>) = AstType::TSClassImplements as u8,
TSInterfaceDeclaration(&'a TSInterfaceDeclaration<'a>) = AstType::TSInterfaceDeclaration as u8,
TSPropertySignature(&'a TSPropertySignature<'a>) = AstType::TSPropertySignature as u8,
TSIndexSignature(&'a TSIndexSignature<'a>) = AstType::TSIndexSignature as u8,
TSCallSignatureDeclaration(&'a TSCallSignatureDeclaration<'a>) =
AstType::TSCallSignatureDeclaration as u8,
TSMethodSignature(&'a TSMethodSignature<'a>) = AstType::TSMethodSignature as u8,
Expand Down Expand Up @@ -580,6 +582,7 @@ impl GetSpan for AstKind<'_> {
Self::TSClassImplements(it) => it.span(),
Self::TSInterfaceDeclaration(it) => it.span(),
Self::TSPropertySignature(it) => it.span(),
Self::TSIndexSignature(it) => it.span(),
Self::TSCallSignatureDeclaration(it) => it.span(),
Self::TSMethodSignature(it) => it.span(),
Self::TSConstructSignatureDeclaration(it) => it.span(),
Expand Down Expand Up @@ -772,6 +775,7 @@ impl GetAddress for AstKind<'_> {
Self::TSClassImplements(it) => Address::from_ptr(it),
Self::TSInterfaceDeclaration(it) => Address::from_ptr(it),
Self::TSPropertySignature(it) => Address::from_ptr(it),
Self::TSIndexSignature(it) => Address::from_ptr(it),
Self::TSCallSignatureDeclaration(it) => Address::from_ptr(it),
Self::TSMethodSignature(it) => Address::from_ptr(it),
Self::TSConstructSignatureDeclaration(it) => Address::from_ptr(it),
Expand Down Expand Up @@ -1592,6 +1596,11 @@ impl<'a> AstKind<'a> {
if let Self::TSPropertySignature(v) = self { Some(v) } else { None }
}

#[inline]
pub fn as_ts_index_signature(self) -> Option<&'a TSIndexSignature<'a>> {
if let Self::TSIndexSignature(v) = self { Some(v) } else { None }
}

#[inline]
pub fn as_ts_call_signature_declaration(self) -> Option<&'a TSCallSignatureDeclaration<'a>> {
if let Self::TSCallSignatureDeclaration(v) = self { Some(v) } else { None }
Expand Down
4 changes: 3 additions & 1 deletion crates/oxc_ast_visit/src/generated/visit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3694,10 +3694,12 @@ pub mod walk {

#[inline]
pub fn walk_ts_index_signature<'a, V: Visit<'a>>(visitor: &mut V, it: &TSIndexSignature<'a>) {
// No `AstKind` for this type
let kind = AstKind::TSIndexSignature(visitor.alloc(it));
visitor.enter_node(kind);
visitor.visit_span(&it.span);
visitor.visit_ts_index_signature_names(&it.parameters);
visitor.visit_ts_type_annotation(&it.type_annotation);
visitor.leave_node(kind);
}

#[inline]
Expand Down
4 changes: 3 additions & 1 deletion crates/oxc_ast_visit/src/generated/visit_mut.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3897,10 +3897,12 @@ pub mod walk_mut {
visitor: &mut V,
it: &mut TSIndexSignature<'a>,
) {
// No `AstType` for this type
let kind = AstType::TSIndexSignature;
visitor.enter_node(kind);
visitor.visit_span(&mut it.span);
visitor.visit_ts_index_signature_names(&mut it.parameters);
visitor.visit_ts_type_annotation(&mut it.type_annotation);
visitor.leave_node(kind);
}

#[inline]
Expand Down
27 changes: 19 additions & 8 deletions crates/oxc_formatter/src/generated/ast_nodes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ pub enum AstNodes<'a> {
TSClassImplements(&'a AstNode<'a, TSClassImplements<'a>>),
TSInterfaceDeclaration(&'a AstNode<'a, TSInterfaceDeclaration<'a>>),
TSPropertySignature(&'a AstNode<'a, TSPropertySignature<'a>>),
TSIndexSignature(&'a AstNode<'a, TSIndexSignature<'a>>),
TSCallSignatureDeclaration(&'a AstNode<'a, TSCallSignatureDeclaration<'a>>),
TSMethodSignature(&'a AstNode<'a, TSMethodSignature<'a>>),
TSConstructSignatureDeclaration(&'a AstNode<'a, TSConstructSignatureDeclaration<'a>>),
Expand Down Expand Up @@ -2469,6 +2470,7 @@ impl<'a> AstNodes<'a> {
Self::TSClassImplements(n) => n.span(),
Self::TSInterfaceDeclaration(n) => n.span(),
Self::TSPropertySignature(n) => n.span(),
Self::TSIndexSignature(n) => n.span(),
Self::TSCallSignatureDeclaration(n) => n.span(),
Self::TSMethodSignature(n) => n.span(),
Self::TSConstructSignatureDeclaration(n) => n.span(),
Expand Down Expand Up @@ -2660,6 +2662,7 @@ impl<'a> AstNodes<'a> {
Self::TSClassImplements(n) => n.parent,
Self::TSInterfaceDeclaration(n) => n.parent,
Self::TSPropertySignature(n) => n.parent,
Self::TSIndexSignature(n) => n.parent,
Self::TSCallSignatureDeclaration(n) => n.parent,
Self::TSMethodSignature(n) => n.parent,
Self::TSConstructSignatureDeclaration(n) => n.parent,
Expand Down Expand Up @@ -2851,6 +2854,7 @@ impl<'a> AstNodes<'a> {
Self::TSClassImplements(n) => SiblingNode::from(n.inner),
Self::TSInterfaceDeclaration(n) => SiblingNode::from(n.inner),
Self::TSPropertySignature(n) => SiblingNode::from(n.inner),
Self::TSIndexSignature(n) => SiblingNode::from(n.inner),
Self::TSCallSignatureDeclaration(n) => SiblingNode::from(n.inner),
Self::TSMethodSignature(n) => SiblingNode::from(n.inner),
Self::TSConstructSignatureDeclaration(n) => SiblingNode::from(n.inner),
Expand Down Expand Up @@ -3042,6 +3046,7 @@ impl<'a> AstNodes<'a> {
Self::TSClassImplements(_) => "TSClassImplements",
Self::TSInterfaceDeclaration(_) => "TSInterfaceDeclaration",
Self::TSPropertySignature(_) => "TSPropertySignature",
Self::TSIndexSignature(_) => "TSIndexSignature",
Self::TSCallSignatureDeclaration(_) => "TSCallSignatureDeclaration",
Self::TSMethodSignature(_) => "TSMethodSignature",
Self::TSConstructSignatureDeclaration(_) => "TSConstructSignatureDeclaration",
Expand Down Expand Up @@ -6787,9 +6792,12 @@ impl<'a> AstNode<'a, ClassElement<'a>> {
}))
}
ClassElement::TSIndexSignature(s) => {
panic!(
"No kind for current enum variant yet, please see `tasks/ast_tools/src/generators/ast_kind.rs`"
)
AstNodes::TSIndexSignature(self.allocator.alloc(AstNode {
inner: s.as_ref(),
parent,
allocator: self.allocator,
following_node: self.following_node,
}))
}
};
self.allocator.alloc(node)
Expand Down Expand Up @@ -9930,9 +9938,12 @@ impl<'a> AstNode<'a, TSSignature<'a>> {
let parent = self.parent;
let node = match self.inner {
TSSignature::TSIndexSignature(s) => {
panic!(
"No kind for current enum variant yet, please see `tasks/ast_tools/src/generators/ast_kind.rs`"
)
AstNodes::TSIndexSignature(self.allocator.alloc(AstNode {
inner: s.as_ref(),
parent,
allocator: self.allocator,
following_node: self.following_node,
}))
}
TSSignature::TSPropertySignature(s) => {
AstNodes::TSPropertySignature(self.allocator.alloc(AstNode {
Expand Down Expand Up @@ -9990,7 +10001,7 @@ impl<'a> AstNode<'a, TSIndexSignature<'a>> {
self.allocator.alloc(AstNode {
inner: &self.inner.parameters,
allocator: self.allocator,
parent: self.parent,
parent: self.allocator.alloc(AstNodes::TSIndexSignature(transmute_self(self))),
following_node,
})
}
Expand All @@ -10001,7 +10012,7 @@ impl<'a> AstNode<'a, TSIndexSignature<'a>> {
self.allocator.alloc(AstNode {
inner: self.inner.type_annotation.as_ref(),
allocator: self.allocator,
parent: self.parent,
parent: self.allocator.alloc(AstNodes::TSIndexSignature(transmute_self(self))),
following_node,
})
}
Expand Down
10 changes: 9 additions & 1 deletion crates/oxc_formatter/src/generated/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2579,7 +2579,15 @@ impl<'a> Format<'a> for AstNode<'a, TSSignature<'a>> {

impl<'a> Format<'a> for AstNode<'a, TSIndexSignature<'a>> {
fn fmt(&self, f: &mut Formatter<'_, 'a>) -> FormatResult<()> {
self.write(f)
format_leading_comments(self.span).fmt(f)?;
let result = self.write(f);
format_trailing_comments(
&self.parent.as_sibling_node(),
&SiblingNode::from(self.inner),
self.following_node.as_ref(),
)
.fmt(f)?;
result
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ input_file: crates/oxc_semantic/tests/fixtures/typescript-eslint/class/declarati
"flags": "ReferenceFlags(Type)",
"id": 0,
"name": "Bar",
"node_id": 16
"node_id": 18
}
]
},
Expand All @@ -48,7 +48,7 @@ input_file: crates/oxc_semantic/tests/fixtures/typescript-eslint/class/declarati
"flags": "ReferenceFlags(Type)",
"id": 1,
"name": "Foo",
"node_id": 25
"node_id": 28
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ input_file: crates/oxc_semantic/tests/fixtures/typescript-eslint/type-declaratio
"flags": "ReferenceFlags(Type)",
"id": 1,
"name": "I",
"node_id": 20
"node_id": 21
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ input_file: crates/oxc_semantic/tests/fixtures/typescript-eslint/type-declaratio
"flags": "ReferenceFlags(Type)",
"id": 1,
"name": "I",
"node_id": 32
"node_id": 33
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ input_file: crates/oxc_semantic/tests/fixtures/typescript-eslint/type-declaratio
"flags": "ReferenceFlags(Type)",
"id": 0,
"name": "T",
"node_id": 14
"node_id": 15
}
]
},
Expand Down
1 change: 0 additions & 1 deletion tasks/ast_tools/src/generators/ast_kind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ const STRUCTS_BLACK_LIST: &[&str] = &[
"BindingPattern",
"BindingProperty",
"TSInterfaceBody",
"TSIndexSignature",
"TSFunctionType",
"Span",
];
Expand Down
Loading