Skip to content

Commit b67f928

Browse files
author
Dave Abrahams
authored
Merge pull request #5640 from apple/emacs-mode-parse-where-clause
[emacs support] Parse new where clause syntax
2 parents dbd6f99 + a0ddcf0 commit b67f928

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

utils/swift-mode.el

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,21 @@ one is present, returning t if so and nil otherwise"
269269
(swift-skip-comments-and-space))))
270270
found))
271271

272+
(defun swift-skip-constraint ()
273+
"Hop over a single type constraint if one is present,
274+
returning t if so and nil otherwise"
275+
(swift-skip-comments-and-space)
276+
(and (swift-skip-type-name)
277+
(swift-skip-re ":\\|==")
278+
(swift-skip-type-name)))
279+
280+
(defun swift-skip-where-clause ()
281+
"Hop over a where clause if one is present, returning t if so
282+
and nil otherwise"
283+
(when (swift-skip-re "\\<where\\>")
284+
(while (and (swift-skip-constraint) (swift-skip-re ",")))
285+
t))
286+
272287
(defun swift-in-string-or-comment ()
273288
"Return non-nil if point is in a string or comment."
274289
(or (nth 3 (syntax-ppss)) (nth 4 (syntax-ppss))))
@@ -311,7 +326,8 @@ Use `M-x hs-show-all' to show them again."
311326
(swift-skip-comments-and-space)
312327
(equal (char-after) ?\())
313328
;; parse the parameter list and any return type
314-
(swift-skip-type-name)))))
329+
(swift-skip-type-name)
330+
(swift-skip-where-clause)))))
315331
(swift-skip-re "{"))
316332
(hs-hide-block :reposition-at-end))))))
317333

0 commit comments

Comments
 (0)