Skip to content

Commit

Permalink
address review comments (instanceof usage on StatementCoverage)
Browse files Browse the repository at this point in the history
Move declaration of TestCoverageCount before its usage
  • Loading branch information
rschnekenbu committed Apr 24, 2024
1 parent fcd1396 commit 37769aa
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions packages/plugin-ext/src/plugin/types-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3330,6 +3330,11 @@ export class TestMessage implements theia.TestMessage {
constructor(public message: string | theia.MarkdownString) { }
}

@es5ClassCompat
export class TestCoverageCount {
constructor( public covered: number, public total: number) { }
}

@es5ClassCompat
export class FileCoverage {

Expand All @@ -3341,7 +3346,7 @@ export class FileCoverage {
const decl = new TestCoverageCount(0, 0);

for (const detail of details) {
if (StatementCoverage.is(detail)) {
if (detail instanceof StatementCoverage) {
statements.total += 1;
statements.covered += detail.executed ? 1 : 0;

Expand Down Expand Up @@ -3380,12 +3385,6 @@ export class StatementCoverage implements theia.StatementCoverage {
constructor(public executed: number | boolean, public location: Position | Range, public branches: BranchCoverage[] = []) { }
}

export namespace StatementCoverage {
export function is(coverage: unknown): coverage is StatementCoverage {
return isObject(coverage) && 'branches' in coverage;
}
}

export class BranchCoverage implements theia.BranchCoverage {
constructor(public executed: number | boolean, public location?: Position | Range, public label?: string) { }
}
Expand All @@ -3394,10 +3393,6 @@ export class BranchCoverage implements theia.BranchCoverage {
export class DeclarationCoverage implements theia.DeclarationCoverage {
constructor(public name: string, public executed: number | boolean, public location: Position | Range) { }
}
@es5ClassCompat
export class TestCoverageCount implements theia.TestCoverageCount {
constructor( public covered: number, public total: number) { }
}

export type FileCoverageDetail = StatementCoverage | DeclarationCoverage;

Expand Down

0 comments on commit 37769aa

Please sign in to comment.