Debian Codegraph @

cmd/gentypes/gentypes.go

raw symbols SCIP
1 // Copyright 2020 Google LLC
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // https://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 // gentypes generates Go types from debugProtocol.json
16 //
17 // Usage:
18 //
19 // $ gentypes <path to debugProtocol.json>
20 package mainscip-go gomod github.com/google/go-dap . `github.com/google/go-dap/cmd/gentypes`/
21
22 import (
23 "bytesscip-go gomod github.com/golang/go/src go1.18 bytes/"
24 "encoding/jsonscip-go gomod github.com/golang/go/src go1.18 `encoding/json`/"
25 "errorsscip-go gomod github.com/golang/go/src go1.18 errors/"
26 "flagscip-go gomod github.com/golang/go/src go1.18 flag/"
27 "fmtscip-go gomod github.com/golang/go/src go1.18 fmt/"
28 "go/formatscip-go gomod github.com/golang/go/src go1.18 `go/format`/"
29 "io/ioutilscip-go gomod github.com/golang/go/src go1.18 `io/ioutil`/"
30 "logscip-go gomod github.com/golang/go/src go1.18 log/"
31 "net/httpscip-go gomod github.com/golang/go/src go1.18 `net/http`/"
32 "osscip-go gomod github.com/golang/go/src go1.18 os/"
33 "stringsscip-go gomod github.com/golang/go/src go1.18 strings/"
34 "unicodescip-go gomod github.com/golang/go/src go1.18 unicode/"
35 )
36
37 var (
38 uFlagscip-go gomod github.com/google/go-dap . `github.com/google/go-dap/cmd/gentypes`/uFlag. = flagscip-go gomod github.com/golang/go/src go1.18 flag/.Boolscip-go gomod github.com/golang/go/src go1.18 flag/Bool().("u", false, "updates the debugProtocol.json file before generating the code")
39 oFlagscip-go gomod github.com/google/go-dap . `github.com/google/go-dap/cmd/gentypes`/oFlag. = flagscip-go gomod github.com/golang/go/src go1.18 flag/.Stringscip-go gomod github.com/golang/go/src go1.18 flag/String().("o", "", "specifies the output file name. If unspecified, outputs to stdout")
40 )
41
42 // parseRef parses the value of a "$ref" key.
43 // For example "#definitions/ProtocolMessage" => "ProtocolMessage".
44 func parseRefscip-go gomod github.com/google/go-dap . `github.com/google/go-dap/cmd/gentypes`/parseRef().(refValue any) string {
45 refContents := refValue.(string)
46 if !stringsscip-go gomod github.com/golang/go/src go1.18 strings/.HasPrefixscip-go gomod github.com/golang/go/src go1.18 strings/HasPrefix().(refContents, "#/definitions/") {
47 logscip-go gomod github.com/golang/go/src go1.18 log/.Fatalscip-go gomod github.com/golang/go/src go1.18 log/Fatal().("want ref to start with '#/definitions/', got ", refValue)
48 }
49
50 return replaceGoTypenamescip-go gomod github.com/google/go-dap . `github.com/google/go-dap/cmd/gentypes`/replaceGoTypename().(refContents[14:])
51 }
52
53 // goFieldName converts a property name from its JSON representation to an
54 // exported Go field name.
55 // For example "__some_property_name" => "SomePropertyName".
56 func goFieldNamescip-go gomod github.com/google/go-dap . `github.com/google/go-dap/cmd/gentypes`/goFieldName().(jsonPropName string) string {
57 var ret stringsscip-go gomod github.com/golang/go/src go1.18 strings/.Builderscip-go gomod github.com/golang/go/src go1.18 strings/Builder#
58 ret.Growscip-go gomod github.com/golang/go/src go1.18 strings/Builder#Grow().(len(jsonPropName))
59 upper := true
60 for _, r := range jsonPropName {
61 switch {
62 case r == '_':
63 upper = true
64 case upper:
65 upper = false
66 ret.WriteRunescip-go gomod github.com/golang/go/src go1.18 strings/Builder#WriteRune().(unicodescip-go gomod github.com/golang/go/src go1.18 unicode/.ToUpperscip-go gomod github.com/golang/go/src go1.18 unicode/ToUpper().(r))
67 default:
68 ret.WriteRunescip-go gomod github.com/golang/go/src go1.18 strings/Builder#WriteRune().(r)
69 }
70 }
71 return ret.Stringscip-go gomod github.com/golang/go/src go1.18 strings/Builder#String().()
72 }
73
74 // parsePropertyType takes the JSON value of a property field and extracts
75 // the Go type of the property. For example, given this map:
76 //
77 // {
78 // "type": "string",
79 // "description": "The command to execute."
80 // },
81 //
82 // It will emit "string".
83 func parsePropertyTypescip-go gomod github.com/google/go-dap . `github.com/google/go-dap/cmd/gentypes`/parsePropertyType().(propValue map[string]any) string {
84 if ref, ok := propValue["$ref"]; ok {
85 return parseRefscip-go gomod github.com/google/go-dap . `github.com/google/go-dap/cmd/gentypes`/parseRef().(ref)
86 }
87
88 if _, ok := propValue["oneOf"]; ok {
89 return "any"
90 }
91 propType, ok := propValue["type"]
92 if !ok {
93 logscip-go gomod github.com/golang/go/src go1.18 log/.Fatalscip-go gomod github.com/golang/go/src go1.18 log/Fatal().("property with no type or ref:", propValue)
94 }
95
96 switch typ := propType.(type) {
97 case string:
98 switch typ {
99 case "string":
100 return "string"
101 case "number":
102 return "int"
103 case "integer":
104 return "int"
105 case "boolean":
106 return "bool"
107 case "array":
108 propItems, ok := propValue["items"]
109 if !ok {
110 logscip-go gomod github.com/golang/go/src go1.18 log/.Fatalscip-go gomod github.com/golang/go/src go1.18 log/Fatal().("missing items type for property of array type:", propValue)
111 }
112 propItemsMap := propItems.(map[string]any)
113 return "[]" + parsePropertyTypescip-go gomod github.com/google/go-dap . `github.com/google/go-dap/cmd/gentypes`/parsePropertyType().(propItemsMap)
114 case "object":
115 // When the type of a property is "object", we'll emit a map with a string
116 // key and a value type that depends on the type of the
117 // additionalProperties field.
118 additionalProps, ok := propValue["additionalProperties"]
119 if !ok {
120 logscip-go gomod github.com/golang/go/src go1.18 log/.Fatalscip-go gomod github.com/golang/go/src go1.18 log/Fatal().("missing additionalProperties field when type=object:", propValue)
121 }
122 var valueType string
123 switch actual := additionalProps.(type) {
124 case bool:
125 valueType = "any"
126 case map[string]any:
127 valueType = parsePropertyTypescip-go gomod github.com/google/go-dap . `github.com/google/go-dap/cmd/gentypes`/parsePropertyType().(actual)
128 default:
129 logscip-go gomod github.com/golang/go/src go1.18 log/.Fatalscip-go gomod github.com/golang/go/src go1.18 log/Fatal().("unexpected additionalProperties value:", additionalProps)
130 }
131 return fmtscip-go gomod github.com/golang/go/src go1.18 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.18 fmt/Sprintf().("map[string]%v", valueType)
132 case "any":
133 return "any"
134 default:
135 logscip-go gomod github.com/golang/go/src go1.18 log/.Fatalfscip-go gomod github.com/golang/go/src go1.18 log/Fatalf().("unknown property type value %v in %v", propType, propValue)
136 }
137
138 case []any:
139 // This field is polymorphic so it needs a generic type.
140 for _, el := range typ {
141 s, ok := el.(string)
142 if !ok {
143 logscip-go gomod github.com/golang/go/src go1.18 log/.Fatalfscip-go gomod github.com/golang/go/src go1.18 log/Fatalf().("property type contains a non-string of type %T: %#v", el, typ)
144 }
145 if s == "object" || s == "array" {
146 // It contains non-fundamental types, so treat it as opaque.
147 return "json.RawMessage"
148 }
149 }
150 // The possible types are all fundamental types, so we can use any.
151 return "any"
152
153 default:
154 logscip-go gomod github.com/golang/go/src go1.18 log/.Fatalfscip-go gomod github.com/golang/go/src go1.18 log/Fatalf().("unknown property type %T (%#v)", typ, typ)
155 }
156
157 panic("unreachable")
158 }
159
160 // maybeParseInheritance helps parse types that inherit from other types.
161 // A type description can have an "allOf" key, which means it inherits from
162 // another type description. Returns the name of the base type specified in
163 // allOf, and the description of the inheriting type.
164 //
165 // Example:
166 //
167 // "allOf": [ { "$ref": "#/definitions/ProtocolMessage" },
168 // {... type description ...} ]
169 //
170 // Returns base type ProtocolMessage and a map representing type description.
171 // If there is no "allOf", returns an empty baseTypeName and descMap itself.
172 func maybeParseInheritancescip-go gomod github.com/google/go-dap . `github.com/google/go-dap/cmd/gentypes`/maybeParseInheritance().(descMap map[string]jsonscip-go gomod github.com/golang/go/src go1.18 `encoding/json`/.RawMessagescip-go gomod github.com/golang/go/src go1.18 `encoding/json`/RawMessage#) (baseTypeName string, typeDescJson map[string]jsonscip-go gomod github.com/golang/go/src go1.18 `encoding/json`/.RawMessagescip-go gomod github.com/golang/go/src go1.18 `encoding/json`/RawMessage#) {
173 allOfListJson, ok := descMap["allOf"]
174 if !ok {
175 return "", descMap
176 }
177
178 var allOfSliceOfJson []jsonscip-go gomod github.com/golang/go/src go1.18 `encoding/json`/.RawMessagescip-go gomod github.com/golang/go/src go1.18 `encoding/json`/RawMessage#
179 if err := jsonscip-go gomod github.com/golang/go/src go1.18 `encoding/json`/.Unmarshalscip-go gomod github.com/golang/go/src go1.18 `encoding/json`/Unmarshal().(allOfListJson, &allOfSliceOfJson); err != nil {
180 logscip-go gomod github.com/golang/go/src go1.18 log/.Fatalscip-go gomod github.com/golang/go/src go1.18 log/Fatal().(err)
181 }
182 if len(allOfSliceOfJson) != 2 {
183 logscip-go gomod github.com/golang/go/src go1.18 log/.Fatalscip-go gomod github.com/golang/go/src go1.18 log/Fatal().("want 2 elements in allOf list, got", allOfSliceOfJson)
184 }
185
186 var baseTypeRef map[string]any
187 if err := jsonscip-go gomod github.com/golang/go/src go1.18 `encoding/json`/.Unmarshalscip-go gomod github.com/golang/go/src go1.18 `encoding/json`/Unmarshal().(allOfSliceOfJson[0], &baseTypeRef); err != nil {
188 logscip-go gomod github.com/golang/go/src go1.18 log/.Fatalscip-go gomod github.com/golang/go/src go1.18 log/Fatal().(err)
189 }
190
191 if err := jsonscip-go gomod github.com/golang/go/src go1.18 `encoding/json`/.Unmarshalscip-go gomod github.com/golang/go/src go1.18 `encoding/json`/Unmarshal().(allOfSliceOfJson[1], &typeDescJson); err != nil {
192 logscip-go gomod github.com/golang/go/src go1.18 log/.Fatalscip-go gomod github.com/golang/go/src go1.18 log/Fatal().(err)
193 }
194 return parseRefscip-go gomod github.com/google/go-dap . `github.com/google/go-dap/cmd/gentypes`/parseRef().(baseTypeRef["$ref"]), typeDescJson
195 }
196
197 // emitToplevelType emits a single type into a string. It takes the type name
198 // and a serialized json object representing the type. The json representation
199 // will have fields: "type", "properties" etc.
200 func emitToplevelTypescip-go gomod github.com/google/go-dap . `github.com/google/go-dap/cmd/gentypes`/emitToplevelType().(typeName string, descJson jsonscip-go gomod github.com/golang/go/src go1.18 `encoding/json`/.RawMessagescip-go gomod github.com/golang/go/src go1.18 `encoding/json`/RawMessage#, goTypeIsStruct map[string]bool) string {
201 var b stringsscip-go gomod github.com/golang/go/src go1.18 strings/.Builderscip-go gomod github.com/golang/go/src go1.18 strings/Builder#
202 var baseType string
203
204 // We don't parse the description all the way to map[string]any
205 // because we have to retain the original JSON-order of properties (in this
206 // type as well as any nested types like "body").
207 var descMap map[string]jsonscip-go gomod github.com/golang/go/src go1.18 `encoding/json`/.RawMessagescip-go gomod github.com/golang/go/src go1.18 `encoding/json`/RawMessage#
208 if err := jsonscip-go gomod github.com/golang/go/src go1.18 `encoding/json`/.Unmarshalscip-go gomod github.com/golang/go/src go1.18 `encoding/json`/Unmarshal().(descJson, &descMap); err != nil {
209 logscip-go gomod github.com/golang/go/src go1.18 log/.Fatalscip-go gomod github.com/golang/go/src go1.18 log/Fatal().(err)
210 }
211 baseType, descMap = maybeParseInheritancescip-go gomod github.com/google/go-dap . `github.com/google/go-dap/cmd/gentypes`/maybeParseInheritance().(descMap)
212
213 typeJson, ok := descMap["type"]
214 if !ok {
215 logscip-go gomod github.com/golang/go/src go1.18 log/.Fatalscip-go gomod github.com/golang/go/src go1.18 log/Fatal().("want description to have 'type', got ", descMap)
216 }
217
218 var descTypeString string
219 if err := jsonscip-go gomod github.com/golang/go/src go1.18 `encoding/json`/.Unmarshalscip-go gomod github.com/golang/go/src go1.18 `encoding/json`/Unmarshal().(typeJson, &descTypeString); err != nil {
220 logscip-go gomod github.com/golang/go/src go1.18 log/.Fatalscip-go gomod github.com/golang/go/src go1.18 log/Fatal().(err)
221 }
222
223 var comment string
224 descriptionJson, ok := descMap["description"]
225 if ok {
226 if err := jsonscip-go gomod github.com/golang/go/src go1.18 `encoding/json`/.Unmarshalscip-go gomod github.com/golang/go/src go1.18 `encoding/json`/Unmarshal().(descriptionJson, &comment); err != nil {
227 logscip-go gomod github.com/golang/go/src go1.18 log/.Fatalscip-go gomod github.com/golang/go/src go1.18 log/Fatal().(err)
228 }
229 }
230
231 if len(comment) > 0 {
232 comment = commentOutEachLinescip-go gomod github.com/google/go-dap . `github.com/google/go-dap/cmd/gentypes`/commentOutEachLine().(fmtscip-go gomod github.com/golang/go/src go1.18 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.18 fmt/Sprintf().("%s: %s", typeName, comment))
233 fmtscip-go gomod github.com/golang/go/src go1.18 fmt/.Fprintscip-go gomod github.com/golang/go/src go1.18 fmt/Fprint().(&b, comment)
234 }
235
236 if descTypeString == "string" {
237 fmtscip-go gomod github.com/golang/go/src go1.18 fmt/.Fprintfscip-go gomod github.com/golang/go/src go1.18 fmt/Fprintf().(&b, "type %s string\n", typeName)
238 return b.Stringscip-go gomod github.com/golang/go/src go1.18 strings/Builder#String().()
239 } else if descTypeString == "object" {
240 fmtscip-go gomod github.com/golang/go/src go1.18 fmt/.Fprintfscip-go gomod github.com/golang/go/src go1.18 fmt/Fprintf().(&b, "type %s struct {\n", typeName)
241 if len(baseType) > 0 {
242 fmtscip-go gomod github.com/golang/go/src go1.18 fmt/.Fprintfscip-go gomod github.com/golang/go/src go1.18 fmt/Fprintf().(&b, "\t%s\n\n", baseType)
243 }
244 } else {
245 logscip-go gomod github.com/golang/go/src go1.18 log/.Fatalscip-go gomod github.com/golang/go/src go1.18 log/Fatal().("want description type to be object or string, got ", descTypeString)
246 }
247
248 var propsMapOfJson map[string]jsonscip-go gomod github.com/golang/go/src go1.18 `encoding/json`/.RawMessagescip-go gomod github.com/golang/go/src go1.18 `encoding/json`/RawMessage#
249 if propsJson, ok := descMap["properties"]; ok {
250 if err := jsonscip-go gomod github.com/golang/go/src go1.18 `encoding/json`/.Unmarshalscip-go gomod github.com/golang/go/src go1.18 `encoding/json`/Unmarshal().(propsJson, &propsMapOfJson); err != nil {
251 logscip-go gomod github.com/golang/go/src go1.18 log/.Fatalscip-go gomod github.com/golang/go/src go1.18 log/Fatal().(err)
252 }
253 } else {
254 b.WriteStringscip-go gomod github.com/golang/go/src go1.18 strings/Builder#WriteString().("}\n")
255 return b.Stringscip-go gomod github.com/golang/go/src go1.18 strings/Builder#String().()
256 }
257
258 propsNamesInOrder, err := keysInOrderscip-go gomod github.com/google/go-dap . `github.com/google/go-dap/cmd/gentypes`/keysInOrder().(descMap["properties"])
259 if err != nil {
260 logscip-go gomod github.com/golang/go/src go1.18 log/.Fatalscip-go gomod github.com/golang/go/src go1.18 log/Fatal().(err)
261 }
262
263 // Stores the properties that are required.
264 requiredMap := make(map[string]bool)
265
266 if requiredJson, ok := descMap["required"]; ok {
267 var required []any
268 if err := jsonscip-go gomod github.com/golang/go/src go1.18 `encoding/json`/.Unmarshalscip-go gomod github.com/golang/go/src go1.18 `encoding/json`/Unmarshal().(requiredJson, &required); err != nil {
269 logscip-go gomod github.com/golang/go/src go1.18 log/.Fatalscip-go gomod github.com/golang/go/src go1.18 log/Fatal().(err)
270 }
271 for _, r := range required {
272 requiredMap[r.(string)] = true
273 }
274 }
275
276 // Some types will have a "body" which should be emitted as a separate type.
277 // Since we can't emit a whole new Go type while in the middle of emitting
278 // another type, we save it for later and emit it after the current type is
279 // done.
280 bodyType := ""
281
282 for _, propName := range propsNamesInOrder {
283 // The JSON schema is designed for the TypeScript type system, where a
284 // subclass can redefine a field in a superclass with a refined type (such
285 // as specific values for a field). To ensure we emit Go structs that can
286 // be unmarshaled from JSON messages properly, we must limit each field
287 // to appear only once in hierarchical types.
288 if propName == "type" && (typeName == "Request" || typeName == "Response" || typeName == "Event") {
289 continue
290 }
291 if propName == "command" && typeName != "Request" && typeName != "Response" {
292 continue
293 }
294 if propName == "event" && typeName != "Event" {
295 continue
296 }
297 if propName == "arguments" && typeName == "Request" {
298 continue
299 }
300
301 var propDesc map[string]any
302 if err := jsonscip-go gomod github.com/golang/go/src go1.18 `encoding/json`/.Unmarshalscip-go gomod github.com/golang/go/src go1.18 `encoding/json`/Unmarshal().(propsMapOfJson[propName], &propDesc); err != nil {
303 logscip-go gomod github.com/golang/go/src go1.18 log/.Fatalscip-go gomod github.com/golang/go/src go1.18 log/Fatal().(err)
304 }
305
306 if propName == "body" {
307 if typeName == "Response" || typeName == "Event" {
308 continue
309 }
310
311 var bodyTypeName string
312 if ref, ok := propDesc["$ref"]; ok {
313 bodyTypeName = parseRefscip-go gomod github.com/google/go-dap . `github.com/google/go-dap/cmd/gentypes`/parseRef().(ref)
314 } else {
315 bodyTypeName = typeName + "Body"
316 bodyType = emitToplevelTypescip-go gomod github.com/google/go-dap . `github.com/google/go-dap/cmd/gentypes`/emitToplevelType().(bodyTypeName, propsMapOfJson["body"], goTypeIsStruct)
317 }
318
319 if requiredMap["body"] {
320 fmtscip-go gomod github.com/golang/go/src go1.18 fmt/.Fprintfscip-go gomod github.com/golang/go/src go1.18 fmt/Fprintf().(&b, "\t%s %s `json:\"body\"`\n", "Body", bodyTypeName)
321 } else {
322 fmtscip-go gomod github.com/golang/go/src go1.18 fmt/.Fprintfscip-go gomod github.com/golang/go/src go1.18 fmt/Fprintf().(&b, "\t%s %s `json:\"body,omitempty\"`\n", "Body", bodyTypeName)
323 }
324 } else if propName == "arguments" && (typeName == "LaunchRequest" || typeName == "AttachRequest" || typeName == "RestartRequest") {
325 // Special case for LaunchRequest or AttachRequest arguments, which are implementation
326 // defined and don't have pre-set field names in the specification.
327 fmtscip-go gomod github.com/golang/go/src go1.18 fmt/.Fprintlnscip-go gomod github.com/golang/go/src go1.18 fmt/Fprintln().(&b, "\tArguments json.RawMessage `json:\"arguments\"`")
328 } else {
329 // Go type of this property.
330 goType := parsePropertyTypescip-go gomod github.com/google/go-dap . `github.com/google/go-dap/cmd/gentypes`/parsePropertyType().(propDesc)
331
332 jsonTag := fmtscip-go gomod github.com/golang/go/src go1.18 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.18 fmt/Sprintf().("`json:\"%s", propName)
333 if requiredMap[propName] {
334 jsonTag += "\"`"
335 } else if typeName == "ContinueResponseBody" && propName == "allThreadsContinued" {
336 // This one special field must not have the omitempty tag, despite being
337 // optional. If this attribute is missing the client will (according to
338 // the specification) assume a value of 'true' for backward
339 // compatibility. See: https://github.com/google/go-dap/issues/39
340 jsonTag += "\"`"
341 } else if typeName == "InitializeRequestArguments" && (propName == "linesStartAt1" || propName == "columnsStartAt1") {
342 // These two special fields must not have the omitempty tag, despite being
343 // optional. If this attribute is missing the server will (according to
344 // the specification) assume a value of 'true'.
345 jsonTag += "\"`"
346 } else if typeName == "ErrorMessage" && propName == "showUser" {
347 // For launch/attach errors, vscode will treat omitted values the same way as true,
348 // so to suppress visible reporting, we must report false explicitly.
349 jsonTag += "\"`"
350 } else {
351 jsonTag += ",omitempty\"`"
352 // If the field should be omitted when empty and is a struct type in Go, make it a pointer,
353 // because non-pointer structs get initialized with default values in Go (and not nil), and
354 // are then indistinguishable from structs with values actually set to zero when serializing
355 // to JSON. Making them a pointer makes them initialize to nil, which is then indeed omitted
356 // during serialization.
357 if _, ok := propDesc["$ref"]; ok {
358 // If we have a ref, then goType is the parsed ref
359 if goTypeIsStruct[goType] {
360 goType = "*" + goType
361 }
362 }
363 }
364 fmtscip-go gomod github.com/golang/go/src go1.18 fmt/.Fprintfscip-go gomod github.com/golang/go/src go1.18 fmt/Fprintf().(&b, "\t%s %s %s\n", goFieldNamescip-go gomod github.com/google/go-dap . `github.com/google/go-dap/cmd/gentypes`/goFieldName().(propName), goType, jsonTag)
365
366 }
367 }
368
369 b.WriteStringscip-go gomod github.com/golang/go/src go1.18 strings/Builder#WriteString().("}\n")
370
371 if len(bodyType) > 0 {
372 b.WriteStringscip-go gomod github.com/golang/go/src go1.18 strings/Builder#WriteString().("\n")
373 b.WriteStringscip-go gomod github.com/golang/go/src go1.18 strings/Builder#WriteString().(bodyType)
374 }
375
376 return b.Stringscip-go gomod github.com/golang/go/src go1.18 strings/Builder#String().()
377 }
378
379 // keysInOrder returns the keys in json object in b, in their original order.
380 // Based on https://github.com/golang/go/issues/27179#issuecomment-415559968
381 func keysInOrderscip-go gomod github.com/google/go-dap . `github.com/google/go-dap/cmd/gentypes`/keysInOrder().(b []byte) ([]string, error) {
382 d := jsonscip-go gomod github.com/golang/go/src go1.18 `encoding/json`/.NewDecoderscip-go gomod github.com/golang/go/src go1.18 `encoding/json`/NewDecoder().(bytesscip-go gomod github.com/golang/go/src go1.18 bytes/.NewReaderscip-go gomod github.com/golang/go/src go1.18 bytes/NewReader().(b))
383 t, err := d.Tokenscip-go gomod github.com/golang/go/src go1.18 `encoding/json`/Decoder#Token().()
384 if err != nil {
385 return nil, err
386 }
387 if t != jsonscip-go gomod github.com/golang/go/src go1.18 `encoding/json`/.Delimscip-go gomod github.com/golang/go/src go1.18 `encoding/json`/Delim#('{') {
388 return nil, errorsscip-go gomod github.com/golang/go/src go1.18 errors/.Newscip-go gomod github.com/golang/go/src go1.18 errors/New().("expected start of object")
389 }
390 var keys []string
391 for {
392 t, err := d.Tokenscip-go gomod github.com/golang/go/src go1.18 `encoding/json`/Decoder#Token().()
393 if err != nil {
394 return nil, err
395 }
396 if t == jsonscip-go gomod github.com/golang/go/src go1.18 `encoding/json`/.Delimscip-go gomod github.com/golang/go/src go1.18 `encoding/json`/Delim#('}') {
397 return keys, nil
398 }
399 keys = append(keys, t.(string))
400 if err := skipValuescip-go gomod github.com/google/go-dap . `github.com/google/go-dap/cmd/gentypes`/skipValue().(d); err != nil {
401 return nil, err
402 }
403 }
404 }
405
406 // replaceGoTypename replaces conflicting type names in the JSON schema with
407 // proper Go type names.
408 func replaceGoTypenamescip-go gomod github.com/google/go-dap . `github.com/google/go-dap/cmd/gentypes`/replaceGoTypename().(typeName string) string {
409 // Since we have a top-level interface named Message, we replace the DAP
410 // message type Message with ErrorMessage.
411 if typeName == "Message" {
412 return "ErrorMessage"
413 }
414 return typeName
415 }
416
417 var errEndscip-go gomod github.com/google/go-dap . `github.com/google/go-dap/cmd/gentypes`/errEnd. = errorsscip-go gomod github.com/golang/go/src go1.18 errors/.Newscip-go gomod github.com/golang/go/src go1.18 errors/New().("invalid end of array or object")
418
419 func skipValuescip-go gomod github.com/google/go-dap . `github.com/google/go-dap/cmd/gentypes`/skipValue().(d *jsonscip-go gomod github.com/golang/go/src go1.18 `encoding/json`/.Decoderscip-go gomod github.com/golang/go/src go1.18 `encoding/json`/Decoder#) error {
420 t, err := d.Tokenscip-go gomod github.com/golang/go/src go1.18 `encoding/json`/Decoder#Token().()
421 if err != nil {
422 return err
423 }
424 switch t {
425 case jsonscip-go gomod github.com/golang/go/src go1.18 `encoding/json`/.Delimscip-go gomod github.com/golang/go/src go1.18 `encoding/json`/Delim#('['), jsonscip-go gomod github.com/golang/go/src go1.18 `encoding/json`/.Delimscip-go gomod github.com/golang/go/src go1.18 `encoding/json`/Delim#('{'):
426 for {
427 if err := skipValuescip-go gomod github.com/google/go-dap . `github.com/google/go-dap/cmd/gentypes`/skipValue().(d); err != nil {
428 if err == errEndscip-go gomod github.com/google/go-dap . `github.com/google/go-dap/cmd/gentypes`/errEnd. {
429 break
430 }
431 return err
432 }
433 }
434 case jsonscip-go gomod github.com/golang/go/src go1.18 `encoding/json`/.Delimscip-go gomod github.com/golang/go/src go1.18 `encoding/json`/Delim#(']'), jsonscip-go gomod github.com/golang/go/src go1.18 `encoding/json`/.Delimscip-go gomod github.com/golang/go/src go1.18 `encoding/json`/Delim#('}'):
435 return errEndscip-go gomod github.com/google/go-dap . `github.com/google/go-dap/cmd/gentypes`/errEnd.
436 }
437 return nil
438 }
439
440 // commentOutEachLine returns s such that a Go comment marker ("//") is
441 // prepended to each line.
442 func commentOutEachLinescip-go gomod github.com/google/go-dap . `github.com/google/go-dap/cmd/gentypes`/commentOutEachLine().(s string) string {
443 parts := stringsscip-go gomod github.com/golang/go/src go1.18 strings/.Splitscip-go gomod github.com/golang/go/src go1.18 strings/Split().(s, "\n")
444 var sb stringsscip-go gomod github.com/golang/go/src go1.18 strings/.Builderscip-go gomod github.com/golang/go/src go1.18 strings/Builder#
445
446 for _, p := range parts {
447 fmtscip-go gomod github.com/golang/go/src go1.18 fmt/.Fprintfscip-go gomod github.com/golang/go/src go1.18 fmt/Fprintf().(&sb, "// %s\n", p)
448 }
449 return sb.Stringscip-go gomod github.com/golang/go/src go1.18 strings/Builder#String().()
450 }
451
452 // emitMethodsForType may emit methods for typeName into sb.
453 func emitMethodsForTypescip-go gomod github.com/google/go-dap . `github.com/google/go-dap/cmd/gentypes`/emitMethodsForType().(sb *stringsscip-go gomod github.com/golang/go/src go1.18 strings/.Builderscip-go gomod github.com/golang/go/src go1.18 strings/Builder#, typeName string) {
454 if typeName == "ProtocolMessage" {
455 fmtscip-go gomod github.com/golang/go/src go1.18 fmt/.Fprintlnscip-go gomod github.com/golang/go/src go1.18 fmt/Fprintln().(sb, "func (m *ProtocolMessage) GetSeq() int {return m.Seq}")
456 }
457 if typeName == "Request" {
458 fmtscip-go gomod github.com/golang/go/src go1.18 fmt/.Fprintlnscip-go gomod github.com/golang/go/src go1.18 fmt/Fprintln().(sb, "func (r *Request) GetRequest() *Request {return r}")
459 }
460 if typeName == "Response" {
461 fmtscip-go gomod github.com/golang/go/src go1.18 fmt/.Fprintlnscip-go gomod github.com/golang/go/src go1.18 fmt/Fprintln().(sb, "func (r *Response) GetResponse() *Response {return r}")
462 }
463 if typeName == "Event" {
464 fmtscip-go gomod github.com/golang/go/src go1.18 fmt/.Fprintlnscip-go gomod github.com/golang/go/src go1.18 fmt/Fprintln().(sb, "func (e *Event) GetEvent() *Event {return e}")
465 }
466 if typeName == "LaunchRequest" || typeName == "AttachRequest" {
467 fmtscip-go gomod github.com/golang/go/src go1.18 fmt/.Fprintfscip-go gomod github.com/golang/go/src go1.18 fmt/Fprintf().(sb, "func (r *%s) GetArguments() json.RawMessage { return r.Arguments }\n", typeName)
468 }
469 }
470
471 func emitCtorscip-go gomod github.com/google/go-dap . `github.com/google/go-dap/cmd/gentypes`/emitCtor().(sb *stringsscip-go gomod github.com/golang/go/src go1.18 strings/.Builderscip-go gomod github.com/golang/go/src go1.18 strings/Builder#, reqs, resps, events []string) {
472 fmtscip-go gomod github.com/golang/go/src go1.18 fmt/.Fprintscip-go gomod github.com/golang/go/src go1.18 fmt/Fprint().(sb, `
473 // Mapping of request commands and corresponding struct constructors that
474 // can be passed to json.Unmarshal.
475 var requestCtor = map[string]messageCtor{`)
476 for _, r := range reqs {
477 req := stringsscip-go gomod github.com/golang/go/src go1.18 strings/.TrimSuffixscip-go gomod github.com/golang/go/src go1.18 strings/TrimSuffix().(firstToLowerscip-go gomod github.com/google/go-dap . `github.com/google/go-dap/cmd/gentypes`/firstToLower().(r), "Request")
478 var msg string
479 if req == "initialize" {
480 msg = `
481 Arguments: InitializeRequestArguments{
482 // Set the default values specified here: https://microsoft.github.io/debug-adapter-protocol/specification#Requests_Initialize.
483 LinesStartAt1: true,
484 ColumnsStartAt1: true,
485 PathFormat: "path",
486 },
487 `
488 }
489 fmtscip-go gomod github.com/golang/go/src go1.18 fmt/.Fprintfscip-go gomod github.com/golang/go/src go1.18 fmt/Fprintf().(sb, "\n\t\"%s\":\tfunc() Message { return &%s{%s} },", req, r, msg)
490 }
491 fmtscip-go gomod github.com/golang/go/src go1.18 fmt/.Fprintscip-go gomod github.com/golang/go/src go1.18 fmt/Fprint().(sb, "\n}")
492
493 fmtscip-go gomod github.com/golang/go/src go1.18 fmt/.Fprintscip-go gomod github.com/golang/go/src go1.18 fmt/Fprint().(sb, `
494 // Mapping of response commands and corresponding struct constructors that
495 // can be passed to json.Unmarshal.
496 var responseCtor = map[string]messageCtor{`)
497 for _, r := range resps {
498 resp := stringsscip-go gomod github.com/golang/go/src go1.18 strings/.TrimSuffixscip-go gomod github.com/golang/go/src go1.18 strings/TrimSuffix().(firstToLowerscip-go gomod github.com/google/go-dap . `github.com/google/go-dap/cmd/gentypes`/firstToLower().(r), "Response")
499
500 fmtscip-go gomod github.com/golang/go/src go1.18 fmt/.Fprintfscip-go gomod github.com/golang/go/src go1.18 fmt/Fprintf().(sb, "\n\t\"%s\":\tfunc() Message { return &%s{} },", resp, r)
501 }
502 fmtscip-go gomod github.com/golang/go/src go1.18 fmt/.Fprintscip-go gomod github.com/golang/go/src go1.18 fmt/Fprint().(sb, "\n}")
503
504 fmtscip-go gomod github.com/golang/go/src go1.18 fmt/.Fprintscip-go gomod github.com/golang/go/src go1.18 fmt/Fprint().(sb, `
505 // Mapping of event ids and corresponding struct constructors that
506 // can be passed to json.Unmarshal.
507 var eventCtor = map[string]messageCtor{`)
508 for _, e := range events {
509 ev := stringsscip-go gomod github.com/golang/go/src go1.18 strings/.TrimSuffixscip-go gomod github.com/golang/go/src go1.18 strings/TrimSuffix().(firstToLowerscip-go gomod github.com/google/go-dap . `github.com/google/go-dap/cmd/gentypes`/firstToLower().(e), "Event")
510 fmtscip-go gomod github.com/golang/go/src go1.18 fmt/.Fprintfscip-go gomod github.com/golang/go/src go1.18 fmt/Fprintf().(sb, "\n\t\"%s\":\tfunc() Message { return &%s{} },", ev, e)
511 }
512 fmtscip-go gomod github.com/golang/go/src go1.18 fmt/.Fprintscip-go gomod github.com/golang/go/src go1.18 fmt/Fprint().(sb, "\n}\n")
513 }
514
515 func firstToLowerscip-go gomod github.com/google/go-dap . `github.com/google/go-dap/cmd/gentypes`/firstToLower().(s string) string {
516 r := []rune(s)
517 return string(unicodescip-go gomod github.com/golang/go/src go1.18 unicode/.ToLowerscip-go gomod github.com/golang/go/src go1.18 unicode/ToLower().(r[0])) + string(r[1:])
518 }
519
520 const preamblescip-go gomod github.com/google/go-dap . `github.com/google/go-dap/cmd/gentypes`/preamble. = `// Copyright 2020 Google LLC
521 //
522 // Licensed under the Apache License, Version 2.0 (the "License");
523 // you may not use this file except in compliance with the License.
524 // You may obtain a copy of the License at
525 //
526 // https://www.apache.org/licenses/LICENSE-2.0
527 //
528 // Unless required by applicable law or agreed to in writing, software
529 // distributed under the License is distributed on an "AS IS" BASIS,
530 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
531 // See the License for the specific language governing permissions and
532 // limitations under the License.
533
534 // Code generated by "cmd/gentypes/gentypes.go"; DO NOT EDIT.
535 // DAP spec: https://microsoft.github.io/debug-adapter-protocol/specification
536 // See cmd/gentypes/README.md for additional details.
537
538 package dap
539
540 import "encoding/json"
541
542 // Message is an interface that all DAP message types implement with pointer
543 // receivers. It's not part of the protocol but is used to enforce static
544 // typing in Go code and provide some common accessors.
545 //
546 // Note: the DAP type "Message" (which is used in the body of ErrorResponse)
547 // is renamed to ErrorMessage to avoid collision with this interface.
548 type Message interface {
549 GetSeq() int
550 }
551
552 // RequestMessage is an interface implemented by all Request-types.
553 type RequestMessage interface {
554 Message
555 // GetRequest provides access to the embedded Request.
556 GetRequest() *Request
557 }
558
559 // ResponseMessage is an interface implemented by all Response-types.
560 type ResponseMessage interface {
561 Message
562 // GetResponse provides access to the embedded Response.
563 GetResponse() *Response
564 }
565
566 // EventMessage is an interface implemented by all Event-types.
567 type EventMessage interface {
568 Message
569 // GetEvent provides access to the embedded Event.
570 GetEvent() *Event
571 }
572
573 // LaunchAttachRequest is an interface implemented by
574 // LaunchRequest and AttachRequest as they contain shared
575 // implementation specific arguments that are not part of
576 // the specification.
577 type LaunchAttachRequest interface {
578 RequestMessage
579 // GetArguments provides access to the Arguments map.
580 GetArguments() json.RawMessage
581 }
582 `
583
584 // typesExcludeList is an exclude list of type names we don't want to emit.
585 var typesExcludeListscip-go gomod github.com/google/go-dap . `github.com/google/go-dap/cmd/gentypes`/typesExcludeList. = map[string]bool{
586 // LaunchRequest and AttachRequest arguments can be arbitrary maps.
587 // Therefore, this type is not used anywhere.
588 "LaunchRequestArguments": true,
589 "AttachRequestArguments": true,
590 "RestartArguments": true,
591 }
592
593 func mainscip-go gomod github.com/google/go-dap . `github.com/google/go-dap/cmd/gentypes`/main().() {
594 flagscip-go gomod github.com/golang/go/src go1.18 flag/.Parsescip-go gomod github.com/golang/go/src go1.18 flag/Parse().()
595
596 logscip-go gomod github.com/golang/go/src go1.18 log/.SetFlagsscip-go gomod github.com/golang/go/src go1.18 log/SetFlags().(logscip-go gomod github.com/golang/go/src go1.18 log/.LstdFlagsscip-go gomod github.com/golang/go/src go1.18 log/LstdFlags. | logscip-go gomod github.com/golang/go/src go1.18 log/.Lshortfilescip-go gomod github.com/golang/go/src go1.18 log/Lshortfile.)
597
598 if flagscip-go gomod github.com/golang/go/src go1.18 flag/.NArgscip-go gomod github.com/golang/go/src go1.18 flag/NArg().() != 1 {
599 fmtscip-go gomod github.com/golang/go/src go1.18 fmt/.Fprintlnscip-go gomod github.com/golang/go/src go1.18 fmt/Fprintln().(osscip-go gomod github.com/golang/go/src go1.18 os/.Stderrscip-go gomod github.com/golang/go/src go1.18 os/Stderr., "Path to the DAP specification json file is required.")
600 fmtscip-go gomod github.com/golang/go/src go1.18 fmt/.Fprintlnscip-go gomod github.com/golang/go/src go1.18 fmt/Fprintln().(osscip-go gomod github.com/golang/go/src go1.18 os/.Stderrscip-go gomod github.com/golang/go/src go1.18 os/Stderr., "gentypes <path/to/debugProtocol.json>")
601 osscip-go gomod github.com/golang/go/src go1.18 os/.Exitscip-go gomod github.com/golang/go/src go1.18 os/Exit().(1)
602 }
603
604 inputFilename := flagscip-go gomod github.com/golang/go/src go1.18 flag/.Argscip-go gomod github.com/golang/go/src go1.18 flag/Arg().(0)
605
606 if *uFlagscip-go gomod github.com/google/go-dap . `github.com/google/go-dap/cmd/gentypes`/uFlag. {
607 if err := updateInputscip-go gomod github.com/google/go-dap . `github.com/google/go-dap/cmd/gentypes`/updateInput().(inputFilename); err != nil {
608 logscip-go gomod github.com/golang/go/src go1.18 log/.Fatalfscip-go gomod github.com/golang/go/src go1.18 log/Fatalf().("Failed to update the input file: %v", err)
609 }
610 }
611
612 inputData, err := ioutilscip-go gomod github.com/golang/go/src go1.18 `io/ioutil`/.ReadFilescip-go gomod github.com/golang/go/src go1.18 `io/ioutil`/ReadFile().(inputFilename)
613 if err != nil {
614 logscip-go gomod github.com/golang/go/src go1.18 log/.Fatalscip-go gomod github.com/golang/go/src go1.18 log/Fatal().(err)
615 }
616
617 var m map[string]jsonscip-go gomod github.com/golang/go/src go1.18 `encoding/json`/.RawMessagescip-go gomod github.com/golang/go/src go1.18 `encoding/json`/RawMessage#
618 if err := jsonscip-go gomod github.com/golang/go/src go1.18 `encoding/json`/.Unmarshalscip-go gomod github.com/golang/go/src go1.18 `encoding/json`/Unmarshal().(inputData, &m); err != nil {
619 logscip-go gomod github.com/golang/go/src go1.18 log/.Fatalscip-go gomod github.com/golang/go/src go1.18 log/Fatal().(err)
620 }
621 var typeMap map[string]jsonscip-go gomod github.com/golang/go/src go1.18 `encoding/json`/.RawMessagescip-go gomod github.com/golang/go/src go1.18 `encoding/json`/RawMessage#
622 if err := jsonscip-go gomod github.com/golang/go/src go1.18 `encoding/json`/.Unmarshalscip-go gomod github.com/golang/go/src go1.18 `encoding/json`/Unmarshal().(m["definitions"], &typeMap); err != nil {
623 logscip-go gomod github.com/golang/go/src go1.18 log/.Fatalscip-go gomod github.com/golang/go/src go1.18 log/Fatal().(err)
624 }
625
626 goTypesIsStruct := make(map[string]bool)
627 for typeName, descJson := range typeMap {
628 var descMap map[string]jsonscip-go gomod github.com/golang/go/src go1.18 `encoding/json`/.RawMessagescip-go gomod github.com/golang/go/src go1.18 `encoding/json`/RawMessage#
629 if err := jsonscip-go gomod github.com/golang/go/src go1.18 `encoding/json`/.Unmarshalscip-go gomod github.com/golang/go/src go1.18 `encoding/json`/Unmarshal().(descJson, &descMap); err != nil {
630 logscip-go gomod github.com/golang/go/src go1.18 log/.Fatalscip-go gomod github.com/golang/go/src go1.18 log/Fatal().(err)
631 }
632 _, descMap = maybeParseInheritancescip-go gomod github.com/google/go-dap . `github.com/google/go-dap/cmd/gentypes`/maybeParseInheritance().(descMap)
633
634 typeJson, ok := descMap["type"]
635 if !ok {
636 logscip-go gomod github.com/golang/go/src go1.18 log/.Fatalscip-go gomod github.com/golang/go/src go1.18 log/Fatal().("want description to have 'type', got ", descMap)
637 }
638
639 var descTypeString string
640 if err := jsonscip-go gomod github.com/golang/go/src go1.18 `encoding/json`/.Unmarshalscip-go gomod github.com/golang/go/src go1.18 `encoding/json`/Unmarshal().(typeJson, &descTypeString); err != nil {
641 logscip-go gomod github.com/golang/go/src go1.18 log/.Fatalscip-go gomod github.com/golang/go/src go1.18 log/Fatal().(err)
642 }
643
644 goTypesIsStruct[replaceGoTypenamescip-go gomod github.com/google/go-dap . `github.com/google/go-dap/cmd/gentypes`/replaceGoTypename().(typeName)] = descTypeString == "object"
645 }
646
647 var b stringsscip-go gomod github.com/golang/go/src go1.18 strings/.Builderscip-go gomod github.com/golang/go/src go1.18 strings/Builder#
648 b.WriteStringscip-go gomod github.com/golang/go/src go1.18 strings/Builder#WriteString().(preamblescip-go gomod github.com/google/go-dap . `github.com/google/go-dap/cmd/gentypes`/preamble.)
649
650 typeNames, err := keysInOrderscip-go gomod github.com/google/go-dap . `github.com/google/go-dap/cmd/gentypes`/keysInOrder().(m["definitions"])
651 if err != nil {
652 logscip-go gomod github.com/golang/go/src go1.18 log/.Fatalscip-go gomod github.com/golang/go/src go1.18 log/Fatal().(err)
653 }
654
655 var requests, responses, events []string
656 for _, typeName := range typeNames {
657 if _, ok := typesExcludeListscip-go gomod github.com/google/go-dap . `github.com/google/go-dap/cmd/gentypes`/typesExcludeList.[typeName]; !ok {
658 b.WriteStringscip-go gomod github.com/golang/go/src go1.18 strings/Builder#WriteString().(emitToplevelTypescip-go gomod github.com/google/go-dap . `github.com/google/go-dap/cmd/gentypes`/emitToplevelType().(replaceGoTypenamescip-go gomod github.com/google/go-dap . `github.com/google/go-dap/cmd/gentypes`/replaceGoTypename().(typeName), typeMap[typeName], goTypesIsStruct))
659 b.WriteStringscip-go gomod github.com/golang/go/src go1.18 strings/Builder#WriteString().("\n")
660 }
661
662 emitMethodsForTypescip-go gomod github.com/google/go-dap . `github.com/google/go-dap/cmd/gentypes`/emitMethodsForType().(&b, replaceGoTypenamescip-go gomod github.com/google/go-dap . `github.com/google/go-dap/cmd/gentypes`/replaceGoTypename().(typeName))
663 // Add the typename to the appropriate list.
664 if stringsscip-go gomod github.com/golang/go/src go1.18 strings/.HasSuffixscip-go gomod github.com/golang/go/src go1.18 strings/HasSuffix().(typeName, "Request") && typeName != "Request" {
665 requests = append(requests, typeName)
666 }
667 if stringsscip-go gomod github.com/golang/go/src go1.18 strings/.HasSuffixscip-go gomod github.com/golang/go/src go1.18 strings/HasSuffix().(typeName, "Response") && typeName != "Response" && typeName != "ErrorResponse" {
668 responses = append(responses, typeName)
669 }
670 if stringsscip-go gomod github.com/golang/go/src go1.18 strings/.HasSuffixscip-go gomod github.com/golang/go/src go1.18 strings/HasSuffix().(typeName, "Event") && typeName != "Event" {
671 events = append(events, typeName)
672 }
673 }
674
675 // Emit the maps from id to response and event types.
676 emitCtorscip-go gomod github.com/google/go-dap . `github.com/google/go-dap/cmd/gentypes`/emitCtor().(&b, requests, responses, events)
677
678 wholeFile := []byte(b.Stringscip-go gomod github.com/golang/go/src go1.18 strings/Builder#String().())
679 formatted, err := formatscip-go gomod github.com/golang/go/src go1.18 `go/format`/.Sourcescip-go gomod github.com/golang/go/src go1.18 `go/format`/Source().(wholeFile)
680 if err != nil {
681 logscip-go gomod github.com/golang/go/src go1.18 log/.Fatalscip-go gomod github.com/golang/go/src go1.18 log/Fatal().(err)
682 }
683 if *oFlagscip-go gomod github.com/google/go-dap . `github.com/google/go-dap/cmd/gentypes`/oFlag. == "" {
684 fmtscip-go gomod github.com/golang/go/src go1.18 fmt/.Printscip-go gomod github.com/golang/go/src go1.18 fmt/Print().(string(formatted))
685 } else {
686 if err := ioutilscip-go gomod github.com/golang/go/src go1.18 `io/ioutil`/.WriteFilescip-go gomod github.com/golang/go/src go1.18 `io/ioutil`/WriteFile().(*oFlagscip-go gomod github.com/google/go-dap . `github.com/google/go-dap/cmd/gentypes`/oFlag., formatted, 0644); err != nil {
687 logscip-go gomod github.com/golang/go/src go1.18 log/.Fatalfscip-go gomod github.com/golang/go/src go1.18 log/Fatalf().("Failed to write the generated file: %v", err)
688 }
689 }
690 }
691
692 func updateInputscip-go gomod github.com/google/go-dap . `github.com/google/go-dap/cmd/gentypes`/updateInput().(inputFilename string) error {
693 resp, err := httpscip-go gomod github.com/golang/go/src go1.18 `net/http`/.Getscip-go gomod github.com/golang/go/src go1.18 `net/http`/Get().("https://raw.githubusercontent.com/microsoft/vscode-debugadapter-node/main/debugProtocol.json")
694 if err != nil {
695 return err
696 }
697 defer resp.Bodyscip-go gomod github.com/golang/go/src go1.18 `net/http`/Response#Body..Closescip-go gomod github.com/golang/go/src go1.18 io/Closer#Close().()
698 data, err := ioutilscip-go gomod github.com/golang/go/src go1.18 `io/ioutil`/.ReadAllscip-go gomod github.com/golang/go/src go1.18 `io/ioutil`/ReadAll().(resp.Bodyscip-go gomod github.com/golang/go/src go1.18 `net/http`/Response#Body.)
699 if err != nil {
700 return err
701 }
702 return ioutilscip-go gomod github.com/golang/go/src go1.18 `io/ioutil`/.WriteFilescip-go gomod github.com/golang/go/src go1.18 `io/ioutil`/WriteFile().(inputFilename, data, 0644)
703 }