Skip to content

Commit

Permalink
Disable coverage check for non-Hack files (#64)
Browse files Browse the repository at this point in the history
* Disable coverage check for non-Hack files
  • Loading branch information
PranayAgarwal authored Jul 23, 2019
1 parent 16b9ed6 commit 9fd0d16
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/Config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import * as vscode from 'vscode';
const hackConfig = vscode.workspace.getConfiguration('hack');

export const clientPath = hackConfig.get<string>('clientPath') || 'hh_client';
export const enableCoverageCheck = hackConfig.get<boolean>('enableConverageCheck', true);
export const enableCoverageCheck = hackConfig.get<boolean>('enableCoverageCheck', true);
export const useLanguageServer = hackConfig.get<boolean>('useLanguageServer', true);
export const useHhast = hackConfig.get<boolean>('useHhast', true);
export const hhastLintMode: 'whole-project' | 'open-files' = hackConfig.get('hhastLintMode', 'whole-project');
Expand Down
21 changes: 11 additions & 10 deletions src/coveragechecker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,21 @@ export class HackCoverageChecker {

public async start(context: vscode.ExtensionContext) {

context.subscriptions.push(vscode.workspace.onDidSaveTextDocument(doc => this.check(doc)));
context.subscriptions.push(vscode.window.onDidChangeActiveTextEditor(editor => {
this.hhvmCoverDiag.clear();
context.subscriptions.push(vscode.workspace.onDidSaveTextDocument(async doc => this.check(doc)));
context.subscriptions.push(vscode.window.onDidChangeActiveTextEditor(async editor => {
if (editor) {
this.check(editor.document);
await this.check(editor.document);
} else {
this.hhvmCoverDiag.clear();
this.coverageStatus.hide();
}
}));
context.subscriptions.push(vscode.commands.registerCommand('hack.toggleCoverageHighlight', () => { this.toggle(); }));
context.subscriptions.push(vscode.commands.registerCommand('hack.toggleCoverageHighlight', async () => this.toggle()));
context.subscriptions.push(this.hhvmCoverDiag, this.coverageStatus);

// Check the active file, if any
if (vscode.window.activeTextEditor) {
this.check(vscode.window.activeTextEditor.document);
await this.check(vscode.window.activeTextEditor.document);
}
}

Expand All @@ -59,16 +59,17 @@ export class HackCoverageChecker {
this.hhvmCoverDiag.clear();
this.visible = false;
} else {
this.visible = true;
const editor = vscode.window.activeTextEditor;
if (editor) {
this.check(editor.document);
await this.check(editor.document);
}
this.visible = true;
}
}

private async check(document: vscode.TextDocument) {
if (document.languageId !== 'hack' && document.uri.scheme !== 'file') {
this.hhvmCoverDiag.clear();
if (document.languageId !== 'hack' || document.uri.scheme !== 'file') {
this.coverageStatus.hide();
return;
}
Expand All @@ -92,7 +93,7 @@ export class HackCoverageChecker {
if (this.visible && coverageResponse.uncoveredRanges) {
const diagnostics: vscode.Diagnostic[] = [];
coverageResponse.uncoveredRanges.forEach(uncoveredRange => {
const diagnostic = new vscode.Diagnostic(uncoveredRange.range, uncoveredRange.message, vscode.DiagnosticSeverity.Information);
const diagnostic = new vscode.Diagnostic(uncoveredRange.range, uncoveredRange.message || coverageResponse.defaultMessage, vscode.DiagnosticSeverity.Information);
diagnostic.source = 'Type Coverage';
diagnostics.push(diagnostic);
});
Expand Down

0 comments on commit 9fd0d16

Please sign in to comment.