@@ -1378,9 +1378,16 @@ Interactively, the behavior depends on ‘narrow-to-defun-include-comments’."
13781378(defun swift-mode:current-defun-name ()
13791379 " Return fully qualified name of defun under the point."
13801380 (save-excursion
1381- (let ((token-list (reverse (swift-mode:current-defun-name-token-list))))
1381+ (let ((token-list (reverse (swift-mode:current-defun-name-token-list)))
1382+ text)
13821383 (if token-list
1383- (mapconcat #'swift-mode:token:text token-list " ." )
1384+ (mapconcat (lambda (token )
1385+ (setq text (swift-mode:token:text token))
1386+ (if (eq (aref text 0 ) ?` )
1387+ (substring text 1 (1- (length text)))
1388+ text))
1389+ token-list
1390+ " ." )
13841391 nil ))))
13851392
13861393(defun swift-mode:current-defun-name-token-list ()
@@ -1390,11 +1397,27 @@ The first element is the name token of the current defun. The rest are the ones
13901397of ancestors."
13911398 (if (bobp )
13921399 nil
1393- (let ((name-token (swift-mode:current-defun-name-token)))
1394- (swift-mode:backward-sexps-until-open-curly-bracket)
1400+ (let ((name-token (swift-mode:current-defun-name-token))
1401+ name-tokens
1402+ next-token)
13951403 (if name-token
1396- (cons name-token (swift-mode:current-defun-name-token-list))
1397- (swift-mode:current-defun-name-token-list)))))
1404+ (progn
1405+ (save-excursion
1406+ (swift-mode:backward-sexps-until-open-curly-bracket)
1407+ (setq name-tokens (swift-mode:current-defun-name-token-list)))
1408+ (while name-token
1409+ (push name-token name-tokens)
1410+ (goto-char (swift-mode:token:end name-token))
1411+ (setq next-token (swift-mode:forward-token-or-list))
1412+ (when (eq (swift-mode:token:type next-token) '<> )
1413+ (setq next-token (swift-mode:forward-token-or-list)))
1414+ (setq name-token
1415+ (when (equal (swift-mode:token:text next-token) " ." )
1416+ (setq next-token (swift-mode:forward-token-or-list))
1417+ (when (eq (swift-mode:token:type next-token) 'identifier )
1418+ next-token))))
1419+ name-tokens)
1420+ '()))))
13981421
13991422(defun swift-mode:current-defun-name-token ()
14001423 " Return the name token of the defun under the point."
0 commit comments