Fix extracting async def type and name in python mode imenu

* lisp/progmodes/python.el (python-imenu--get-defun-type-name):
New function.
(python-imenu--build-tree): Use python-imenu--get-defun-type-name for
extract async or simple def type and name at current
position (Bug#24820).
* test/lisp/progmodes/python-tests.el (python-imenu-create-index-1):
(python-imenu-create-flat-index-1): Add async def's.
This commit is contained in:
Dmitry Lazurkin
2017-01-04 21:46:21 +03:00
committed by Noam Postavsky
parent 55b5265847
commit d4a97088f6
2 changed files with 22 additions and 7 deletions

View File

@@ -3559,6 +3559,9 @@ class Baz(object):
def c(self):
pass
async def d(self):
pass
"
(goto-char (point-max))
(should (equal
@@ -3580,7 +3583,8 @@ class Baz(object):
(list
"Frob (class)"
(cons "*class definition*" (copy-marker 601))
(cons "c (def)" (copy-marker 626)))))
(cons "c (def)" (copy-marker 626))
(cons "d (async def)" (copy-marker 665)))))
(python-imenu-create-index)))))
(ert-deftest python-imenu-create-index-2 ()
@@ -3702,6 +3706,9 @@ class Baz(object):
def c(self):
pass
async def d(self):
pass
"
(goto-char (point-max))
(should (equal
@@ -3714,7 +3721,8 @@ class Baz(object):
(cons "Baz.a" (copy-marker 539))
(cons "Baz.b" (copy-marker 570))
(cons "Baz.Frob" (copy-marker 601))
(cons "Baz.Frob.c" (copy-marker 626)))
(cons "Baz.Frob.c" (copy-marker 626))
(cons "Baz.Frob.d" (copy-marker 665)))
(python-imenu-create-flat-index)))))
(ert-deftest python-imenu-create-flat-index-2 ()