Exemplo n.º 1
0
 def menu_items(self):
     # self.menu_data comes in the way of [datum, mod, alias,
     # secondary_datum, type_datum], where (mod, alias, secondary_datum)
     # and type_datum are mutually exclusive.
     datum, mod, alias, crate, urls, typ = self.menu_data
     menu = []
     if mod:
         if 'file_name' in mod:
             menu.append(jump_to_target_from_decl(jump_to_alias_definition_menu_item, self.tree, mod))
         if crate:
             # Add references to extern mods via aliases (known local crates)
             menu.append(jump_to_crate_menu_item(self.tree, crate['file_name'], 1))
             menu.append(find_references_menu_item(self.tree, alias['qualname'], "module-alias-ref", "alias"))
         if urls:
             # Add references to extern mods via aliases (standard library crates)
             menu = [find_references_menu_item(self.tree, alias['qualname'], "module-alias-ref", "alias")]
             menu.extend(std_lib_links_menu(urls))
         elif alias and 'location' in alias:
             # Add references to extern mods via aliases (unknown local crates)
             menu = [find_references_menu_item(self.tree, alias['qualname'], "module-alias-ref", "alias")]
         elif 'file_name' in mod:
             menu.insert(0, jump_to_target_from_decl(jump_to_module_definition_menu_item, self.tree, mod))
         else:
             if 'file_name' in mod and 'def_file' in mod and mod['def_file'] == mod['file_name']:
                 menu.insert(0, jump_to_target_from_decl(jump_to_definition_menu_item, self.tree, mod))
             else:
                 menu.insert(0, jump_to_target_from_decl(jump_to_module_declaration_menu_item, self.tree, mod))
                 menu.insert(0, jump_to_module_definition_menu_item(self.tree, mod['def_file'], 1))
         menu.extend(generic_module_menu(mod, self.tree))
     elif typ:
         menu = [jump_to_target_from_decl(jump_to_definition_menu_item, self.tree, typ)]
         menu.extend(generic_type_menu(typ, self.tree))
     return menu
Exemplo n.º 2
0
 def menu_items(self):
     fn_def, fn_decl = self.menu_data
     menu = []
     if fn_def:
         menu.insert(0, jump_to_target_from_decl(jump_to_definition_menu_item, self.tree, fn_def))
         if fn_decl and (fn_def['file_name'] != fn_decl['file_name'] or fn_def['file_line'] != fn_decl['file_line']):
             menu.insert(0, jump_to_target_from_decl(jump_to_trait_method_menu_item, self.tree, fn_decl))
         menu.extend(generic_function_menu(fn_def['qualname'], self.tree))
     elif fn_decl:
         menu = generic_function_menu(fn_decl['qualname'], self.tree)
         menu.insert(0, jump_to_target_from_decl(jump_to_trait_method_menu_item, self.tree, fn_decl))
     return menu
Exemplo n.º 3
0
 def menu_items(self):
     datum, kind, aliased_datum = self.menu_data
     if not kind:
         return [
             find_references_menu_item(self.tree, datum['qualname'],
                                       "module-alias-ref", "alias")
         ]
     elif kind == 'modules':
         return [
             jump_to_module_definition_menu_item(self.tree,
                                                 aliased_datum['def_file'],
                                                 1),
             find_references_menu_item(aliased_datum, datum['qualname'],
                                       "module-alias-ref", "alias")
         ]
     elif kind == 'types':
         return [
             jump_to_target_from_decl(jump_to_type_declaration_menu_item,
                                      self.tree, aliased_datum),
             find_references_menu_item(self.tree, datum['qualname'],
                                       "type-ref", "alias")
         ]
     elif kind == 'variables':
         return [
             jump_to_target_from_decl(
                 jump_to_variable_declaration_menu_item, self.tree,
                 aliased_datum),
             find_references_menu_item(self.tree, datum['qualname'],
                                       "var-ref", "alias")
         ]
     elif kind == 'functions':
         return [
             jump_to_target_from_decl(
                 jump_to_function_declaration_menu_item, self.tree,
                 aliased_datum),
             find_references_menu_item(self.tree, datum['qualname'],
                                       "function-ref", "alias")
         ]
     elif kind == 'crate':
         return [
             jump_to_crate_menu_item(self.tree, aliased_datum['file_name'],
                                     1),
             find_references_menu_item(self.tree, datum['qualname'],
                                       "module-alias-ref", "alias")
         ]
     elif kind == 'urls':
         return std_lib_links_menu(aliased_datum)
     return []
Exemplo n.º 4
0
 def menu_items(self):
     menu = []
     if self.menu_data:
         menu.append(
             jump_to_target_from_decl(jump_to_definition_menu_item,
                                      self.tree, self.menu_data))
         menu.extend(generic_type_menu(self.menu_data, self.tree))
     return menu
Exemplo n.º 5
0
 def menu_items(self):
     if self.menu_data:
         menu = [
             jump_to_target_from_decl(jump_to_definition_menu_item,
                                      self.tree, self.menu_data)
         ]
         menu.extend(generic_variable_menu(self.menu_data, self.tree))
         return menu
     return []
Exemplo n.º 6
0
 def menu_items(self):
     # decl is only defined if datum is not a decl (i.e. we're looking at an impl).
     qualname, decl, count = self.menu_data
     menu = generic_function_menu(qualname, self.tree)
     if decl:
         menu.insert(0, jump_to_target_from_decl(jump_to_trait_method_menu_item, self.tree, decl))
     elif count:
         menu.append(trait_impl_menu_item(self.tree, qualname, count))
     return menu
Exemplo n.º 7
0
 def menu_items(self):
     # decl is only defined if datum is not a decl (i.e. we're looking at an impl).
     qualname, decl, count = self.menu_data
     menu = generic_function_menu(qualname, self.tree)
     if decl:
         menu.insert(
             0,
             jump_to_target_from_decl(jump_to_trait_method_menu_item,
                                      self.tree, decl))
     elif count:
         menu.append(trait_impl_menu_item(self.tree, qualname, count))
     return menu
Exemplo n.º 8
0
 def menu_items(self):
     fn_def, fn_decl = self.menu_data
     menu = []
     if fn_def:
         menu.insert(
             0,
             jump_to_target_from_decl(jump_to_definition_menu_item,
                                      self.tree, fn_def))
         if fn_decl and (fn_def['file_name'] != fn_decl['file_name']
                         or fn_def['file_line'] != fn_decl['file_line']):
             menu.insert(
                 0,
                 jump_to_target_from_decl(jump_to_trait_method_menu_item,
                                          self.tree, fn_decl))
         menu.extend(generic_function_menu(fn_def['qualname'], self.tree))
     elif fn_decl:
         menu = generic_function_menu(fn_decl['qualname'], self.tree)
         menu.insert(
             0,
             jump_to_target_from_decl(jump_to_trait_method_menu_item,
                                      self.tree, fn_decl))
     return menu
Exemplo n.º 9
0
 def menu_items(self):
     datum, kind, aliased_datum = self.menu_data
     if not kind:
         return [find_references_menu_item(self.tree, datum['qualname'], "module-alias-ref", "alias")]
     elif kind == 'modules':
         return [jump_to_module_definition_menu_item(self.tree, aliased_datum['def_file'], 1),
                 find_references_menu_item(aliased_datum, datum['qualname'], "module-alias-ref", "alias")]
     elif kind == 'types':
         return [jump_to_target_from_decl(jump_to_type_declaration_menu_item, self.tree, aliased_datum),
                 find_references_menu_item(self.tree, datum['qualname'], "type-ref", "alias")]
     elif kind == 'variables':
         return [jump_to_target_from_decl(jump_to_variable_declaration_menu_item, self.tree, aliased_datum),
                 find_references_menu_item(self.tree, datum['qualname'], "var-ref", "alias")]
     elif kind == 'functions':
         return [jump_to_target_from_decl(jump_to_function_declaration_menu_item, self.tree, aliased_datum),
                 find_references_menu_item(self.tree, datum['qualname'], "function-ref", "alias")]
     elif kind == 'crate':
         return [jump_to_crate_menu_item(self.tree, aliased_datum['file_name'], 1),
                 find_references_menu_item(self.tree, datum['qualname'], "module-alias-ref", "alias")]
     elif kind == 'urls':
         return std_lib_links_menu(aliased_datum)
     return []
Exemplo n.º 10
0
 def menu_items(self):
     # self.menu_data comes in the way of [datum, mod, alias,
     # secondary_datum, type_datum], where (mod, alias, secondary_datum)
     # and type_datum are mutually exclusive.
     datum, mod, alias, crate, urls, typ = self.menu_data
     menu = []
     if mod:
         if 'file_name' in mod:
             menu.append(
                 jump_to_target_from_decl(
                     jump_to_alias_definition_menu_item, self.tree, mod))
         if crate:
             # Add references to extern mods via aliases (known local crates)
             menu.append(
                 jump_to_crate_menu_item(self.tree, crate['file_name'], 1))
             menu.append(
                 find_references_menu_item(self.tree, alias['qualname'],
                                           "module-alias-ref", "alias"))
         if urls:
             # Add references to extern mods via aliases (standard library crates)
             menu = [
                 find_references_menu_item(self.tree, alias['qualname'],
                                           "module-alias-ref", "alias")
             ]
             menu.extend(std_lib_links_menu(urls))
         elif alias and 'location' in alias:
             # Add references to extern mods via aliases (unknown local crates)
             menu = [
                 find_references_menu_item(self.tree, alias['qualname'],
                                           "module-alias-ref", "alias")
             ]
         elif 'file_name' in mod:
             menu.insert(
                 0,
                 jump_to_target_from_decl(
                     jump_to_module_definition_menu_item, self.tree, mod))
         else:
             if 'file_name' in mod and 'def_file' in mod and mod[
                     'def_file'] == mod['file_name']:
                 menu.insert(
                     0,
                     jump_to_target_from_decl(jump_to_definition_menu_item,
                                              self.tree, mod))
             else:
                 menu.insert(
                     0,
                     jump_to_target_from_decl(
                         jump_to_module_declaration_menu_item, self.tree,
                         mod))
                 menu.insert(
                     0,
                     jump_to_module_definition_menu_item(
                         self.tree, mod['def_file'], 1))
         menu.extend(generic_module_menu(mod, self.tree))
     elif typ:
         menu = [
             jump_to_target_from_decl(jump_to_definition_menu_item,
                                      self.tree, typ)
         ]
         menu.extend(generic_type_menu(typ, self.tree))
     return menu
Exemplo n.º 11
0
 def menu_items(self):
     menu = []
     if self.menu_data:
         menu.append(jump_to_target_from_decl(jump_to_definition_menu_item, self.tree, self.menu_data))
         menu.extend(generic_type_menu(self.menu_data, self.tree))
     return menu
Exemplo n.º 12
0
 def menu_items(self):
     if self.menu_data:
         menu = [jump_to_target_from_decl(jump_to_definition_menu_item, self.tree, self.menu_data)]
         menu.extend(generic_variable_menu(self.menu_data, self.tree))
         return menu
     return []