Anonymous avatar Anonymous committed c1da6c7

Proposing function parameters in functions as completion

Comments (0)

Files changed (5)

+- Proposing function parameters in functions : May 22, 2006
+
+
 - Auto-complete local variable names : May 22, 2006
 
 
   What if the statement in current line is spread in more than one line.
 
 
-* Proposing function parameters in the function @ 1
-
-
 --- Remaining Stories ---
 ? Change program goals and description; principles.html
   ? Go toward refactoring and ... library rather than an IDE

docs/workingon.txt

---- Auto-complete local variable names @ 3 ---
+--- Proposing function parameters in functions @ 1 ---
 
-- Test not including class body variables
-- Test nested Functions
-- Better scope endpoints selection
-- Test imports inside functions
-- Test nested Classes
+- Normal params
+- Keyword args
 
+? Loop variables
 ? Not proposing local_variables that are defined after current position
 ? Remote pair programming support
 ? Completions are context dependant

rope/codeassist.py

     @staticmethod
     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')
         for node in function_node.getChildNodes():
             compiler.walk(node, new_visitor)
         return new_visitor

ropetest/codeassisttest.py

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