Tree-sitter kinds generator_function_declaration / generator_function were
missing from both the wasm and native kernel function-type lists, so
function* / async function* (and const g = function* () {}) produced no
nodes. Add the kinds on both paths and cover TS+JS declaration/expression
forms in extraction tests.
Co-authored-by: Colby McHenry <colbymchenry@users.noreply.github.com>
This commit is contained in:
co-authored by
Colby McHenry
parent
72869f2d9e
commit
df435d50d1
@@ -23,7 +23,7 @@ impl<'t> Walker<'t> {
|
||||
// variable_declarator (`export const useAuth = () => {}`).
|
||||
if name_override.is_none()
|
||||
&& name == "<anonymous>"
|
||||
&& matches!(node.kind(), "arrow_function" | "function_expression")
|
||||
&& matches!(node.kind(), "arrow_function" | "function_expression" | "generator_function")
|
||||
{
|
||||
if let Some(parent) = node.parent() {
|
||||
if parent.kind() == "variable_declarator" {
|
||||
@@ -342,9 +342,9 @@ impl<'t> Walker<'t> {
|
||||
}
|
||||
let name = self.text(name_node).to_string();
|
||||
|
||||
// Arrow/function values extract as functions, named by the declarator.
|
||||
// Arrow/function/generator values extract as functions, named by the declarator.
|
||||
if let Some(v) = value {
|
||||
if matches!(v.kind(), "arrow_function" | "function_expression") {
|
||||
if matches!(v.kind(), "arrow_function" | "function_expression" | "generator_function") {
|
||||
self.extract_function(v, None);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ fn is_method_type(v: Variant, kind: &str) -> bool {
|
||||
}
|
||||
|
||||
fn is_function_type(kind: &str) -> bool {
|
||||
matches!(kind, "function_declaration" | "arrow_function" | "function_expression")
|
||||
matches!(kind, "function_declaration" | "generator_function_declaration" | "arrow_function" | "function_expression" | "generator_function")
|
||||
}
|
||||
|
||||
fn is_class_type(v: Variant, kind: &str) -> bool {
|
||||
@@ -792,7 +792,7 @@ impl<'t> Walker<'t> {
|
||||
if let Some(name_node) = node.child_by_field_name("name") {
|
||||
return self.text(name_node).to_string();
|
||||
}
|
||||
if matches!(node.kind(), "arrow_function" | "function_expression") {
|
||||
if matches!(node.kind(), "arrow_function" | "function_expression" | "generator_function") {
|
||||
return "<anonymous>".to_string();
|
||||
}
|
||||
for i in 0..node.named_child_count() {
|
||||
|
||||
Reference in New Issue
Block a user