src/context.ts: remove mutex from context
The mutex is only used in the startLanguageServer command.
Change-Id: I19db3bead919d2080b0c7e1a40371164d3a2d8e6
Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/404155
Run-TryBot: Jamal Carvalho <jamal@golang.org>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
TryBot-Result: kokoro <noreply+kokoro@google.com>
diff --git a/src/commands/startLanguageServer.ts b/src/commands/startLanguageServer.ts
index 09777b0..565b42c 100644
--- a/src/commands/startLanguageServer.ts
+++ b/src/commands/startLanguageServer.ts
@@ -22,6 +22,9 @@
updateRestartHistory
} from '../language/goLanguageServer';
import { LegacyLanguageService } from '../language/registerDefaultProviders';
+import { Mutex } from '../utils/mutex';
+
+const languageServerStartMutex = new Mutex();
export function startLanguageServer(ctx: vscode.ExtensionContext, goCtx: GoExtensionContext) {
return async (reason?: RestartReason) => {
@@ -32,7 +35,7 @@
updateRestartHistory(goCtx, reason, cfg.enabled);
}
- const unlock = await goCtx.languageServerStartMutex.lock();
+ const unlock = await languageServerStartMutex.lock();
try {
// If the client has already been started, make sure to clear existing
// diagnostics and stop it.
diff --git a/src/context.ts b/src/context.ts
index a1bff86..bc602d4 100644
--- a/src/context.ts
+++ b/src/context.ts
@@ -8,7 +8,6 @@
import { LanguageServerConfig, Restart, ServerInfo } from './language/goLanguageServer';
import { LegacyLanguageService } from './language/registerDefaultProviders';
-import { Mutex } from './utils/mutex';
// Global variables used for management of the language client.
// They are global so that the server can be easily restarted with
@@ -29,5 +28,4 @@
crashCount: number;
// Some metrics for automated issue reports:
restartHistory: Restart[];
- languageServerStartMutex: Mutex;
}
diff --git a/src/goMain.ts b/src/goMain.ts
index 336327e..38909e1 100644
--- a/src/goMain.ts
+++ b/src/goMain.ts
@@ -112,7 +112,6 @@
import { GoExplorerProvider } from './goExplorer';
import { VulncheckProvider } from './goVulncheck';
-import { Mutex } from './utils/mutex';
import { GoExtensionContext } from './context';
import * as commands from './commands';
@@ -121,8 +120,7 @@
export const goCtx: GoExtensionContext = {
lastUserAction: new Date(),
crashCount: 0,
- restartHistory: [],
- languageServerStartMutex: new Mutex()
+ restartHistory: []
};
export let buildDiagnosticCollection: vscode.DiagnosticCollection;
diff --git a/test/gopls/extension.test.ts b/test/gopls/extension.test.ts
index a111fcd..5a9b9e4 100644
--- a/test/gopls/extension.test.ts
+++ b/test/gopls/extension.test.ts
@@ -16,7 +16,6 @@
} from '../../src/language/goLanguageServer';
import sinon = require('sinon');
import { getGoVersion, GoVersion } from '../../src/util';
-import { Mutex } from '../../src/utils/mutex';
import { GoExtensionContext } from '../../src/context';
// FakeOutputChannel is a fake output channel used to buffer
@@ -97,8 +96,7 @@
const goCtx: GoExtensionContext = {
lastUserAction: new Date(),
crashCount: 0,
- restartHistory: [],
- languageServerStartMutex: new Mutex()
+ restartHistory: []
};
// file path to open.
this.fakeOutputChannel = new FakeOutputChannel();
diff --git a/test/gopls/survey.test.ts b/test/gopls/survey.test.ts
index 128e616..f8bbf7a 100644
--- a/test/gopls/survey.test.ts
+++ b/test/gopls/survey.test.ts
@@ -9,7 +9,6 @@
import goLanguageServer = require('../../src/language/goLanguageServer');
import goSurvey = require('../../src/goSurvey');
import goDeveloperSurvey = require('../../src/goDeveloperSurvey');
-import { Mutex } from '../../src/utils/mutex';
import { GoExtensionContext } from '../../src/context';
suite('gopls survey tests', () => {
@@ -223,8 +222,7 @@
const goCtx: GoExtensionContext = {
lastUserAction: new Date(),
crashCount: 0,
- restartHistory: [],
- languageServerStartMutex: new Mutex()
+ restartHistory: []
};
const stub = sandbox.stub(vscode.window, 'showInformationMessage').resolves({ title: choice });
const getGoplsOptOutConfigStub = sandbox.stub(goLanguageServer, 'getGoplsOptOutConfig').returns(testConfig);
diff --git a/test/integration/codelens.test.ts b/test/integration/codelens.test.ts
index 31500ef..44a6284 100644
--- a/test/integration/codelens.test.ts
+++ b/test/integration/codelens.test.ts
@@ -16,7 +16,6 @@
import { GoRunTestCodeLensProvider } from '../../src/goRunTestCodelens';
import { subTestAtCursor } from '../../src/goTest';
import { getCurrentGoPath, getGoVersion } from '../../src/util';
-import { Mutex } from '../../src/utils/mutex';
suite('Code lenses for testing and benchmarking', function () {
this.timeout(20000);
@@ -36,8 +35,7 @@
const goCtx: GoExtensionContext = {
lastUserAction: new Date(),
crashCount: 0,
- restartHistory: [],
- languageServerStartMutex: new Mutex()
+ restartHistory: []
};
await updateGoVarsFromConfig(goCtx);
diff --git a/test/integration/coverage.test.ts b/test/integration/coverage.test.ts
index fbbaf65..750fa1d 100644
--- a/test/integration/coverage.test.ts
+++ b/test/integration/coverage.test.ts
@@ -13,7 +13,6 @@
import path = require('path');
import sinon = require('sinon');
import vscode = require('vscode');
-import { Mutex } from '../../src/utils/mutex';
import { GoExtensionContext } from '../../src/context';
// The ideal test would check that each open editor containing a file with coverage
@@ -30,8 +29,7 @@
const goCtx: GoExtensionContext = {
lastUserAction: new Date(),
crashCount: 0,
- restartHistory: [],
- languageServerStartMutex: new Mutex()
+ restartHistory: []
};
await updateGoVarsFromConfig(goCtx);
diff --git a/test/integration/extension.test.ts b/test/integration/extension.test.ts
index 574e911..157825f 100644
--- a/test/integration/extension.test.ts
+++ b/test/integration/extension.test.ts
@@ -50,7 +50,6 @@
import cp = require('child_process');
import os = require('os');
import { GoExtensionContext } from '../../src/context';
-import { Mutex } from '../../src/utils/mutex';
const testAll = (isModuleMode: boolean) => {
const dummyCancellationSource = new vscode.CancellationTokenSource();
@@ -73,8 +72,7 @@
const goCtx: GoExtensionContext = {
lastUserAction: new Date(),
crashCount: 0,
- restartHistory: [],
- languageServerStartMutex: new Mutex()
+ restartHistory: []
};
await updateGoVarsFromConfig(goCtx);
diff --git a/test/integration/goDebugConfiguration.test.ts b/test/integration/goDebugConfiguration.test.ts
index 98b5a24..2865674 100644
--- a/test/integration/goDebugConfiguration.test.ts
+++ b/test/integration/goDebugConfiguration.test.ts
@@ -15,7 +15,6 @@
import { MockCfg } from '../mocks/MockCfg';
import { extensionId } from '../../src/const';
import { GoExtensionContext } from '../../src/context';
-import { Mutex } from '../../src/utils/mutex';
suite('Debug Environment Variable Merge Test', () => {
const debugConfigProvider = new GoDebugConfigurationProvider();
@@ -28,8 +27,7 @@
const goCtx: GoExtensionContext = {
lastUserAction: new Date(),
crashCount: 0,
- restartHistory: [],
- languageServerStartMutex: new Mutex()
+ restartHistory: []
};
await updateGoVarsFromConfig(goCtx);
await vscode.workspace.openTextDocument(vscode.Uri.file(filePath));
diff --git a/test/integration/statusbar.test.ts b/test/integration/statusbar.test.ts
index bf97017..e6f669d 100644
--- a/test/integration/statusbar.test.ts
+++ b/test/integration/statusbar.test.ts
@@ -28,15 +28,13 @@
import ourutil = require('../../src/util');
import { GoExtensionContext } from '../../src/context';
import { setGOROOTEnvVar } from '../../src/goMain';
-import { Mutex } from '../../src/utils/mutex';
describe('#initGoStatusBar()', function () {
this.beforeAll(async () => {
const goCtx: GoExtensionContext = {
lastUserAction: new Date(),
crashCount: 0,
- restartHistory: [],
- languageServerStartMutex: new Mutex()
+ restartHistory: []
};
await updateGoVarsFromConfig(goCtx); // should initialize the status bar.
});