@@ -482,9 +482,9 @@ statements."
482
482
483
483
(if go-fontify-function-calls
484
484
; ; Function call/method name
485
- `((,( concat " \\ ( " go-identifier-regexp " \\ )[[:space:]]*( " ) 1 font-lock-function- name-face )
486
- ; ; Bracketed function call
487
- (,( concat " [^[:word:][:multibyte:]]( \\ ( " go-identifier-regexp " \\ ))[[:space:]]*( " ) 1 font-lock-function-name-face ))
485
+ `((go--match-func- name
486
+ ( 1 font-lock- function-name-face nil t )
487
+ ( 2 font-lock-function-name-face nil t ) ))
488
488
; ; Method name
489
489
`((, go-func-meth-regexp 2 font-lock-function-name-face )))
490
490
@@ -1458,19 +1458,19 @@ the next comma or to the closing paren."
1458
1458
(setq found-match t )))
1459
1459
1460
1460
; ; Advance to next comma. We are done if there are no more commas.
1461
- (setq done (not (go--search-next-comma end))))
1461
+ (setq done (not (go--search-next-comma end ?\) ))))
1462
1462
found-match))
1463
1463
1464
- (defun go--search-next-comma (end )
1464
+ (defun go--search-next-comma (end closer )
1465
1465
" Search forward from point for a comma whose nesting level is
1466
1466
the same as point. If it reaches a closing parenthesis before a
1467
1467
comma, it stops at it. Return non-nil if comma was found."
1468
1468
(let ((orig-level (go-paren-level)))
1469
1469
(while (and (< (point ) end)
1470
- (or (looking-at-p " [^,)] " )
1470
+ (or (not ( member ( char-after ) `( ?, , closer )) )
1471
1471
(> (go-paren-level) orig-level)))
1472
1472
(forward-char ))
1473
- (when (and (looking-at-p " , " )
1473
+ (when (and (eq ( char-after ) ?, )
1474
1474
(< (point ) (1- end)))
1475
1475
(forward-char )
1476
1476
t )))
@@ -1502,7 +1502,7 @@ comma, it stops at it. Return non-nil if comma was found."
1502
1502
(goto-char (match-end 1 ))
1503
1503
(unless (member (match-string 1 ) go-constants)
1504
1504
(setq found-match t )))
1505
- (setq done (not (go--search-next-comma end))))
1505
+ (setq done (not (go--search-next-comma end ?\) ))))
1506
1506
found-match))
1507
1507
1508
1508
(defun go--containing-decl ()
@@ -1705,6 +1705,35 @@ We are looking for the right-hand-side of the type alias"
1705
1705
found-match))
1706
1706
1707
1707
1708
+ (defconst go--match-func-name-re
1709
+ (concat " \\ (?:^\\ |[^)]\\ )(\\ (" go-identifier-regexp " \\ ))(\\ |\\ (" go-identifier-regexp " \\ )[[(]" ))
1710
+
1711
+ (defun go--match-func-name (end )
1712
+ " Search for func names in decls and invocations."
1713
+ (let (found-match)
1714
+ (while (and
1715
+ (not found-match)
1716
+ ; ; Match "(foo)(" or "foo[" or "foo(".
1717
+ (re-search-forward go--match-func-name-re end t ))
1718
+ (if (eq (char-before ) ?\( )
1719
+ ; ; Followed directly by "(" is a match.
1720
+ (setq found-match t )
1721
+ ; ; Followed by "[". We are a match if there is at least one
1722
+ ; ; comma between the "[" and "]", and if "]" is followed by
1723
+ ; ; "(".
1724
+ (let ((commas 0 ))
1725
+ (while (go--search-next-comma end ?\] )
1726
+ (cl-incf commas))
1727
+ (forward-char )
1728
+ (setq found-match (and
1729
+ ; ; We found a comma (so we are sure these are type
1730
+ ; ; params), or we are at file level (so we are sure
1731
+ ; ; it is a func decl).
1732
+ (or (> commas 0 ) (= 0 (go-paren-level)))
1733
+ (eq (char-after ) ?\( ))))))
1734
+ found-match))
1735
+
1736
+
1708
1737
(defconst go--map-value-re
1709
1738
(concat " \\ _<map\\ _>\\ [\\ (?:\\ [[^]]*\\ ]\\ )*[^]]*\\ ]" go-type-name-regexp))
1710
1739
0 commit comments