Commits

Ali Gholami Rudi  committed f7e0f5c

interface: providing Location.lineno for older versions of rope

  • Participants
  • Parent commits 2c5f129

Comments (0)

Files changed (1)

File ropemode/interface.py

 
 class Location(object):
     def __init__(self, location):
+        self.location = location
         self.filename = location.resource.real_path
-        self.lineno = location.lineno
         self.offset = location.offset
         self.note = ''
         if location.unsure:
             self.note = '?'
 
+    @property
+    def lineno(self):
+        if hasattr(self.location, 'lineno'):
+            return self.location.lineno
+        return self.location.resource.read().count('\n', 0, self.offset) + 1
+
 
 class _CodeAssist(object):