Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Source field in Breakpoint events optional #67

Merged
merged 2 commits into from Dec 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 12 additions & 7 deletions cmd/gentypes/gentypes.go
Expand Up @@ -62,10 +62,10 @@ func goFieldName(jsonPropName string) string {
// parsePropertyType takes the JSON value of a property field and extracts
// the Go type of the property. For example, given this map:
//
// {
// "type": "string",
// "description": "The command to execute."
// },
// {
// "type": "string",
// "description": "The command to execute."
// },
//
// It will emit "string".
func parsePropertyType(propValue map[string]interface{}) string {
Expand Down Expand Up @@ -132,8 +132,8 @@ func parsePropertyType(propValue map[string]interface{}) string {
//
// Example:
//
// "allOf": [ { "$ref": "#/definitions/ProtocolMessage" },
// {... type description ...} ]
// "allOf": [ { "$ref": "#/definitions/ProtocolMessage" },
// {... type description ...} ]
//
// Returns base type ProtocolMessage and a map representing type description.
// If there is no "allOf", returns an empty baseTypeName and descMap itself.
Expand Down Expand Up @@ -318,8 +318,13 @@ func emitToplevelType(typeName string, descJson json.RawMessage) string {
} else {
jsonTag += ",omitempty\"`"
}

if typeName == "Breakpoint" && goType == "Source" {
// Make the Source field in Breakpoint a pointer since a DAP client may distinguish
// between zero and nil source values.
goType = "*" + goType
}
fmt.Fprintf(&b, "\t%s %s %s\n", goFieldName(propName), goType, jsonTag)

}
}

Expand Down
20 changes: 10 additions & 10 deletions schematypes.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.