Support Go language in 'etags'
* lib-src/etags.c <Ruby_help>: Fix documentation of Ruby tags. <Go_help>: New help. <Go_suffixes>: New variable. (Go_functions): New function. <lang_names>: Add entry for Go. (Bug#22370) * doc/emacs/maintaining.texi (Tag Syntax): Document Go support. * doc/man/etags.1: Mention Go support. * etc/NEWS: Mention Go support. * test/etags/go-src/test.go: * test/etags/go-src/test1.go: New test files. * test/etags/Makefile (GOSRC): New variable. (SRCS): Add $(GOSRC). * test/etags/ETAGS.good_1: * test/etags/ETAGS.good_2: * test/etags/ETAGS.good_3: * test/etags/ETAGS.good_4: * test/etags/ETAGS.good_5: * test/etags/ETAGS.good_6: * test/etags/CTAGS.good: Adapt to addition of Go tests.
This commit is contained in:
parent
25b79d7bc7
commit
40a85fba44
14 changed files with 223 additions and 5 deletions
|
@ -2217,6 +2217,9 @@ in the file.
|
|||
@item
|
||||
In Fortran code, functions, subroutines and block data are tags.
|
||||
|
||||
@item
|
||||
In Go code, packages, functions, and types are tags.
|
||||
|
||||
@item
|
||||
In HTML input files, the tags are the @code{title} and the @code{h1},
|
||||
@code{h2}, @code{h3} headers. Also, tags are @code{name=} in anchors
|
||||
|
|
|
@ -50,7 +50,7 @@ format understood by
|
|||
.BR vi ( 1 )\c
|
||||
\&. Both forms of the program understand
|
||||
the syntax of C, Objective C, C++, Java, Fortran, Ada, Cobol, Erlang,
|
||||
Forth, HTML, LaTeX, Emacs Lisp/Common Lisp, Lua, Makefile, Pascal, Perl,
|
||||
Forth, Go, HTML, LaTeX, Emacs Lisp/Common Lisp, Lua, Makefile, Pascal, Perl,
|
||||
Ruby, PHP, PostScript, Python, Prolog, Scheme and
|
||||
most assembler\-like syntaxes.
|
||||
Both forms read the files specified on the command line, and write a tag
|
||||
|
|
4
etc/NEWS
4
etc/NEWS
|
@ -1833,6 +1833,10 @@ qualified names by hand.
|
|||
Names of modules, classes, methods, functions, and constants are
|
||||
tagged. Overloaded operators are also tagged.
|
||||
|
||||
+++
|
||||
*** New language Go
|
||||
Names of packages, functions, and types are tagged.
|
||||
|
||||
+++
|
||||
*** Improved support for Lua
|
||||
|
||||
|
|
|
@ -354,6 +354,7 @@ static void Cstar_entries (FILE *);
|
|||
static void Erlang_functions (FILE *);
|
||||
static void Forth_words (FILE *);
|
||||
static void Fortran_functions (FILE *);
|
||||
static void Go_functions (FILE *);
|
||||
static void HTML_labels (FILE *);
|
||||
static void Lisp_functions (FILE *);
|
||||
static void Lua_functions (FILE *);
|
||||
|
@ -641,6 +642,10 @@ static const char *Fortran_suffixes [] =
|
|||
static const char Fortran_help [] =
|
||||
"In Fortran code, functions, subroutines and block data are tags.";
|
||||
|
||||
static const char *Go_suffixes [] = {"go", NULL};
|
||||
static const char Go_help [] =
|
||||
"In Go code, functions, interfaces and packages are tags.";
|
||||
|
||||
static const char *HTML_suffixes [] =
|
||||
{ "htm", "html", "shtml", NULL };
|
||||
static const char HTML_help [] =
|
||||
|
@ -727,7 +732,7 @@ static const char *Ruby_suffixes [] =
|
|||
{ "rb", "ruby", NULL };
|
||||
static const char Ruby_help [] =
|
||||
"In Ruby code, 'def' or 'class' or 'module' at the beginning of\n\
|
||||
a line generate a tag.";
|
||||
a line generate a tag. Constants also generate a tag.";
|
||||
|
||||
/* Can't do the `SCM' or `scm' prefix with a version number. */
|
||||
static const char *Scheme_suffixes [] =
|
||||
|
@ -794,6 +799,7 @@ static language lang_names [] =
|
|||
{ "erlang", Erlang_help, Erlang_functions, Erlang_suffixes },
|
||||
{ "forth", Forth_help, Forth_words, Forth_suffixes },
|
||||
{ "fortran", Fortran_help, Fortran_functions, Fortran_suffixes },
|
||||
{ "go", Go_help, Go_functions, Go_suffixes },
|
||||
{ "html", HTML_help, HTML_labels, HTML_suffixes },
|
||||
{ "java", Cjava_help, Cjava_entries, Cjava_suffixes },
|
||||
{ "lisp", Lisp_help, Lisp_functions, Lisp_suffixes },
|
||||
|
@ -4207,6 +4213,73 @@ Fortran_functions (FILE *inf)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Go language support
|
||||
* Original code by Xi Lu <lx@shellcodes.org> (2016)
|
||||
*/
|
||||
static void
|
||||
Go_functions(FILE *inf)
|
||||
{
|
||||
char *cp, *name;
|
||||
|
||||
LOOP_ON_INPUT_LINES(inf, lb, cp)
|
||||
{
|
||||
cp = skip_spaces (cp);
|
||||
|
||||
if (LOOKING_AT (cp, "package"))
|
||||
{
|
||||
name = cp;
|
||||
while (!notinname (*cp) && *cp != '\0')
|
||||
cp++;
|
||||
make_tag (name, cp - name, false, lb.buffer,
|
||||
cp - lb.buffer + 1, lineno, linecharno);
|
||||
}
|
||||
else if (LOOKING_AT (cp, "func"))
|
||||
{
|
||||
/* Go implementation of interface, such as:
|
||||
func (n *Integer) Add(m Integer) ...
|
||||
skip `(n *Integer)` part.
|
||||
*/
|
||||
if (*cp == '(')
|
||||
{
|
||||
while (*cp != ')')
|
||||
cp++;
|
||||
cp = skip_spaces (cp+1);
|
||||
}
|
||||
|
||||
if (*cp)
|
||||
{
|
||||
name = cp;
|
||||
|
||||
while (!notinname (*cp))
|
||||
cp++;
|
||||
|
||||
make_tag (name, cp - name, true, lb.buffer,
|
||||
cp - lb.buffer + 1, lineno, linecharno);
|
||||
}
|
||||
}
|
||||
else if (members && LOOKING_AT (cp, "type"))
|
||||
{
|
||||
name = cp;
|
||||
|
||||
/* Ignore the likes of the following:
|
||||
type (
|
||||
A
|
||||
)
|
||||
*/
|
||||
if (*cp == '(')
|
||||
return;
|
||||
|
||||
while (!notinname (*cp) && *cp != '\0')
|
||||
cp++;
|
||||
|
||||
make_tag (name, cp - name, false, lb.buffer,
|
||||
cp - lb.buffer + 1, lineno, linecharno);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Ada parsing
|
||||
|
|
|
@ -947,6 +947,10 @@ MoveLayerAfter lua-src/allegro.lua /^function MoveLayerAfter (this_one)$/
|
|||
MoveLayerBefore lua-src/allegro.lua /^function MoveLayerBefore (this_one)$/
|
||||
MoveLayerBottom lua-src/allegro.lua /^function MoveLayerBottom ()$/
|
||||
MoveLayerTop lua-src/allegro.lua /^function MoveLayerTop ()$/
|
||||
Mtest.go go-src/test.go 1
|
||||
Mtest.go go-src/test.go /^func main() {$/
|
||||
Mtest1.go go-src/test1.go 1
|
||||
Mtest1.go go-src/test1.go /^func main() {$/
|
||||
Mx.cc cp-src/x.cc /^main(int argc, char *argv[])$/
|
||||
NAME y-src/cccp.c 8
|
||||
NATNUMP c-src/emacs/src/lisp.h /^NATNUMP (Lisp_Object x)$/
|
||||
|
@ -1077,6 +1081,8 @@ Pkg1_Proc2/p ada-src/waroquiers.ada /^ procedure Pkg1_Proc2 (I : Integer);$/
|
|||
Pkg1_Proc2/p ada-src/waroquiers.ada /^ procedure Pkg1_Proc2 (I : Integer) is$/
|
||||
PostControls pyt-src/server.py /^ def PostControls(self):$/
|
||||
Pre_Call_State/t ada-src/2ataspri.ads /^ type Pre_Call_State is new System.Address;$/
|
||||
PrintAdd go-src/test1.go /^func (s str) PrintAdd() {$/
|
||||
PrintAdd go-src/test1.go /^func (n intNumber) PrintAdd() {$/
|
||||
Private objc-src/Subprocess.m /^@interface Subprocess(Private)$/
|
||||
Private_T/b ada-src/etags-test-for.ada /^ task body Private_T is$/
|
||||
Private_T/b ada-src/waroquiers.ada /^ task body Private_T is$/
|
||||
|
@ -3135,6 +3141,7 @@ instance_method_question? ruby-src/test.rb /^ def instance_method_questio
|
|||
instr y-src/parse.y 80
|
||||
instr parse.y 80
|
||||
instruct c-src/etags.c 2527
|
||||
intNumber go-src/test1.go 13
|
||||
integer c-src/emacs/src/lisp.h 2127
|
||||
integer cccp.y 113
|
||||
integer y-src/cccp.y 112
|
||||
|
@ -3738,6 +3745,7 @@ plain_C_suffixes c-src/etags.c 643
|
|||
plainc c-src/etags.c 2934
|
||||
plist c-src/emacs/src/lisp.h 697
|
||||
plus cp-src/functions.cpp /^void Date::plus ( int days , int month , int year /
|
||||
plus go-src/test1.go 5
|
||||
plusvalseq prol-src/natded.prolog /^plusvalseq([]) --> [].$/
|
||||
pointer c-src/emacs/src/lisp.h 2125
|
||||
poll_for_input c-src/emacs/src/keyboard.c /^poll_for_input (struct atimer *timer)$/
|
||||
|
@ -3950,6 +3958,7 @@ save_getcjmp c-src/emacs/src/keyboard.c /^save_getcjmp (sys_jmp_buf temp)$/
|
|||
save_type c-src/emacs/src/lisp.h /^save_type (struct Lisp_Save_Value *v, int n)$/
|
||||
savenstr c-src/etags.c /^savenstr (const char *cp, int len)$/
|
||||
savestr c-src/etags.c /^savestr (const char *cp)$/
|
||||
say go-src/test.go /^func say(msg string) {$/
|
||||
scan_separators c-src/etags.c /^scan_separators (char *name)$/
|
||||
scolonseen c-src/etags.c 2447
|
||||
scratch c-src/sysdep.h 56
|
||||
|
@ -4075,6 +4084,7 @@ step cp-src/clheir.hpp /^ virtual void step(void) { }$/
|
|||
step_everybody cp-src/clheir.cpp /^void step_everybody(void)$/
|
||||
stop_polling c-src/emacs/src/keyboard.c /^stop_polling (void)$/
|
||||
store_user_signal_events c-src/emacs/src/keyboard.c /^store_user_signal_events (void)$/
|
||||
str go-src/test1.go 9
|
||||
strcaseeq c-src/etags.c /^#define strcaseeq(s,t) (assert ((s)!=NULL && (t)!=/
|
||||
streq c-src/etags.c /^#define streq(s,t) (assert ((s)!=NULL || (t)!=NULL/
|
||||
string_intervals c-src/emacs/src/lisp.h /^string_intervals (Lisp_Object s)$/
|
||||
|
@ -4217,6 +4227,7 @@ terminateInput objc-src/Subprocess.m /^- terminateInput$/
|
|||
test c-src/emacs/src/lisp.h 1871
|
||||
test cp-src/c.C 86
|
||||
test erl-src/gs_dialog.erl /^test() ->$/
|
||||
test go-src/test1.go /^func test(p plus) {$/
|
||||
test php-src/ptest.php /^test $/
|
||||
test.me22b lua-src/test.lua /^ local function test.me22b (one)$/
|
||||
test.me_22a lua-src/test.lua /^ function test.me_22a(one, two)$/
|
||||
|
|
|
@ -2283,6 +2283,18 @@ constant (a-forth-constant(a-forth-constant38,628
|
|||
code assemby-code-word 43,685
|
||||
: a-forth-word 50,870
|
||||
|
||||
go-src/test.go,48
|
||||
package main1,0
|
||||
func say(5,28
|
||||
func main(9,72
|
||||
|
||||
go-src/test1.go,119
|
||||
package main1,0
|
||||
func (s str) PrintAdd(17,136
|
||||
func (n intNumber) PrintAdd(21,189
|
||||
func test(25,248
|
||||
func main(29,285
|
||||
|
||||
html-src/softwarelibero.html,200
|
||||
Cos'è il software libero?4,38
|
||||
Licenze d'uso di un programmalicenze65,2500
|
||||
|
|
|
@ -2852,6 +2852,18 @@ constant (a-forth-constant(a-forth-constant38,628
|
|||
code assemby-code-word 43,685
|
||||
: a-forth-word 50,870
|
||||
|
||||
go-src/test.go,48
|
||||
package main1,0
|
||||
func say(5,28
|
||||
func main(9,72
|
||||
|
||||
go-src/test1.go,119
|
||||
package main1,0
|
||||
func (s str) PrintAdd(17,136
|
||||
func (n intNumber) PrintAdd(21,189
|
||||
func test(25,248
|
||||
func main(29,285
|
||||
|
||||
html-src/softwarelibero.html,200
|
||||
Cos'è il software libero?4,38
|
||||
Licenze d'uso di un programmalicenze65,2500
|
||||
|
|
|
@ -2600,6 +2600,21 @@ constant (a-forth-constant(a-forth-constant38,628
|
|||
code assemby-code-word 43,685
|
||||
: a-forth-word 50,870
|
||||
|
||||
go-src/test.go,48
|
||||
package main1,0
|
||||
func say(5,28
|
||||
func main(9,72
|
||||
|
||||
go-src/test1.go,172
|
||||
package main1,0
|
||||
type plus 5,28
|
||||
type str 9,65
|
||||
type intNumber 13,99
|
||||
func (s str) PrintAdd(17,136
|
||||
func (n intNumber) PrintAdd(21,189
|
||||
func test(25,248
|
||||
func main(29,285
|
||||
|
||||
html-src/softwarelibero.html,200
|
||||
Cos'è il software libero?4,38
|
||||
Licenze d'uso di un programmalicenze65,2500
|
||||
|
|
|
@ -2447,6 +2447,18 @@ constant (a-forth-constant(a-forth-constant38,628
|
|||
code assemby-code-word 43,685
|
||||
: a-forth-word 50,870
|
||||
|
||||
go-src/test.go,48
|
||||
package main1,0
|
||||
func say(5,28
|
||||
func main(9,72
|
||||
|
||||
go-src/test1.go,119
|
||||
package main1,0
|
||||
func (s str) PrintAdd(17,136
|
||||
func (n intNumber) PrintAdd(21,189
|
||||
func test(25,248
|
||||
func main(29,285
|
||||
|
||||
html-src/softwarelibero.html,200
|
||||
Cos'è il software libero?4,38
|
||||
Licenze d'uso di un programmalicenze65,2500
|
||||
|
|
|
@ -3333,6 +3333,21 @@ constant (a-forth-constant(a-forth-constant38,628
|
|||
code assemby-code-word 43,685
|
||||
: a-forth-word 50,870
|
||||
|
||||
go-src/test.go,48
|
||||
package main1,0
|
||||
func say(5,28
|
||||
func main(9,72
|
||||
|
||||
go-src/test1.go,172
|
||||
package main1,0
|
||||
type plus 5,28
|
||||
type str 9,65
|
||||
type intNumber 13,99
|
||||
func (s str) PrintAdd(17,136
|
||||
func (n intNumber) PrintAdd(21,189
|
||||
func test(25,248
|
||||
func main(29,285
|
||||
|
||||
html-src/softwarelibero.html,200
|
||||
Cos'è il software libero?4,38
|
||||
Licenze d'uso di un programmalicenze65,2500
|
||||
|
|
|
@ -3333,6 +3333,21 @@ constant (a-forth-constant(a-forth-constant38,628
|
|||
code assemby-code-word 43,685
|
||||
: a-forth-word 50,870
|
||||
|
||||
go-src/test.go,48
|
||||
package main1,0
|
||||
func say(5,28
|
||||
func main(9,72
|
||||
|
||||
go-src/test1.go,172
|
||||
package main1,0
|
||||
type plus 5,28
|
||||
type str 9,65
|
||||
type intNumber 13,99
|
||||
func (s str) PrintAdd(17,136
|
||||
func (n intNumber) PrintAdd(21,189
|
||||
func test(25,248
|
||||
func main(29,285
|
||||
|
||||
html-src/softwarelibero.html,200
|
||||
Cos'è il software libero?4,38
|
||||
Licenze d'uso di un programmalicenze65,2500
|
||||
|
|
|
@ -11,6 +11,7 @@ ELSRC=$(addprefix ./el-src/,TAGTEST.EL emacs/lisp/progmodes/etags.el)
|
|||
ERLSRC=$(addprefix ./erl-src/,gs_dialog.erl)
|
||||
FORTHSRC=$(addprefix ./forth-src/,test-forth.fth)
|
||||
FSRC=$(addprefix ./f-src/,entry.for entry.strange_suffix entry.strange)
|
||||
GOSRC=$(addprefix ./go-src/,test.go test1.go)
|
||||
HTMLSRC=$(addprefix ./html-src/,softwarelibero.html index.shtml algrthms.html software.html)
|
||||
#JAVASRC=$(addprefix ./java-src/, )
|
||||
LUASRC=$(addprefix ./lua-src/,allegro.lua test.lua)
|
||||
|
@ -27,9 +28,9 @@ RBSRC=$(addprefix ./ruby-src/,test.rb test1.ruby)
|
|||
TEXSRC=$(addprefix ./tex-src/,testenv.tex gzip.texi texinfo.tex nonewline.tex)
|
||||
YSRC=$(addprefix ./y-src/,parse.y parse.c atest.y cccp.c cccp.y)
|
||||
SRCS=${ADASRC} ${ASRC} ${CSRC} ${CPSRC} ${ELSRC} ${ERLSRC} ${FSRC}\
|
||||
${FORTHSRC} ${HTMLSRC} ${JAVASRC} ${LUASRC} ${MAKESRC} ${OBJCSRC}\
|
||||
${OBJCPPSRC} ${PASSRC} ${PHPSRC} ${PERLSRC} ${PSSRC} ${PROLSRC} ${PYTSRC}\
|
||||
${RBSRC} ${TEXSRC} ${YSRC}
|
||||
${FORTHSRC} ${GOSRC} ${HTMLSRC} ${JAVASRC} ${LUASRC} ${MAKESRC}\
|
||||
${OBJCSRC} ${OBJCPPSRC} ${PASSRC} ${PHPSRC} ${PERLSRC} ${PSSRC}\
|
||||
${PROLSRC} ${PYTSRC} ${RBSRC} ${TEXSRC} ${YSRC}
|
||||
NONSRCS=./f-src/entry.strange ./erl-src/lists.erl ./cp-src/clheir.hpp.gz
|
||||
|
||||
ETAGS_PROG=../../lib-src/etags
|
||||
|
|
11
test/etags/go-src/test.go
Normal file
11
test/etags/go-src/test.go
Normal file
|
@ -0,0 +1,11 @@
|
|||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
func say(msg string) {
|
||||
fmt.Println(msg)
|
||||
}
|
||||
|
||||
func main() {
|
||||
say("Hello, Emacs!")
|
||||
}
|
34
test/etags/go-src/test1.go
Normal file
34
test/etags/go-src/test1.go
Normal file
|
@ -0,0 +1,34 @@
|
|||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
type plus interface {
|
||||
PrintAdd()
|
||||
}
|
||||
|
||||
type str struct {
|
||||
a, b string
|
||||
}
|
||||
|
||||
type intNumber struct {
|
||||
a, b int
|
||||
}
|
||||
|
||||
func (s str) PrintAdd() {
|
||||
fmt.Println(s.a + s.b)
|
||||
}
|
||||
|
||||
func (n intNumber) PrintAdd() {
|
||||
fmt.Println(n.a + n.b)
|
||||
}
|
||||
|
||||
func test(p plus) {
|
||||
p.PrintAdd()
|
||||
}
|
||||
|
||||
func main() {
|
||||
s := str{a: "Hello,", b: "Emacs!"}
|
||||
number := intNumber{a: 1, b: 2}
|
||||
test(number)
|
||||
test(s)
|
||||
}
|
Loading…
Add table
Reference in a new issue