From b1247d2d0d51108c910a73891ff3116e5f032ab1 Mon Sep 17 00:00:00 2001 From: "Kali Kaneko (leap communications)" Date: Sat, 12 Jan 2019 18:39:45 +0100 Subject: [pkg] all your deps are vendored to us --- .../message/pipeline/testdata/ssa/catalog_gen.go | 37 +++ .../pipeline/testdata/ssa/extracted.gotext.json | 298 +++++++++++++++++++++ .../x/text/message/pipeline/testdata/ssa/ssa.go | 202 ++++++++++++++ 3 files changed, 537 insertions(+) create mode 100644 vendor/golang.org/x/text/message/pipeline/testdata/ssa/catalog_gen.go create mode 100644 vendor/golang.org/x/text/message/pipeline/testdata/ssa/extracted.gotext.json create mode 100644 vendor/golang.org/x/text/message/pipeline/testdata/ssa/ssa.go (limited to 'vendor/golang.org/x/text/message/pipeline/testdata/ssa') diff --git a/vendor/golang.org/x/text/message/pipeline/testdata/ssa/catalog_gen.go b/vendor/golang.org/x/text/message/pipeline/testdata/ssa/catalog_gen.go new file mode 100644 index 0000000..2e14d5a --- /dev/null +++ b/vendor/golang.org/x/text/message/pipeline/testdata/ssa/catalog_gen.go @@ -0,0 +1,37 @@ +// Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT. + +package main + +import ( + "golang.org/x/text/language" + "golang.org/x/text/message" + "golang.org/x/text/message/catalog" +) + +type dictionary struct { + index []uint32 + data string +} + +func (d *dictionary) Lookup(key string) (data string, ok bool) { + p := messageKeyToIndex[key] + start, end := d.index[p], d.index[p+1] + if start == end { + return "", false + } + return d.data[start:end], true +} + +func init() { + dict := map[string]catalog.Dictionary{} + fallback := language.MustParse("en-US") + cat, err := catalog.NewFromMap(dict, catalog.Fallback(fallback)) + if err != nil { + panic(err) + } + message.DefaultCatalog = cat +} + +var messageKeyToIndex = map[string]int{} + +// Total table size 0 bytes (0KiB); checksum: 811C9DC5 diff --git a/vendor/golang.org/x/text/message/pipeline/testdata/ssa/extracted.gotext.json b/vendor/golang.org/x/text/message/pipeline/testdata/ssa/extracted.gotext.json new file mode 100644 index 0000000..0d886b3 --- /dev/null +++ b/vendor/golang.org/x/text/message/pipeline/testdata/ssa/extracted.gotext.json @@ -0,0 +1,298 @@ +{ + "language": "en-US", + "messages": [ + { + "id": "inline {ARG1}", + "key": "inline %s", + "message": "inline {ARG1}", + "translation": "", + "placeholders": [ + { + "id": "ARG1", + "string": "%[1]s", + "type": "string", + "underlyingType": "string", + "argNum": 1, + "expr": "\"ARG1\"" + } + ], + "position": "testdata/ssa/ssa.go:16:7" + }, + { + "id": "global printer used {ARG1}", + "key": "global printer used %s", + "message": "global printer used {ARG1}", + "translation": "", + "placeholders": [ + { + "id": "ARG1", + "string": "%[1]s", + "type": "string", + "underlyingType": "string", + "argNum": 1, + "expr": "\"ARG1\"" + } + ], + "position": "testdata/ssa/ssa.go:17:8" + }, + { + "id": "number: {2}, string: {STRING_ARG}, bool: {True}", + "key": "number: %d, string: %s, bool: %v", + "message": "number: {2}, string: {STRING_ARG}, bool: {True}", + "translation": "", + "placeholders": [ + { + "id": "2", + "string": "%[1]d", + "type": "int", + "underlyingType": "int", + "argNum": 1, + "expr": "2" + }, + { + "id": "STRING_ARG", + "string": "%[2]s", + "type": "string", + "underlyingType": "string", + "argNum": 2, + "expr": "\"STRING ARG\"" + }, + { + "id": "True", + "string": "%[3]v", + "type": "bool", + "underlyingType": "bool", + "argNum": 3, + "expr": "true" + } + ], + "position": "testdata/ssa/ssa.go:22:9" + }, + { + "id": "empty string", + "key": "empty string", + "message": "empty string", + "translation": "", + "position": "testdata/ssa/ssa.go:23:9" + }, + { + "id": "Lovely weather today!", + "key": "Lovely weather today!", + "message": "Lovely weather today!", + "translation": "", + "position": "testdata/ssa/ssa.go:24:8" + }, + { + "id": "number one", + "key": "number one", + "message": "number one", + "translation": "", + "position": "testdata/ssa/ssa.go:32:8" + }, + { + "id": [ + "v", + "number: {C}" + ], + "key": "number: %d", + "message": "number: {C}", + "translation": "", + "placeholders": [ + { + "id": "C", + "string": "%[1]d", + "type": "string", + "underlyingType": "string", + "argNum": 1, + "expr": "c" + } + ], + "position": "testdata/ssa/ssa.go:79:10" + }, + { + "id": [ + "format", + "constant local {Args}" + ], + "key": "constant local %s", + "message": "constant local {Args}", + "translation": "", + "placeholders": [ + { + "id": "Args", + "string": "%[1]s", + "type": "[]interface{}", + "underlyingType": "[]interface{}", + "argNum": 1, + "expr": "args" + } + ], + "position": "testdata/ssa/ssa.go:88:11" + }, + { + "id": [ + "a", + "foo {Arg1} {B}" + ], + "key": "foo %s %s", + "message": "foo {Arg1} {B}", + "translation": "", + "placeholders": [ + { + "id": "Arg1", + "string": "%[1]s", + "type": "string", + "underlyingType": "string", + "argNum": 1, + "expr": "arg1" + }, + { + "id": "B", + "string": "%[2]s", + "type": "string", + "underlyingType": "string", + "argNum": 2, + "expr": "b" + } + ], + "position": "testdata/ssa/ssa.go:139:7" + }, + { + "id": [ + "a", + "bar {Arg1} {B}" + ], + "key": "bar %s %s", + "message": "bar {Arg1} {B}", + "translation": "", + "placeholders": [ + { + "id": "Arg1", + "string": "%[1]s", + "type": "string", + "underlyingType": "string", + "argNum": 1, + "expr": "arg1" + }, + { + "id": "B", + "string": "%[2]s", + "type": "string", + "underlyingType": "string", + "argNum": 2, + "expr": "b" + } + ], + "position": "testdata/ssa/ssa.go:139:7" + }, + { + "id": [ + "a", + "foo" + ], + "key": "foo", + "message": "foo", + "translation": "", + "position": "testdata/ssa/ssa.go:153:8" + }, + { + "id": [ + "a", + "bar" + ], + "key": "bar", + "message": "bar", + "translation": "", + "position": "testdata/ssa/ssa.go:153:8" + }, + { + "id": [ + "a", + "baz" + ], + "key": "baz", + "message": "baz", + "translation": "", + "position": "testdata/ssa/ssa.go:153:8" + }, + { + "id": [ + "str", + "const str" + ], + "key": "const str", + "message": "const str", + "translation": "", + "position": "testdata/ssa/ssa.go:168:11" + }, + { + "id": [ + "globalStr", + "See you around in {City}!" + ], + "key": "See you around in %s!", + "message": "See you around in {City}!", + "translation": "", + "placeholders": [ + { + "id": "City", + "string": "%[1]s", + "type": "string", + "underlyingType": "string", + "argNum": 1, + "expr": "city" + } + ], + "position": "testdata/ssa/ssa.go:181:5" + }, + { + "id": [ + "constFood", + "Please eat your {Food}!" + ], + "key": "Please eat your %s!", + "message": "Please eat your {Food}!", + "translation": "", + "comment": "Ho ho ho", + "placeholders": [ + { + "id": "Food", + "string": "%[1]s", + "type": "string", + "underlyingType": "string", + "argNum": 1, + "expr": "food", + "comment": "the food to be consumed by the subject" + } + ], + "position": "testdata/ssa/ssa.go:193:2" + }, + { + "id": [ + "msgHello", + "Hello, {Integer} and {Arg_2}!" + ], + "key": "Hello, %d and %s!", + "message": "Hello, {Integer} and {Arg_2}!", + "translation": "", + "comment": "Ho ho ho", + "placeholders": [ + { + "id": "Integer", + "string": "%[1]d", + "type": "", + "underlyingType": "int", + "argNum": 1 + }, + { + "id": "Arg_2", + "string": "%[2]s", + "type": "", + "underlyingType": "string", + "argNum": 2 + } + ], + "position": "testdata/ssa/ssa.go:193:2" + } + ] +} \ No newline at end of file diff --git a/vendor/golang.org/x/text/message/pipeline/testdata/ssa/ssa.go b/vendor/golang.org/x/text/message/pipeline/testdata/ssa/ssa.go new file mode 100644 index 0000000..1591242 --- /dev/null +++ b/vendor/golang.org/x/text/message/pipeline/testdata/ssa/ssa.go @@ -0,0 +1,202 @@ +package main + +import ( + "golang.org/x/text/language" + "golang.org/x/text/message" +) + +// In this test, lowercap strings are ones that need to be picked up for +// translation, whereas uppercap strings should not be picked up. + +func main() { + p := message.NewPrinter(language.English) + + // TODO: probably should use type instead of string content for argument + // substitution. + wrapf(p, "inline %s", "ARG1") + gwrapf("global printer used %s", "ARG1") + + w := wrapped{p} + + // Comment about wrapf. + w.wrapf("number: %d, string: %s, bool: %v", 2, "STRING ARG", true) + w.wrapf("empty string") + w.wrap("Lovely weather today!") + + more(&w) +} + +var printer = message.NewPrinter(language.English) + +func more(w wrapper) { + w.wrap("number one") + w.wrapf("speed of light: %s", "C") +} + +func gwrapf(format string, args ...interface{}) { + v := format + a := args + printer.Printf(v, a...) +} + +func wrapf(p *message.Printer, format string, args ...interface{}) { + v := format + a := args + p.Printf(v, a...) +} + +func wrap(p *message.Printer, format string) { + v := format + b := "0" + a := []interface{}{3, b} + s := a[:] + p.Printf(v, s...) +} + +type wrapper interface { + wrapf(format string, args ...interface{}) + wrap(msg string) +} + +type wrapped struct { + p *message.Printer +} + +// TODO: calls over interfaces do not get picked up. It looks like this is +// because w is not a pointer receiver, while the other method is. Mixing of +// receiver types does not seem to be allowed by callgraph/cha. +func (w wrapped) wrapf(format string, args ...interface{}) { + w.p.Printf(format, args...) +} + +func (w *wrapped) wrap(msg string) { + w.p.Printf(msg) +} + +func fint(p *message.Printer, x int) { + v := "number: %d" + const c = "DAFDA" + p.Printf(v, c) +} + +const format = "constant local" + " %s" + +// NOTE: pass is not called. Ensure it is picked up anyway. +func pass(p *message.Printer, args ...interface{}) { + // TODO: find an example caller to find substituted types and argument + // examples. + p.Sprintf(format, args...) +} + +func lookup(p *message.Printer, x int) { + // TODO: pick up all elements from slice foo. + p.Printf(foo[x]) +} + +var foo = []string{ + "aaaa", + "bbbb", +} + +func field(p *message.Printer, x int) { + // TODO: pick up strings in field BAR from all composite literals of + // typeof(strct.Foo.Bar). + p.Printf(strct.Foo.Bar, x) +} + +type fooStruct struct { + Foo barStruct +} + +type barStruct struct { + other int + Bar string +} + +var strct = fooStruct{ + Foo: barStruct{0, "foo %d"}, +} + +func call(p *message.Printer, x int) { + // TODO: pick up constant return values. + p.Printf(fn()) +} + +func fn() string { + return "const str" +} + +// Both strings get picked up. +func ifConst(p *message.Printer, cond bool, arg1 string) { + a := "foo %s %s" + if cond { + a = "bar %s %s" + } + b := "FOO" + if cond { + b = "BAR" + } + wrapf(p, a, arg1, b) +} + +// Pick up all non-empty strings in this function. +func ifConst2(x int) { + a := "" + switch x { + case 0: + a = "foo" + case 1: + a = "bar" + case 2: + a = "baz" + } + gwrapf(a) +} + +// TODO: pick up strings passed to the second argument in calls to freeVar. +func freeVar(p *message.Printer, str string) { + fn := func(p *message.Printer) { + p.Printf(str) + } + fn(p) +} + +func freeConst(p *message.Printer) { + // str is a message + const str = "const str" + fn := func(p *message.Printer) { + p.Printf(str) + } + fn(p) +} + +func global(p *message.Printer) { + // city describes the expected next meeting place + city := "Amsterdam" + // See a person around. + p.Printf(globalStr, city) +} + +// globalStr is a global variable with a string constant assigned to it. +var globalStr = "See you around in %s!" + +func global2(p *message.Printer) { + const food = "Pastrami" + wrapf(p, constFood, + food, // the food to be consumed by the subject + ) +} + +// Comment applying to all constants in a block are ignored. +var ( + // Ho ho ho + notAMessage, constFood, msgHello = "NOPE!", consume, hello +) + +// A block comment. +var ( + // This comment takes precedence. + hello = "Hello, %d and %s!" + + consume = "Please eat your %s!" +) -- cgit v1.2.3