-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SIA-R65: Provide classes and number of matches in diagnostic (#1164)
* SIA-ER65: Split result to show why we pass * Simplify reason * Updated PR according to review comments * Removed ER65, moved extended diagnostics to R65 and introduced number of matches * Updated nonTargets to exclude targets * Seperated matchingTargets and matchingNonTargets * Ran yarn document * Polish code * Cleanup * Fix up test
- Loading branch information
Zsófia Tóth
authored
Jul 8, 2022
1 parent
5c6fa6c
commit 377153e
Showing
8 changed files
with
203 additions
and
792 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import { Diagnostic } from "@siteimprove/alfa-act"; | ||
import { Map } from "@siteimprove/alfa-map"; | ||
|
||
export class MatchingClasses extends Diagnostic { | ||
public static of( | ||
message: string, | ||
matchingTargets: Map<string, number> = Map.empty(), | ||
matchingNonTargets: Map<string, number> = Map.empty() | ||
): Diagnostic { | ||
return new MatchingClasses(message, matchingTargets, matchingNonTargets); | ||
} | ||
|
||
private readonly _matchingTargets: Map<string, number>; | ||
private readonly _matchingNonTargets: Map<string, number>; | ||
|
||
private constructor( | ||
message: string, | ||
matchingTargets: Map<string, number>, | ||
matchingNonTargets: Map<string, number> | ||
) { | ||
super(message); | ||
this._matchingTargets = matchingTargets; | ||
this._matchingNonTargets = matchingNonTargets; | ||
} | ||
|
||
public get matchingTargets(): Map<string, number> { | ||
return this._matchingTargets; | ||
} | ||
|
||
public get matchingNonTargets(): Map<string, number> { | ||
return this._matchingNonTargets; | ||
} | ||
|
||
public equals(value: MatchingClasses): boolean; | ||
|
||
public equals(value: unknown): value is this; | ||
|
||
public equals(value: unknown): boolean { | ||
return ( | ||
value instanceof MatchingClasses && | ||
value._matchingTargets.equals(this._matchingTargets) && | ||
value._matchingNonTargets.equals(this._matchingNonTargets) | ||
); | ||
} | ||
|
||
public toJSON(): MatchingClasses.JSON { | ||
return { | ||
...super.toJSON(), | ||
matchingTargets: this._matchingTargets.toJSON(), | ||
matchingNonTargets: this._matchingNonTargets.toJSON(), | ||
}; | ||
} | ||
} | ||
|
||
/** | ||
* @internal | ||
*/ | ||
export namespace MatchingClasses { | ||
export interface JSON extends Diagnostic.JSON { | ||
matchingTargets: Map.JSON<string, number>; | ||
matchingNonTargets: Map.JSON<string, number>; | ||
} | ||
|
||
export function isMatchingClasses( | ||
value: Diagnostic | ||
): value is MatchingClasses; | ||
|
||
export function isMatchingClasses(value: unknown): value is MatchingClasses; | ||
|
||
export function isMatchingClasses(value: unknown): value is MatchingClasses { | ||
return value instanceof MatchingClasses; | ||
} | ||
} |
Oops, something went wrong.