Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

Check and notify if the file seems to be generated. Fixes #1295. #1425

Merged
merged 3 commits into from
Dec 31, 2017
Merged
Show file tree
Hide file tree
Changes from all 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
10 changes: 10 additions & 0 deletions src/goCheck.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,16 @@ export function removeTestStatus(e: vscode.TextDocumentChangeEvent) {
statusBarItem.text = '';
}

export function notifyIfGeneratedFile(e: vscode.TextDocumentChangeEvent) {
if (e.document.isUntitled || e.document.languageId !== 'go') {
return;
}

if (e.document.lineAt(0).text.match(/^\/\/ Code generated .* DO NOT EDIT\.$/)) {
vscode.window.showWarningMessage('This file seems to be generated. DO NOT EDIT.');
}
}

export function check(fileUri: vscode.Uri, goConfig: vscode.WorkspaceConfiguration): Promise<ICheckResult[]> {
outputChannel.clear();
let runningToolsPromises = [];
Expand Down
3 changes: 2 additions & 1 deletion src/goMain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { GoRunTestCodeLensProvider } from './goRunTestCodelens';
import { GoSignatureHelpProvider } from './goSignature';
import { GoWorkspaceSymbolProvider } from './goSymbol';
import { GoCodeActionProvider } from './goCodeAction';
import { check, removeTestStatus } from './goCheck';
import { check, removeTestStatus, notifyIfGeneratedFile } from './goCheck';
import { updateGoPathGoRootFromConfig, offerToInstallTools } from './goInstallTools';
import { GO_MODE } from './goMode';
import { showHideStatus } from './goStatus';
Expand Down Expand Up @@ -154,6 +154,7 @@ export function activate(ctx: vscode.ExtensionContext): void {
vscode.window.onDidChangeActiveTextEditor(showHideStatus, null, ctx.subscriptions);
vscode.window.onDidChangeActiveTextEditor(getCodeCoverage, null, ctx.subscriptions);
vscode.workspace.onDidChangeTextDocument(parseLiveFile, null, ctx.subscriptions);
vscode.workspace.onDidChangeTextDocument(notifyIfGeneratedFile, null, ctx.subscriptions);

startBuildOnSaveWatcher(ctx.subscriptions);

Expand Down