Anonymous avatar Anonymous committed 1c6c3e4

generate: using Scope.get_defined_names() for finding redefinitions

Comments (0)

Files changed (1)

rope/contrib/generate.py

     def element_already_exists(self):
         if self.pyname is None or isinstance(self.pyname, pynames.UnboundName):
             return False
-        return True
+        return self.get_name() in self.goal_scope.get_defined_names()
 
     def get_name(self):
         return codeanalyze.get_name_at(self.resource, self.offset)
     def element_already_exists(self):
         if self.pyname is None or isinstance(self.pyname, pynames.UnboundName):
             return False
-        if self.get_name() not in self.goal_scope:
-            return False
-        return True
+        return self.get_name() in self.goal_scope.get_defined_names()
 
     def is_static_method(self):
         return self.primary is not None and \
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.