Skip to content

Adding baseline methods for verification of findAllRefs, GoTo*, Occurrences, highlights and rename deprecating the corresponding verification methods from fourslash tests #52576

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 33 commits into from
Mar 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
ded19c8
Updates to baselines
sheetalkamat Feb 15, 2023
be67396
Replace baselineFindAllReferencesMulti with baselineCommands
sheetalkamat Feb 15, 2023
c43ffd0
Existing baselines for Rename
sheetalkamat Feb 15, 2023
59722d3
Existing baselines for getFileReference
sheetalkamat Feb 15, 2023
a7224b1
Existing baselines findAllRefs Part1
sheetalkamat Feb 16, 2023
f324653
Existing baselines findAllRefs Part2
sheetalkamat Feb 16, 2023
2fa05ef
Existing baselines findAllRefs Part3
sheetalkamat Feb 16, 2023
61a2df3
Existing baselines findAllRefs Part4
sheetalkamat Feb 16, 2023
91822d7
Existing baselines findAllRefs Part5
sheetalkamat Feb 16, 2023
36751fe
Remove unused method
sheetalkamat Feb 15, 2023
e5c8272
Replace findReferencesDefinitionDisplayPartsAtCaretAre with baselineF…
sheetalkamat Feb 15, 2023
1cbe130
Replace renameLocations with baselinRename
sheetalkamat Feb 15, 2023
e7ee12f
Replace rangesAreRenameLocations with baselineRename
sheetalkamat Feb 15, 2023
fac55da
Replace rangesWithSameTextAreRenameLocations to baselineRenameAtRange…
sheetalkamat Feb 16, 2023
f0a6dbb
Replace rangesAreOccurrences with baselineDocumentHighlights
sheetalkamat Feb 16, 2023
994340a
Replace occurrencesAtPositionContains with baselineDocumentHighlights
sheetalkamat Feb 16, 2023
25d422a
Replace occurrencesAtPositionCount with baselineDocumentHighlights
sheetalkamat Feb 16, 2023
7bef12f
Replace rangesWithSameTextAreDocumentHighlights with baselineDocument…
sheetalkamat Feb 16, 2023
8ca3a78
Replace rangesAreDocumentHighlights with baselineDocumentHighlights
sheetalkamat Feb 16, 2023
65a8e0d
Replace documentHighlightsOf with baselineDocumentHighlights
sheetalkamat Feb 16, 2023
b58f683
Replace noDocumentHighlights with baselineDocumentHighlights
sheetalkamat Feb 16, 2023
b9bc6b5
Replace goToSourceDefinition with baselineGoToSourceDefinition
sheetalkamat Feb 16, 2023
65c690c
Replace goTo.implementation() with verify.baselineGoToImplementation
sheetalkamat Feb 16, 2023
8926a59
Replace allRangesAppearInImplementationList with baselineGoToImplemen…
sheetalkamat Feb 16, 2023
f484b12
Replace implementationListIsEmpty with baselineGoToImplementation
sheetalkamat Feb 16, 2023
8818a54
Remove unused goToTypeDefinition
sheetalkamat Feb 16, 2023
8217fe3
Replace goToType with baselineGoToType
sheetalkamat Feb 17, 2023
37262c6
Remove unused typeDefinitionCountIs
sheetalkamat Feb 17, 2023
1b54b06
Replace goToDefinition with baselineGoToDefinition
sheetalkamat Feb 18, 2023
4238173
Reaplce goToDefinitionForMarkers with baselineGetDefinitionAtPosition
sheetalkamat Mar 2, 2023
8f381b0
Reaplce goToDefinitionName with baselineGetDefinitionAtPosition
sheetalkamat Mar 2, 2023
100712e
Replace goToDefinitionIs with baselineGetDefinitionAtPosition
sheetalkamat Mar 3, 2023
f837b62
Merge branch 'main' into goToDefContext
sheetalkamat Mar 22, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1,123 changes: 541 additions & 582 deletions src/harness/fourslashImpl.ts

Large diffs are not rendered by default.

175 changes: 84 additions & 91 deletions src/harness/fourslashInterfaceImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,6 @@ export class GoTo {
this.state.goToEOF();
}

public implementation() {
this.state.goToImplementation();
}

public position(positionOrLineAndCharacter: number | ts.LineAndCharacter, fileNameOrIndex?: string | number): void {
if (fileNameOrIndex !== undefined) {
this.file(fileNameOrIndex);
Expand Down Expand Up @@ -173,14 +169,6 @@ export class VerifyNegatable {
this.state.verifyQuickInfoExists(this.negative);
}

public typeDefinitionCountIs(expectedCount: number) {
this.state.verifyTypeDefinitionsCount(this.negative, expectedCount);
}

public implementationListIsEmpty() {
this.state.verifyImplementationListIsEmpty(this.negative);
}

public isValidBraceCompletionAtPosition(openingBrace: string) {
this.state.verifyBraceCompletionAtPosition(this.negative, openingBrace);
}
Expand Down Expand Up @@ -318,68 +306,88 @@ export class Verify extends VerifyNegatable {
this.state.verifyFormatDocumentChangesNothing();
}

public goToDefinitionIs(endMarkers: ArrayOrSingle<string>) {
this.state.verifyGoToDefinitionIs(endMarkers);
public verifyGetEmitOutputForCurrentFile(expected: string): void {
this.state.verifyGetEmitOutputForCurrentFile(expected);
}

public verifyGetEmitOutputContentsForCurrentFile(expected: ts.OutputFile[]): void {
this.state.verifyGetEmitOutputContentsForCurrentFile(expected);
}

public symbolAtLocation(startRange: FourSlash.Range, ...declarationRanges: FourSlash.Range[]) {
this.state.verifySymbolAtLocation(startRange, declarationRanges);
}

public goToDefinition(startMarkerName: ArrayOrSingle<string>, endMarkerName: ArrayOrSingle<string>, range?: FourSlash.Range): void;
public goToDefinition(startsAndEnds: [ArrayOrSingle<string>, ArrayOrSingle<string>][] | { [startMarkerName: string]: ArrayOrSingle<string> }): void;
public goToDefinition(arg0: any, endMarkerName?: ArrayOrSingle<string>) {
this.state.verifyGoToDefinition(arg0, endMarkerName);
public typeOfSymbolAtLocation(range: FourSlash.Range, symbol: ts.Symbol, expected: string) {
this.state.verifyTypeOfSymbolAtLocation(range, symbol, expected);
}

public goToType(startMarkerName: ArrayOrSingle<string>, endMarkerName: ArrayOrSingle<string>): void;
public goToType(startsAndEnds: [ArrayOrSingle<string>, ArrayOrSingle<string>][] | { [startMarkerName: string]: ArrayOrSingle<string> }): void;
public goToType(arg0: any, endMarkerName?: ArrayOrSingle<string>) {
this.state.verifyGoToType(arg0, endMarkerName);
public typeAtLocation(range: FourSlash.Range, expected: string) {
this.state.verifyTypeAtLocation(range, expected);
}

public goToSourceDefinition(startMarkerNames: ArrayOrSingle<string>, end: { file: string } | ArrayOrSingle<string>) {
this.state.verifyGoToSourceDefinition(startMarkerNames, end);
public baselineCommands(...commands: BaselineCommand[]) {
this.state.verifyBaselineCommands(...commands);
}

public goToDefinitionForMarkers(...markerNames: string[]) {
this.state.verifyGoToDefinitionForMarkers(markerNames);
public baselineFindAllReferences(...markerOrRange: FourSlash.MarkerOrNameOrRange[]) {
this.state.verifyBaselineCommands({ type: "findAllReferences", markerOrRange });
}

public goToDefinitionName(name: string, containerName: string) {
this.state.verifyGoToDefinitionName(name, containerName);
public baselineFindAllReferencesAtRangesWithText(...rangeText: string[]) {
this.state.verifyBaselineCommands({ type: "findAllReferences", rangeText });
}

public verifyGetEmitOutputForCurrentFile(expected: string): void {
this.state.verifyGetEmitOutputForCurrentFile(expected);
public baselineGetFileReferences(...fileName: string[]) {
this.state.verifyBaselineCommands({ type: "getFileReferences", fileName });
}

public verifyGetEmitOutputContentsForCurrentFile(expected: ts.OutputFile[]): void {
this.state.verifyGetEmitOutputContentsForCurrentFile(expected);
public baselineGoToDefinition(...markerOrRange: FourSlash.MarkerOrNameOrRange[]) {
this.state.verifyBaselineCommands({ type: "goToDefinition", markerOrRange });
}

public symbolAtLocation(startRange: FourSlash.Range, ...declarationRanges: FourSlash.Range[]) {
this.state.verifySymbolAtLocation(startRange, declarationRanges);
public baselineGoToDefinitionAtRangesWithText(...rangeText: string[]) {
this.state.verifyBaselineCommands({ type: "goToDefinition", rangeText });
}

public typeOfSymbolAtLocation(range: FourSlash.Range, symbol: ts.Symbol, expected: string) {
this.state.verifyTypeOfSymbolAtLocation(range, symbol, expected);
public baselineGetDefinitionAtPosition(...markerOrRange: FourSlash.MarkerOrNameOrRange[]) {
this.state.verifyBaselineCommands({ type: "getDefinitionAtPosition", markerOrRange });
}

public typeAtLocation(range: FourSlash.Range, expected: string) {
this.state.verifyTypeAtLocation(range, expected);
public baselineGetDefinitionAtRangesWithText(...rangeText: string[]) {
this.state.verifyBaselineCommands({ type: "getDefinitionAtPosition", rangeText });
}

public baselineFindAllReferences(...markerNames: string[]) {
this.state.verifyBaselineFindAllReferences(...markerNames);
public baselineGoToSourceDefinition(...markerOrRange: FourSlash.MarkerOrNameOrRange[]) {
this.state.verifyBaselineCommands({ type: "goToSourceDefinition", markerOrRange });
}

public baselineFindAllReferencesMulti(seq: number, ...markerNames: string[]) {
this.state.verifyBaselineFindAllReferencesMulti(seq, ...markerNames);
public baselineGoToSourceDefinitionAtRangesWithText(...rangeText: string[]) {
this.state.verifyBaselineCommands({ type: "goToSourceDefinition", rangeText });
}

public baselineGetFileReferences(fileName: string) {
this.state.verifyBaselineGetFileReferences(fileName);
public baselineGoToType(...markerOrRange: FourSlash.MarkerOrNameOrRange[]) {
this.state.verifyBaselineCommands({ type: "goToType", markerOrRange });
}

public findReferencesDefinitionDisplayPartsAtCaretAre(expected: ts.SymbolDisplayPart[]) {
this.state.verifyDisplayPartsOfReferencedSymbol(expected);
public baselineGoToTypeAtRangesWithText(...rangeText: string[]) {
this.state.verifyBaselineCommands({ type: "goToType", rangeText });
}

public baselineGoToImplementation(...markerOrRange: FourSlash.MarkerOrNameOrRange[]) {
this.state.verifyBaselineCommands({ type: "goToImplementation", markerOrRange });
}

public baselineGoToImplementationAtRangesWithText(...rangeText: string[]) {
this.state.verifyBaselineCommands({ type: "goToImplementation", rangeText });
}

public baselineDocumentHighlights(markerOrRange?: ArrayOrSingle<FourSlash.MarkerOrNameOrRange>, options?: VerifyDocumentHighlightsOptions) {
this.state.verifyBaselineCommands({ type: "documentHighlights", markerOrRange, options });
}

public baselineDocumentHighlightsAtRangesWithText(rangeText?: ArrayOrSingle<string>, options?: VerifyDocumentHighlightsOptions) {
this.state.verifyBaselineCommands({ type: "documentHighlights", rangeText, options });
}

public noErrors() {
Expand Down Expand Up @@ -516,42 +524,6 @@ export class Verify extends VerifyNegatable {
this.state.verifyNavigateTo(options);
}

public occurrencesAtPositionContains(range: FourSlash.Range, isWriteAccess?: boolean) {
this.state.verifyOccurrencesAtPositionListContains(range.fileName, range.pos, range.end, isWriteAccess);
}

public occurrencesAtPositionCount(expectedCount: number) {
this.state.verifyOccurrencesAtPositionListCount(expectedCount);
}

public rangesAreOccurrences(isWriteAccess?: boolean, ranges?: FourSlash.Range[]) {
this.state.verifyRangesAreOccurrences(isWriteAccess, ranges);
}

public rangesWithSameTextAreRenameLocations(...texts: string[]) {
this.state.verifyRangesWithSameTextAreRenameLocations(...texts);
}

public rangesAreRenameLocations(options?: FourSlash.Range[] | { findInStrings?: boolean, findInComments?: boolean, ranges?: FourSlash.Range[], providePrefixAndSuffixTextForRename?: boolean }) {
this.state.verifyRangesAreRenameLocations(options);
}

public rangesAreDocumentHighlights(ranges?: FourSlash.Range[], options?: VerifyDocumentHighlightsOptions) {
this.state.verifyRangesAreDocumentHighlights(ranges, options);
}

public rangesWithSameTextAreDocumentHighlights() {
this.state.verifyRangesWithSameTextAreDocumentHighlights();
}

public documentHighlightsOf(startRange: FourSlash.Range, ranges: FourSlash.Range[], options?: VerifyDocumentHighlightsOptions) {
this.state.verifyDocumentHighlightsOf(startRange, ranges, options);
}

public noDocumentHighlights(startRange: FourSlash.Range) {
this.state.verifyNoDocumentHighlights(startRange);
}

/**
* This method *requires* a contiguous, complete, and ordered stream of classifications for a file.
*/
Expand Down Expand Up @@ -593,12 +565,12 @@ export class Verify extends VerifyNegatable {
this.state.verifyRenameInfoFailed(message, preferences);
}

public renameLocations(startRanges: ArrayOrSingle<FourSlash.Range>, options: RenameLocationsOptions) {
this.state.verifyRenameLocations(startRanges, options);
public baselineRename(markerOrRange?: ArrayOrSingle<FourSlash.MarkerOrNameOrRange>, options?: RenameOptions) {
this.state.verifyBaselineCommands({ type: "findRenameLocations", markerOrRange, options });
}

public baselineRename(marker: string, options: RenameOptions) {
this.state.baselineRename(marker, options);
public baselineRenameAtRangesWithText(rangeText?: ArrayOrSingle<string>, options?: RenameOptions) {
this.state.verifyBaselineCommands({ type: "findRenameLocations", rangeText, options });
}

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

public allRangesAppearInImplementationList(markerName: string) {
this.state.verifyRangesInImplementationList(markerName);
}

public getEditsForFileRename(options: GetEditsForFileRenameOptions) {
this.state.getEditsForFileRename(options);
}
Expand All @@ -650,6 +618,9 @@ export class Verify extends VerifyNegatable {
export class Edit {
constructor(private state: FourSlash.TestState) {
}
public caretPosition() {
return this.state.caretPosition();
}
public backspace(count?: number) {
this.state.deleteCharBehindMarker(count);
}
Expand Down Expand Up @@ -1855,7 +1826,7 @@ export interface VerifyCompletionListContainsOptions extends ts.UserPreferences
}

export interface VerifyDocumentHighlightsOptions {
filesToSearch?: readonly string[];
filesToSearch: readonly string[];
}

export type NewFileContent = string | { readonly [filename: string]: string };
Expand Down Expand Up @@ -1936,3 +1907,25 @@ export interface RenameOptions {
readonly findInComments?: boolean;
readonly providePrefixAndSuffixTextForRename?: boolean;
}
export type BaselineCommandWithMarkerOrRange = {
type: "findAllReferences" | "goToDefinition" | "getDefinitionAtPosition" | "goToSourceDefinition" | "goToType" | "goToImplementation";
markerOrRange?: ArrayOrSingle<FourSlash.MarkerOrNameOrRange>;
rangeText?: ArrayOrSingle<string>;
} | {
type: "findRenameLocations";
markerOrRange?: ArrayOrSingle<FourSlash.MarkerOrNameOrRange>;
rangeText?: ArrayOrSingle<string>;
options?: RenameOptions;
} | {
type: "documentHighlights";
markerOrRange?: ArrayOrSingle<FourSlash.MarkerOrNameOrRange>;
rangeText?: ArrayOrSingle<string>;
options?: VerifyDocumentHighlightsOptions;
};
export type BaselineCommand = BaselineCommandWithMarkerOrRange | {
type: "getFileReferences";
fileName: ArrayOrSingle<string>;
} | {
type: "customWork";
work: () => string | undefined;
};
Loading