@@ -167,19 +167,33 @@ The cursor must be at the beginning of a statement."
167167 (let ((token (swift-mode:forward-token-or-list))
168168 (defun-keywords
169169 '(" import" " typealias" " associatedtype"
170- " enum" " struct" " class " " protocol" " extension"
170+ " enum" " struct" " protocol" " extension"
171171 " func" " init" " deinit" " subscript" " get" " set" " willSet" " didSet"
172172 " prefix" " postfix" " infix" " precedencegroup"
173173 " var" " let"
174174 " case" ))
175175 (stop-tokens '(\; implicit-\; {} } \) \]
176- anonymous-function-parameter-in outside-of-buffer)))
176+ anonymous-function-parameter-in outside-of-buffer))
177+ (class-token nil ))
177178 (while (not (or
178179 (memq (swift-mode:token:type token) stop-tokens)
179180 (member (swift-mode:token:text token) defun-keywords)))
181+ ; ; "class" token may be either a class declaration keyword or a modifier:
182+ ; ;
183+ ; ; // Nested class named "final"
184+ ; ; class Foo { class final {} }
185+ ; ;
186+ ; ; // Nonoverridable class method named "foo"
187+ ; ; class Foo { class final func foo() {} }
188+ ; ;
189+ ; ; Keeps scanning and returns the token if there are no other
190+ ; ; `defun-keywords' .
191+ (when (equal (swift-mode:token:text token) " class" )
192+ (setq class-token token))
180193 (setq token (swift-mode:forward-token-or-list)))
181- (when (member (swift-mode:token:text token) defun-keywords)
182- token)))
194+ (if (member (swift-mode:token:text token) defun-keywords)
195+ token
196+ class-token)))
183197
184198(defun swift-mode:class-like-member-p ()
185199 " Return t if the cursor is on a member of a class-like declaration.
0 commit comments