@@ -103,8 +103,7 @@ names."
103103 " Scan declarations from current point.
104104
105105Return found declarations in reverse order."
106- (let (previous-token
107- next-token
106+ (let (next-token
108107 next-type
109108 next-text
110109 name-token
@@ -320,6 +319,16 @@ TYPE is one of `case', `let', or `var'."
320319 items))
321320
322321(defun swift-mode:scan-function-name-and-parameter-names ()
322+ " Parse function name and parameter names.
323+
324+ The point is assumed to be before a function name.
325+
326+ Return tokens of function names and parameter names.
327+
328+ For example, given the following code, this return tokens \" foo\" , \" a\" ,
329+ and \" c\" .
330+
331+ func foo(a b: Int, c: Int)"
323332 (let* ((name-token
324333 (swift-mode:forward-token-or-list-except-curly-bracket))
325334 next-token
@@ -368,19 +377,21 @@ TYPE is one of `case', `let', or `var'."
368377 " Convert list of DECLARATIONS to alist for `imenu--index-alist' .
369378
370379Declarations are organized as trees."
371- (mapcan
372- (lambda (declaration )
373- (let* ((name-token (swift-mode:declaration:name-token declaration))
374- (name (swift-mode:token:text name-token))
375- (position (swift-mode:token:start name-token))
376- (children (swift-mode:declaration:children declaration)))
377- (cons
378- (cons name position)
379- (mapcar
380- (lambda (pair )
381- (cons (concat name " ." (car pair)) (cdr pair)))
382- (swift-mode:format-for-imenu:flat children)))))
383- declarations))
380+ (apply
381+ 'nconc
382+ (mapcar
383+ (lambda (declaration )
384+ (let* ((name-token (swift-mode:declaration:name-token declaration))
385+ (name (swift-mode:token:text name-token))
386+ (position (swift-mode:token:start name-token))
387+ (children (swift-mode:declaration:children declaration)))
388+ (cons
389+ (cons name position)
390+ (mapcar
391+ (lambda (pair )
392+ (cons (concat name " ." (car pair)) (cdr pair)))
393+ (swift-mode:format-for-imenu:flat children)))))
394+ declarations)))
384395
385396(defun swift-mode:format-for-imenu:nested (declarations )
386397 " Convert list of DECLARATIONS to alist for `imenu--index-alist' .
0 commit comments