Skip to content

Commit 1b745df

Browse files
authored
Adding baseline methods for verification of findAllRefs, GoTo*, Occurrences, highlights and rename deprecating the corresponding verification methods from fourslash tests (#52576)
1 parent a82b927 commit 1b745df

File tree

1,500 files changed

+752985
-159830
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,500 files changed

+752985
-159830
lines changed

src/harness/fourslashImpl.ts

Lines changed: 541 additions & 582 deletions
Large diffs are not rendered by default.

src/harness/fourslashInterfaceImpl.ts

Lines changed: 84 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,6 @@ export class GoTo {
9797
this.state.goToEOF();
9898
}
9999

100-
public implementation() {
101-
this.state.goToImplementation();
102-
}
103-
104100
public position(positionOrLineAndCharacter: number | ts.LineAndCharacter, fileNameOrIndex?: string | number): void {
105101
if (fileNameOrIndex !== undefined) {
106102
this.file(fileNameOrIndex);
@@ -173,14 +169,6 @@ export class VerifyNegatable {
173169
this.state.verifyQuickInfoExists(this.negative);
174170
}
175171

176-
public typeDefinitionCountIs(expectedCount: number) {
177-
this.state.verifyTypeDefinitionsCount(this.negative, expectedCount);
178-
}
179-
180-
public implementationListIsEmpty() {
181-
this.state.verifyImplementationListIsEmpty(this.negative);
182-
}
183-
184172
public isValidBraceCompletionAtPosition(openingBrace: string) {
185173
this.state.verifyBraceCompletionAtPosition(this.negative, openingBrace);
186174
}
@@ -318,68 +306,88 @@ export class Verify extends VerifyNegatable {
318306
this.state.verifyFormatDocumentChangesNothing();
319307
}
320308

321-
public goToDefinitionIs(endMarkers: ArrayOrSingle<string>) {
322-
this.state.verifyGoToDefinitionIs(endMarkers);
309+
public verifyGetEmitOutputForCurrentFile(expected: string): void {
310+
this.state.verifyGetEmitOutputForCurrentFile(expected);
311+
}
312+
313+
public verifyGetEmitOutputContentsForCurrentFile(expected: ts.OutputFile[]): void {
314+
this.state.verifyGetEmitOutputContentsForCurrentFile(expected);
315+
}
316+
317+
public symbolAtLocation(startRange: FourSlash.Range, ...declarationRanges: FourSlash.Range[]) {
318+
this.state.verifySymbolAtLocation(startRange, declarationRanges);
323319
}
324320

325-
public goToDefinition(startMarkerName: ArrayOrSingle<string>, endMarkerName: ArrayOrSingle<string>, range?: FourSlash.Range): void;
326-
public goToDefinition(startsAndEnds: [ArrayOrSingle<string>, ArrayOrSingle<string>][] | { [startMarkerName: string]: ArrayOrSingle<string> }): void;
327-
public goToDefinition(arg0: any, endMarkerName?: ArrayOrSingle<string>) {
328-
this.state.verifyGoToDefinition(arg0, endMarkerName);
321+
public typeOfSymbolAtLocation(range: FourSlash.Range, symbol: ts.Symbol, expected: string) {
322+
this.state.verifyTypeOfSymbolAtLocation(range, symbol, expected);
329323
}
330324

331-
public goToType(startMarkerName: ArrayOrSingle<string>, endMarkerName: ArrayOrSingle<string>): void;
332-
public goToType(startsAndEnds: [ArrayOrSingle<string>, ArrayOrSingle<string>][] | { [startMarkerName: string]: ArrayOrSingle<string> }): void;
333-
public goToType(arg0: any, endMarkerName?: ArrayOrSingle<string>) {
334-
this.state.verifyGoToType(arg0, endMarkerName);
325+
public typeAtLocation(range: FourSlash.Range, expected: string) {
326+
this.state.verifyTypeAtLocation(range, expected);
335327
}
336328

337-
public goToSourceDefinition(startMarkerNames: ArrayOrSingle<string>, end: { file: string } | ArrayOrSingle<string>) {
338-
this.state.verifyGoToSourceDefinition(startMarkerNames, end);
329+
public baselineCommands(...commands: BaselineCommand[]) {
330+
this.state.verifyBaselineCommands(...commands);
339331
}
340332

341-
public goToDefinitionForMarkers(...markerNames: string[]) {
342-
this.state.verifyGoToDefinitionForMarkers(markerNames);
333+
public baselineFindAllReferences(...markerOrRange: FourSlash.MarkerOrNameOrRange[]) {
334+
this.state.verifyBaselineCommands({ type: "findAllReferences", markerOrRange });
343335
}
344336

345-
public goToDefinitionName(name: string, containerName: string) {
346-
this.state.verifyGoToDefinitionName(name, containerName);
337+
public baselineFindAllReferencesAtRangesWithText(...rangeText: string[]) {
338+
this.state.verifyBaselineCommands({ type: "findAllReferences", rangeText });
347339
}
348340

349-
public verifyGetEmitOutputForCurrentFile(expected: string): void {
350-
this.state.verifyGetEmitOutputForCurrentFile(expected);
341+
public baselineGetFileReferences(...fileName: string[]) {
342+
this.state.verifyBaselineCommands({ type: "getFileReferences", fileName });
351343
}
352344

353-
public verifyGetEmitOutputContentsForCurrentFile(expected: ts.OutputFile[]): void {
354-
this.state.verifyGetEmitOutputContentsForCurrentFile(expected);
345+
public baselineGoToDefinition(...markerOrRange: FourSlash.MarkerOrNameOrRange[]) {
346+
this.state.verifyBaselineCommands({ type: "goToDefinition", markerOrRange });
355347
}
356348

357-
public symbolAtLocation(startRange: FourSlash.Range, ...declarationRanges: FourSlash.Range[]) {
358-
this.state.verifySymbolAtLocation(startRange, declarationRanges);
349+
public baselineGoToDefinitionAtRangesWithText(...rangeText: string[]) {
350+
this.state.verifyBaselineCommands({ type: "goToDefinition", rangeText });
359351
}
360352

361-
public typeOfSymbolAtLocation(range: FourSlash.Range, symbol: ts.Symbol, expected: string) {
362-
this.state.verifyTypeOfSymbolAtLocation(range, symbol, expected);
353+
public baselineGetDefinitionAtPosition(...markerOrRange: FourSlash.MarkerOrNameOrRange[]) {
354+
this.state.verifyBaselineCommands({ type: "getDefinitionAtPosition", markerOrRange });
363355
}
364356

365-
public typeAtLocation(range: FourSlash.Range, expected: string) {
366-
this.state.verifyTypeAtLocation(range, expected);
357+
public baselineGetDefinitionAtRangesWithText(...rangeText: string[]) {
358+
this.state.verifyBaselineCommands({ type: "getDefinitionAtPosition", rangeText });
367359
}
368360

369-
public baselineFindAllReferences(...markerNames: string[]) {
370-
this.state.verifyBaselineFindAllReferences(...markerNames);
361+
public baselineGoToSourceDefinition(...markerOrRange: FourSlash.MarkerOrNameOrRange[]) {
362+
this.state.verifyBaselineCommands({ type: "goToSourceDefinition", markerOrRange });
371363
}
372364

373-
public baselineFindAllReferencesMulti(seq: number, ...markerNames: string[]) {
374-
this.state.verifyBaselineFindAllReferencesMulti(seq, ...markerNames);
365+
public baselineGoToSourceDefinitionAtRangesWithText(...rangeText: string[]) {
366+
this.state.verifyBaselineCommands({ type: "goToSourceDefinition", rangeText });
375367
}
376368

377-
public baselineGetFileReferences(fileName: string) {
378-
this.state.verifyBaselineGetFileReferences(fileName);
369+
public baselineGoToType(...markerOrRange: FourSlash.MarkerOrNameOrRange[]) {
370+
this.state.verifyBaselineCommands({ type: "goToType", markerOrRange });
379371
}
380372

381-
public findReferencesDefinitionDisplayPartsAtCaretAre(expected: ts.SymbolDisplayPart[]) {
382-
this.state.verifyDisplayPartsOfReferencedSymbol(expected);
373+
public baselineGoToTypeAtRangesWithText(...rangeText: string[]) {
374+
this.state.verifyBaselineCommands({ type: "goToType", rangeText });
375+
}
376+
377+
public baselineGoToImplementation(...markerOrRange: FourSlash.MarkerOrNameOrRange[]) {
378+
this.state.verifyBaselineCommands({ type: "goToImplementation", markerOrRange });
379+
}
380+
381+
public baselineGoToImplementationAtRangesWithText(...rangeText: string[]) {
382+
this.state.verifyBaselineCommands({ type: "goToImplementation", rangeText });
383+
}
384+
385+
public baselineDocumentHighlights(markerOrRange?: ArrayOrSingle<FourSlash.MarkerOrNameOrRange>, options?: VerifyDocumentHighlightsOptions) {
386+
this.state.verifyBaselineCommands({ type: "documentHighlights", markerOrRange, options });
387+
}
388+
389+
public baselineDocumentHighlightsAtRangesWithText(rangeText?: ArrayOrSingle<string>, options?: VerifyDocumentHighlightsOptions) {
390+
this.state.verifyBaselineCommands({ type: "documentHighlights", rangeText, options });
383391
}
384392

385393
public noErrors() {
@@ -516,42 +524,6 @@ export class Verify extends VerifyNegatable {
516524
this.state.verifyNavigateTo(options);
517525
}
518526

519-
public occurrencesAtPositionContains(range: FourSlash.Range, isWriteAccess?: boolean) {
520-
this.state.verifyOccurrencesAtPositionListContains(range.fileName, range.pos, range.end, isWriteAccess);
521-
}
522-
523-
public occurrencesAtPositionCount(expectedCount: number) {
524-
this.state.verifyOccurrencesAtPositionListCount(expectedCount);
525-
}
526-
527-
public rangesAreOccurrences(isWriteAccess?: boolean, ranges?: FourSlash.Range[]) {
528-
this.state.verifyRangesAreOccurrences(isWriteAccess, ranges);
529-
}
530-
531-
public rangesWithSameTextAreRenameLocations(...texts: string[]) {
532-
this.state.verifyRangesWithSameTextAreRenameLocations(...texts);
533-
}
534-
535-
public rangesAreRenameLocations(options?: FourSlash.Range[] | { findInStrings?: boolean, findInComments?: boolean, ranges?: FourSlash.Range[], providePrefixAndSuffixTextForRename?: boolean }) {
536-
this.state.verifyRangesAreRenameLocations(options);
537-
}
538-
539-
public rangesAreDocumentHighlights(ranges?: FourSlash.Range[], options?: VerifyDocumentHighlightsOptions) {
540-
this.state.verifyRangesAreDocumentHighlights(ranges, options);
541-
}
542-
543-
public rangesWithSameTextAreDocumentHighlights() {
544-
this.state.verifyRangesWithSameTextAreDocumentHighlights();
545-
}
546-
547-
public documentHighlightsOf(startRange: FourSlash.Range, ranges: FourSlash.Range[], options?: VerifyDocumentHighlightsOptions) {
548-
this.state.verifyDocumentHighlightsOf(startRange, ranges, options);
549-
}
550-
551-
public noDocumentHighlights(startRange: FourSlash.Range) {
552-
this.state.verifyNoDocumentHighlights(startRange);
553-
}
554-
555527
/**
556528
* This method *requires* a contiguous, complete, and ordered stream of classifications for a file.
557529
*/
@@ -593,12 +565,12 @@ export class Verify extends VerifyNegatable {
593565
this.state.verifyRenameInfoFailed(message, preferences);
594566
}
595567

596-
public renameLocations(startRanges: ArrayOrSingle<FourSlash.Range>, options: RenameLocationsOptions) {
597-
this.state.verifyRenameLocations(startRanges, options);
568+
public baselineRename(markerOrRange?: ArrayOrSingle<FourSlash.MarkerOrNameOrRange>, options?: RenameOptions) {
569+
this.state.verifyBaselineCommands({ type: "findRenameLocations", markerOrRange, options });
598570
}
599571

600-
public baselineRename(marker: string, options: RenameOptions) {
601-
this.state.baselineRename(marker, options);
572+
public baselineRenameAtRangesWithText(rangeText?: ArrayOrSingle<string>, options?: RenameOptions) {
573+
this.state.verifyBaselineCommands({ type: "findRenameLocations", rangeText, options });
602574
}
603575

604576
public verifyQuickInfoDisplayParts(kind: string, kindModifiers: string, textSpan: FourSlash.TextSpan,
@@ -622,10 +594,6 @@ export class Verify extends VerifyNegatable {
622594
this.state.verifyProjectInfo(expected);
623595
}
624596

625-
public allRangesAppearInImplementationList(markerName: string) {
626-
this.state.verifyRangesInImplementationList(markerName);
627-
}
628-
629597
public getEditsForFileRename(options: GetEditsForFileRenameOptions) {
630598
this.state.getEditsForFileRename(options);
631599
}
@@ -650,6 +618,9 @@ export class Verify extends VerifyNegatable {
650618
export class Edit {
651619
constructor(private state: FourSlash.TestState) {
652620
}
621+
public caretPosition() {
622+
return this.state.caretPosition();
623+
}
653624
public backspace(count?: number) {
654625
this.state.deleteCharBehindMarker(count);
655626
}
@@ -1855,7 +1826,7 @@ export interface VerifyCompletionListContainsOptions extends ts.UserPreferences
18551826
}
18561827

18571828
export interface VerifyDocumentHighlightsOptions {
1858-
filesToSearch?: readonly string[];
1829+
filesToSearch: readonly string[];
18591830
}
18601831

18611832
export type NewFileContent = string | { readonly [filename: string]: string };
@@ -1936,3 +1907,25 @@ export interface RenameOptions {
19361907
readonly findInComments?: boolean;
19371908
readonly providePrefixAndSuffixTextForRename?: boolean;
19381909
}
1910+
export type BaselineCommandWithMarkerOrRange = {
1911+
type: "findAllReferences" | "goToDefinition" | "getDefinitionAtPosition" | "goToSourceDefinition" | "goToType" | "goToImplementation";
1912+
markerOrRange?: ArrayOrSingle<FourSlash.MarkerOrNameOrRange>;
1913+
rangeText?: ArrayOrSingle<string>;
1914+
} | {
1915+
type: "findRenameLocations";
1916+
markerOrRange?: ArrayOrSingle<FourSlash.MarkerOrNameOrRange>;
1917+
rangeText?: ArrayOrSingle<string>;
1918+
options?: RenameOptions;
1919+
} | {
1920+
type: "documentHighlights";
1921+
markerOrRange?: ArrayOrSingle<FourSlash.MarkerOrNameOrRange>;
1922+
rangeText?: ArrayOrSingle<string>;
1923+
options?: VerifyDocumentHighlightsOptions;
1924+
};
1925+
export type BaselineCommand = BaselineCommandWithMarkerOrRange | {
1926+
type: "getFileReferences";
1927+
fileName: ArrayOrSingle<string>;
1928+
} | {
1929+
type: "customWork";
1930+
work: () => string | undefined;
1931+
};

0 commit comments

Comments
 (0)