Update DAP protocol to 1.41.0

Update the script to include the DAP version in the file headers.

Remove http file caching. Was never used.
This commit is contained in:
Ben Clayton 2020-06-10 12:50:21 +01:00
parent f0c28f93dd
commit bb3dbcd2c3
6 changed files with 185 additions and 45 deletions

View File

@ -14,6 +14,8 @@
// Generated with protocol_gen.go -- do not edit this file. // Generated with protocol_gen.go -- do not edit this file.
// go run scripts/protocol_gen/protocol_gen.go // go run scripts/protocol_gen/protocol_gen.go
//
// DAP version 1.41.0
#ifndef dap_protocol_h #ifndef dap_protocol_h
#define dap_protocol_h #define dap_protocol_h
@ -125,8 +127,8 @@ struct Source {
DAP_DECLARE_STRUCT_TYPEINFO(Source); DAP_DECLARE_STRUCT_TYPEINFO(Source);
// Information about a Breakpoint created in setBreakpoints or // Information about a Breakpoint created in setBreakpoints,
// setFunctionBreakpoints. // setFunctionBreakpoints, setInstructionBreakpoints, or setDataBreakpoints.
struct Breakpoint { struct Breakpoint {
Breakpoint(); Breakpoint();
~Breakpoint(); ~Breakpoint();
@ -142,12 +144,17 @@ struct Breakpoint {
// An optional identifier for the breakpoint. It is needed if breakpoint // An optional identifier for the breakpoint. It is needed if breakpoint
// events are used to update or remove breakpoints. // events are used to update or remove breakpoints.
optional<integer> id; optional<integer> id;
// An optional memory reference to where the breakpoint is set.
optional<string> instructionReference;
// The start line of the actual range covered by the breakpoint. // The start line of the actual range covered by the breakpoint.
optional<integer> line; optional<integer> line;
// An optional message about the state of the breakpoint. // An optional message about the state of the breakpoint.
// This is shown to the user and can be used to explain why a breakpoint could // This is shown to the user and can be used to explain why a breakpoint could
// not be verified. // not be verified.
optional<string> message; optional<string> message;
// An optional offset from the instruction reference.
// This can be negative.
optional<integer> offset;
// The source where the breakpoint is located. // The source where the breakpoint is located.
optional<Source> source; optional<Source> source;
// If true breakpoint could be set (but not necessarily at the desired // If true breakpoint could be set (but not necessarily at the desired
@ -374,6 +381,9 @@ struct Capabilities {
// The debug adapter supports breakpoints that break execution after a // The debug adapter supports breakpoints that break execution after a
// specified number of hits. // specified number of hits.
optional<boolean> supportsHitConditionalBreakpoints; optional<boolean> supportsHitConditionalBreakpoints;
// The debug adapter supports adding breakpoints based on instruction
// references.
optional<boolean> supportsInstructionBreakpoints;
// The debug adapter supports the 'loadedSources' request. // The debug adapter supports the 'loadedSources' request.
optional<boolean> supportsLoadedSourcesRequest; optional<boolean> supportsLoadedSourcesRequest;
// The debug adapter supports logpoints by interpreting the 'logMessage' // The debug adapter supports logpoints by interpreting the 'logMessage'
@ -398,6 +408,9 @@ struct Capabilities {
optional<boolean> supportsStepBack; optional<boolean> supportsStepBack;
// The debug adapter supports the 'stepInTargets' request. // The debug adapter supports the 'stepInTargets' request.
optional<boolean> supportsStepInTargetsRequest; optional<boolean> supportsStepInTargetsRequest;
// The debug adapter supports stepping granularities (argument 'granularity')
// for the stepping requests.
optional<boolean> supportsSteppingGranularity;
// The debug adapter supports the 'terminate' request. // The debug adapter supports the 'terminate' request.
optional<boolean> supportsTerminateRequest; optional<boolean> supportsTerminateRequest;
// The debug adapter supports the 'terminateThreads' request. // The debug adapter supports the 'terminateThreads' request.
@ -1094,6 +1107,9 @@ struct InitializeResponse : public Response {
// The debug adapter supports breakpoints that break execution after a // The debug adapter supports breakpoints that break execution after a
// specified number of hits. // specified number of hits.
optional<boolean> supportsHitConditionalBreakpoints; optional<boolean> supportsHitConditionalBreakpoints;
// The debug adapter supports adding breakpoints based on instruction
// references.
optional<boolean> supportsInstructionBreakpoints;
// The debug adapter supports the 'loadedSources' request. // The debug adapter supports the 'loadedSources' request.
optional<boolean> supportsLoadedSourcesRequest; optional<boolean> supportsLoadedSourcesRequest;
// The debug adapter supports logpoints by interpreting the 'logMessage' // The debug adapter supports logpoints by interpreting the 'logMessage'
@ -1118,6 +1134,9 @@ struct InitializeResponse : public Response {
optional<boolean> supportsStepBack; optional<boolean> supportsStepBack;
// The debug adapter supports the 'stepInTargets' request. // The debug adapter supports the 'stepInTargets' request.
optional<boolean> supportsStepInTargetsRequest; optional<boolean> supportsStepInTargetsRequest;
// The debug adapter supports stepping granularities (argument 'granularity')
// for the stepping requests.
optional<boolean> supportsSteppingGranularity;
// The debug adapter supports the 'terminate' request. // The debug adapter supports the 'terminate' request.
optional<boolean> supportsTerminateRequest; optional<boolean> supportsTerminateRequest;
// The debug adapter supports the 'terminateThreads' request. // The debug adapter supports the 'terminateThreads' request.
@ -1376,6 +1395,15 @@ struct NextResponse : public Response {
DAP_DECLARE_STRUCT_TYPEINFO(NextResponse); DAP_DECLARE_STRUCT_TYPEINFO(NextResponse);
// The granularity of one 'step' in the stepping requests 'next', 'stepIn',
// 'stepOut', and 'stepBack'.
struct SteppingGranularity {
SteppingGranularity();
~SteppingGranularity();
};
DAP_DECLARE_STRUCT_TYPEINFO(SteppingGranularity);
// The request starts the debuggee to run again for one step. // The request starts the debuggee to run again for one step.
// The debug adapter first sends the response and then a 'stopped' event (with // The debug adapter first sends the response and then a 'stopped' event (with
// reason 'step') after the step has completed. // reason 'step') after the step has completed.
@ -1385,6 +1413,9 @@ struct NextRequest : public Request {
NextRequest(); NextRequest();
~NextRequest(); ~NextRequest();
// Optional granularity to step. If no granularity is specified, a granularity
// of 'statement' is assumed.
optional<SteppingGranularity> granularity;
// Execute 'next' for this thread. // Execute 'next' for this thread.
integer threadId; integer threadId;
}; };
@ -2063,6 +2094,61 @@ struct SetFunctionBreakpointsRequest : public Request {
DAP_DECLARE_STRUCT_TYPEINFO(SetFunctionBreakpointsRequest); DAP_DECLARE_STRUCT_TYPEINFO(SetFunctionBreakpointsRequest);
// Response to 'setInstructionBreakpoints' request
struct SetInstructionBreakpointsResponse : public Response {
SetInstructionBreakpointsResponse();
~SetInstructionBreakpointsResponse();
// Information about the breakpoints. The array elements correspond to the
// elements of the 'breakpoints' array.
array<Breakpoint> breakpoints;
};
DAP_DECLARE_STRUCT_TYPEINFO(SetInstructionBreakpointsResponse);
// Properties of a breakpoint passed to the setInstructionBreakpoints request
struct InstructionBreakpoint {
InstructionBreakpoint();
~InstructionBreakpoint();
// An optional expression for conditional breakpoints.
// It is only honored by a debug adapter if the capability
// 'supportsConditionalBreakpoints' is true.
optional<string> condition;
// An optional expression that controls how many hits of the breakpoint are
// ignored. The backend is expected to interpret the expression as needed. The
// attribute is only honored by a debug adapter if the capability
// 'supportsHitConditionalBreakpoints' is true.
optional<string> hitCondition;
// The instruction reference of the breakpoint.
// This should be a memory or instruction pointer reference from an
// EvaluateResponse, Variable, StackFrame, GotoTarget, or Breakpoint.
string instructionReference;
// An optional offset from the instruction reference.
// This can be negative.
optional<integer> offset;
};
DAP_DECLARE_STRUCT_TYPEINFO(InstructionBreakpoint);
// Replaces all existing instruction breakpoints. Typically, instruction
// breakpoints would be set from a diassembly window. To clear all instruction
// breakpoints, specify an empty array. When an instruction breakpoint is hit, a
// 'stopped' event (with reason 'instruction breakpoint') is generated. Clients
// should only call this request if the capability
// 'supportsInstructionBreakpoints' is true.
struct SetInstructionBreakpointsRequest : public Request {
using Response = SetInstructionBreakpointsResponse;
SetInstructionBreakpointsRequest();
~SetInstructionBreakpointsRequest();
// The instruction references of the breakpoints
array<InstructionBreakpoint> breakpoints;
};
DAP_DECLARE_STRUCT_TYPEINFO(SetInstructionBreakpointsRequest);
// Response to 'setVariable' request. // Response to 'setVariable' request.
struct SetVariableResponse : public Response { struct SetVariableResponse : public Response {
SetVariableResponse(); SetVariableResponse();
@ -2263,6 +2349,9 @@ struct StepBackRequest : public Request {
StepBackRequest(); StepBackRequest();
~StepBackRequest(); ~StepBackRequest();
// Optional granularity to step. If no granularity is specified, a granularity
// of 'statement' is assumed.
optional<SteppingGranularity> granularity;
// Execute 'stepBack' for this thread. // Execute 'stepBack' for this thread.
integer threadId; integer threadId;
}; };
@ -2292,6 +2381,9 @@ struct StepInRequest : public Request {
StepInRequest(); StepInRequest();
~StepInRequest(); ~StepInRequest();
// Optional granularity to step. If no granularity is specified, a granularity
// of 'statement' is assumed.
optional<SteppingGranularity> granularity;
// Optional id of the target to step into. // Optional id of the target to step into.
optional<integer> targetId; optional<integer> targetId;
// Execute 'stepIn' for this thread. // Execute 'stepIn' for this thread.
@ -2360,6 +2452,9 @@ struct StepOutRequest : public Request {
StepOutRequest(); StepOutRequest();
~StepOutRequest(); ~StepOutRequest();
// Optional granularity to step. If no granularity is specified, a granularity
// of 'statement' is assumed.
optional<SteppingGranularity> granularity;
// Execute 'stepOut' for this thread. // Execute 'stepOut' for this thread.
integer threadId; integer threadId;
}; };
@ -2368,7 +2463,7 @@ DAP_DECLARE_STRUCT_TYPEINFO(StepOutRequest);
// The event indicates that the execution of the debuggee has stopped due to // The event indicates that the execution of the debuggee has stopped due to
// some condition. This can be caused by a break point previously set, a // some condition. This can be caused by a break point previously set, a
// stepping action has completed, by executing a debugger statement etc. // stepping request has completed, by executing a debugger statement etc.
struct StoppedEvent : public Event { struct StoppedEvent : public Event {
StoppedEvent(); StoppedEvent();
~StoppedEvent(); ~StoppedEvent();
@ -2392,7 +2487,7 @@ struct StoppedEvent : public Event {
// //
// May be one of the following enumeration values: // May be one of the following enumeration values:
// 'step', 'breakpoint', 'exception', 'pause', 'entry', 'goto', 'function // 'step', 'breakpoint', 'exception', 'pause', 'entry', 'goto', 'function
// breakpoint', 'data breakpoint' // breakpoint', 'data breakpoint', 'instruction breakpoint'
string reason; string reason;
// Additional information. E.g. if reason is 'exception', text contains the // Additional information. E.g. if reason is 'exception', text contains the
// exception name. This string is shown in the UI. // exception name. This string is shown in the UI.

View File

@ -14,6 +14,8 @@
// Generated with protocol_gen.go -- do not edit this file. // Generated with protocol_gen.go -- do not edit this file.
// go run scripts/protocol_gen/protocol_gen.go // go run scripts/protocol_gen/protocol_gen.go
//
// DAP version 1.41.0
#include "dap/protocol.h" #include "dap/protocol.h"

View File

@ -14,6 +14,8 @@
// Generated with protocol_gen.go -- do not edit this file. // Generated with protocol_gen.go -- do not edit this file.
// go run scripts/protocol_gen/protocol_gen.go // go run scripts/protocol_gen/protocol_gen.go
//
// DAP version 1.41.0
#include "dap/protocol.h" #include "dap/protocol.h"
@ -157,6 +159,7 @@ NextRequest::NextRequest() = default;
NextRequest::~NextRequest() = default; NextRequest::~NextRequest() = default;
DAP_IMPLEMENT_STRUCT_TYPEINFO(NextRequest, DAP_IMPLEMENT_STRUCT_TYPEINFO(NextRequest,
"next", "next",
DAP_FIELD(granularity, "granularity"),
DAP_FIELD(threadId, "threadId")); DAP_FIELD(threadId, "threadId"));
PauseRequest::PauseRequest() = default; PauseRequest::PauseRequest() = default;
@ -242,6 +245,12 @@ DAP_IMPLEMENT_STRUCT_TYPEINFO(SetFunctionBreakpointsRequest,
"setFunctionBreakpoints", "setFunctionBreakpoints",
DAP_FIELD(breakpoints, "breakpoints")); DAP_FIELD(breakpoints, "breakpoints"));
SetInstructionBreakpointsRequest::SetInstructionBreakpointsRequest() = default;
SetInstructionBreakpointsRequest::~SetInstructionBreakpointsRequest() = default;
DAP_IMPLEMENT_STRUCT_TYPEINFO(SetInstructionBreakpointsRequest,
"setInstructionBreakpoints",
DAP_FIELD(breakpoints, "breakpoints"));
SetVariableRequest::SetVariableRequest() = default; SetVariableRequest::SetVariableRequest() = default;
SetVariableRequest::~SetVariableRequest() = default; SetVariableRequest::~SetVariableRequest() = default;
DAP_IMPLEMENT_STRUCT_TYPEINFO(SetVariableRequest, DAP_IMPLEMENT_STRUCT_TYPEINFO(SetVariableRequest,
@ -272,12 +281,14 @@ StepBackRequest::StepBackRequest() = default;
StepBackRequest::~StepBackRequest() = default; StepBackRequest::~StepBackRequest() = default;
DAP_IMPLEMENT_STRUCT_TYPEINFO(StepBackRequest, DAP_IMPLEMENT_STRUCT_TYPEINFO(StepBackRequest,
"stepBack", "stepBack",
DAP_FIELD(granularity, "granularity"),
DAP_FIELD(threadId, "threadId")); DAP_FIELD(threadId, "threadId"));
StepInRequest::StepInRequest() = default; StepInRequest::StepInRequest() = default;
StepInRequest::~StepInRequest() = default; StepInRequest::~StepInRequest() = default;
DAP_IMPLEMENT_STRUCT_TYPEINFO(StepInRequest, DAP_IMPLEMENT_STRUCT_TYPEINFO(StepInRequest,
"stepIn", "stepIn",
DAP_FIELD(granularity, "granularity"),
DAP_FIELD(targetId, "targetId"), DAP_FIELD(targetId, "targetId"),
DAP_FIELD(threadId, "threadId")); DAP_FIELD(threadId, "threadId"));
@ -291,6 +302,7 @@ StepOutRequest::StepOutRequest() = default;
StepOutRequest::~StepOutRequest() = default; StepOutRequest::~StepOutRequest() = default;
DAP_IMPLEMENT_STRUCT_TYPEINFO(StepOutRequest, DAP_IMPLEMENT_STRUCT_TYPEINFO(StepOutRequest,
"stepOut", "stepOut",
DAP_FIELD(granularity, "granularity"),
DAP_FIELD(threadId, "threadId")); DAP_FIELD(threadId, "threadId"));
TerminateRequest::TerminateRequest() = default; TerminateRequest::TerminateRequest() = default;

View File

@ -14,6 +14,8 @@
// Generated with protocol_gen.go -- do not edit this file. // Generated with protocol_gen.go -- do not edit this file.
// go run scripts/protocol_gen/protocol_gen.go // go run scripts/protocol_gen/protocol_gen.go
//
// DAP version 1.41.0
#include "dap/protocol.h" #include "dap/protocol.h"
@ -134,6 +136,7 @@ DAP_IMPLEMENT_STRUCT_TYPEINFO(
DAP_FIELD(supportsGotoTargetsRequest, "supportsGotoTargetsRequest"), DAP_FIELD(supportsGotoTargetsRequest, "supportsGotoTargetsRequest"),
DAP_FIELD(supportsHitConditionalBreakpoints, DAP_FIELD(supportsHitConditionalBreakpoints,
"supportsHitConditionalBreakpoints"), "supportsHitConditionalBreakpoints"),
DAP_FIELD(supportsInstructionBreakpoints, "supportsInstructionBreakpoints"),
DAP_FIELD(supportsLoadedSourcesRequest, "supportsLoadedSourcesRequest"), DAP_FIELD(supportsLoadedSourcesRequest, "supportsLoadedSourcesRequest"),
DAP_FIELD(supportsLogPoints, "supportsLogPoints"), DAP_FIELD(supportsLogPoints, "supportsLogPoints"),
DAP_FIELD(supportsModulesRequest, "supportsModulesRequest"), DAP_FIELD(supportsModulesRequest, "supportsModulesRequest"),
@ -144,6 +147,7 @@ DAP_IMPLEMENT_STRUCT_TYPEINFO(
DAP_FIELD(supportsSetVariable, "supportsSetVariable"), DAP_FIELD(supportsSetVariable, "supportsSetVariable"),
DAP_FIELD(supportsStepBack, "supportsStepBack"), DAP_FIELD(supportsStepBack, "supportsStepBack"),
DAP_FIELD(supportsStepInTargetsRequest, "supportsStepInTargetsRequest"), DAP_FIELD(supportsStepInTargetsRequest, "supportsStepInTargetsRequest"),
DAP_FIELD(supportsSteppingGranularity, "supportsSteppingGranularity"),
DAP_FIELD(supportsTerminateRequest, "supportsTerminateRequest"), DAP_FIELD(supportsTerminateRequest, "supportsTerminateRequest"),
DAP_FIELD(supportsTerminateThreadsRequest, DAP_FIELD(supportsTerminateThreadsRequest,
"supportsTerminateThreadsRequest"), "supportsTerminateThreadsRequest"),
@ -240,6 +244,14 @@ DAP_IMPLEMENT_STRUCT_TYPEINFO(SetFunctionBreakpointsResponse,
"", "",
DAP_FIELD(breakpoints, "breakpoints")); DAP_FIELD(breakpoints, "breakpoints"));
SetInstructionBreakpointsResponse::SetInstructionBreakpointsResponse() =
default;
SetInstructionBreakpointsResponse::~SetInstructionBreakpointsResponse() =
default;
DAP_IMPLEMENT_STRUCT_TYPEINFO(SetInstructionBreakpointsResponse,
"",
DAP_FIELD(breakpoints, "breakpoints"));
SetVariableResponse::SetVariableResponse() = default; SetVariableResponse::SetVariableResponse() = default;
SetVariableResponse::~SetVariableResponse() = default; SetVariableResponse::~SetVariableResponse() = default;
DAP_IMPLEMENT_STRUCT_TYPEINFO(SetVariableResponse, DAP_IMPLEMENT_STRUCT_TYPEINFO(SetVariableResponse,

View File

@ -14,6 +14,8 @@
// Generated with protocol_gen.go -- do not edit this file. // Generated with protocol_gen.go -- do not edit this file.
// go run scripts/protocol_gen/protocol_gen.go // go run scripts/protocol_gen/protocol_gen.go
//
// DAP version 1.41.0
#include "dap/protocol.h" #include "dap/protocol.h"
@ -51,8 +53,11 @@ DAP_IMPLEMENT_STRUCT_TYPEINFO(Breakpoint,
DAP_FIELD(endColumn, "endColumn"), DAP_FIELD(endColumn, "endColumn"),
DAP_FIELD(endLine, "endLine"), DAP_FIELD(endLine, "endLine"),
DAP_FIELD(id, "id"), DAP_FIELD(id, "id"),
DAP_FIELD(instructionReference,
"instructionReference"),
DAP_FIELD(line, "line"), DAP_FIELD(line, "line"),
DAP_FIELD(message, "message"), DAP_FIELD(message, "message"),
DAP_FIELD(offset, "offset"),
DAP_FIELD(source, "source"), DAP_FIELD(source, "source"),
DAP_FIELD(verified, "verified")); DAP_FIELD(verified, "verified"));
@ -112,6 +117,7 @@ DAP_IMPLEMENT_STRUCT_TYPEINFO(
DAP_FIELD(supportsGotoTargetsRequest, "supportsGotoTargetsRequest"), DAP_FIELD(supportsGotoTargetsRequest, "supportsGotoTargetsRequest"),
DAP_FIELD(supportsHitConditionalBreakpoints, DAP_FIELD(supportsHitConditionalBreakpoints,
"supportsHitConditionalBreakpoints"), "supportsHitConditionalBreakpoints"),
DAP_FIELD(supportsInstructionBreakpoints, "supportsInstructionBreakpoints"),
DAP_FIELD(supportsLoadedSourcesRequest, "supportsLoadedSourcesRequest"), DAP_FIELD(supportsLoadedSourcesRequest, "supportsLoadedSourcesRequest"),
DAP_FIELD(supportsLogPoints, "supportsLogPoints"), DAP_FIELD(supportsLogPoints, "supportsLogPoints"),
DAP_FIELD(supportsModulesRequest, "supportsModulesRequest"), DAP_FIELD(supportsModulesRequest, "supportsModulesRequest"),
@ -122,6 +128,7 @@ DAP_IMPLEMENT_STRUCT_TYPEINFO(
DAP_FIELD(supportsSetVariable, "supportsSetVariable"), DAP_FIELD(supportsSetVariable, "supportsSetVariable"),
DAP_FIELD(supportsStepBack, "supportsStepBack"), DAP_FIELD(supportsStepBack, "supportsStepBack"),
DAP_FIELD(supportsStepInTargetsRequest, "supportsStepInTargetsRequest"), DAP_FIELD(supportsStepInTargetsRequest, "supportsStepInTargetsRequest"),
DAP_FIELD(supportsSteppingGranularity, "supportsSteppingGranularity"),
DAP_FIELD(supportsTerminateRequest, "supportsTerminateRequest"), DAP_FIELD(supportsTerminateRequest, "supportsTerminateRequest"),
DAP_FIELD(supportsTerminateThreadsRequest, DAP_FIELD(supportsTerminateThreadsRequest,
"supportsTerminateThreadsRequest"), "supportsTerminateThreadsRequest"),
@ -230,6 +237,10 @@ DAP_IMPLEMENT_STRUCT_TYPEINFO(Module,
DAP_FIELD(symbolStatus, "symbolStatus"), DAP_FIELD(symbolStatus, "symbolStatus"),
DAP_FIELD(version, "version")); DAP_FIELD(version, "version"));
SteppingGranularity::SteppingGranularity() = default;
SteppingGranularity::~SteppingGranularity() = default;
DAP_IMPLEMENT_STRUCT_TYPEINFO(SteppingGranularity, "");
Scope::Scope() = default; Scope::Scope() = default;
Scope::~Scope() = default; Scope::~Scope() = default;
DAP_IMPLEMENT_STRUCT_TYPEINFO(Scope, DAP_IMPLEMENT_STRUCT_TYPEINFO(Scope,
@ -288,6 +299,16 @@ DAP_IMPLEMENT_STRUCT_TYPEINFO(FunctionBreakpoint,
DAP_FIELD(hitCondition, "hitCondition"), DAP_FIELD(hitCondition, "hitCondition"),
DAP_FIELD(name, "name")); DAP_FIELD(name, "name"));
InstructionBreakpoint::InstructionBreakpoint() = default;
InstructionBreakpoint::~InstructionBreakpoint() = default;
DAP_IMPLEMENT_STRUCT_TYPEINFO(InstructionBreakpoint,
"",
DAP_FIELD(condition, "condition"),
DAP_FIELD(hitCondition, "hitCondition"),
DAP_FIELD(instructionReference,
"instructionReference"),
DAP_FIELD(offset, "offset"));
StackFrame::StackFrame() = default; StackFrame::StackFrame() = default;
StackFrame::~StackFrame() = default; StackFrame::~StackFrame() = default;
DAP_IMPLEMENT_STRUCT_TYPEINFO(StackFrame, DAP_IMPLEMENT_STRUCT_TYPEINFO(StackFrame,

View File

@ -33,29 +33,29 @@ import (
"strings" "strings"
) )
var (
cache = flag.String("cache", "", "File cache of the .json schema")
)
const ( const (
jsonURL = "https://raw.githubusercontent.com/microsoft/vscode-debugadapter-node/master/debugProtocol.json" protocolURL = "https://raw.githubusercontent.com/microsoft/vscode-debugadapter-node/master/debugProtocol.json"
packageURL = "https://raw.githubusercontent.com/microsoft/vscode-debugadapter-node/master/protocol/package.json"
versionTag = "${version}"
commonPrologue = `// Copyright 2019 Google LLC commonPrologue = `// Copyright 2019 Google LLC
// //
// Licensed under the Apache License, Version 2.0 (the "License"); // Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License. // you may not use this file except in compliance with the License.
// You may obtain a copy of the License at // You may obtain a copy of the License at
// //
// https://www.apache.org/licenses/LICENSE-2.0 // https://www.apache.org/licenses/LICENSE-2.0
// //
// Unless required by applicable law or agreed to in writing, software // Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, // distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
// Generated with protocol_gen.go -- do not edit this file. // Generated with protocol_gen.go -- do not edit this file.
// go run scripts/protocol_gen/protocol_gen.go // go run scripts/protocol_gen/protocol_gen.go
//
// DAP version ${version}
` `
headerPrologue = commonPrologue + ` headerPrologue = commonPrologue + `
@ -527,18 +527,20 @@ type cppFilePaths map[structType]string
type cppFiles map[structType]*os.File type cppFiles map[structType]*os.File
func run() error { func run() error {
data, err := loadJSONFile() pkg := struct {
if err != nil { Version string `json:"version"`
}{}
if err := loadJSONFile(packageURL, &pkg); err != nil {
return err return err
} }
r := root{}
d := json.NewDecoder(bytes.NewReader(data)) protocol := root{}
if err := d.Decode(&r); err != nil { if err := loadJSONFile(protocolURL, &protocol); err != nil {
return err return err
} }
hPath, cppPaths := outputPaths() hPath, cppPaths := outputPaths()
if err := emitFiles(&r, hPath, cppPaths); err != nil { if err := emitFiles(&protocol, hPath, cppPaths, pkg.Version); err != nil {
return err return err
} }
@ -551,12 +553,14 @@ func run() error {
return err return err
} }
} }
} else {
fmt.Printf("clang-format not found on PATH. Please format before committing.")
} }
return nil return nil
} }
func emitFiles(r *root, hPath string, cppPaths map[structType]string) error { func emitFiles(r *root, hPath string, cppPaths map[structType]string, version string) error {
h, err := os.Create(hPath) h, err := os.Create(hPath)
if err != nil { if err != nil {
return err return err
@ -572,9 +576,9 @@ func emitFiles(r *root, hPath string, cppPaths map[structType]string) error {
defer f.Close() defer f.Close()
} }
h.WriteString(headerPrologue) h.WriteString(strings.ReplaceAll(headerPrologue, versionTag, version))
for _, f := range cppFiles { for _, f := range cppFiles {
f.WriteString(cppPrologue) f.WriteString(strings.ReplaceAll(cppPrologue, versionTag, version))
} }
structs, err := buildStructs(r) structs, err := buildStructs(r)
@ -618,25 +622,19 @@ func emitFiles(r *root, hPath string, cppPaths map[structType]string) error {
return nil return nil
} }
func loadJSONFile() ([]byte, error) { func loadJSONFile(url string, obj interface{}) error {
if *cache != "" { resp, err := http.Get(url)
data, err := ioutil.ReadFile(*cache)
if err == nil {
return data, nil
}
}
resp, err := http.Get(jsonURL)
if err != nil { if err != nil {
return nil, err return err
} }
data, err := ioutil.ReadAll(resp.Body) data, err := ioutil.ReadAll(resp.Body)
if err != nil { if err != nil {
return nil, err return err
} }
if *cache != "" { if err := json.NewDecoder(bytes.NewReader(data)).Decode(obj); err != nil {
ioutil.WriteFile(*cache, data, 0777) return err
} }
return data, nil return nil
} }
func outputPaths() (string, cppFilePaths) { func outputPaths() (string, cppFilePaths) {