Ali Gholami Rudi  committed d1d18b3

Not proposing variables that are defined later in the current scope

  • Participants
  • Parent commits 895dcb4

Comments (0)

Files changed (3)

File docs/workingon.txt

   What if the statement in current line is spread in more than one line.
 - More tests for explicit and implicit continuations
-i Transform big unextractible methods into method objects
+? Transform big unextractible methods into method objects
+- Not proposing variables defined after current line in the same scope
 * Ignoring """ or ''' string content
 ! scopes_count does not work because there might be loops and other blocks
 ? Add rope.scopes module
 ? Completions for for-loop, except, lambda, with variables
-? Not proposing local_variables that are defined after current position
 ? Remote pair programming support
 ? Completions are context dependant
 ? Separating ui modules and packages

File rope/

 class _CurrentStatementRangeFinder(object):
     """A method object for finding the range of current statement"""
     def __init__(self, lines, lineno):
         self.lines = lines
         self.lineno = lineno
         end_line = self.lineno
         if True or self.lines[self.lineno].rstrip().endswith(':'):
             for i in range(self.lineno + 1, len(self.lines)):
-                if self.get_line_indents(i) > last_indents:
+                if self.get_line_indents(i) >= last_indents:
                     end_line = i

File ropetest/

         result = self.assist.complete_code(code, len(code))
         self.assert_proposal_in_result('my_var', 'global_variable', result)
+    def test_not_proposing_later_defined_variables_in_current_block(self):
+        code = "my_\nmy_var = 10\n"
+        result = self.assist.complete_code(code, 3)
+        self.assert_proposal_not_in_result('my_var', 'global_variable', result)
+    def test_not_proposing_later_defined_variables_in_current_function(self):
+        code = "def f():\n    my_\n    my_var = 10\n"
+        result = self.assist.complete_code(code, 16)
+        self.assert_proposal_not_in_result('my_var', 'local_variable', result)
 if __name__ == '__main__':