Anonymous avatar Anonymous committed 96b51a8

interface: use rope.base.utils.cacheit when possible

Comments (0)

Files changed (1)


 import os
 import rope.base.change
-from rope.base import libutils
+from rope.base import libutils, utils
 from rope.contrib import codeassist, generate, autoimport, findit
 from ropemode import refactor, decorators, dialog
         self.interface = interface
         self.autoimport = interface.autoimport
         self.env = env
-        self._source = None
-        self._offset = None
-        self._starting_offset = None
-        self._starting = None
-        self._expression = None
     def code_assist(self, prefix):
         names = self._calculate_proposals()
         return prefix
+    @utils.cacheit
     def offset(self):
-        if self._offset is None:
-            self._offset = self.env.get_offset()
-        return self._offset
+        return self.env.get_offset()
+    @utils.cacheit
     def source(self):
-        if self._source is None:
-            self._source = self.interface._get_text()
-        return self._source
+        return self.interface._get_text()
+    @utils.cacheit
     def starting_offset(self):
-        if self._starting_offset is None:
-            self._starting_offset = codeassist.starting_offset(self.source,
-                                                               self.offset)
-        return self._starting_offset
+        return codeassist.starting_offset(self.source, self.offset)
+    @utils.cacheit
     def starting(self):
-        if self._starting is None:
-            self._starting = self.source[self.starting_offset:self.offset]
-        return self._starting
+        return self.source[self.starting_offset:self.offset]
+    @utils.cacheit
     def expression(self):
-        if self._expression is None:
-            self._expression = codeassist.starting_expression(self.source,
-                                                              self.offset)
-        return self._expression
+        return codeassist.starting_expression(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.