Example #1
0
    def do_it(cursor, result):

        class Reference(object):
            def __init__(self, referenced_range, referencing_range):
                self.referenced_range = referenced_range
                self.referencing_range = referencing_range

        referenced_cursor = get_definition_or_reference(cursor)
        if referenced_cursor:
            if not intersects_with_selection(referenced_cursor):
                # Limit the extent to start at the name
                constrained_extent = SourceRange.from_locations(
                    referenced_cursor.location,
                    referenced_cursor.extent.end)
                result.add(Reference(
                           constrained_extent,
                           cursor.extent))

        for child in cursor.get_children():
            if intersects_with_selection(child):
                do_it(child, result)
Example #2
0
 def _find_definition_in_translation_unit(self, translation_unit, location):
     cursor = clang.cindex.Cursor.from_location(translation_unit, location)
     if cursor.kind.is_unexposed:
         self._editor.display_message("Item at current location is not exposed. Cursor kind: " + str(cursor.kind))
     return get_definition_or_reference(cursor)