emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/go-mode 7ab928a 146/495: Add support for methods that have


From: ELPA Syncer
Subject: [nongnu] elpa/go-mode 7ab928a 146/495: Add support for methods that have no name for the receiver
Date: Sat, 7 Aug 2021 09:05:01 -0400 (EDT)

branch: elpa/go-mode
commit 7ab928a57e4d6b8b16b27faabc848beb180e5246
Author: Dominik Honnef <dominikh@fork-bomb.org>
Commit: Dominik Honnef <dominikh@fork-bomb.org>

    Add support for methods that have no name for the receiver
    
    `func (Foo) ...` is valid Go. Our regexes didn't catch this as method
    definitions and in turn broke fontification as well as navigation (and
    thus also indentation) for those.
---
 go-mode.el                                   | 8 +++++++-
 indentation_tests/unnamed_method_receiver.go | 8 ++++++++
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/go-mode.el b/go-mode.el
index 55bfa31..00300e4 100644
--- a/go-mode.el
+++ b/go-mode.el
@@ -86,7 +86,12 @@
 (defconst go-label-regexp go-identifier-regexp)
 (defconst go-type-regexp "[[:word:][:multibyte:]*]+")
 (defconst go-func-regexp (concat (go--regexp-enclose-in-symbol "func") "\\s 
*\\(" go-identifier-regexp "\\)"))
-(defconst go-func-meth-regexp (concat (go--regexp-enclose-in-symbol "func") 
"\\s *\\(?:(\\s *" go-identifier-regexp "\\s +" go-type-regexp "\\s *)\\s 
*\\)?\\(" go-identifier-regexp "\\)("))
+(defconst go-func-meth-regexp (concat
+                               (go--regexp-enclose-in-symbol "func") "\\s 
*\\(?:(\\s *"
+                               "\\(" go-identifier-regexp "\\s +\\)?" 
go-type-regexp
+                               "\\s *)\\s *\\)?\\("
+                               go-identifier-regexp
+                               "\\)("))
 (defconst go-builtins
   '("append" "cap"   "close"   "complex" "copy"
     "delete" "imag"  "len"     "make"    "new"
@@ -173,6 +178,7 @@
      ;; TODO do we actually need this one or isn't it just a function call?
      (,(concat "\\.\\s *(" go-type-name-regexp) 1 font-lock-type-face) ;; Type 
conversion
      (,(concat (go--regexp-enclose-in-symbol "func") "[[:space:]]+(" 
go-identifier-regexp "[[:space:]]+" go-type-name-regexp ")") 1 
font-lock-type-face) ;; Method receiver
+     (,(concat (go--regexp-enclose-in-symbol "func") "[[:space:]]+(" 
go-type-name-regexp ")") 1 font-lock-type-face) ;; Method receiver without 
variable name
      ;; Like the original go-mode this also marks compound literal
      ;; fields. There, it was marked as to fix, but I grew quite
      ;; accustomed to it, so it'll stay for now.
diff --git a/indentation_tests/unnamed_method_receiver.go 
b/indentation_tests/unnamed_method_receiver.go
new file mode 100644
index 0000000..c0909ad
--- /dev/null
+++ b/indentation_tests/unnamed_method_receiver.go
@@ -0,0 +1,8 @@
+package main
+
+type A int
+
+func (A) Foo() (A,
+       A) {
+       // Code goes here
+}



reply via email to

[Prev in Thread] Current Thread [Next in Thread]