mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-05 08:11:30 -06:00
Add fourslash function for validating syntactic classification (#50362)
This commit is contained in:
parent
df25b77d0f
commit
7bafbeae90
@ -2749,6 +2749,13 @@ namespace FourSlash {
|
||||
// fs.writeFileSync(testfilePath, newfile);
|
||||
}
|
||||
|
||||
public verifyEncodedSyntacticClassificationsLength(expected: number) {
|
||||
const actual = this.languageService.getEncodedSyntacticClassifications(this.activeFile.fileName, ts.createTextSpan(0, this.activeFile.content.length));
|
||||
if (actual.spans.length !== expected) {
|
||||
this.raiseError(`encodedSyntacticClassificationsLength failed - expected total spans to be ${expected} got ${actual.spans.length}`);
|
||||
}
|
||||
}
|
||||
|
||||
public verifyEncodedSemanticClassificationsLength(format: ts.SemanticClassificationFormat, expected: number) {
|
||||
const actual = this.languageService.getEncodedSemanticClassifications(this.activeFile.fileName, ts.createTextSpan(0, this.activeFile.content.length), format);
|
||||
if (actual.spans.length !== expected) {
|
||||
|
||||
@ -541,6 +541,10 @@ namespace FourSlashInterface {
|
||||
this.state.verifySyntacticClassifications(classifications);
|
||||
}
|
||||
|
||||
public encodedSyntacticClassificationsLength(length: number) {
|
||||
this.state.verifyEncodedSyntacticClassificationsLength(length);
|
||||
}
|
||||
|
||||
public encodedSemanticClassificationsLength(format: ts.SemanticClassificationFormat, length: number) {
|
||||
this.state.verifyEncodedSemanticClassificationsLength(format, length);
|
||||
}
|
||||
|
||||
@ -378,8 +378,10 @@ declare namespace FourSlashInterface {
|
||||
rangesAreDocumentHighlights(ranges?: Range[], options?: VerifyDocumentHighlightsOptions): void;
|
||||
rangesWithSameTextAreDocumentHighlights(): void;
|
||||
documentHighlightsOf(startRange: Range, ranges: Range[], options?: VerifyDocumentHighlightsOptions): void;
|
||||
/** Prefer semanticClassificationsAre for more descriptive tests */
|
||||
encodedSemanticClassificationsLength(format: "original" | "2020", length: number)
|
||||
/** Prefer {@link syntacticClassificationsAre} for more descriptive tests */
|
||||
encodedSyntacticClassificationsLength(expected: number): void;
|
||||
/** Prefer {@link semanticClassificationsAre} for more descriptive tests */
|
||||
encodedSemanticClassificationsLength(format: "original" | "2020", length: number): void;
|
||||
/**
|
||||
* This method *requires* a contiguous, complete, and ordered stream of classifications for a file.
|
||||
*/
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user