From d2c76161a976a4adeda876abeed46acbd1f80819 Mon Sep 17 00:00:00 2001 From: Ryan Luker Date: Sat, 15 Jul 2017 12:44:59 -0700 Subject: [PATCH] Cleanup watch and render functions (#79) * prevent document is not defined error * always start watch even on coverage error for active file * add lcov file content check to prevent failed to parse error * convert icon to png * remove uuid use unique machine id * increment image vscode version * increment appveyor code version --- appveyor.yml | 2 +- images/icon.png | Bin 0 -> 4889 bytes images/icon.svg | 103 ------------------------------------------ package.json | 4 +- src/extension.ts | 3 +- src/gutters.ts | 6 ++- src/indicators.ts | 1 + src/reporter.ts | 7 ++- src/wrappers/uuid.ts | 7 --- test/reporter.test.ts | 24 ++-------- 10 files changed, 17 insertions(+), 140 deletions(-) create mode 100644 images/icon.png delete mode 100644 images/icon.svg delete mode 100644 src/wrappers/uuid.ts diff --git a/appveyor.yml b/appveyor.yml index f38d1db..cb7d4f8 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,5 +1,5 @@ environment: - CODE_VERSION: 1.12.2 + CODE_VERSION: 1.14.0 install: - ps: Install-Product node 6.11.0 x64 diff --git a/images/icon.png b/images/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..9fef3d95f6f102351f1d14042bd708d6ee668ae2 GIT binary patch literal 4889 zcmV+!6XxuRP)z>%8FWQhbW?9;ba!ELWdL_~cP?peYja~^ zaAhuUa%Y?FJQ@H15|&9sK~#90?VV|O6jj#8|EIdMk_{plk`8pp!V(sl07(d7*f$0A zWpTp|A9%-Y#0B4HV4NTh;xK>+qM)b)2nH1e83V3y2_!_u1tVJrBH0L#kOfFO>8|sB z$RZ)#>8+}}N!RZaee2$H4%|c4ty}k;L+E%=+|V9TtTy%&nW6}+1)&ERT>*qLA(R-t z0K5ToY8rDHKs^)ch*1up9KbmMg$ybXL_S5VI(j1a%xM7ZlE0NqkgE-Fl(=L~gvgx2 z;1psS3POJXfikJ90dRx~xdddX1R?8qR$+-ux}3sw=K$JNt*=UNNCk_N2{Z{noGa~N z#&H5NAPD;q;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 @@ - - - -image/svg+xml \ No newline at end of file diff --git a/package.json b/package.json index 6a6e71d..0f1a874 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "type": "git", "url": "https://github.com/ryanluker/vscode-coverage-gutters" }, - "icon": "images/icon.svg", + "icon": "images/icon.png", "galleryBanner": { "color": "#24381b", "theme": "dark" @@ -16,7 +16,7 @@ "bugs": "https://github.com/ryanluker/vscode-coverage-gutters/issues", "publisher": "ryanluker", "engines": { - "vscode": "^1.11.0" + "vscode": "^1.14.0" }, "categories": [ "Other" diff --git a/src/extension.ts b/src/extension.ts index 96536d3..11e339e 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -9,7 +9,6 @@ import {Fs} from "./wrappers/fs"; import {Glob} from "./wrappers/glob"; import {LcovParse} from "./wrappers/lcov-parse"; import {Request} from "./wrappers/request"; -import {Uuid} from "./wrappers/uuid"; import {Vscode} from "./wrappers/vscode"; const fsImpl = new Fs(); @@ -19,7 +18,7 @@ const globImpl = new Glob(); export function activate(context: vscode.ExtensionContext) { const enableMetrics = vscode.workspace.getConfiguration("telemetry").get("enableTelemetry") as boolean; - const reporter = new Reporter(new Request(), new Uuid(), "", enableMetrics); + const reporter = new Reporter(new Request(), vscode.env.machineId, "", enableMetrics); const configStore = new Config(vscodeImpl, context, reporter).get(); const statusBarToggler = new StatusBarToggler(configStore); const lcov = new Lcov(configStore, globImpl, vscodeImpl, fsImpl); diff --git a/src/gutters.ts b/src/gutters.ts index 93d708b..a91d908 100644 --- a/src/gutters.ts +++ b/src/gutters.ts @@ -63,7 +63,10 @@ export class Gutters { const textEditor = window.activeTextEditor; try { const lcovPath = await this.lcov.find(); - await this.loadAndRenderCoverage(textEditor, lcovPath); + + // When we try to load the coverage when watch is actived we dont want to error + // if the active file has no coverage + this.loadAndRenderCoverage(textEditor, lcovPath).catch(() => {}); this.lcovWatcher = vscodeImpl.watchFile(lcovPath); this.lcovWatcher.onDidChange((event) => this.renderCoverageOnVisible(lcovPath)); @@ -124,6 +127,7 @@ export class Gutters { } private async loadAndRenderCoverage(textEditor: TextEditor, lcovPath: string): Promise { + if (!textEditor.document) { return ; } const lcovFile = await this.lcov.load(lcovPath); const file = textEditor.document.fileName; const coveredLines = await this.indicators.extract(lcovFile, file); diff --git a/src/indicators.ts b/src/indicators.ts index f6752b2..9f0aa25 100644 --- a/src/indicators.ts +++ b/src/indicators.ts @@ -42,6 +42,7 @@ export class Indicators { } public extract(lcovFile: string, file: string): Promise { + if (lcovFile === "") { return Promise.reject("No coverage details inside lcov file!"); } return new Promise((resolve, reject) => { this.parse.source(lcovFile, (err, data) => { if (err) { return reject(err); } diff --git a/src/reporter.ts b/src/reporter.ts index 83d7d64..a027772 100644 --- a/src/reporter.ts +++ b/src/reporter.ts @@ -1,8 +1,7 @@ import {Request} from "./wrappers/request"; -import {Uuid} from "./wrappers/uuid"; const EXT_NAME = "vscode-coverage-gutters"; -const EXT_VERSION = "1.0.0"; +const EXT_VERSION = "1.1.0"; export class Reporter { private readonly cid: string; @@ -10,10 +9,10 @@ export class Reporter { private readonly gaTrackingId: string; private readonly request: Request; - constructor(request: Request, uuid: Uuid, gaTrackingId: string, enableMetrics: boolean) { + constructor(request: Request, machineId: string, gaTrackingId: string, enableMetrics: boolean) { this.gaTrackingId = gaTrackingId; this.request = request; - this.cid = uuid.get(); + this.cid = machineId; this.enableMetrics = enableMetrics; } diff --git a/src/wrappers/uuid.ts b/src/wrappers/uuid.ts deleted file mode 100644 index 4c49ee7..0000000 --- a/src/wrappers/uuid.ts +++ /dev/null @@ -1,7 +0,0 @@ -import {v4} from "uuid"; - -export class Uuid { - public get(): string { - return v4(); - } -} diff --git a/test/reporter.test.ts b/test/reporter.test.ts index 8c1fdfa..291f6b9 100644 --- a/test/reporter.test.ts +++ b/test/reporter.test.ts @@ -11,11 +11,7 @@ suite("Reporter Tests", function() { }, }; - const fakeUuid = { - get() { - return "fakeuuidhere"; - }, - }; + const fakeUuid = "fakeuuidhere"; const reporter = new Reporter(fakeRequest, fakeUuid, "", false); reporter.sendEvent("test", "action"); @@ -30,11 +26,7 @@ suite("Reporter Tests", function() { }, }; - const fakeUuid = { - get() { - return "fakeuuidhere"; - }, - }; + const fakeUuid = "fakeuuidhere"; const reporter = new Reporter(fakeRequest, fakeUuid, "", true); reporter.sendEvent("test", "action"); @@ -49,11 +41,7 @@ suite("Reporter Tests", function() { }, }; - const fakeUuid = { - get() { - return "fakeuuidhere"; - }, - }; + const fakeUuid = "fakeuuidhere"; const reporter = new Reporter(fakeRequest, fakeUuid, "", true); reporter.sendEvent("test", "action"); @@ -68,11 +56,7 @@ suite("Reporter Tests", function() { }, }; - const fakeUuid = { - get() { - return "fakeuuidhere"; - }, - }; + const fakeUuid = "fakeuuidhere"; const reporter = new Reporter(fakeRequest, fakeUuid, "123", true); reporter.sendEvent("test", "action");