Exemple #1
0
class _FileMatcher(object):

    def __init__(self, files):
        self.matcher = HelperMatcher(files, _DoesFileMatch())
        self.slash_count = 0

    def find_matches(self, starting):
        slash_count = starting.count('/')
        if slash_count != self.slash_count:
            self.matcher.invalidate()
            self.slash_count = slash_count
        return self.matcher.find_matches(starting)
class FindTypeHandle(uihelpers.FindItemHandle):

    def __init__(self, context):
        self.core = context.core
        self.pycore = context.project.get_pycore()
        self.matcher = None

    def find_matches(self, starting):
        """Returns the Files in the project whose names starts with starting"""
        if self.matcher is None:
            @simple_stoppable('Finding Classes')
            def calculate(handle):
                return self.pycore.get_classes(handle)
            types = list(calculate())
            types.sort(cmp=self._compare_types)
            self.matcher = HelperMatcher(types, DoesMatch(self._to_search_text))
        return self.matcher.find_matches(starting)

    def _to_search_text(self, entry):
        return entry.get_name()

    def selected(self, pyclass):
        editor_manager = self.core.get_editor_manager()
        pymodule = pyclass.get_module()
        file_editor = editor_manager.get_resource_editor(
            pymodule.get_resource())
        file_editor.get_editor().goto_line(pyclass.get_ast().lineno)

    def to_string(self, pyclass):
        return '%s: %s' % (pyclass.get_module().get_resource().path,
                           pyclass.get_name())

    def _compare_types(self, type1, type2):
        return cmp(type1.get_name(), type2.get_name())
 def find_matches(self, starting):
     """Returns the Files in the project whose names starts with starting"""
     if self.matcher is None:
         @simple_stoppable('Finding Classes')
         def calculate(handle):
             return self.pycore.get_classes(handle)
         types = list(calculate())
         types.sort(cmp=self._compare_types)
         self.matcher = HelperMatcher(types, DoesMatch(self._to_search_text))
     return self.matcher.find_matches(starting)
Exemple #4
0
 def __init__(self, files):
     self.matcher = HelperMatcher(files, _DoesFileMatch())
     self.slash_count = 0