;; JavaScript/JSX 标签查询
;; 定义使用 @name.definition.* 前缀
;; 引用使用 @name.reference.* 前缀

;; ==================== 定义 ====================

;; 函数声明
(function_declaration
  name: (identifier) @name.definition.function) @definition.function

;; 生成器函数
(generator_function_declaration
  name: (identifier) @name.definition.function) @definition.function

;; 箭头函数赋值 (const/let)
(lexical_declaration
  (variable_declarator
    name: (identifier) @name.definition.function
    value: [(arrow_function) (function)])) @definition.function

;; 箭头函数赋值 (var)
(variable_declaration
  (variable_declarator
    name: (identifier) @name.definition.function
    value: [(arrow_function) (function)])) @definition.function

;; 赋值表达式中的函数
(assignment_expression
  left: (identifier) @name.definition.function
  right: [(arrow_function) (function)]) @definition.function

(assignment_expression
  left: (member_expression
    property: (property_identifier) @name.definition.function)
  right: [(arrow_function) (function)]) @definition.function

;; 对象方法
(pair
  key: (property_identifier) @name.definition.function
  value: [(arrow_function) (function)]) @definition.function

;; 方法定义
(method_definition
  name: (property_identifier) @name.definition.method) @definition.method

;; 类定义
(class_declaration
  name: (identifier) @name.definition.class) @definition.class

(class
  name: (identifier) @name.definition.class) @definition.class

;; ==================== 引用 ====================

;; 函数调用
(call_expression
  function: (identifier) @name.reference.call) @reference.call

(call_expression
  function: (member_expression
    property: (property_identifier) @name.reference.call)) @reference.call

;; new 表达式
(new_expression
  constructor: (identifier) @name.reference.class) @reference.class
