Skip to content

Commit 343a5dc

Browse files
committed
src/goLanguageServer: deprecate documentLink configuration
gopls has had an importShortcut setting for a while, which is meant to replace the documentLink setting in go.languageServerExperimentalFeatures. Delete the setting entirely and notify its users of the replacement. Change-Id: I5b1828b1409400b84ffc2732f38cb905f343855a Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/280597 Trust: Rebecca Stambler <rstambler@golang.org> Trust: Suzy Mueller <suzmue@golang.org> Run-TryBot: Rebecca Stambler <rstambler@golang.org> TryBot-Result: kokoro <noreply+kokoro@google.com> Reviewed-by: Suzy Mueller <suzmue@golang.org>
1 parent b730717 commit 343a5dc

File tree

5 files changed

+15
-32
lines changed

5 files changed

+15
-32
lines changed

docs/settings.md

-4
Original file line numberDiff line numberDiff line change
@@ -366,16 +366,12 @@ Use this setting to enable/disable experimental features from the language serve
366366

367367
Default:{<br/>
368368
&nbsp;&nbsp;`"diagnostics": true`,<br/>
369-
&nbsp;&nbsp;`"documentLink": true`,<br/>
370369
}
371370

372371

373372
#### `diagnostics`
374373
If true, the language server will provide build, vet errors and the extension will ignore the `buildOnSave`, `vetOnSave` settings.
375374

376-
#### `documentLink`
377-
If true, the language server will provide clickable Godoc links for import statements.
378-
379375
### `go.languageServerFlags`
380376

381377
Flags like -rpc.trace and -logfile to be used while running the language server.

package.json

+1-7
Original file line numberDiff line numberDiff line change
@@ -1605,17 +1605,11 @@
16051605
"type": "boolean",
16061606
"default": true,
16071607
"description": "If true, the language server will provide build, vet errors and the extension will ignore the `buildOnSave`, `vetOnSave` settings."
1608-
},
1609-
"documentLink": {
1610-
"type": "boolean",
1611-
"default": true,
1612-
"description": "If true, the language server will provide clickable Godoc links for import statements."
16131608
}
16141609
},
16151610
"additionalProperties": false,
16161611
"default": {
1617-
"diagnostics": true,
1618-
"documentLink": true
1612+
"diagnostics": true
16191613
},
16201614
"description": "Use this setting to enable/disable experimental features from the language server."
16211615
},

src/goLanguageServer.ts

-13
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ export interface LanguageServerConfig {
7676
env: any;
7777
features: {
7878
diagnostics: boolean;
79-
documentLink: boolean;
8079
};
8180
checkForUpdates: string;
8281
}
@@ -394,16 +393,6 @@ export async function buildLanguageClient(cfg: BuildLanguageClientOption): Promi
394393
}
395394
return next(uri, diagnostics);
396395
},
397-
provideDocumentLinks: (
398-
document: vscode.TextDocument,
399-
token: vscode.CancellationToken,
400-
next: ProvideDocumentLinksSignature
401-
) => {
402-
if (!cfg.features.documentLink) {
403-
return null;
404-
}
405-
return next(document, token);
406-
},
407396
provideCompletionItem: async (
408397
document: vscode.TextDocument,
409398
position: vscode.Position,
@@ -709,7 +698,6 @@ export function watchLanguageServerConfiguration(e: vscode.ConfigurationChangeEv
709698
}
710699

711700
export function buildLanguageServerConfig(goConfig: vscode.WorkspaceConfiguration): LanguageServerConfig {
712-
713701
const cfg: LanguageServerConfig = {
714702
serverName: '',
715703
path: '',
@@ -721,7 +709,6 @@ export function buildLanguageServerConfig(goConfig: vscode.WorkspaceConfiguratio
721709
// TODO: We should have configs that match these names.
722710
// Ultimately, we should have a centralized language server config rather than separate fields.
723711
diagnostics: goConfig['languageServerExperimentalFeatures']['diagnostics'],
724-
documentLink: goConfig['languageServerExperimentalFeatures']['documentLink']
725712
},
726713
env: toolExecutionEnvironment(),
727714
checkForUpdates: getCheckForToolsUpdatesConfig(goConfig),

src/goMain.ts

+8-1
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,13 @@ export function activate(ctx: vscode.ExtensionContext) {
105105
setCurrentGoRoot(resolvePath(configGOROOT));
106106
}
107107

108+
// Present a warning about the deprecation of the go.documentLink setting.
109+
if (getGoConfig()['languageServerExperimentalFeatures']['documentLink'] === false) {
110+
vscode.window.showErrorMessage(`The 'go.languageServerExperimentalFeature.documentLink' setting is now deprecated.
111+
Please use 'gopls.importShortcut' instead.
112+
See https://github.com/golang/tools/blob/master/gopls/doc/settings.md#importshortcut-enum for more details.`);
113+
}
114+
108115
updateGoVarsFromConfig().then(async () => {
109116
suggestUpdates(ctx);
110117
offerToInstallLatestGoVersion();
@@ -594,7 +601,7 @@ function addOnSaveTextDocumentListeners(ctx: vscode.ExtensionContext) {
594601
if (document.languageId !== 'go') {
595602
return;
596603
}
597-
const session = vscode.debug.activeDebugSession;
604+
const session = vscode.debug.activeDebugSession;
598605
if (session && (session.type === 'go' || session.type === 'godlvdap')) {
599606
const neverAgain = { title: `Don't Show Again` };
600607
const ignoreActiveDebugWarningKey = 'ignoreActiveDebugWarningKey';

test/gopls/update.test.ts

+6-7
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ suite('getCheckForToolUpdatesConfig tests', () => {
1919
const defaultConfigInspector = getGoConfig().inspect(CHECK_FOR_UPDATES);
2020

2121
test('default is as expected', () => {
22-
const {key, defaultValue, globalValue, workspaceValue} = defaultConfigInspector;
22+
const { key, defaultValue, globalValue, workspaceValue } = defaultConfigInspector;
2323
assert.deepStrictEqual(
2424
{ key, defaultValue, globalValue, workspaceValue },
25-
{ key: `go.${CHECK_FOR_UPDATES}`, defaultValue : 'proxy', globalValue: undefined, workspaceValue: undefined},
25+
{ key: `go.${CHECK_FOR_UPDATES}`, defaultValue: 'proxy', globalValue: undefined, workspaceValue: undefined },
2626
CHECK_FOR_UPDATES);
2727
assert.strictEqual(getGoConfig().get(LEGACY_CHECK_FOR_UPDATES), true, LEGACY_CHECK_FOR_UPDATES);
2828
});
@@ -31,14 +31,14 @@ suite('getCheckForToolUpdatesConfig tests', () => {
3131
// vscode.getConfiguration is read-only, and doesn't allow property modification
3232
// so working with sinon directly doesn't seem possible.
3333
class TestWorkspaceConfiguration implements vscode.WorkspaceConfiguration {
34-
constructor(private _wrapped: vscode.WorkspaceConfiguration) {}
34+
constructor(private _wrapped: vscode.WorkspaceConfiguration) { }
3535
public get<T>(params: string) { return this._wrapped.get<T>(params); }
3636
public has(params: string) { return this._wrapped.has(params); }
3737
public inspect<T>(params: string) { return this._wrapped.inspect<T>(params); }
3838
public update<T>(
3939
section: string, value: any,
4040
configurationTarget?: vscode.ConfigurationTarget | boolean, overrideInLanguage?: boolean) {
41-
return this._wrapped.update(section, value, configurationTarget, overrideInLanguage);
41+
return this._wrapped.update(section, value, configurationTarget, overrideInLanguage);
4242
}
4343
[key: string]: any;
4444
}
@@ -62,7 +62,7 @@ suite('getCheckForToolUpdatesConfig tests', () => {
6262
.withArgs(LEGACY_CHECK_FOR_UPDATES).returns(false)
6363
.withArgs(CHECK_FOR_UPDATES).returns('proxy');
6464
sinon.stub(gocfg, 'inspect').withArgs(CHECK_FOR_UPDATES).returns(
65-
Object.assign({}, defaultConfigInspector, { globalValue: 'proxy' }));
65+
Object.assign({}, defaultConfigInspector, { globalValue: 'proxy' }));
6666

6767
assert.strictEqual(getCheckForToolUpdatesConfig(gocfg), 'proxy');
6868
});
@@ -72,7 +72,7 @@ suite('getCheckForToolUpdatesConfig tests', () => {
7272
.withArgs(LEGACY_CHECK_FOR_UPDATES).returns(false)
7373
.withArgs(CHECK_FOR_UPDATES).returns('off');
7474
sinon.stub(gocfg, 'inspect').withArgs(CHECK_FOR_UPDATES).returns(
75-
Object.assign({}, defaultConfigInspector, { workspaceValue: 'off' }));
75+
Object.assign({}, defaultConfigInspector, { workspaceValue: 'off' }));
7676
assert.strictEqual(getCheckForToolUpdatesConfig(gocfg), 'off');
7777
});
7878
});
@@ -176,7 +176,6 @@ suite('gopls update tests', () => {
176176
env: {},
177177
features: {
178178
diagnostics: true,
179-
documentLink: true,
180179
},
181180
flags: [],
182181
modtime: new Date(),

0 commit comments

Comments
 (0)