Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Tmain/list-fields-with-prefix.d/stdout-expected.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ x UCTAGSxpath no NONE s-- no -- 0 xpath
- UCTAGSpackage yes Go s-- no -- 0 the real package specified by the package name
- UCTAGSpackageName yes Go s-- no -- 0 the name for referring the package
- UCTAGSreceiver no Go s-- no -- 1 the name of the receiver
- UCTAGStparams no Go s-- no -- 1 the type parameters
- UCTAGSimplements yes Inko s-- no rw 0 Trait being implemented
- UCTAGSproperties no JavaScript s-- no -- 2 properties (static)
- UCTAGSassignment yes LdScript s-- no -- 0 how a value is assigned to the symbol
Expand Down
1 change: 1 addition & 0 deletions Tmain/list-fields.d/stdout-expected.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ z kind no NONE s-- no r- 0 [tags output] prepend "kind:" to k/ (or K/) field out
- package yes Go s-- no -- 0 the real package specified by the package name
- packageName yes Go s-- no -- 0 the name for referring the package
- receiver no Go s-- no -- 1 the name of the receiver
- tparams no Go s-- no -- 1 the type parameters
- implements yes Inko s-- no rw 0 Trait being implemented
- properties no JavaScript s-- no -- 2 properties (static)
- assignment yes LdScript s-- no -- 0 how a value is assigned to the symbol
Expand Down
4 changes: 4 additions & 0 deletions Units/parser-go.r/go-generics.d/args.ctags
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
--sort=no
--fields=+{signature}{nth}
--kinds-Go=+{tparam}
--fields-Go=+{tparams}
31 changes: 31 additions & 0 deletions Units/parser-go.r/go-generics.d/expected.tags
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
x input.go /^package x$/;" p
T input.go /^func min[T ~int|~float64](x, y T) T {$/;" Z func:x.min typeref:constraint:~int|~float64 nth:0
min input.go /^func min[T ~int|~float64](x, y T) T {$/;" f package:x typeref:typename:T signature:(x, y T) tparams:[T ~int|~float64]
S1 input.go /^func EqualFunc[S1 ~[]E1, S2 ~[]E2, E1, E2 any](s1 S1, s2 S2, eq func(E1, E2) bool) bool {$/;" Z func:x.EqualFunc typeref:constraint:~[]E1 nth:0
S2 input.go /^func EqualFunc[S1 ~[]E1, S2 ~[]E2, E1, E2 any](s1 S1, s2 S2, eq func(E1, E2) bool) bool {$/;" Z func:x.EqualFunc typeref:constraint:~[]E2 nth:1
E1 input.go /^func EqualFunc[S1 ~[]E1, S2 ~[]E2, E1, E2 any](s1 S1, s2 S2, eq func(E1, E2) bool) bool {$/;" Z func:x.EqualFunc typeref:constraint:any nth:2
E2 input.go /^func EqualFunc[S1 ~[]E1, S2 ~[]E2, E1, E2 any](s1 S1, s2 S2, eq func(E1, E2) bool) bool {$/;" Z func:x.EqualFunc typeref:constraint:any nth:3
EqualFunc input.go /^func EqualFunc[S1 ~[]E1, S2 ~[]E2, E1, E2 any](s1 S1, s2 S2, eq func(E1, E2) bool) bool {$/;" f package:x typeref:typename:bool signature:(s1 S1, s2 S2, eq func(E1, E2) bool) tparams:[S1 ~[]E1, S2 ~[]E2, E1, E2 any]
L input.go /^func F0[L ~[]M, M comparable, _, G any](s L, v M) int {$/;" Z func:x.F0 typeref:constraint:~[]M nth:0
M input.go /^func F0[L ~[]M, M comparable, _, G any](s L, v M) int {$/;" Z func:x.F0 typeref:constraint:comparable nth:1
G input.go /^func F0[L ~[]M, M comparable, _, G any](s L, v M) int {$/;" Z func:x.F0 typeref:constraint:any nth:3
F0 input.go /^func F0[L ~[]M, M comparable, _, G any](s L, v M) int {$/;" f package:x typeref:typename:int signature:(s L, v M) tparams:[L ~[]M, M comparable, _, G any]
N input.go /^func F1[N ~[]O, O comparable, _ any](s N, v O) int {$/;" Z func:x.F1 typeref:constraint:~[]O nth:0
O input.go /^func F1[N ~[]O, O comparable, _ any](s N, v O) int {$/;" Z func:x.F1 typeref:constraint:comparable nth:1
F1 input.go /^func F1[N ~[]O, O comparable, _ any](s N, v O) int {$/;" f package:x typeref:typename:int signature:(s N, v O) tparams:[N ~[]O, O comparable, _ any]
E input.go /^type Set[E comparable] struct {$/;" Z struct:x.Set typeref:constraint:comparable nth:0
Set input.go /^type Set[E comparable] struct {$/;" s package:x tparams:[E comparable]
m input.go /^ m map[E]struct{}$/;" m struct:x.Set typeref:typename:map[E]struct{}
E input.go /^func New[E comparable]() *Set[E] {$/;" Z func:x.New typeref:constraint:comparable nth:0
New input.go /^func New[E comparable]() *Set[E] {$/;" f package:x typeref:typename:*Set[E] signature:() tparams:[E comparable]
T input.go /^type List[T any] struct {$/;" Z struct:x.List typeref:constraint:any nth:0
List input.go /^type List[T any] struct {$/;" s package:x tparams:[T any]
next input.go /^ next *List[T]$/;" m struct:x.List typeref:typename:*List[T]
value input.go /^ value T$/;" m struct:x.List typeref:typename:T
X input.go /^type List2[X any] = []X$/;" Z talias:x.List2 typeref:constraint:any nth:0
List2 input.go /^type List2[X any] = []X$/;" a package:x typeref:typename:[]X tparams:[X any]
K input.go /^type Assoc[K comparable, V any] = map[K]V$/;" Z talias:x.Assoc typeref:constraint:comparable nth:0
V input.go /^type Assoc[K comparable, V any] = map[K]V$/;" Z talias:x.Assoc typeref:constraint:any nth:1
Assoc input.go /^type Assoc[K comparable, V any] = map[K]V$/;" a package:x typeref:typename:map[K]V tparams:[K comparable, V any]
UUIDBuflen input.go /^ UUIDBuflen = 256$/;" c package:x
UUID input.go /^type UUID [UUIDBuflen]byte$/;" t package:x typeref:typename:[UUIDBuflen]byte
59 changes: 59 additions & 0 deletions Units/parser-go.r/go-generics.d/input.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package x

// Taken from https://go.dev/ref/spec#Function_types
func min[T ~int|~float64](x, y T) T {
if x < y {
return x
}
return y
}


// Taken from podman/vendor/golang.org/x/exp/slices/slices.go
func EqualFunc[S1 ~[]E1, S2 ~[]E2, E1, E2 any](s1 S1, s2 S2, eq func(E1, E2) bool) bool {
if len(s1) != len(s2) {
return false
}
for i, v1 := range s1 {
v2 := s2[i]
if !eq(v1, v2) {
return false
}
}
return true
}

func F0[L ~[]M, M comparable, _, G any](s L, v M) int {
return -1
}

func F1[N ~[]O, O comparable, _ any](s N, v O) int {
return -1
}

// podman/vendor/github.com/containers/image/v5/internal/set/set.go
type Set[E comparable] struct {
m map[E]struct{}
}

func New[E comparable]() *Set[E] {
return &Set[E]{
m: map[E]struct{}{},
}
}

// Taken from https://go.dev/ref/spec#Type_definitions
type List[T any] struct {
next *List[T]
value T
}

// Aliases
type List2[X any] = []X
type Assoc[K comparable, V any] = map[K]V

// Taken from podman/vendor/github.com/digitalocean/go-libvirt/remote_protocol.gen.go
const (
UUIDBuflen = 256
)
type UUID [UUIDBuflen]byte
1 change: 1 addition & 0 deletions Units/parser-go.r/go-generics.d/validator
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
go
3 changes: 3 additions & 0 deletions docs/news/HEAD.rst
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ QemuHX:
Go:

* Add ``receiver`` field to ``func`` kind tags.
* Start supporting generics:
+ Add ``tparam`` kind to extract type parameters, and
+ Add ``tparams`` field to ``func`` kind tags.

New parsers
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down
Loading
Loading