Add fourslash function for validating syntactic classification (#50362)

This commit is contained in:
Daniel Rosenwasser
2022-08-18 11:28:08 -07:00
committed by GitHub
parent df25b77d0f
commit 7bafbeae90
3 changed files with 15 additions and 2 deletions

View File

@@ -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) {

View File

@@ -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);
}