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

(method_declaration
  name: (identifier) @name) @definition.method

(formal_parameters
  (formal_parameter
    name: (identifier) @name)) @definition.parameter

(local_variable_declaration
  declarator: (variable_declarator
    name: (identifier) @name)) @definition.variable

(field_declaration
  declarator: (variable_declarator
    name: (identifier) @name)) @definition.variable

(interface_declaration
  name: (identifier) @name) @definition.interface

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

(import_declaration
  (scoped_identifier) @name) @reference.import

(import_declaration
  (identifier) @name) @reference.import

(method_invocation
  name: (identifier) @name
  arguments: (argument_list)) @reference.call

(type_list
  (type_identifier) @name) @reference.implementation

(object_creation_expression
  type: (type_identifier) @name) @reference.class

(superclass (type_identifier) @name) @reference.class

(type_identifier) @name @reference.type

[
  (assignment_expression left: (identifier) @name)
  (assignment_expression right: (identifier) @name)
  (return_statement (identifier) @name)
  (argument_list (identifier) @name)
  (binary_expression left: (identifier) @name)
  (binary_expression right: (identifier) @name)
] @reference.variable
