Anonymous avatar Anonymous committed 783765b

don't pass resources that don't exist to code assists

Comments (0)

Files changed (1)


         text = self._get_text()
         offset = self.env.get_offset()
         docs = get_doc(self.project, text, offset,
-                       self._get_resource(), maxfixes)
+                       self.resource, maxfixes)
         self.env.show_doc(docs, prefix)
         if docs is None:
             self.env.message('No docs avilable!')
     def _get_text(self):
-        if not self.env.is_modified():
-            return self._get_resource().read()
+        resource = self.resource
+        if not self.env.is_modified() and resource is not None:
+            return
         return self.env.get_text()
     def _base_findit(self, do_find, optionals, get_kwds):
     def analyze_module(self):
         """Perform static object analysis on this module"""
-        resource = self._get_resource()
-        self.project.pycore.analyze_module(resource)
+        self.project.pycore.analyze_module(self.resource)
     def analyze_modules(self):
     def run_module(self):
         """Run and perform dynamic object analysis on this module"""
-        resource = self._get_resource()
-        process = self.project.pycore.run_module(resource)
+        process = self.project.pycore.run_module(self.resource)
     def _get_location(self):
-        resource = self._get_resource()
         offset = self.env.get_offset()
-        return resource, offset
+        return self.resource, offset
     def _get_resource(self, filename=None):
         if filename is None:
         resource = libutils.path_to_resource(self.project, filename, 'file')
         return resource
+    @property
+    def resource(self):
+        """the current resource
+        Returns `None` when file does not exist.
+        """
+        resource = self._get_resource()
+        if resource and resource.exists():
+            return resource
     def _check_project(self):
         if self.project is None:
             if self.env.get('guess_project'):
     def _calculate_proposals(self):
-        resource = self.interface._get_resource()
+        resource = self.interface.resource
         maxfixes = self.env.get('codeassist_maxfixes')
         proposals = codeassist.code_assist(
             self.interface.project, self.source, self.offset,
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.