(
  (comment)* @doc
  .
  (function_declaration
    name: (identifier) @name) @definition.function
  (#strip! @doc "^//\\s*")
  (#set-adjacent! @doc @definition.function)
)

(
  (comment)* @doc
  .
  (method_declaration
    name: (field_identifier) @name) @definition.method
  (#strip! @doc "^//\\s*")
  (#set-adjacent! @doc @definition.method)
)

(type_spec
  name: (type_identifier) @name) @definition.type

(type_parameter_declaration
  (type_identifier) @name) @definition.type

(type_identifier) @name @reference.type

(call_expression
  function: [
    (identifier) @name
    (parenthesized_expression (identifier) @name)
  ]) @reference.call

(import_declaration
  (import_spec
    path: (interpreted_string_literal) @name)) @reference.module

(import_declaration
  (import_spec
    name: (package_identifier) @name)) @reference.import

(var_declaration
  (var_spec
    name: (identifier) @name)) @definition.variable

(const_declaration
  (const_spec
    name: (identifier) @name)) @definition.constant

(short_var_declaration
  left: (expression_list (identifier) @name)) @definition.variable

(parameter_declaration
  (identifier) @name) @definition.parameter

[
  (binary_expression left: (identifier) @name)
  (binary_expression right: (identifier) @name)
  (return_statement (identifier) @name)
  (argument_list (identifier) @name)
  (assignment_statement left: (expression_list (identifier) @name))
  (inc_statement (identifier) @name)
  (dec_statement (identifier) @name)
  (range_clause left: (expression_list (identifier) @name))
] @reference.variable
