Skip to content

Commit 39dadee

Browse files
committed
sync: merge microsoft/vscode-go@efb94c8 into master
Change-Id: Ia05ff126a38fde31743c1ad72091b9e5b9e334e0
2 parents 9af87f1 + efb94c8 commit 39dadee

File tree

8 files changed

+95
-91
lines changed

8 files changed

+95
-91
lines changed

.travis.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,19 @@ matrix:
1717

1818
os:
1919
- osx
20+
- linux
2021

2122
before_install:
2223
# Call xvfb directly on linux runs and give it time to start
2324
- if [[ $TRAVIS_OS_NAME == "linux" ]]; then
2425
export DISPLAY=:99.0;
25-
Xvfb :99 &
26+
Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &
2627
sleep 3;
2728
sudo apt-get update && sudo apt-get install -y libsecret-1-0;
2829
fi
2930

3031
install:
31-
- TRAVIS_NODE_VERSION="6";
32+
- TRAVIS_NODE_VERSION="8";
3233
# Clear out whatever version of NVM Travis has as it is old.
3334
- rm -rf ~/.nvm;
3435
# Grab NVM.
@@ -49,7 +50,7 @@ install:
4950
- go get -u -v github.com/ramya-rao-a/go-outline
5051
- go get -u -v github.com/rogpeppe/godef
5152
- go get -u -v github.com/sqs/goreturns
52-
- go get -u -v github.com/uudashr/gopkgs/cmd/gopkgs
53+
- go get -u -v github.com/uudashr/gopkgs/v2/cmd/gopkgs
5354
- go get -u -v github.com/zmb3/gogetdoc
5455
- go get -u -v golang.org/x/lint/golint
5556
- go get -u -v golang.org/x/tools/cmd/gorename

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ Install and open [Visual Studio Code](https://code.visualstudio.com). Press `Ctr
107107

108108
This extension uses a set of Go tools to provide the various rich features. These tools are installed in your GOPATH by default. If you wish to have these tools in a separate location, provide the desired location in the setting `go.toolsGopath`. Read more about this and the tools at [Go tools that the Go extension depends on](https://github.com/Microsoft/vscode-go/wiki/Go-tools-that-the-Go-extension-depends-on).
109109

110-
You will see `Analysis Tools Missing` in the bottom right, clicking this will offer to install all of the dependent Go tools. You can also run the [command](https://code.visualstudio.com/docs/getstarted/userinterface#_command-palette) `Go: Install/Update tools` to install/update the same.
110+
You will see `Analysis Tools Missing` in the bottom right, clicking this will offer to install all of the dependent Go tools. You can also run the [command](https://code.visualstudio.com/docs/getstarted/userinterface#_command-palette) `Go: Install/Update tools` to install/update the same. You need to have git installed for these tool installations to work.
111111

112112
**Note 1**: Read [GOPATH in the VS Code Go extension](https://github.com/Microsoft/vscode-go/wiki/GOPATH-in-the-VS-Code-Go-extension) to learn about the different ways you can get the extension to set GOPATH.
113113

build/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM golang:latest AS gobuilder
1+
FROM golang:1.14 AS gobuilder
22

33
ENV GO111MODULE on
44
ENV GOBIN /gobin
@@ -29,7 +29,7 @@ RUN go get -u -v \
2929
github.com/ramya-rao-a/go-outline \
3030
github.com/rogpeppe/godef \
3131
github.com/sqs/goreturns \
32-
github.com/uudashr/gopkgs/cmd/gopkgs \
32+
github.com/uudashr/gopkgs/v2/cmd/gopkgs \
3333
github.com/zmb3/gogetdoc \
3434
golang.org/x/lint/golint \
3535
golang.org/x/tools/cmd/gorename

src/debugAdapter/goDebug.ts

Lines changed: 72 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,6 @@ interface LaunchRequestArguments extends DebugProtocol.LaunchRequestArguments {
256256
stackTraceDepth: number;
257257

258258
showGlobalVariables?: boolean;
259-
currentFile: string;
260259
packagePathToGoModPathMap: { [key: string]: string };
261260
}
262261

@@ -282,7 +281,6 @@ interface AttachRequestArguments extends DebugProtocol.AttachRequestArguments {
282281
stackTraceDepth: number;
283282

284283
showGlobalVariables?: boolean;
285-
currentFile: string;
286284
}
287285

288286
process.on('uncaughtException', (err: any) => {
@@ -427,46 +425,46 @@ class Delve {
427425

428426
if (!!launchArgs.noDebug) {
429427
if (mode === 'debug') {
430-
if (isProgramDirectory && launchArgs.currentFile) {
431-
program = launchArgs.currentFile;
432-
isProgramDirectory = false;
428+
this.noDebug = true;
429+
const runArgs = ['run'];
430+
const runOptions: { [key: string]: any } = { env };
431+
if (launchArgs.buildFlags) {
432+
runArgs.push(launchArgs.buildFlags);
433+
}
434+
if (isProgramDirectory) {
435+
runOptions.cwd = program;
436+
runArgs.push('.');
437+
} else {
438+
runArgs.push(program);
439+
}
440+
if (launchArgs.args) {
441+
runArgs.push(...launchArgs.args);
433442
}
434443

435-
if (!isProgramDirectory) {
436-
this.noDebug = true;
437-
const runArgs = ['run'];
438-
if (launchArgs.buildFlags) {
439-
runArgs.push(launchArgs.buildFlags);
444+
this.debugProcess = spawn(getBinPathWithPreferredGopath('go', []), runArgs, runOptions);
445+
this.debugProcess.stderr.on('data', (chunk) => {
446+
const str = chunk.toString();
447+
if (this.onstderr) {
448+
this.onstderr(str);
440449
}
441-
runArgs.push(program);
442-
if (launchArgs.args) {
443-
runArgs.push(...launchArgs.args);
450+
});
451+
this.debugProcess.stdout.on('data', (chunk) => {
452+
const str = chunk.toString();
453+
if (this.onstdout) {
454+
this.onstdout(str);
444455
}
445-
this.debugProcess = spawn(getBinPathWithPreferredGopath('go', []), runArgs, { env });
446-
this.debugProcess.stderr.on('data', (chunk) => {
447-
const str = chunk.toString();
448-
if (this.onstderr) {
449-
this.onstderr(str);
450-
}
451-
});
452-
this.debugProcess.stdout.on('data', (chunk) => {
453-
const str = chunk.toString();
454-
if (this.onstdout) {
455-
this.onstdout(str);
456-
}
457-
});
458-
this.debugProcess.on('close', (code) => {
459-
logError('Process exiting with code: ' + code);
460-
if (this.onclose) {
461-
this.onclose(code);
462-
}
463-
});
464-
this.debugProcess.on('error', (err) => {
465-
reject(err);
466-
});
467-
resolve();
468-
return;
469-
}
456+
});
457+
this.debugProcess.on('close', (code) => {
458+
logError('Process exiting with code: ' + code);
459+
if (this.onclose) {
460+
this.onclose(code);
461+
}
462+
});
463+
this.debugProcess.on('error', (err) => {
464+
reject(err);
465+
});
466+
resolve();
467+
return;
470468
}
471469
}
472470
this.noDebug = false;
@@ -702,7 +700,7 @@ class Delve {
702700
await this.callPromise('Detach', [this.isApiV1 ? true : { Kill: isLocalDebugging }]);
703701
} catch (err) {
704702
log('DetachResponse');
705-
logError(err, 'Failed to detach');
703+
logError(`Failed to detach - ${err.toString() || ''}`);
706704
shouldForceClean = isLocalDebugging;
707705
}
708706
}
@@ -841,8 +839,7 @@ class GoDebugSession extends LoggingDebugSession {
841839
// So, update it to use the same separator as the remote path to ease
842840
// in replacing the local path in it with remote path
843841
filePath = filePath.replace(/\/|\\/g, this.remotePathSeparator);
844-
return filePath
845-
.replace(this.delve.program.replace(/\/|\\/g, this.remotePathSeparator), this.delve.remotePath);
842+
return filePath.replace(this.delve.program.replace(/\/|\\/g, this.remotePathSeparator), this.delve.remotePath);
846843
}
847844

848845
protected toLocalPath(pathToConvert: string): string {
@@ -1852,7 +1849,8 @@ class GoDebugSession extends LoggingDebugSession {
18521849
// https://github.com/go-delve/delve/issues/852
18531850
// This affects macOS only although we're agnostic of the OS at this stage, only handle the error
18541851
if (errorMessage === 'bad access') {
1855-
errorMessage = 'unpropagated fatalpanic: signal SIGSEGV (EXC_BAD_ACCESS). This fatalpanic is not traceable on macOS, see https://github.com/go-delve/delve/issues/852';
1852+
errorMessage =
1853+
'unpropagated fatalpanic: signal SIGSEGV (EXC_BAD_ACCESS). This fatalpanic is not traceable on macOS, see https://github.com/go-delve/delve/issues/852';
18561854
}
18571855

18581856
logError(message + ' - ' + errorMessage);
@@ -1887,39 +1885,40 @@ class GoDebugSession extends LoggingDebugSession {
18871885
Object.assign(stackTraceIn, { full: false, cfg: this.delve.loadConfig });
18881886
}
18891887
this.delve.call<DebugLocation[] | StacktraceOut>(
1890-
this.delve.isApiV1 ?
1891-
'StacktraceGoroutine' : 'Stacktrace', [stackTraceIn], (err, out) => {
1892-
if (err) {
1893-
logError('dumpStacktrace: Failed to produce stack trace' + err);
1894-
return;
1895-
}
1896-
const locations = this.delve.isApiV1 ? <DebugLocation[]>out : (<StacktraceOut>out).Locations;
1897-
log('locations', locations);
1898-
const stackFrames = locations.map((location, frameId) => {
1899-
const uniqueStackFrameId = this.stackFrameHandles.create([goroutineId, frameId]);
1900-
return new StackFrame(
1901-
uniqueStackFrameId,
1902-
location.function ? location.function.name : '<unknown>',
1903-
location.file === '<autogenerated>' ? null : new Source(
1904-
path.basename(location.file),
1905-
this.toLocalPath(location.file)
1906-
),
1907-
location.line,
1908-
0
1909-
);
1910-
});
1888+
this.delve.isApiV1 ? 'StacktraceGoroutine' : 'Stacktrace',
1889+
[stackTraceIn],
1890+
(err, out) => {
1891+
if (err) {
1892+
logError('dumpStacktrace: Failed to produce stack trace' + err);
1893+
return;
1894+
}
1895+
const locations = this.delve.isApiV1 ? <DebugLocation[]>out : (<StacktraceOut>out).Locations;
1896+
log('locations', locations);
1897+
const stackFrames = locations.map((location, frameId) => {
1898+
const uniqueStackFrameId = this.stackFrameHandles.create([goroutineId, frameId]);
1899+
return new StackFrame(
1900+
uniqueStackFrameId,
1901+
location.function ? location.function.name : '<unknown>',
1902+
location.file === '<autogenerated>'
1903+
? null
1904+
: new Source(path.basename(location.file), this.toLocalPath(location.file)),
1905+
location.line,
1906+
0
1907+
);
1908+
});
19111909

1912-
// Dump stacktrace into error logger
1913-
logError(`Last known immediate stacktrace (goroutine id ${goroutineId}):`);
1914-
let output = '';
1915-
stackFrames.forEach((stackFrame) => {
1916-
output = output.concat(`\t${stackFrame.source.path}:${stackFrame.line}\n`);
1917-
if (stackFrame.name) {
1918-
output = output.concat(`\t\t${stackFrame.name}\n`);
1919-
}
1920-
});
1921-
logError(output);
1910+
// Dump stacktrace into error logger
1911+
logError(`Last known immediate stacktrace (goroutine id ${goroutineId}):`);
1912+
let output = '';
1913+
stackFrames.forEach((stackFrame) => {
1914+
output = output.concat(`\t${stackFrame.source.path}:${stackFrame.line}\n`);
1915+
if (stackFrame.name) {
1916+
output = output.concat(`\t\t${stackFrame.name}\n`);
1917+
}
19221918
});
1919+
logError(output);
1920+
}
1921+
);
19231922
}
19241923
}
19251924

src/goDebugConfiguration.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,6 @@ export class GoDebugConfigurationProvider implements vscode.DebugConfigurationPr
109109
debugConfiguration['mode'] =
110110
activeEditor && activeEditor.document.fileName.endsWith('_test.go') ? 'test' : 'debug';
111111
}
112-
debugConfiguration['currentFile'] =
113-
activeEditor && activeEditor.document.languageId === 'go' && activeEditor.document.fileName;
114112

115113
const neverAgain = { title: `Don't Show Again` };
116114
const ignoreWarningKey = 'ignoreDebugLaunchRemoteWarning';

src/goInstallTools.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -362,15 +362,18 @@ export async function promptForUpdatingTool(toolName: string) {
362362
const updateMsg = `Your version of ${tool.name} appears to be out of date. Please update for an improved experience.`;
363363
const choices: string[] = ['Update'];
364364
if (toolName === `gopls`) {
365-
choices.push('Release Notes'); // TODO(hyangah): pass more info such as version, release note location.
365+
choices.push('Release Notes'); // TODO(hyangah): pass more info such as version, release note location.
366366
}
367367
vscode.window.showInformationMessage(updateMsg, ...choices).then((selected) => {
368368
switch (selected) {
369369
case 'Update':
370370
installTools([tool], goVersion);
371371
break;
372372
case 'Release Notes':
373-
vscode.commands.executeCommand('vscode.open', vscode.Uri.parse('https://github.com/golang/go/issues/33030#issuecomment-510151934'));
373+
vscode.commands.executeCommand(
374+
'vscode.open',
375+
vscode.Uri.parse('https://github.com/golang/go/issues/33030#issuecomment-510151934')
376+
);
374377
break;
375378
default:
376379
declinedUpdates.push(tool);

src/goLanguageServer.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,12 @@ export async function registerLanguageFeatures(ctx: vscode.ExtensionContext) {
150150
// { languageId: 'go', uri: document.uri });
151151

152152
const editorParamHintsEnabled = vscode.workspace.getConfiguration(
153-
'editor.parameterHints', document.uri)['enabled'];
154-
const goParamHintsEnabled = vscode.workspace.getConfiguration(
155-
'[go]', document.uri)['editor.parameterHints.enabled'];
153+
'editor.parameterHints',
154+
document.uri
155+
)['enabled'];
156+
const goParamHintsEnabled = vscode.workspace.getConfiguration('[go]', document.uri)[
157+
'editor.parameterHints.enabled'
158+
];
156159

157160
let paramHintsEnabled: boolean = false;
158161
if (typeof goParamHintsEnabled === 'undefined') {
@@ -166,8 +169,8 @@ export async function registerLanguageFeatures(ctx: vscode.ExtensionContext) {
166169
}
167170

168171
function configureCommands(
169-
r: vscode.CompletionItem[] | vscode.CompletionList | null | undefined):
170-
vscode.CompletionItem[] | vscode.CompletionList | null | undefined {
172+
r: vscode.CompletionItem[] | vscode.CompletionList | null | undefined
173+
): vscode.CompletionItem[] | vscode.CompletionList | null | undefined {
171174
if (r) {
172175
(Array.isArray(r) ? r : r.items).forEach((i: vscode.CompletionItem) => {
173176
i.command = cmd;
@@ -177,12 +180,12 @@ export async function registerLanguageFeatures(ctx: vscode.ExtensionContext) {
177180
}
178181
const ret = next(document, position, context, token);
179182

180-
const isThenable = <T>(obj: vscode.ProviderResult<T>): obj is Thenable<T> => obj && (<any>obj)['then'];
183+
const isThenable = <T>(obj: vscode.ProviderResult<T>): obj is Thenable<T> =>
184+
obj && (<any>obj)['then'];
181185
if (isThenable<vscode.CompletionItem[] | vscode.CompletionList | null | undefined>(ret)) {
182186
return ret.then(configureCommands);
183187
}
184188
return configureCommands(ret);
185-
186189
}
187190
}
188191
}

src/telemetry.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ function sendTelemetryEvent(
184184
measures?: { [key: string]: number }
185185
): void {
186186
if (!aiKey) {
187-
return; // cannot enable telemetry
187+
return; // cannot enable telemetry
188188
}
189189
telemtryReporter = telemtryReporter
190190
? telemtryReporter

0 commit comments

Comments
 (0)