Anonymous avatar Anonymous committed 8c2dc2f

Not proposing unmatching function parameters

Comments (0)

Files changed (4)

 * Auto completion after "."s @ 3
-  * Auto-completing "self."s @ 2
+  * Auto-completing "self."s
 * Auto completing and comments and strings @ 1


---- Proposing function parameters in functions @ 1 ---
-- Normal params
-- Keyword args
-? Loop variables
+! Scopes_count does not work because there might be loops and other blocks
+? Add rope.scopes module
+? For loop, except, lambda variables
 ? Not proposing local_variables that are defined after current position
 ? Remote pair programming support
 ? Completions are context dependant


     def walk_function(starting, function_node):
         new_visitor = _FunctionScopeVisitor(starting, function_node.lineno)
         for arg in function_node.argnames:
-            new_visitor.scope.var_dict[arg] = CompletionProposal(arg, 'local_variable')
+            if arg.startswith(starting):
+                new_visitor.scope.var_dict[arg] = CompletionProposal(arg, 'local_variable')
         for node in function_node.getChildNodes():
             compiler.walk(node, new_visitor)
         return new_visitor


         self.assert_proposal_in_result('my_list', 'local_variable', result)
         self.assert_proposal_in_result('my_kws', 'local_variable', result)
+    def test_not_proposing_unmatching_function_parameters_in_functions(self):
+        code = "def my_func(my_param):\n    my_var = 20\n    you_"
+        result = self.assist.complete_code(code, len(code))
+        self.assert_proposal_not_in_result('my_param', 'local_variable', result)
 if __name__ == '__main__':
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
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.