Commits

Anonymous committed c824a7f

delay time-consuming calculating codeassist completion proposal type until it is accessed

Comments (0)

Files changed (1)

rope/contrib/codeassist.py

 
     def __init__(self, name, scope, pyname=None):
         self.name = name
-        self.scope = scope
         self.pyname = pyname
-        if pyname is not None:
-            self.type = self._get_type()
-        else:
-            self.type = None
+        self.scope = self._get_scope(scope)
 
     def __str__(self):
         return '%s (%s, %s)' % (self.name, self.scope, self.type)
             if isinstance(pyobject, pyobjects.AbstractFunction):
                 return pyobject.get_param_names()
 
-    def _get_type(self):
+    @property
+    def type(self):
         pyname = self.pyname
         if isinstance(pyname, builtins.BuiltinName):
-            self.scope = 'builtin'
             pyobject = pyname.get_object()
             if isinstance(pyobject, builtins.BuiltinFunction):
                 return 'function'
                  isinstance(pyobject, builtins.BuiltinName):
                 return 'instance'
         elif isinstance(pyname, pynames.ImportedModule):
-            self.scope = 'imported'
             return 'module'
         elif isinstance(pyname, pynames.ImportedName) or \
            isinstance(pyname, pynames.DefinedName):
-            if isinstance(pyname, pynames.ImportedName):
-                self.scope = 'imported'
             pyobject = pyname.get_object()
             if isinstance(pyobject, pyobjects.AbstractFunction):
                 return 'function'
                 return 'class'
         return 'instance'
 
+    def _get_scope(self, scope):
+        if isinstance(self.pyname, builtins.BuiltinName):
+            return 'builtin'
+        if isinstance(self.pyname, pynames.ImportedModule) or \
+           isinstance(self.pyname, pynames.ImportedName):
+            return 'imported'
+        return scope
+
     def get_doc(self):
         """Get the proposed object's docstring.
 
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 ProjectModifiedEvent.java.
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.