Skip to content
This repository was archived by the owner on Jul 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,11 @@
"title": "Go: Cancel Running Tests",
"description": "Cancels running tests."
},
{
"command": "go.apply.coverprofile",
"title": "Go: Apply Cover Profile",
"description": "Applies existing cover profile."
},
{
"command": "go.godoctor.extract",
"title": "Go: Extract to function",
Expand Down
22 changes: 19 additions & 3 deletions src/goMain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@
'use strict';

import vscode = require('vscode');
import * as path from 'path';
import { browsePackages } from './goBrowsePackage';
import { buildCode } from './goBuild';
import { check, notifyIfGeneratedFile, removeTestStatus } from './goCheck';
import { GoCodeActionProvider } from './goCodeAction';
import { applyCodeCoverage, initCoverageDecorators, removeCodeCoverageOnFileChange, toggleCoverageCurrentPackage, updateCodeCoverageDecorators } from './goCover';
import { applyCodeCoverage, applyCodeCoverageToAllEditors, initCoverageDecorators, removeCodeCoverageOnFileChange, toggleCoverageCurrentPackage, updateCodeCoverageDecorators } from './goCover';
import { GoDebugConfigurationProvider } from './goDebugConfiguration';
import { extractFunction, extractVariable } from './goDoctor';
import { runFillStruct } from './goFillStruct';
Expand All @@ -32,9 +33,9 @@ import { GoRunTestCodeLensProvider } from './goRunTestCodelens';
import { showHideStatus } from './goStatus';
import { testAtCursor, testCurrentFile, testCurrentPackage, testPrevious, testWorkspace } from './goTest';
import { vetCode } from './goVet';
import { setGlobalState, getFromGlobalState, updateGlobalState } from './stateUtils';
import { getFromGlobalState, setGlobalState, updateGlobalState } from './stateUtils';
import { cancelRunningTests, showTestOutput } from './testUtils';
import { cleanupTempDir, disposeTelemetryReporter, getBinPath, getGoConfig, getCurrentGoPath, getExtensionCommands, getGoVersion, getToolsEnvVars, getToolsGopath, getWorkspaceFolderPath, handleDiagnosticErrors, isGoPathSet, sendTelemetryEvent } from './util';
import { cleanupTempDir, disposeTelemetryReporter, getBinPath, getCurrentGoPath, getExtensionCommands, getGoConfig, getGoVersion, getToolsEnvVars, getToolsGopath, getWorkspaceFolderPath, handleDiagnosticErrors, isGoPathSet, sendTelemetryEvent } from './util';

export let buildDiagnosticCollection: vscode.DiagnosticCollection;
export let lintDiagnosticCollection: vscode.DiagnosticCollection;
Expand Down Expand Up @@ -357,6 +358,21 @@ export function activate(ctx: vscode.ExtensionContext): void {

ctx.subscriptions.push(vscode.commands.registerCommand('go.install.package', installCurrentPackage));

ctx.subscriptions.push(vscode.commands.registerCommand('go.apply.coverprofile', () => {
if (!vscode.window.activeTextEditor || vscode.window.activeTextEditor.document.fileName.endsWith('.go')) {
Comment thread
Eun marked this conversation as resolved.
Outdated
vscode.window.showErrorMessage('Cannot apply coverage profile when no Go file is open.');
return;
}
vscode.window.showInputBox({
prompt: 'Enter the path to the coverage profile'
}).then(coverProfilePath => {
if (!coverProfilePath) {
return;
}
applyCodeCoverageToAllEditors(coverProfilePath, path.dirname(vscode.window.activeTextEditor.document.fileName));
});
}));

vscode.languages.setLanguageConfiguration(GO_MODE.language, {
wordPattern: /(-?\d*\.\d\w*)|([^\`\~\!\@\#\%\^\&\*\(\)\-\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\?\s]+)/g,
});
Expand Down