Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

Commit

Permalink
Add debug configuration options for test debug codelens (#1749)
Browse files Browse the repository at this point in the history
* Obtain debug test codelens cfg from vsconfig

* Add delve v2 config on test codelens provider

* Move test delve config to go.delveConfig

* Merge fix

* Merge default debug configurations into a single one

* Use dlvconfig from resolveDebugConfiguration
  • Loading branch information
lggomez authored and ramya-rao-a committed Jun 27, 2018
1 parent 47464f0 commit dc7c473
Show file tree
Hide file tree
Showing 4 changed files with 128 additions and 76 deletions.
181 changes: 115 additions & 66 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -453,13 +453,13 @@
}
},
"description": "LoadConfig describes to delve, how to load values from target's memory",
"default": {
"followPointers": true,
"maxVariableRecurse": 1,
"maxStringLen": 64,
"maxArrayValues": 64,
"maxStructFields": -1
}
"default": {
"followPointers": true,
"maxVariableRecurse": 1,
"maxStringLen": 64,
"maxArrayValues": 64,
"maxStructFields": -1
}
},
"useApiV1": {
"type": "boolean",
Expand Down Expand Up @@ -645,71 +645,71 @@
"scope": "resource"
},
"go.coverageDecorator": {
"type": "object",
"properties": {
"type": {
"type": "string",
"default": "highlight",
"enum": [
"highlight",
"gutter"
]
},
"coveredHighlightColor": {
"type": "string",
"default": "rgba(64,128,128,0.5)",
"description": "Color in the rgba format to use to highlight covered code."
},
"uncoveredHighlightColor": {
"type": "string",
"default": "rgba(128,64,64,0.25)",
"description": "Color in the rgba format to use to highlight uncovered code."
},
"coveredGutterStyle": {
"type": "string",
"default": "blockblue",
"enum": [
"blockblue",
"blockred",
"blockgreen",
"blockyellow",
"slashred",
"slashgreen",
"slashblue",
"slashyellow",
"verticalred",
"verticalgreen",
"verticalblue",
"verticalyellow"
],
"description": "Gutter style to indicate covered code."
},
"uncoveredGutterStyle": {
"type": "string",
"default": "blockblue",
"enum": [
"blockblue",
"blockred",
"blockgreen",
"blockyellow",
"slashred",
"slashgreen",
"slashblue",
"slashyellow",
"verticalred",
"verticalgreen",
"verticalblue",
"verticalyellow"
],
"description": "Gutter style to indicate covered code."
}
"type": "object",
"properties": {
"type": {
"type": "string",
"default": "highlight",
"enum": [
"highlight",
"gutter"
]
},
"coveredHighlightColor": {
"type": "string",
"default": "rgba(64,128,128,0.5)",
"description": "Color in the rgba format to use to highlight covered code."
},
"uncoveredHighlightColor": {
"type": "string",
"default": "rgba(128,64,64,0.25)",
"description": "Color in the rgba format to use to highlight uncovered code."
},
"coveredGutterStyle": {
"type": "string",
"default": "blockblue",
"enum": [
"blockblue",
"blockred",
"blockgreen",
"blockyellow",
"slashred",
"slashgreen",
"slashblue",
"slashyellow",
"verticalred",
"verticalgreen",
"verticalblue",
"verticalyellow"
],
"description": "Gutter style to indicate covered code."
},
"uncoveredGutterStyle": {
"type": "string",
"default": "blockblue",
"enum": [
"blockblue",
"blockred",
"blockgreen",
"blockyellow",
"slashred",
"slashgreen",
"slashblue",
"slashyellow",
"verticalred",
"verticalgreen",
"verticalblue",
"verticalyellow"
],
"description": "Gutter style to indicate covered code."
}
},
"default": {
"type": "highlight",
"coveredHighlightColor": "rgba(64,128,128,0.5)",
"uncoveredHighlightColor": "rgba(128,64,64,0.25)",
"coveredGutterStyle": "blockblue",
"uncoveredGutterStyle": "slashyellow"
"uncoveredGutterStyle": "slashyellow"
},
"description": "This option lets you choose the way to display code coverage. Choose either to highlight the complete line or to show a decorator in the gutter. You can customize the color for the former and the style for the latter.",
"scope": "resource"
Expand Down Expand Up @@ -1064,6 +1064,55 @@
"description": "Folder names (not paths) to ignore while using Go to Symbol in Workspace feature",
"scope": "resource"
},
"go.delveConfig": {
"type": "object",
"properties": {
"dlvLoadConfig": {
"type": "object",
"properties": {
"followPointers": {
"type": "boolean",
"description": "FollowPointers requests pointers to be automatically dereferenced",
"default": true
},
"maxVariableRecurse": {
"type": "number",
"description": "MaxVariableRecurse is how far to recurse when evaluating nested types",
"default": 1
},
"maxStringLen": {
"type": "number",
"description": "MaxStringLen is the maximum number of bytes read from a string",
"default": 64
},
"maxArrayValues": {
"type": "number",
"description": "MaxArrayValues is the maximum number of elements read from an array, a slice or a map",
"default": 64
},
"maxStructFields": {
"type": "number",
"description": "MaxStructFields is the maximum number of fields read from a struct, -1 will read all fields",
"default": -1
}
},
"description": "LoadConfig describes to delve, how to load values from target's memory",
"default": {
"followPointers": true,
"maxVariableRecurse": 1,
"maxStringLen": 64,
"maxArrayValues": 64,
"maxStructFields": -1
}
},
"useApiV1": {
"type": "boolean",
"description": "If true, the v1 of delve apis will be used, else v2 will be used",
"default": true
}
},
"scope": "resource"
},
"go.alternateTools": {
"type": "object",
"default": {},
Expand Down
19 changes: 11 additions & 8 deletions src/goDebugConfiguration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,33 +24,36 @@ export class GoDebugConfigurationProvider implements vscode.DebugConfigurationPr
}

public resolveDebugConfiguration?(folder: vscode.WorkspaceFolder | undefined, debugConfiguration: vscode.DebugConfiguration, token?: vscode.CancellationToken): vscode.DebugConfiguration {

const gopath = getCurrentGoPath(folder ? folder.uri : null);

if (!debugConfiguration || !debugConfiguration.request) { // if 'request' is missing interpret this as a missing launch.json
let activeEditor = vscode.window.activeTextEditor;
if (!activeEditor || activeEditor.document.languageId !== 'go') {
return;
}

return {
debugConfiguration = {
'name': 'Launch',
'type': 'go',
'request': 'launch',
'mode': 'debug',
'program': activeEditor.document.fileName,
'env': {
'GOPATH': gopath
}
'program': activeEditor.document.fileName
};
}

const gopath = getCurrentGoPath(folder ? folder.uri : null);
if (!debugConfiguration['env']) {
debugConfiguration['env'] = { 'GOPATH': gopath };
} else if (!debugConfiguration['env']['GOPATH']) {
debugConfiguration['env']['GOPATH'] = gopath;
}

const dlvConfig = vscode.workspace.getConfiguration('go', folder ? folder.uri : null).get('delveConfig');
if (!debugConfiguration.hasOwnProperty('useApiV1') && dlvConfig.hasOwnProperty('useApiV1')) {
debugConfiguration['useApiV1'] = dlvConfig['useApiV1'];
}
if (!debugConfiguration.hasOwnProperty('dlvLoadConfig') && dlvConfig.hasOwnProperty('dlvLoadConfig')) {
debugConfiguration['dlvLoadConfig'] = dlvConfig['dlvLoadConfig'];
}

return debugConfiguration;
}

Expand Down
2 changes: 1 addition & 1 deletion src/goRunTestCodelens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,4 +139,4 @@ export class GoRunTestCodeLensProvider extends GoBaseCodeLensProvider {

return Promise.all([testPromise, benchmarkPromise]).then(() => codelens);
}
}
}
2 changes: 1 addition & 1 deletion src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -789,4 +789,4 @@ export function killTree(processId: number): void {
} catch (err) {
}
}
}
}

0 comments on commit dc7c473

Please sign in to comment.