Skip to content

Commit e64855c

Browse files
committed
Handle contextSpan in fourslash test for verification
1 parent 4ec9b2f commit e64855c

File tree

1,490 files changed

+2275212
-2956
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,490 files changed

+2275212
-2956
lines changed

src/harness/fourslashImpl.ts

Lines changed: 348 additions & 511 deletions
Large diffs are not rendered by default.

src/harness/fourslashInterfaceImpl.ts

Lines changed: 56 additions & 98 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
}
@@ -310,64 +298,64 @@ export class Verify extends VerifyNegatable {
310298
this.state.verifyFormatDocumentChangesNothing();
311299
}
312300

313-
public goToDefinitionIs(endMarkers: ArrayOrSingle<string>) {
314-
this.state.verifyGoToDefinitionIs(endMarkers);
301+
public verifyGetEmitOutputForCurrentFile(expected: string): void {
302+
this.state.verifyGetEmitOutputForCurrentFile(expected);
315303
}
316304

317-
public goToDefinition(startMarkerName: ArrayOrSingle<string>, endMarkerName: ArrayOrSingle<string>, range?: FourSlash.Range): void;
318-
public goToDefinition(startsAndEnds: [ArrayOrSingle<string>, ArrayOrSingle<string>][] | { [startMarkerName: string]: ArrayOrSingle<string> }): void;
319-
public goToDefinition(arg0: any, endMarkerName?: ArrayOrSingle<string>) {
320-
this.state.verifyGoToDefinition(arg0, endMarkerName);
305+
public verifyGetEmitOutputContentsForCurrentFile(expected: ts.OutputFile[]): void {
306+
this.state.verifyGetEmitOutputContentsForCurrentFile(expected);
321307
}
322308

323-
public goToType(startMarkerName: ArrayOrSingle<string>, endMarkerName: ArrayOrSingle<string>): void;
324-
public goToType(startsAndEnds: [ArrayOrSingle<string>, ArrayOrSingle<string>][] | { [startMarkerName: string]: ArrayOrSingle<string> }): void;
325-
public goToType(arg0: any, endMarkerName?: ArrayOrSingle<string>) {
326-
this.state.verifyGoToType(arg0, endMarkerName);
309+
public symbolAtLocation(startRange: FourSlash.Range, ...declarationRanges: FourSlash.Range[]) {
310+
this.state.verifySymbolAtLocation(startRange, declarationRanges);
327311
}
328312

329-
public goToSourceDefinition(startMarkerNames: ArrayOrSingle<string>, end: { file: string } | ArrayOrSingle<string>) {
330-
this.state.verifyGoToSourceDefinition(startMarkerNames, end);
313+
public typeOfSymbolAtLocation(range: FourSlash.Range, symbol: ts.Symbol, expected: string) {
314+
this.state.verifyTypeOfSymbolAtLocation(range, symbol, expected);
331315
}
332316

333-
public goToDefinitionForMarkers(...markerNames: string[]) {
334-
this.state.verifyGoToDefinitionForMarkers(markerNames);
317+
public typeAtLocation(range: FourSlash.Range, expected: string) {
318+
this.state.verifyTypeAtLocation(range, expected);
335319
}
336320

337-
public goToDefinitionName(name: string, containerName: string) {
338-
this.state.verifyGoToDefinitionName(name, containerName);
321+
public baselineCommands(...commands: BaselineCommand[]) {
322+
this.state.verifyBaselineCommands(...commands);
339323
}
340324

341-
public verifyGetEmitOutputForCurrentFile(expected: string): void {
342-
this.state.verifyGetEmitOutputForCurrentFile(expected);
325+
public baselineFindAllReferences(...markerOrRange: FourSlash.MarkerOrNameOrRange[]) {
326+
this.state.verifyBaselineFindAllReferences(markerOrRange);
343327
}
344328

345-
public verifyGetEmitOutputContentsForCurrentFile(expected: ts.OutputFile[]): void {
346-
this.state.verifyGetEmitOutputContentsForCurrentFile(expected);
329+
public baselineGetFileReferences(...fileName: string[]) {
330+
this.state.verifyBaselineGetFileReferences(fileName);
347331
}
348332

349-
public symbolAtLocation(startRange: FourSlash.Range, ...declarationRanges: FourSlash.Range[]) {
350-
this.state.verifySymbolAtLocation(startRange, declarationRanges);
333+
public baselineGoToDefinition(...markerOrRange: FourSlash.MarkerOrNameOrRange[]) {
334+
this.state.verifyBaselineGoToDefinition(markerOrRange);
351335
}
352336

353-
public typeOfSymbolAtLocation(range: FourSlash.Range, symbol: ts.Symbol, expected: string) {
354-
this.state.verifyTypeOfSymbolAtLocation(range, symbol, expected);
337+
public baselineGetDefinitionAtPosition(...markerOrRange: FourSlash.MarkerOrNameOrRange[]) {
338+
this.state.verifyBaselineGetDefinitionAtPosition(markerOrRange);
355339
}
356340

357-
public typeAtLocation(range: FourSlash.Range, expected: string) {
358-
this.state.verifyTypeAtLocation(range, expected);
341+
public baselineGoToSourceDefinition(...markerOrRange: FourSlash.MarkerOrNameOrRange[]) {
342+
this.state.verifyBaselineGoToSourceDefinition(markerOrRange);
359343
}
360344

361-
public baselineFindAllReferences(...markerNames: string[]) {
362-
this.state.verifyBaselineFindAllReferences(...markerNames);
345+
public baselineGoToType(...markerOrRange: FourSlash.MarkerOrNameOrRange[]) {
346+
this.state.verifyBaselineGoToType(markerOrRange);
363347
}
364348

365-
public baselineFindAllReferencesMulti(seq: number, ...markerNames: string[]) {
366-
this.state.verifyBaselineFindAllReferencesMulti(seq, ...markerNames);
349+
public baselineGoToImplementation(...markerOrRange: FourSlash.MarkerOrNameOrRange[]) {
350+
this.state.verifyBaselineGoToImplementation(markerOrRange);
367351
}
368352

369-
public baselineGetFileReferences(fileName: string) {
370-
this.state.verifyBaselineGetFileReferences(fileName);
353+
public baselineOccurences(...markerOrRange: FourSlash.MarkerOrNameOrRange[]) {
354+
this.state.verifyBaselineOccurences(markerOrRange);
355+
}
356+
357+
public baselineDocumentHighlights(markerOrRange: ArrayOrSingle<FourSlash.MarkerOrNameOrRange>, options?: VerifyDocumentHighlightsOptions) {
358+
this.state.verifyBaselineDocumentHighlights(markerOrRange, options);
371359
}
372360

373361
public findReferencesDefinitionDisplayPartsAtCaretAre(expected: ts.SymbolDisplayPart[]) {
@@ -508,42 +496,6 @@ export class Verify extends VerifyNegatable {
508496
this.state.verifyNavigateTo(options);
509497
}
510498

511-
public occurrencesAtPositionContains(range: FourSlash.Range, isWriteAccess?: boolean) {
512-
this.state.verifyOccurrencesAtPositionListContains(range.fileName, range.pos, range.end, isWriteAccess);
513-
}
514-
515-
public occurrencesAtPositionCount(expectedCount: number) {
516-
this.state.verifyOccurrencesAtPositionListCount(expectedCount);
517-
}
518-
519-
public rangesAreOccurrences(isWriteAccess?: boolean, ranges?: FourSlash.Range[]) {
520-
this.state.verifyRangesAreOccurrences(isWriteAccess, ranges);
521-
}
522-
523-
public rangesWithSameTextAreRenameLocations(...texts: string[]) {
524-
this.state.verifyRangesWithSameTextAreRenameLocations(...texts);
525-
}
526-
527-
public rangesAreRenameLocations(options?: FourSlash.Range[] | { findInStrings?: boolean, findInComments?: boolean, ranges?: FourSlash.Range[], providePrefixAndSuffixTextForRename?: boolean }) {
528-
this.state.verifyRangesAreRenameLocations(options);
529-
}
530-
531-
public rangesAreDocumentHighlights(ranges?: FourSlash.Range[], options?: VerifyDocumentHighlightsOptions) {
532-
this.state.verifyRangesAreDocumentHighlights(ranges, options);
533-
}
534-
535-
public rangesWithSameTextAreDocumentHighlights() {
536-
this.state.verifyRangesWithSameTextAreDocumentHighlights();
537-
}
538-
539-
public documentHighlightsOf(startRange: FourSlash.Range, ranges: FourSlash.Range[], options?: VerifyDocumentHighlightsOptions) {
540-
this.state.verifyDocumentHighlightsOf(startRange, ranges, options);
541-
}
542-
543-
public noDocumentHighlights(startRange: FourSlash.Range) {
544-
this.state.verifyNoDocumentHighlights(startRange);
545-
}
546-
547499
/**
548500
* This method *requires* a contiguous, complete, and ordered stream of classifications for a file.
549501
*/
@@ -585,12 +537,8 @@ export class Verify extends VerifyNegatable {
585537
this.state.verifyRenameInfoFailed(message, preferences);
586538
}
587539

588-
public renameLocations(startRanges: ArrayOrSingle<FourSlash.Range>, options: RenameLocationsOptions) {
589-
this.state.verifyRenameLocations(startRanges, options);
590-
}
591-
592-
public baselineRename(marker: string, options: RenameOptions) {
593-
this.state.baselineRename(marker, options);
540+
public baselineRename(markerOrRange: ArrayOrSingle<FourSlash.MarkerOrNameOrRange>, options?: RenameOptions) {
541+
this.state.baselineRename(markerOrRange, options);
594542
}
595543

596544
public verifyQuickInfoDisplayParts(kind: string, kindModifiers: string, textSpan: FourSlash.TextSpan,
@@ -614,10 +562,6 @@ export class Verify extends VerifyNegatable {
614562
this.state.verifyProjectInfo(expected);
615563
}
616564

617-
public allRangesAppearInImplementationList(markerName: string) {
618-
this.state.verifyRangesInImplementationList(markerName);
619-
}
620-
621565
public getEditsForFileRename(options: GetEditsForFileRenameOptions) {
622566
this.state.getEditsForFileRename(options);
623567
}
@@ -642,6 +586,9 @@ export class Verify extends VerifyNegatable {
642586
export class Edit {
643587
constructor(private state: FourSlash.TestState) {
644588
}
589+
public caretPosition() {
590+
return this.state.caretPosition();
591+
}
645592
public backspace(count?: number) {
646593
this.state.deleteCharBehindMarker(count);
647594
}
@@ -1846,7 +1793,7 @@ export interface VerifyCompletionListContainsOptions extends ts.UserPreferences
18461793
}
18471794

18481795
export interface VerifyDocumentHighlightsOptions {
1849-
filesToSearch?: readonly string[];
1796+
filesToSearch: readonly string[];
18501797
}
18511798

18521799
export type NewFileContent = string | { readonly [filename: string]: string };
@@ -1912,18 +1859,29 @@ export interface MoveToNewFileOptions {
19121859
readonly preferences?: ts.UserPreferences;
19131860
}
19141861

1915-
export type RenameLocationsOptions = readonly RenameLocationOptions[] | {
1916-
readonly findInStrings?: boolean;
1917-
readonly findInComments?: boolean;
1918-
readonly ranges: readonly RenameLocationOptions[];
1919-
readonly providePrefixAndSuffixTextForRename?: boolean;
1920-
};
19211862
export interface DiagnosticIgnoredInterpolations {
19221863
template: string
19231864
}
1924-
export type RenameLocationOptions = FourSlash.Range | { readonly range: FourSlash.Range, readonly prefixText?: string, readonly suffixText?: string };
19251865
export interface RenameOptions {
19261866
readonly findInStrings?: boolean;
19271867
readonly findInComments?: boolean;
19281868
readonly providePrefixAndSuffixTextForRename?: boolean;
19291869
}
1870+
export type BaselineCommand = {
1871+
type: "findAllReferences" | "goToDefinition" | "getDefinitionAtPosition" | "goToSourceDefinition" | "goToType" | "goToImplementation" | "occurences";
1872+
markerOrRange: ArrayOrSingle<FourSlash.MarkerOrNameOrRange>;
1873+
} | {
1874+
type: "getFileReferences";
1875+
fileName: ArrayOrSingle<string>;
1876+
} | {
1877+
type: "findRenameLocations";
1878+
markerOrRange: ArrayOrSingle<FourSlash.MarkerOrNameOrRange>;
1879+
options?: RenameOptions;
1880+
} | {
1881+
type: "documentHighlights";
1882+
markerOrRange: ArrayOrSingle<FourSlash.MarkerOrNameOrRange>;
1883+
options?: VerifyDocumentHighlightsOptions;
1884+
} | {
1885+
type: "customWork";
1886+
work: () => string | undefined;
1887+
};

tests/baselines/reference/ambientShorthandFindAllRefs.baseline.jsonc

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,24 @@
11
// === /tests/cases/fourslash/user.ts ===
22
// import {/*FIND ALL REFS*/[|x|]} from "jquery";
33

4+
[
5+
{
6+
=== Definition ===
7+
// === /tests/cases/fourslash/user.ts ===
8+
// import {[|x|]} from "jquery";
9+
=== ContextSpan ===
10+
// === /tests/cases/fourslash/user.ts ===
11+
// [|import {x} from "jquery";|]
12+
=== References ===
13+
=== 0 ===
14+
// === /tests/cases/fourslash/user.ts ===
15+
// import {[|x|]} from "jquery";
16+
=== ContextSpan ===
17+
// === /tests/cases/fourslash/user.ts ===
18+
// [|import {x} from "jquery";|]
19+
}
20+
]
21+
422
[
523
{
624
"definition": {
@@ -85,6 +103,24 @@
85103
// === /tests/cases/fourslash/user2.ts ===
86104
// import {/*FIND ALL REFS*/[|x|]} from "jquery";
87105

106+
[
107+
{
108+
=== Definition ===
109+
// === /tests/cases/fourslash/user2.ts ===
110+
// import {[|x|]} from "jquery";
111+
=== ContextSpan ===
112+
// === /tests/cases/fourslash/user2.ts ===
113+
// [|import {x} from "jquery";|]
114+
=== References ===
115+
=== 0 ===
116+
// === /tests/cases/fourslash/user2.ts ===
117+
// import {[|x|]} from "jquery";
118+
=== ContextSpan ===
119+
// === /tests/cases/fourslash/user2.ts ===
120+
// [|import {x} from "jquery";|]
121+
}
122+
]
123+
88124
[
89125
{
90126
"definition": {

0 commit comments

Comments
 (0)