Commits

Anonymous committed 2691081

occurrences: passing a single PyName to create_finder()

  • Participants
  • Parent commits 28e097a

Comments (0)

Files changed (12)

rope/contrib/codeassist.py

     def is_match(occurrence):
         return unsure
     finder = occurrences.create_finder(
-        project.pycore, name, [pyname], unsure=is_match)
+        project.pycore, name, pyname, unsure=is_match)
     if resources is None:
         resources = project.pycore.get_python_files()
     job_set = task_handle.create_jobset('Finding Occurrences',

rope/refactor/change_signature.py

         changes = ChangeSet('Changing signature of <%s>' % self.name)
         job_set = handle.create_jobset('Collecting Changes', len(resources))
         finder = occurrences.create_finder(
-            self.pycore, self.name, [self.pyname], instance=self.primary,
+            self.pycore, self.name, self.pyname, instance=self.primary,
             in_hierarchy=in_hierarchy and self.is_method())
         if self.others:
             name, pyname = self.others
             constructor_finder = occurrences.create_finder(
-                self.pycore, name, [pyname], only_calls=True)
+                self.pycore, name, pyname, only_calls=True)
             finder = occurrences.MultipleFinders([finder, constructor_finder])
         for file in resources:
             job_set.started_job('Working on <%s>' % file.path)

rope/refactor/encapsulate_field.py

         if setter is None:
             setter = 'set_' + self.name
         renamer = GetterSetterRenameInModule(
-            self.pycore, self.name, [self.pyname], getter, setter)
+            self.pycore, self.name, self.pyname, getter, setter)
         for file in resources:
             job_set.started_job('Working on <%s>' % file.path)
             if file == self.resource:
 
 class GetterSetterRenameInModule(object):
 
-    def __init__(self, pycore, name, pynames, getter, setter):
+    def __init__(self, pycore, name, pyname, getter, setter):
         self.pycore = pycore
         self.name = name
-        self.finder = occurrences.create_finder(pycore, name, pynames)
+        self.finder = occurrences.create_finder(pycore, name, pyname)
         self.getter = getter
         self.setter = setter
 

rope/refactor/importutils/__init__.py

             if alias is not None:
                 imported = alias
             occurrence_finder = occurrences.create_finder(
-                self.pycore, imported, [pymodule[imported]],
-                imports=False)
+                self.pycore, imported, pymodule[imported], imports=False)
             source = rename.rename_in_module(
                 occurrence_finder, module_name + '.' + name,
                 pymodule=pymodule, replace_primary=True)
         old_pyname = rope.base.evaluate.get_string_result(
             pymodule.get_scope(), name)
         occurrence_finder = occurrences.create_finder(
-            self.pycore, old_name, [old_pyname], imports=False)
+            self.pycore, old_name, old_pyname, imports=False)
         changes = rope.refactor.sourceutils.ChangeCollector(pymodule.source_code)
         for occurrence in occurrence_finder.find_occurrences(pymodule=pymodule):
             start, end = occurrence.get_primary_range()

rope/refactor/inline.py

         self.pymodule = self.pyfunction.get_module()
         self.resource = self.pyfunction.get_module().get_resource()
         self.occurrence_finder = occurrences.create_finder(
-            self.pycore, self.name, [self.pyname])
+            self.pycore, self.name, self.pyname)
         self.normal_generator = _DefinitionGenerator(self.project,
                                                      self.pyfunction)
         self._init_imports()
     definition = definition_with_assignment[definition_with_assignment.\
                                             index('=') + 1:].strip()
 
-    occurrence_finder = occurrences.create_finder(pycore, name, [pyname])
+    occurrence_finder = occurrences.create_finder(pycore, name, pyname)
     changed_source = rename.rename_in_module(
         occurrence_finder, definition, pymodule=pymodule,
         replace_primary=True, writes=False, region=region)

rope/refactor/introduce_factory.py

 
     def _rename_occurrences(self, file_, changed_name, global_factory):
         finder = occurrences.create_finder(self.pycore, self.old_name,
-                                            [self.old_pyname], only_calls=True)
+                                           self.old_pyname, only_calls=True)
         result = rename.rename_in_module(finder, changed_name, resource=file_,
                                          replace_primary=global_factory)
         return result

rope/refactor/introduce_parameter.py

 
     def _change_function_occurances(self, collector, function_start,
                                     function_end, new_name):
-        finder = occurrences.create_finder(self.pycore, self.name,
-                                            [self.pyname])
+        finder = occurrences.create_finder(self.pycore, self.name, self.pyname)
         for occurrence in finder.find_occurrences(resource=self.resource):
             start, end = occurrence.get_primary_range()
             if function_start <= start < function_end:

rope/refactor/method_object.py

             body = param + ' = None\n' + body
             pymod = self.pycore.get_string_module(body, self.resource)
             pyname = pymod[param]
-            finder = occurrences.create_finder(
-                self.pycore, param, [pyname])
+            finder = occurrences.create_finder(self.pycore, param, pyname)
             result = rename.rename_in_module(finder, 'self.' + param,
                                              pymodule=pymod)
             body = result[result.index('\n') + 1:]

rope/refactor/move.py

         body = self_name + ' = None\n' + self._get_unchanged_body()
         pymodule = self.pycore.get_string_module(body)
         finder = occurrences.create_finder(
-            self.pycore, self_name, [pymodule[self_name]])
+            self.pycore, self_name, pymodule[self_name])
         result = rename.rename_in_module(finder, host, pymodule=pymodule)
         if result is None:
             result = body
         placeholder = '__rope_moving_%s_' % self.old_name
         handle = _ChangeMoveOccurrencesHandle(placeholder)
         occurrence_finder = occurrences.create_finder(
-            self.pycore, self.old_name, [self.old_pyname])
+            self.pycore, self.old_name, self.old_pyname)
         start, end = self._get_moving_region()
         renamer = ModuleSkipRenamer(occurrence_finder, self.source,
                                     handle, start, end)
 
     def _create_finder(self, imports):
         return occurrences.create_finder(self.pycore, self.old_name,
-                                          [self.old_pyname], imports=imports)
+                                         self.old_pyname, imports=imports)
 
     def new_pymodule(self, pymodule, source):
         if source is not None:

rope/refactor/occurrences.py

             return False
 
 
-def create_finder(pycore, name, pynames, only_calls=False, imports=True,
+def create_finder(pycore, name, pyname, only_calls=False, imports=True,
                   unsure=None, docs=False, instance=None, in_hierarchy=False):
-    pynames = set(pynames)
+    pynames = set([pyname])
     filters = []
     if only_calls:
         filters.append(CallsFilter())

rope/refactor/rename.py

         changes = ChangeSet('Renaming <%s> to <%s>' %
                             (self.old_name, new_name))
         finder = occurrences.create_finder(
-            self.pycore, self.old_name, [self.old_pyname], unsure=unsure,
+            self.pycore, self.old_name, self.old_pyname, unsure=unsure,
             docs=docs, instance=self.old_instance,
             in_hierarchy=in_hierarchy and self.is_method())
         job_set = task_handle.create_jobset('Collecting Changes', len(resources))
                             (self.old_name, new_name))
         scope_start, scope_end = self._get_scope_offset()
         finder = occurrences.create_finder(
-            self.pycore, self.old_name, [self.old_pyname],
+            self.pycore, self.old_name, self.old_pyname,
             imports=False, only_calls=only_calls)
         new_contents = rename_in_module(
             finder, new_name, pymodule=self.pymodule, replace_primary=True,

ropetest/refactor/renametest.py

         pymod = self.pycore.get_module('mod1')
         old_pyname = pymod['a']
         finder = rope.refactor.occurrences.create_finder(
-            self.pycore, 'a', [old_pyname])
+            self.pycore, 'a', old_pyname)
         refactored = rename.rename_in_module(
             finder, 'new_var', pymodule=pymod, replace_primary=True)
         self.assertEquals('new_var = 10\nprint(1+new_var)\n', refactored)