Commits

Anonymous committed 1418dd0

libutils: added analyze_modules()

  • Participants
  • Parent commits 3f3ef60

Comments (0)

Files changed (2)

rope/base/libutils.py

 
 import rope.base.project
 import rope.base.pycore
+from rope.base import taskhandle
 
 
 def path_to_resource(project, path, type=None):
     if project.pycore.automatic_soa:
         rope.base.pycore.perform_soa_on_changed_scopes(project, resource,
                                                        old_content)
+
+def analyze_modules(project, task_handle=taskhandle.NullTaskHandle()):
+    """Perform static object analysis on all python files in the project
+
+    Note that this might be really time consuming.
+    """
+    resources = project.pycore.get_python_files()
+    job_set = task_handle.create_jobset('Analyzing Modules', len(resources))
+    for resource in resources:
+        job_set.started_job('Working on <%s>' % resource.path)
+        project.pycore.analyze_module(resource)
+        job_set.finished_job()

ropetest/advanced_oi_test.py

         p_type = f_scope['p'].get_object().get_type()
         self.assertEquals(c_class, p_type)
 
+    def test_report_libutils_and_analyze_all_modules(self):
+        code = 'class C(object):\n    pass\ndef f(p):\n    pass\nf(C())\n'
+        self.mod.write(code)
+        rope.base.libutils.analyze_modules(self.project)
+        pymod = self.pycore.resource_to_pyobject(self.mod)
+        c_class = pymod['C'].get_object()
+        f_scope = pymod['f'].get_object().get_scope()
+        p_type = f_scope['p'].get_object().get_type()
+        self.assertEquals(c_class, p_type)
+
     def test_validation_problems_for_objectdb_retrievals(self):
         mod1 = testutils.create_module(self.project, 'mod1')
         mod2 = testutils.create_module(self.project, 'mod2')