Example #1
0
File: menus.py Project: nbstar/dxr
def type_menu(tree, type):
    """Return menu for type reference."""
    qualname, kind = type['qualname'], type.get('kind')
    menu = [{'html': "Find declarations",
             'title': "Find declarations of this class",
             'href': search_url(tree, "+type-decl:%s" % quote(qualname)),
             'icon': 'reference'}]
    if kind == 'class' or kind == 'struct':
        menu.append({'html': "Find subclasses",
                     'title': "Find subclasses of this class",
                     'href': search_url(tree, "+derived:%s" % quote(qualname)),
                     'icon': 'type'})
        menu.append({'html': "Find base classes",
                     'title': "Find base classes of this class",
                     'href': search_url(tree, "+bases:%s" % quote(qualname)),
                     'icon': 'type'})
    menu.append({'html': "Find members",
                 'title': "Find members of this class",
                 'href': search_url(tree, "+member:%s" % quote(qualname)),
                 'icon': 'members'})
    menu.append({'html': "Find references",
                 'title': "Find references to this class",
                 'href': search_url(tree, "+type-ref:%s" % quote(qualname)),
                 'icon': 'reference'})
    return menu
Example #2
0
File: menus.py Project: nbstar/dxr
def function_menu(tree, func):
    """Build menu for a function."""
    qualname = func['qualname']
    isvirtual = 'override' in func
    # Things we can do with qualified name
    menu = [{'html': "Find declarations",
             'title': "Find declarations of this function",
             'href': search_url(tree, "+function-decl:%s" % quote(qualname)),
             'icon': 'reference'},
            {'html': "Find callers",
             'title': "Find functions that call this function",
             'href': search_url(tree, "+callers:%s" % quote(qualname)),
             'icon': 'method'},
            {'html': "Find references",
             'title': "Find references to this function",
             'href': search_url(tree, "+function-ref:%s" % quote(qualname)),
             'icon': 'reference'}]
    if isvirtual:
        menu.append({'html': "Find overridden",
                     'title': "Find functions that this function overrides",
                     'href': search_url(tree, "+overridden:%s" % quote(qualname)),
                     'icon': 'method'})
        menu.append({'html': "Find overrides",
                     'title': "Find overrides of this function",
                     'href': search_url(tree, "+overrides:%s" % quote(qualname)),
                     'icon': 'method'})
    return menu
Example #3
0
def function_menu_generic(tree, datum, tree_config):
    menu = []
    menu.append({
        'html':
        "Find callers",
        'title':
        "Find functions that call this function",
        'href':
        search_url(tree_config, "+callers:%s" % quote(datum['qualname'])),
        'icon':
        'method'
    })
    menu.append({
        'html':
        "Find callees",
        'title':
        "Find functions that are called by this function",
        'href':
        search_url(tree_config, "+called-by:%s" % quote(datum['qualname'])),
        'icon':
        'method'
    })
    add_find_references(tree_config, menu, datum['qualname'], "function-ref",
                        "function")
    return menu
Example #4
0
def type_menu(tree, type):
    """Return menu for type reference."""
    qualname, kind = type['qualname'], type.get('kind')
    menu = [{
        'html': "Find declarations",
        'title': "Find declarations of this class",
        'href': search_url(tree, "+type-decl:%s" % quote(qualname)),
        'icon': 'reference'
    }]
    if kind == 'class' or kind == 'struct':
        menu.append({
            'html': "Find subclasses",
            'title': "Find subclasses of this class",
            'href': search_url(tree, "+derived:%s" % quote(qualname)),
            'icon': 'type'
        })
        menu.append({
            'html': "Find base classes",
            'title': "Find base classes of this class",
            'href': search_url(tree, "+bases:%s" % quote(qualname)),
            'icon': 'type'
        })
    menu.append({
        'html': "Find members",
        'title': "Find members of this class",
        'href': search_url(tree, "+member:%s" % quote(qualname)),
        'icon': 'members'
    })
    menu.append({
        'html': "Find references",
        'title': "Find references to this class",
        'href': search_url(tree, "+type-ref:%s" % quote(qualname)),
        'icon': 'reference'
    })
    return menu
Example #5
0
File: menus.py Project: bitslab/dxr
 def _more_menu_items(self):
     qualname, has_overriddens, has_overrides = self.menu_data[1:]
     qualname = quote(qualname)
     tree = self.tree.name
     yield {'html': "Find declarations",
            'title': "Find declarations of this function",
            'href': search_url(tree, "+function-decl:%s" % qualname),
            'icon': 'reference'}
     yield {'html': "Find callers",
            'title': "Find functions that call this function",
            'href': search_url(tree, "+callers:%s" % qualname),
            'icon': 'method'}
     yield {'html': "Find references",
            'title': "Find references to this function",
            'href': search_url(tree, "+function-ref:%s" % qualname),
            'icon': 'reference'}
     if has_overriddens:
         yield {'html': "Find overridden",
                'title': "Find functions that this function overrides",
                'href': search_url(tree, "+overridden:%s" % qualname),
                'icon': 'method'}
     if has_overrides:
         yield {'html': "Find overrides",
                'title': "Find overrides of this function",
                'href': search_url(tree, "+overrides:%s" % qualname),
                'icon': 'method'}
Example #6
0
File: menu.py Project: nbstar/dxr
def type_menu_generic(tree, datum, tree_config):
    menu = []
    kind = datum['kind']
    if kind == 'trait':
        menu.append({
            'html':   "Find sub-traits",
            'title':  "Find sub-traits of this trait",
            'href':   search_url(tree_config, "+derived:%s" % quote(datum['qualname'])),
            'icon':   'type'
        })
        menu.append({
            'html':   "Find super-traits",
            'title':  "Find super-traits of this trait",
            'href':   search_url(tree_config, "+bases:%s" % quote(datum['qualname'])),
            'icon':   'type'
        })
    
    if kind == 'struct' or kind == 'enum' or kind == 'trait':
        menu.append({
            'html':   "Find impls",
            'title':  "Find impls which involve this " + kind,
            'href':   search_url(tree_config, "+impl:%s" % quote(datum['qualname'])),
            'icon':   'reference'
        })
    add_find_references(tree_config, menu, datum['qualname'], "type-ref", kind)
    return menu
Example #7
0
class FunctionRef(_RefWithDefinition):
    """Ref for function definitions or references"""
    @classmethod
    def _condensed_menu_data(cls, tree, prop):
        return prop[
            'qualname'], 'has_overriddens' in prop, 'has_overrides' in prop

    def _more_menu_items(self, (qualname, has_overriddens, has_overrides)):
        yield {
            'html':
            "Find declarations",
            'title':
            "Find declarations of this function",
            'href':
            search_url(self.tree.name, "+function-decl:%s" % quote(qualname)),
            'icon':
            'reference'
        }
        yield {
            'html': "Find callers",
            'title': "Find functions that call this function",
            'href': search_url(self.tree.name,
                               "+callers:%s" % quote(qualname)),
            'icon': 'method'
        }
        yield {
            'html':
            "Find references",
            'title':
            "Find references to this function",
            'href':
            search_url(self.tree.name, "+function-ref:%s" % quote(qualname)),
            'icon':
            'reference'
        }
        if has_overriddens:
            yield {
                'html':
                "Find overridden",
                'title':
                "Find functions that this function overrides",
                'href':
                search_url(self.tree.name, "+overridden:%s" % quote(qualname)),
                'icon':
                'method'
            }
        if has_overrides:
            yield {
                'html':
                "Find overrides",
                'title':
                "Find overrides of this function",
                'href':
                search_url(self.tree.name, "+overrides:%s" % quote(qualname)),
                'icon':
                'method'
            }
Example #8
0
File: menu.py Project: gartung/dxr
def call_menu(qualname, tree):
    return [{'html': "Find callers",
             'title': "Find functions that call this function",
             'href': search_url(tree, "+callers:%s" % quote(qualname)),
             'icon': 'method'},
            {'html': "Find callees",  # TODO: Probably useless. Remove.
             'title': "Find functions that are called by this function",
             'href': search_url(tree, "+called-by:%s" % quote(qualname)),
             'icon': 'method'}]
Example #9
0
File: menus.py Project: gartung/dxr
 def menu_items(self):
     qualname = self.menu_data
     yield {'html': 'Find subclasses',
            'title': 'Find subclasses of this class',
            'href': search_url(self.tree, '+derived:' + qualname),
            'icon': 'type'}
     yield {'html': 'Find base classes',
            'title': 'Find base classes of this class',
            'href': search_url(self.tree, '+bases:' + qualname),
            'icon': 'type'}
Example #10
0
class TypeRef(_QualnameRef):
    @classmethod
    def _condensed_menu_data(cls, tree, prop):
        return (super(TypeRef, cls)._condensed_menu_data(tree, prop) +
                (prop.get('kind', 'type'), 'has_subclass'
                 in prop, 'has_base_class' in prop))

    def _more_menu_items(self, (qualname, kind, has_subclass, has_base_class)):
        """Return menu for type reference."""
        def kind_plural():
            if kind == 'class':
                return 'classes'
            elif kind == 'struct':
                return 'structs'
            else:
                return 'types'

        yield {
            'html': "Find declarations",
            'title': "Find declarations of this %s" % kind,
            'href': search_url(self.tree.name,
                               "+type-decl:%s" % quote(qualname)),
            'icon': 'reference'
        }
        if has_subclass:
            kinds = kind_plural()
            yield {
                'html': "Find sub%s" % kinds,
                'title': "Find sub%s of this %s" % (kinds, kind),
                'href': search_url(self.tree.name,
                                   "+derived:%s" % quote(qualname)),
                'icon': 'type'
            }
        if has_base_class:
            kinds = kind_plural()
            yield {
                'html': "Find base %s" % kinds,
                'title': "Find base %s of this %s" % (kinds, kind),
                'href': search_url(self.tree.name,
                                   "+bases:%s" % quote(qualname)),
                'icon': 'type'
            }
        yield {
            'html': "Find members",
            'title': "Find members of this %s" % kind,
            'href': search_url(self.tree.name, "+member:%s" % quote(qualname)),
            'icon': 'members'
        }
        yield {
            'html': "Find references",
            'title': "Find references to this %s" % kind,
            'href': search_url(self.tree.name,
                               "+type-ref:%s" % quote(qualname)),
            'icon': 'reference'
        }
Example #11
0
File: menus.py Project: nbstar/dxr
def variable_menu(tree, variable):
    """Build menu for a variable."""
    qualname = variable['qualname']
    return [{'html': "Find declarations",
             'title': "Find declarations of this variable",
             'href': search_url(tree, "+var-decl:%s" % quote(qualname)),
             'icon': 'reference'},
            {'html': "Find references",
             'title': "Find reference to this variable",
             'href': search_url(tree, "+var-ref:%s" % quote(qualname)),
             'icon': 'field'}]
Example #12
0
File: menus.py Project: nbstar/dxr
def namespace_menu(tree, namespace):
    """Build menu for a namespace."""
    qualname = namespace['qualname']
    return [{'html': "Find definitions",
             'title': "Find definitions of this namespace",
             'href': search_url(tree, "+namespace:%s" % quote(qualname)),
             'icon': 'jump'},
            {'html': "Find references",
             'title': "Find references to this namespace",
             'href': search_url(tree, "+namespace-ref:%s" % quote(qualname)),
             'icon': 'reference'}]
Example #13
0
File: menus.py Project: nbstar/dxr
def class_menu(tree, qualname):
    """Generate menu for a class definition."""
    return [
        {'html': 'Find subclasses',
         'title': 'Find subclasses of this class',
         'href': search_url(tree, '+derived:' + qualname),
         'icon': 'type'},
        {'html': 'Find base classes',
         'title': 'Find base classes of this class',
         'href': search_url(tree, '+bases:' + qualname),
         'icon': 'type'},
    ]
Example #14
0
 def menu_items(self):
     qualname = self.menu_data
     yield {
         "html": "Find subclasses",
         "title": "Find subclasses of this class",
         "href": search_url(self.tree.name, "+derived:" + qualname),
         "icon": "type",
     }
     yield {
         "html": "Find base classes",
         "title": "Find base classes of this class",
         "href": search_url(self.tree.name, "+bases:" + qualname),
         "icon": "type",
     }
Example #15
0
def variable_menu(tree, variable):
    """Build menu for a variable."""
    qualname = variable['qualname']
    return [{
        'html': "Find declarations",
        'title': "Find declarations of this variable",
        'href': search_url(tree, "+var-decl:%s" % quote(qualname)),
        'icon': 'reference'
    }, {
        'html': "Find references",
        'title': "Find reference to this variable",
        'href': search_url(tree, "+var-ref:%s" % quote(qualname)),
        'icon': 'field'
    }]
Example #16
0
 def menu_items(self):
     qualname = self.menu_data
     yield {
         'html': 'Find subclasses',
         'title': 'Find subclasses of this class',
         'href': search_url(self.tree.name, '+derived:' + qualname),
         'icon': 'type'
     }
     yield {
         'html': 'Find base classes',
         'title': 'Find base classes of this class',
         'href': search_url(self.tree.name, '+bases:' + qualname),
         'icon': 'type'
     }
Example #17
0
def namespace_menu(tree, namespace):
    """Build menu for a namespace."""
    qualname = namespace['qualname']
    return [{
        'html': "Find definitions",
        'title': "Find definitions of this namespace",
        'href': search_url(tree, "+namespace:%s" % quote(qualname)),
        'icon': 'jump'
    }, {
        'html': "Find references",
        'title': "Find references to this namespace",
        'href': search_url(tree, "+namespace-ref:%s" % quote(qualname)),
        'icon': 'reference'
    }]
Example #18
0
File: menu.py Project: gartung/dxr
def type_menu(tree_config, kind, qualname):
    if kind == 'trait':
        yield {'html': "Find sub-traits",
               'title': "Find sub-traits of this trait",
               'href': search_url(tree_config, "+derived:%s" % quote(qualname)),
               'icon': 'type'}
        yield {'html': "Find super-traits",
               'title': "Find super-traits of this trait",
               'href': search_url(tree_config, "+bases:%s" % quote(qualname)),
               'icon': 'type'}
    if kind == 'struct' or kind == 'enum' or kind == 'trait':
        yield {'html': "Find impls",
               'title': "Find impls which involve this " + kind,
               'href': search_url(tree_config, "+impl:%s" % quote(qualname)),
               'icon': 'reference'}
Example #19
0
def function_menu(tree, datum, tree_config):
    menu = function_menu_generic(tree, datum, tree_config)

    if 'declid' in datum and datum['declid'] in tree.data.functions:
        # it's an implementation, find the decl
        decl = tree.data.functions[datum['declid']]
        add_jump_definition(tree, tree_config, menu, decl,
                            "Jump to trait method")
    else:
        # it's a decl, find implementations
        impls = tree.data.index('functions', 'declid')
        count = len(impls[datum['id']]) if datum['id'] in impls else 0
        if count > 0:
            menu.append({
                'html':
                "Find implementations (%d)" % count,
                'title':
                "Find implementations of this trait method",
                'href':
                search_url(tree_config,
                           "+fn-impls:%s" % quote(datum['qualname'])),
                'icon':
                'method'
            })

    return Ref(menu)
Example #20
0
File: menus.py Project: mcphail/dxr
def class_menu(tree, qualname):
    """Generate menu for a class definition."""
    return [
        {
            'html': 'Find subclasses',
            'title': 'Find subclasses of this class',
            'href': search_url(tree, '+derived:' + qualname),
            'icon': 'type'
        },
        {
            'html': 'Find base classes',
            'title': 'Find base classes of this class',
            'href': search_url(tree, '+bases:' + qualname),
            'icon': 'type'
        },
    ]
Example #21
0
File: menus.py Project: nbstar/dxr
def typedef_menu(tree, typedef):
    """Build menu for typedef."""
    qualname = typedef['qualname']
    return [{'html': "Find references",
             'title': "Find references to this typedef",
             'href': search_url(tree, "+type-ref:%s" % quote(qualname)),
             'icon': 'reference'}]
Example #22
0
 def test_search_url(self):
     """Test unicode of various widths, slashes, and spaces."""
     with self.app().test_request_context():
         eq_(
             search_url(u'tr éé', u'ev il:searcheß/ªre/bes†'),
             '/tr%20%C3%A9%C3%A9/search?q=ev+il%3Asearche%C3%9F%2F%C2%AAre%2Fbes%E2%80%A0'
         )
Example #23
0
File: menus.py Project: nbstar/dxr
def macro_menu(tree, macro):
    """Return menu for macro reference."""
    name = macro['name']
    return [{'html': "Find references",
             'title': "Find references to macros with this name",
             'href': search_url(tree, "+macro-ref:%s" % name),
             'icon': 'reference'}]
Example #24
0
File: menus.py Project: nbstar/dxr
def namespace_alias_menu(tree, namespace_alias):
    """Build menu for a namespace."""
    qualname = namespace_alias['qualname']
    return [{'html': "Find references",
             'title': "Find references to this namespace alias",
             'href': search_url(tree, "+namespace-alias-ref:%s" % quote(qualname)),
             'icon': 'reference'}]
Example #25
0
class VariableRef(_QualnameRef):
    def _more_menu_items(self, (qualname, )):
        yield {
            'html': "Find declarations",
            'title': "Find declarations of this variable",
            'href': search_url(self.tree.name,
                               "+var-decl:%s" % quote(qualname)),
            'icon': 'reference'
        }
        yield {
            'html': "Find references",
            'title': "Find reference to this variable",
            'href': search_url(self.tree.name,
                               "+var-ref:%s" % quote(qualname)),
            'icon': 'field'
        }
Example #26
0
def trait_impl_menu_item(tree_config, qualname, count):
    return {
        'html': "Find implementations (%d)" % count,
        'title': "Find implementations of this trait method",
        'href': search_url(tree_config.name, "+fn-impls:%s" % quote(qualname)),
        'icon': 'method'
    }
Example #27
0
File: menu.py Project: nbstar/dxr
def function_menu_generic(tree, datum, tree_config):
    menu = []
    menu.append({
        'html':   "Find callers",
        'title':  "Find functions that call this function",
        'href':   search_url(tree_config, "+callers:%s" % quote(datum['qualname'])),
        'icon':   'method'
    })
    menu.append({
        'html':   "Find callees",
        'title':  "Find functions that are called by this function",
        'href':   search_url(tree_config, "+called-by:%s" % quote(datum['qualname'])),
        'icon':   'method'
    })
    add_find_references(tree_config, menu, datum['qualname'], "function-ref", "function")
    return menu
Example #28
0
File: menu.py Project: bozzmob/dxr
def trait_impl_menu_item(tree_config, qualname, count):
    return {
        "html": "Find implementations (%d)" % count,
        "title": "Find implementations of this trait method",
        "href": search_url(tree_config, "+fn-impls:%s" % quote(qualname)),
        "icon": "method",
    }
Example #29
0
def call_menu(qualname, tree):
    return [{
        'html': "Find callers",
        'title': "Find calls of this function",
        'href': search_url(tree.name, "+callers:%s" % quote(qualname)),
        'icon': 'method'
    }]
Example #30
0
File: menu.py Project: bozzmob/dxr
def use_items_menu_item(tree_config, qualname):
    return {
        "html": "Find use items",
        "title": "Find instances of this module in 'use' items",
        "href": search_url(tree_config, "+module-use:%s" % quote(qualname)),
        "icon": "reference",
    }
Example #31
0
File: menu.py Project: nbstar/dxr
def add_find_references(tree_config, menu, qualname, search_term, kind):
    menu.append({
        'html':   "Find references",
        'title':  "Find references to this " + kind,
        'href':   search_url(tree_config, "+" + search_term + ":%s" % quote(qualname)),
        'icon':   'reference'
    })
Example #32
0
 def filtered_search_menu(self, filter_name, name, html='Find declaration',
                          title='Search for declarations.', icon='class'):
     return {
         'html': html,
         'title': title,
         'href': search_url(self.tree, '%s:%s' % (filter_name, name)),
         'icon': icon
     }
Example #33
0
def use_items_menu_item(tree_config, qualname):
    return {
        'html': "Find use items",
        'title': "Find instances of this module in 'use' items",
        'href': search_url(tree_config.name,
                           "+module-use:%s" % quote(qualname)),
        'icon': 'reference'
    }
Example #34
0
def filtered_search_menu(tree, term, html, title, filter_name, icon):
    """Return a menu for searching in given tree for a specific term using a filter."""

    return {
        'html': html,
        'title': title,
        'href': search_url(tree.name, '%s:%s' % (filter_name, term)),
        'icon': icon
    }
Example #35
0
def macro_menu(tree, macro):
    """Return menu for macro reference."""
    name = macro['name']
    return [{
        'html': "Find references",
        'title': "Find references to macros with this name",
        'href': search_url(tree, "+macro-ref:%s" % name),
        'icon': 'reference'
    }]
Example #36
0
File: menu.py Project: bozzmob/dxr
def call_menu(qualname, tree):
    return [
        {
            "html": "Find callers",
            "title": "Find calls of this function",
            "href": search_url(tree, "+callers:%s" % quote(qualname)),
            "icon": "method",
        }
    ]
Example #37
0
class TypedefRef(_QualnameRef):
    def _more_menu_items(self, (qualname, )):
        yield {
            'html': "Find references",
            'title': "Find references to this typedef",
            'href': search_url(self.tree.name,
                               "+type-ref:%s" % quote(qualname)),
            'icon': 'reference'
        }
Example #38
0
def filtered_search_menu(tree, term, html, title, filter_name, icon):
    """Return a menu for searching in given tree for a specific term using a filter."""

    return {
        'html': html,
        'title': title,
        'href': search_url(tree.name, '%s:%s' % (filter_name, term)),
        'icon': icon
    }
Example #39
0
def typedef_menu(tree, typedef):
    """Build menu for typedef."""
    qualname = typedef['qualname']
    return [{
        'html': "Find references",
        'title': "Find references to this typedef",
        'href': search_url(tree, "+type-ref:%s" % quote(qualname)),
        'icon': 'reference'
    }]
Example #40
0
class TypeRef(_QualnameRef):
    @classmethod
    def _condensed_menu_data(cls, tree, prop):
        """Hang onto qualname *and* kind."""
        return (super(TypeRef, cls)._condensed_menu_data(tree, prop) +
                (prop.get('kind', ''), ))

    def _more_menu_items(self, (qualname, kind)):
        """Return menu for type reference."""
        yield {
            'html': "Find declarations",
            'title': "Find declarations of this class",
            'href': search_url(self.tree.name,
                               "+type-decl:%s" % quote(qualname)),
            'icon': 'reference'
        }
        if kind == 'class' or kind == 'struct':
            yield {
                'html': "Find subclasses",
                'title': "Find subclasses of this class",
                'href': search_url(self.tree.name,
                                   "+derived:%s" % quote(qualname)),
                'icon': 'type'
            }
            yield {
                'html': "Find base classes",
                'title': "Find base classes of this class",
                'href': search_url(self.tree.name,
                                   "+bases:%s" % quote(qualname)),
                'icon': 'type'
            }
        yield {
            'html': "Find members",
            'title': "Find members of this class",
            'href': search_url(self.tree.name, "+member:%s" % quote(qualname)),
            'icon': 'members'
        }
        yield {
            'html': "Find references",
            'title': "Find references to this class",
            'href': search_url(self.tree.name,
                               "+type-ref:%s" % quote(qualname)),
            'icon': 'reference'
        }
Example #41
0
File: menu.py Project: nbstar/dxr
def module_menu_generic(tree, datum, tree_config):
    menu = []
    menu.append({
        'html':   "Find use items",
        'title':  "Find instances of this module in 'use' items",
        'href':   search_url(tree_config, "+module-use:%s" % quote(datum['qualname'])),
        'icon':   'reference'
    })
    add_find_references(tree_config, menu, datum['qualname'], "module-ref", "module")
    return menu
Example #42
0
class NamespaceRef(_QualnameRef):
    def _more_menu_items(self, (qualname, )):
        yield {
            'html': "Find definitions",
            'title': "Find definitions of this namespace",
            'href': search_url(self.tree.name,
                               "+namespace:%s" % quote(qualname)),
            'icon': 'jump'
        }
        yield {
            'html':
            "Find references",
            'title':
            "Find references to this namespace",
            'href':
            search_url(self.tree.name, "+namespace-ref:%s" % quote(qualname)),
            'icon':
            'reference'
        }
Example #43
0
def add_find_references(tree_config, menu, qualname, search_term, kind):
    menu.append({
        'html':
        "Find references",
        'title':
        "Find references to this " + kind,
        'href':
        search_url(tree_config, "+" + search_term + ":%s" % quote(qualname)),
        'icon':
        'reference'
    })
Example #44
0
File: menu.py Project: gartung/dxr
def find_references_menu_item(tree_config, qualname, filter_name, kind):
    """A sort of compound menu that handles finding various sorts of
    references

    Should be broken into several.

    """
    return {'html':   "Find references",
            'title':  "Find references to this " + kind,
            'href':   search_url(tree_config, "+" + filter_name + ":%s" % quote(qualname)),
            'icon':   'reference'}
Example #45
0
 def menu_items(self):
     qualname, name, typename = self.menu_data
     for text, filtername, title, icon in [
         ("Find definition of %s %s" % (typename, name), "id", "Find definition", "class"),
         ("Find references to %s %s" % (typename, name), "ref", "Find references", "method"),
     ]:
         yield {
             "html": text,
             "title": title,
             "href": search_url(self.tree.name, '+%s:"%s"' % (filtername, qualname)),
             "icon": icon,
         }
Example #46
0
File: menu.py Project: bozzmob/dxr
def type_menu(tree_config, kind, qualname):
    if kind == "trait":
        yield {
            "html": "Find sub-traits",
            "title": "Find sub-traits of this trait",
            "href": search_url(tree_config, "+derived:%s" % quote(qualname)),
            "icon": "type",
        }
        yield {
            "html": "Find super-traits",
            "title": "Find super-traits of this trait",
            "href": search_url(tree_config, "+bases:%s" % quote(qualname)),
            "icon": "type",
        }
    if kind == "struct" or kind == "enum" or kind == "trait":
        yield {
            "html": "Find impls",
            "title": "Find impls which involve this " + kind,
            "href": search_url(tree_config, "+impl:%s" % quote(qualname)),
            "icon": "reference",
        }
Example #47
0
File: menu.py Project: bozzmob/dxr
def find_references_menu_item(tree_config, qualname, filter_name, kind):
    """A sort of compound menu that handles finding various sorts of
    references

    Should be broken into several.

    """
    return {
        "html": "Find references",
        "title": "Find references to this " + kind,
        "href": search_url(tree_config, "+" + filter_name + ":%s" % quote(qualname)),
        "icon": "reference",
    }
Example #48
0
File: menus.py Project: bitslab/dxr
 def menu_items(self):
     search_for_def, qualname = self.menu_data[:2]
     if search_for_def:
         menu = [{'html': "Jump to definition",
                  'title': "Jump to definition",
                  'href': '%s&%s' % (search_url(self.tree.name,
                                                '+function:%s' % quote(qualname)),
                                     'redirect=true'),
                  'icon': 'jump'}]
     else:
         menu = []
     menu.extend(self._more_menu_items())
     return menu
Example #49
0
def function_menu(tree, func):
    """Build menu for a function."""
    qualname = func['qualname']
    isvirtual = 'override' in func
    # Things we can do with qualified name
    menu = [{
        'html': "Find declarations",
        'title': "Find declarations of this function",
        'href': search_url(tree, "+function-decl:%s" % quote(qualname)),
        'icon': 'reference'
    }, {
        'html': "Find callers",
        'title': "Find functions that call this function",
        'href': search_url(tree, "+callers:%s" % quote(qualname)),
        'icon': 'method'
    }, {
        'html': "Find references",
        'title': "Find references to this function",
        'href': search_url(tree, "+function-ref:%s" % quote(qualname)),
        'icon': 'reference'
    }]
    if isvirtual:
        menu.append({
            'html':
            "Find overridden",
            'title':
            "Find functions that this function overrides",
            'href':
            search_url(tree, "+overridden:%s" % quote(qualname)),
            'icon':
            'method'
        })
        menu.append({
            'html': "Find overrides",
            'title': "Find overrides of this function",
            'href': search_url(tree, "+overrides:%s" % quote(qualname)),
            'icon': 'method'
        })
    return menu
Example #50
0
def namespace_alias_menu(tree, namespace_alias):
    """Build menu for a namespace."""
    qualname = namespace_alias['qualname']
    return [{
        'html':
        "Find references",
        'title':
        "Find references to this namespace alias",
        'href':
        search_url(tree, "+namespace-alias-ref:%s" % quote(qualname)),
        'icon':
        'reference'
    }]
Example #51
0
def type_menu_generic(tree, datum, tree_config):
    menu = []
    kind = datum['kind']
    if kind == 'trait':
        menu.append({
            'html':
            "Find sub-traits",
            'title':
            "Find sub-traits of this trait",
            'href':
            search_url(tree_config, "+derived:%s" % quote(datum['qualname'])),
            'icon':
            'type'
        })
        menu.append({
            'html':
            "Find super-traits",
            'title':
            "Find super-traits of this trait",
            'href':
            search_url(tree_config, "+bases:%s" % quote(datum['qualname'])),
            'icon':
            'type'
        })

    if kind == 'struct' or kind == 'enum' or kind == 'trait':
        menu.append({
            'html':
            "Find impls",
            'title':
            "Find impls which involve this " + kind,
            'href':
            search_url(tree_config, "+impl:%s" % quote(datum['qualname'])),
            'icon':
            'reference'
        })
    add_find_references(tree_config, menu, datum['qualname'], "type-ref", kind)
    return menu
Example #52
0
def type_menu(tree_config, kind, qualname):
    if kind == 'trait':
        yield {
            'html': "Find sub-traits",
            'title': "Find sub-traits of this trait",
            'href': search_url(tree_config.name,
                               "+derived:%s" % quote(qualname)),
            'icon': 'type'
        }
        yield {
            'html': "Find super-traits",
            'title': "Find super-traits of this trait",
            'href': search_url(tree_config.name,
                               "+bases:%s" % quote(qualname)),
            'icon': 'type'
        }
    if kind == 'struct' or kind == 'enum' or kind == 'trait':
        yield {
            'html': "Find impls",
            'title': "Find impls which involve this " + kind,
            'href': search_url(tree_config.name, "+impl:%s" % quote(qualname)),
            'icon': 'reference'
        }
Example #53
0
class NamespaceAliasRef(_QualnameRef):
    def _more_menu_items(self, (qualname, )):
        """Build menu for a namespace."""
        yield {
            'html':
            "Find references",
            'title':
            "Find references to this namespace alias",
            'href':
            search_url(self.tree.name,
                       "+namespace-alias-ref:%s" % quote(qualname)),
            'icon':
            'reference'
        }
Example #54
0
def module_menu_generic(tree, datum, tree_config):
    menu = []
    menu.append({
        'html':
        "Find use items",
        'title':
        "Find instances of this module in 'use' items",
        'href':
        search_url(tree_config, "+module-use:%s" % quote(datum['qualname'])),
        'icon':
        'reference'
    })
    add_find_references(tree_config, menu, datum['qualname'], "module-ref",
                        "module")
    return menu
Example #55
0
 def _more_menu_items(self):
     qualname, has_overriddens, has_overrides = self.menu_data[1:]
     qualname = quote(qualname)
     tree = self.tree.name
     yield {
         'html': "Find declarations",
         'title': "Find declarations of this function",
         'href': search_url(tree, "+function-decl:%s" % qualname),
         'icon': 'reference'
     }
     yield {
         'html': "Find callers",
         'title': "Find functions that call this function",
         'href': search_url(tree, "+callers:%s" % qualname),
         'icon': 'method'
     }
     yield {
         'html': "Find references",
         'title': "Find references to this function",
         'href': search_url(tree, "+function-ref:%s" % qualname),
         'icon': 'reference'
     }
     if has_overriddens:
         yield {
             'html': "Find overridden",
             'title': "Find functions that this function overrides",
             'href': search_url(tree, "+overridden:%s" % qualname),
             'icon': 'method'
         }
     if has_overrides:
         yield {
             'html': "Find overrides",
             'title': "Find overrides of this function",
             'href': search_url(tree, "+overrides:%s" % qualname),
             'icon': 'method'
         }
Example #56
0
 def menu_items(self):
     search_for_def, qualname = self.menu_data[:2]
     if search_for_def:
         menu = [{
             'html':
             "Jump to definition",
             'title':
             "Jump to definition",
             'href':
             '%s&%s' % (search_url(self.tree.name, '+function:%s' %
                                   quote(qualname)), 'redirect=true'),
             'icon':
             'jump'
         }]
     else:
         menu = []
     menu.extend(self._more_menu_items())
     return menu
Example #57
0
File: menu.py Project: nbstar/dxr
def function_menu(tree, datum, tree_config):
    menu = function_menu_generic(tree, datum, tree_config)

    if 'declid' in datum and datum['declid'] in tree.data.functions:
        # it's an implementation, find the decl
        decl = tree.data.functions[datum['declid']]
        add_jump_definition(tree, tree_config, menu, decl, "Jump to trait method")
    else:
        # it's a decl, find implementations
        impls = tree.data.index('functions', 'declid')
        count = len(impls[datum['id']]) if datum['id'] in impls else 0
        if count > 0:
            menu.append({
                'html':   "Find implementations (%d)"%count,
                'title':  "Find implementations of this trait method",
                'href':   search_url(tree_config, "+fn-impls:%s" % quote(datum['qualname'])),
                'icon':   'method'
            })

    return Ref(menu)
Example #58
0
 def search(self, query):
     """ Auxiliary function for getting the search url for query """
     return search_url(self.tree.config.wwwroot,
                       self.tree.name,
                       query)
Example #59
0
File: menu.py Project: gartung/dxr
def use_items_menu_item(tree_config, qualname):
    return {'html': "Find use items",
            'title': "Find instances of this module in 'use' items",
            'href': search_url(tree_config, "+module-use:%s" % quote(qualname)),
            'icon': 'reference'}
Example #60
0
File: menu.py Project: gartung/dxr
def trait_impl_menu_item(tree_config, qualname, count):
    return {'html': "Find implementations (%d)" % count,
            'title': "Find implementations of this trait method",
            'href': search_url(tree_config, "+fn-impls:%s" % quote(qualname)),
            'icon': 'method'}