src/goReferencesCodelens: delete references codelens code
The references codelens deprecation notice was sent in early Nov (v0.36.0 release).
There was no complaint or user feedback. Deleting the code now.
Fixes golang/vscode-go#2519
Change-Id: I4f0bf0a0f17d9b7520a938cdc7431d5be53dc5ea
Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/464098
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
Reviewed-by: Peter Weinberger <pjw@google.com>
TryBot-Result: kokoro <noreply+kokoro@google.com>
diff --git a/src/goMain.ts b/src/goMain.ts
index dd413ac..42dcf26 100644
--- a/src/goMain.ts
+++ b/src/goMain.ts
@@ -39,7 +39,6 @@
import { GO_MODE } from './goMode';
import { GO111MODULE, goModInit, isModSupported } from './goModules';
import { playgroundCommand } from './goPlayground';
-import { GoReferencesCodeLensProvider } from './goReferencesCodelens';
import { GoRunTestCodeLensProvider } from './goRunTestCodelens';
import { disposeGoStatusBar, expandGoStatusBar, updateGoStatusBar } from './goStatus';
@@ -121,7 +120,6 @@
registerCommand('go.environment.status', expandGoStatusBar);
GoRunTestCodeLensProvider.activate(ctx, goCtx);
- GoReferencesCodeLensProvider.activate(ctx, goCtx);
GoDebugConfigurationProvider.activate(ctx, goCtx);
GoDebugFactory.activate(ctx);
@@ -391,46 +389,4 @@
}
}
}
- const codelensFeatures = cfg['enableCodeLens'];
- if (codelensFeatures && codelensFeatures['references']) {
- const promptKey = 'promptedCodeLensReferencesFeatureDeprecation';
- const prompted = getFromGlobalState(promptKey, false);
- if (!prompted) {
- const msg =
- "The 'go.enableCodeLens.references' setting will be removed soon. Please see [Issue 2509](https://go.dev/s/vscode-issue/2509).";
- const selected = await vscode.window.showWarningMessage(msg, 'Update Settings', "Don't show again");
- switch (selected) {
- case 'Update Settings':
- {
- const { globalValue, workspaceValue, workspaceFolderValue } = cfg.inspect<{
- [key: string]: boolean;
- }>('enableCodeLens') || {
- globalValue: undefined,
- workspaceValue: undefined,
- workspaceFolderValue: undefined
- };
- if (globalValue && globalValue['references']) {
- delete globalValue.references;
- cfg.update('enableCodeLens', globalValue, vscode.ConfigurationTarget.Global);
- }
- if (workspaceValue && workspaceValue['references']) {
- delete workspaceValue.references;
- cfg.update('enableCodeLens', workspaceValue, vscode.ConfigurationTarget.Workspace);
- }
- if (workspaceFolderValue && workspaceFolderValue['references']) {
- delete workspaceFolderValue.references;
- cfg.update(
- 'enableCodeLens',
- workspaceFolderValue,
- vscode.ConfigurationTarget.WorkspaceFolder
- );
- }
- }
- break;
- case "Don't show again":
- updateGlobalState(promptKey, true);
- break;
- }
- }
- }
}
diff --git a/src/goReferencesCodelens.ts b/src/goReferencesCodelens.ts
deleted file mode 100644
index dfb913f..0000000
--- a/src/goReferencesCodelens.ts
+++ /dev/null
@@ -1,135 +0,0 @@
-/* eslint-disable @typescript-eslint/no-explicit-any */
-/*---------------------------------------------------------
- * Copyright (C) Microsoft Corporation. All rights reserved.
- * Licensed under the MIT License. See LICENSE in the project root for license information.
- *--------------------------------------------------------*/
-
-'use strict';
-
-import { isAbsolute } from 'path';
-import { CancellationToken, CodeLens, Range, TextDocument } from 'vscode';
-import { getGoConfig } from './config';
-import { GoBaseCodeLensProvider } from './goBaseCodelens';
-import { GoDocumentSymbolProvider } from './goDocumentSymbols';
-import { GoReferenceProvider } from './language/legacy/goReferences';
-import { getBinPath } from './util';
-import vscode = require('vscode');
-import { GO_MODE } from './goMode';
-import { GoExtensionContext } from './context';
-
-const methodRegex = /^func\s+\(\s*\w+\s+\*?\w+\s*\)\s+/;
-
-class ReferencesCodeLens extends CodeLens {
- constructor(public document: TextDocument, range: Range) {
- super(range);
- }
-}
-
-export class GoReferencesCodeLensProvider extends GoBaseCodeLensProvider {
- static activate(ctx: vscode.ExtensionContext, goCtx: GoExtensionContext) {
- const referencesCodeLensProvider = new this(goCtx);
- ctx.subscriptions.push(vscode.languages.registerCodeLensProvider(GO_MODE, referencesCodeLensProvider));
- ctx.subscriptions.push(
- vscode.workspace.onDidChangeConfiguration(async (e: vscode.ConfigurationChangeEvent) => {
- if (!e.affectsConfiguration('go')) {
- return;
- }
- const updatedGoConfig = getGoConfig();
- if (updatedGoConfig['enableCodeLens']) {
- referencesCodeLensProvider.setEnabled(updatedGoConfig['enableCodeLens']['references']);
- }
- })
- );
- }
-
- constructor(private readonly goCtx: GoExtensionContext) {
- super();
- }
-
- public provideCodeLenses(document: TextDocument, token: CancellationToken): CodeLens[] | Thenable<CodeLens[]> {
- if (!this.enabled) {
- return [];
- }
- const codeLensConfig = getGoConfig(document.uri).get<{ [key: string]: any }>('enableCodeLens');
- const codelensEnabled = codeLensConfig ? codeLensConfig['references'] : false;
- if (!codelensEnabled) {
- return Promise.resolve([]);
- }
-
- const goGuru = getBinPath('guru');
- if (!isAbsolute(goGuru)) {
- return Promise.resolve([]);
- }
-
- return this.provideDocumentSymbols(document, token).then((symbols) => {
- return symbols.map((symbol) => {
- let position = symbol.range.start;
-
- // Add offset for functions as go-outline returns position at the keyword func instead of func name
- if (symbol.kind === vscode.SymbolKind.Function) {
- const funcDecl = document.lineAt(position.line).text.substr(position.character);
- const match = methodRegex.exec(funcDecl);
- position = position.translate(0, match ? match[0].length : 5);
- }
- return new ReferencesCodeLens(document, new vscode.Range(position, position));
- });
- });
- }
-
- public resolveCodeLens?(inputCodeLens: CodeLens, token: CancellationToken): CodeLens | Thenable<CodeLens> {
- const codeLens = inputCodeLens as ReferencesCodeLens;
-
- if (token.isCancellationRequested) {
- return Promise.resolve(codeLens);
- }
-
- const options = {
- includeDeclaration: false
- };
- const referenceProvider = new GoReferenceProvider();
- return referenceProvider.provideReferences(codeLens.document, codeLens.range.start, options, token).then(
- (references) => {
- codeLens.command = {
- title: references.length === 1 ? '1 reference' : references.length + ' references',
- command: 'editor.action.showReferences',
- arguments: [codeLens.document.uri, codeLens.range.start, references]
- };
- return codeLens;
- },
- (err) => {
- console.log(err);
- codeLens.command = {
- title: 'Error finding references',
- command: ''
- };
- return codeLens;
- }
- );
- }
-
- private async provideDocumentSymbols(
- document: TextDocument,
- token: CancellationToken
- ): Promise<vscode.DocumentSymbol[]> {
- const symbolProvider = GoDocumentSymbolProvider(this.goCtx);
- const isTestFile = document.fileName.endsWith('_test.go');
- const symbols = await symbolProvider.provideDocumentSymbols(document, token);
- return symbols[0].children.filter((symbol) => {
- if (symbol.kind === vscode.SymbolKind.Interface) {
- return true;
- }
- if (symbol.kind === vscode.SymbolKind.Function) {
- if (
- isTestFile &&
- (symbol.name.startsWith('Test') ||
- symbol.name.startsWith('Example') ||
- symbol.name.startsWith('Benchmark'))
- ) {
- return false;
- }
- return true;
- }
- return false;
- });
- }
-}