Anonymous avatar Anonymous committed 47ea9a7

codeanalyze: using get_primary_range() in get_primary_at()

Comments (0)

Files changed (1)

rope/base/codeanalyze.py

 
     def get_primary_at(self, offset):
         offset = self._get_fixed_offset(offset)
-        return self.source[self._find_primary_start(offset):
-                           self._find_word_end(offset) + 1].strip()
+        start, end = self.get_primary_range(offset)
+        return self.source[start:end].strip()
 
     def get_splitted_primary_before(self, offset):
         """returns expression, starting, starting_offset
         return operation
 
     def get_primary_range(self, offset):
-        offset = max(0, offset)
         start = self._find_primary_start(offset)
         end = self._find_word_end(offset) + 1
         return (start, end)
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.