rope_py3k / rope / refactor / functionutils.py

Diff from to

rope/refactor/functionutils.py

 import rope.base.exceptions
 import rope.base.pyobjects
+from rope.base.builtins import Lambda
 from rope.base import worder
 
 
         scope = pyfunction.get_scope()
         parent = scope.parent
         parameter_names = pyfunction.get_param_names()
-        is_method = pyfunction.get_kind() == 'method'
-        info = _FunctionParser(code, is_method)
+        kind = pyfunction.get_kind()
+        is_method = kind == 'method'
+        is_lambda = kind == 'lambda'
+        info = _FunctionParser(code, is_method, is_lambda)
         args, keywords = info.get_parameters()
         args_arg = None
         keywords_arg = None
         word_finder = worder.Worder(pymodule.source_code)
         lineno = pyfunction.get_ast().lineno
         start = pymodule.lines.get_line_start(lineno)
-        call = word_finder.get_function_and_args_in_header(start)
+        if isinstance(pyfunction, Lambda):
+            call = word_finder.get_lambda_and_args(start)
+        else:
+            call = word_finder.get_function_and_args_in_header(start)
         return DefinitionInfo._read(pyfunction, call)
 
 
 
 class _FunctionParser(object):
 
-    def __init__(self, call, implicit_arg):
+    def __init__(self, call, implicit_arg, is_lambda=False):
         self.call = call
         self.implicit_arg = implicit_arg
         self.word_finder = worder.Worder(self.call)
-        self.last_parens = self.call.rindex(')')
+        if is_lambda:
+            self.last_parens = self.call.rindex(':')
+        else:
+            self.last_parens = self.call.rindex(')')
         self.first_parens = self.word_finder._find_parens_start(self.last_parens)
 
     def get_parameters(self):
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.