Remove non-baselining fourslash FAR validation (#48564)

* Fix fourslash failures

* Delete unused FAR fourslash helpers
This commit is contained in:
Andrew Casey 2022-04-04 16:54:10 -07:00 committed by GitHub
parent 99ea99b386
commit 493ddc2447
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
21 changed files with 22611 additions and 268 deletions

View File

@ -1122,83 +1122,18 @@ namespace FourSlash {
}
}
private verifyDocumentHighlightsRespectFilesList(files: readonly string[]): void {
const startFile = this.activeFile.fileName;
for (const fileName of files) {
const searchFileNames = startFile === fileName ? [startFile] : [startFile, fileName];
const highlights = this.getDocumentHighlightsAtCurrentPosition(searchFileNames);
if (highlights && !highlights.every(dh => ts.contains(searchFileNames, dh.fileName))) {
this.raiseError(`When asking for document highlights only in files ${searchFileNames}, got document highlights in ${unique(highlights, dh => dh.fileName)}`);
}
}
}
public verifyReferenceGroups(starts: ArrayOrSingle<string> | ArrayOrSingle<Range>, parts: readonly FourSlashInterface.ReferenceGroup[]): void {
interface ReferenceGroupJson {
definition: string | { text: string, range: ts.TextSpan };
references: ts.ReferenceEntry[];
}
interface RangeMarkerData {
id?: string;
isWriteAccess?: boolean,
isDefinition?: boolean,
isInString?: true,
contextRangeIndex?: number,
contextRangeDelta?: number,
contextRangeId?: string
}
const fullExpected = ts.map<FourSlashInterface.ReferenceGroup, ReferenceGroupJson>(parts, ({ definition, ranges }) => ({
definition: typeof definition === "string" ? definition : { ...definition, range: ts.createTextSpanFromRange(definition.range) },
references: ranges.map<ts.ReferenceEntry>(r => {
const { isWriteAccess = false, isDefinition = false, isInString, contextRangeIndex, contextRangeDelta, contextRangeId } = (r.marker && r.marker.data || {}) as RangeMarkerData;
let contextSpan: ts.TextSpan | undefined;
if (contextRangeDelta !== undefined) {
const allRanges = this.getRanges();
const index = allRanges.indexOf(r);
if (index !== -1) {
contextSpan = ts.createTextSpanFromRange(allRanges[index + contextRangeDelta]);
}
}
else if (contextRangeId !== undefined) {
const allRanges = this.getRanges();
const contextRange = ts.find(allRanges, range => (range.marker?.data as RangeMarkerData)?.id === contextRangeId);
if (contextRange) {
contextSpan = ts.createTextSpanFromRange(contextRange);
}
}
else if (contextRangeIndex !== undefined) {
contextSpan = ts.createTextSpanFromRange(this.getRanges()[contextRangeIndex]);
}
return {
textSpan: ts.createTextSpanFromRange(r),
fileName: r.fileName,
...(contextSpan ? { contextSpan } : undefined),
isWriteAccess,
isDefinition,
...(isInString ? { isInString: true } : undefined),
};
}),
}));
for (const start of toArray<string | Range>(starts)) {
this.goToMarkerOrRange(start);
const fullActual = ts.map<ts.ReferencedSymbol, ReferenceGroupJson>(this.findReferencesAtCaret(), ({ definition, references }, i) => {
const text = definition.displayParts.map(d => d.text).join("");
return {
definition: fullExpected.length > i && typeof fullExpected[i].definition === "string" ? text : { text, range: definition.textSpan },
references,
};
});
this.assertObjectsEqual(fullActual, fullExpected);
if (parts) {
this.verifyDocumentHighlightsRespectFilesList(unique(ts.flatMap(parts, p => p.ranges), r => r.fileName));
}
}
}
public verifyBaselineFindAllReferences(...markerNames: string[]) {
ts.Debug.assert(markerNames.length > 0, "Must pass at least one marker name to `verifyBaselineFindAllReferences()`");
this.verifyBaselineFindAllReferencesWorker("", markerNames);
}
// Used when a single test needs to produce multiple baselines
public verifyBaselineFindAllReferencesMulti(seq: number, ...markerNames: string[]) {
ts.Debug.assert(markerNames.length > 0, "Must pass at least one marker name to `baselineFindAllReferences()`");
this.verifyBaselineFindAllReferencesWorker(`.${seq}`, markerNames);
}
private verifyBaselineFindAllReferencesWorker(suffix: string, markerNames: string[]) {
const baseline = markerNames.map(markerName => {
this.goToMarker(markerName);
const marker = this.getMarkerByName(markerName);
@ -1213,7 +1148,7 @@ namespace FourSlash {
// Write response JSON
return baselineContent + JSON.stringify(references, undefined, 2);
}).join("\n\n");
Harness.Baseline.runBaseline(this.getBaselineFileNameForContainingTestFile(".baseline.jsonc"), baseline);
Harness.Baseline.runBaseline(this.getBaselineFileNameForContainingTestFile(`${suffix}.baseline.jsonc`), baseline);
}
public verifyBaselineGetFileReferences(fileName: string) {
@ -1280,11 +1215,6 @@ namespace FourSlash {
}
}
public verifySingleReferenceGroup(definition: FourSlashInterface.ReferenceGroupDefinition, ranges?: Range[] | string) {
ranges = ts.isString(ranges) ? this.rangesByText().get(ranges)! : ranges || this.getRanges();
this.verifyReferenceGroups(ranges, [{ definition, ranges }]);
}
private assertObjectsEqual<T>(fullActual: T, fullExpected: T, msgPrefix = ""): void {
const recur = <U>(actual: U, expected: U, path: string) => {
const fail = (msg: string) => {
@ -2403,15 +2333,6 @@ namespace FourSlash {
this.goToPosition(len);
}
private goToMarkerOrRange(markerOrRange: string | Range) {
if (typeof markerOrRange === "string") {
this.goToMarker(markerOrRange);
}
else {
this.goToRangeStart(markerOrRange);
}
}
public goToRangeStart({ fileName, pos }: Range) {
this.openFile(fileName);
this.goToPosition(pos);

View File

@ -352,12 +352,12 @@ namespace FourSlashInterface {
this.state.verifyBaselineFindAllReferences(...markerNames);
}
public baselineGetFileReferences(fileName: string) {
this.state.verifyBaselineGetFileReferences(fileName);
public baselineFindAllReferencesMulti(seq: number, ...markerNames: string[]) {
this.state.verifyBaselineFindAllReferencesMulti(seq, ...markerNames);
}
public singleReferenceGroup(definition: ReferenceGroupDefinition, ranges?: FourSlash.Range[] | string) {
this.state.verifySingleReferenceGroup(definition, ranges);
public baselineGetFileReferences(fileName: string) {
this.state.verifyBaselineGetFileReferences(fileName);
}
public findReferencesDefinitionDisplayPartsAtCaretAre(expected: ts.SymbolDisplayPart[]) {

View File

@ -0,0 +1,116 @@
// === /tests/cases/fourslash/findAllRefsOnDefinition-import.ts ===
// export class Test{
//
// constructor(){
//
// }
//
// public /*FIND ALL REFS*/[|start|](){
// return this;
// }
//
// public stop(){
// return this;
// }
// }
// === /tests/cases/fourslash/findAllRefsOnDefinition.ts ===
// import Second = require("./findAllRefsOnDefinition-import");
//
// var second = new Second.Test()
// second.[|start|]();
// second.stop();
[
{
"definition": {
"containerKind": "",
"containerName": "",
"fileName": "/tests/cases/fourslash/findAllRefsOnDefinition-import.ts",
"kind": "method",
"name": "(method) Test.start(): this",
"textSpan": {
"start": 58,
"length": 5
},
"displayParts": [
{
"text": "(",
"kind": "punctuation"
},
{
"text": "method",
"kind": "text"
},
{
"text": ")",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "Test",
"kind": "className"
},
{
"text": ".",
"kind": "punctuation"
},
{
"text": "start",
"kind": "methodName"
},
{
"text": "(",
"kind": "punctuation"
},
{
"text": ")",
"kind": "punctuation"
},
{
"text": ":",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "this",
"kind": "keyword"
}
],
"contextSpan": {
"start": 51,
"length": 42
}
},
"references": [
{
"textSpan": {
"start": 58,
"length": 5
},
"fileName": "/tests/cases/fourslash/findAllRefsOnDefinition-import.ts",
"contextSpan": {
"start": 51,
"length": 42
},
"isWriteAccess": true,
"isDefinition": true
},
{
"textSpan": {
"start": 100,
"length": 5
},
"fileName": "/tests/cases/fourslash/findAllRefsOnDefinition.ts",
"isWriteAccess": false,
"isDefinition": false
}
]
}
]

View File

@ -0,0 +1,116 @@
// === /tests/cases/fourslash/findAllRefsOnDefinition-import.ts ===
// export class Test{
//
// constructor(){
//
// }
//
// public /*FIND ALL REFS*/[|start|](){
// return this;
// }
//
// public stop(){
// return this;
// }
// }
// === /tests/cases/fourslash/findAllRefsOnDefinition.ts ===
// import Second = require("./findAllRefsOnDefinition-import");
//
// var second = new Second.Test()
// second.[|start|]();
// second.stop();
[
{
"definition": {
"containerKind": "",
"containerName": "",
"fileName": "/tests/cases/fourslash/findAllRefsOnDefinition-import.ts",
"kind": "method",
"name": "(method) Test.start(): this",
"textSpan": {
"start": 58,
"length": 5
},
"displayParts": [
{
"text": "(",
"kind": "punctuation"
},
{
"text": "method",
"kind": "text"
},
{
"text": ")",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "Test",
"kind": "className"
},
{
"text": ".",
"kind": "punctuation"
},
{
"text": "start",
"kind": "methodName"
},
{
"text": "(",
"kind": "punctuation"
},
{
"text": ")",
"kind": "punctuation"
},
{
"text": ":",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "this",
"kind": "keyword"
}
],
"contextSpan": {
"start": 51,
"length": 42
}
},
"references": [
{
"textSpan": {
"start": 58,
"length": 5
},
"fileName": "/tests/cases/fourslash/findAllRefsOnDefinition-import.ts",
"contextSpan": {
"start": 51,
"length": 42
},
"isWriteAccess": true,
"isDefinition": true
},
{
"textSpan": {
"start": 100,
"length": 5
},
"fileName": "/tests/cases/fourslash/findAllRefsOnDefinition.ts",
"isWriteAccess": false,
"isDefinition": false
}
]
}
]

View File

@ -0,0 +1,953 @@
// === /tests/cases/fourslash/a.ts ===
// const x: /*FIND ALL REFS*/[|any|] = 0;
// const any = 2;
// const y: [|any|] = any;
// function f(b: boolean): boolean;
// type T = never; type U = never;
// function n(x: number): number;
// function o(x: object): object;
// function s(x: string): string;
// function sy(s: symbol): symbol;
// function v(v: void): void;
// === /tests/cases/fourslash/b.ts ===
// const z: [|any|] = 0;
[
{
"definition": {
"containerKind": "",
"containerName": "",
"fileName": "/tests/cases/fourslash/a.ts",
"kind": "keyword",
"name": "any",
"textSpan": {
"start": 9,
"length": 3
},
"displayParts": [
{
"text": "any",
"kind": "keyword"
}
]
},
"references": [
{
"textSpan": {
"start": 9,
"length": 3
},
"fileName": "/tests/cases/fourslash/a.ts",
"isWriteAccess": false,
"isDefinition": false
},
{
"textSpan": {
"start": 42,
"length": 3
},
"fileName": "/tests/cases/fourslash/a.ts",
"isWriteAccess": false,
"isDefinition": false
},
{
"textSpan": {
"start": 9,
"length": 3
},
"fileName": "/tests/cases/fourslash/b.ts",
"isWriteAccess": false,
"isDefinition": false
}
]
}
]
// === /tests/cases/fourslash/a.ts ===
// const x: [|any|] = 0;
// const any = 2;
// const y: /*FIND ALL REFS*/[|any|] = any;
// function f(b: boolean): boolean;
// type T = never; type U = never;
// function n(x: number): number;
// function o(x: object): object;
// function s(x: string): string;
// function sy(s: symbol): symbol;
// function v(v: void): void;
// === /tests/cases/fourslash/b.ts ===
// const z: [|any|] = 0;
[
{
"definition": {
"containerKind": "",
"containerName": "",
"fileName": "/tests/cases/fourslash/a.ts",
"kind": "keyword",
"name": "any",
"textSpan": {
"start": 9,
"length": 3
},
"displayParts": [
{
"text": "any",
"kind": "keyword"
}
]
},
"references": [
{
"textSpan": {
"start": 9,
"length": 3
},
"fileName": "/tests/cases/fourslash/a.ts",
"isWriteAccess": false,
"isDefinition": false
},
{
"textSpan": {
"start": 42,
"length": 3
},
"fileName": "/tests/cases/fourslash/a.ts",
"isWriteAccess": false,
"isDefinition": false
},
{
"textSpan": {
"start": 9,
"length": 3
},
"fileName": "/tests/cases/fourslash/b.ts",
"isWriteAccess": false,
"isDefinition": false
}
]
}
]
// === /tests/cases/fourslash/a.ts ===
// const x: any = 0;
// const any = 2;
// const y: any = any;
// function f(b: /*FIND ALL REFS*/[|boolean|]): [|boolean|];
// type T = never; type U = never;
// function n(x: number): number;
// function o(x: object): object;
// function s(x: string): string;
// function sy(s: symbol): symbol;
// function v(v: void): void;
[
{
"definition": {
"containerKind": "",
"containerName": "",
"fileName": "/tests/cases/fourslash/a.ts",
"kind": "keyword",
"name": "boolean",
"textSpan": {
"start": 67,
"length": 7
},
"displayParts": [
{
"text": "boolean",
"kind": "keyword"
}
]
},
"references": [
{
"textSpan": {
"start": 67,
"length": 7
},
"fileName": "/tests/cases/fourslash/a.ts",
"isWriteAccess": false,
"isDefinition": false
},
{
"textSpan": {
"start": 77,
"length": 7
},
"fileName": "/tests/cases/fourslash/a.ts",
"isWriteAccess": false,
"isDefinition": false
}
]
}
]
// === /tests/cases/fourslash/a.ts ===
// const x: any = 0;
// const any = 2;
// const y: any = any;
// function f(b: [|boolean|]): /*FIND ALL REFS*/[|boolean|];
// type T = never; type U = never;
// function n(x: number): number;
// function o(x: object): object;
// function s(x: string): string;
// function sy(s: symbol): symbol;
// function v(v: void): void;
[
{
"definition": {
"containerKind": "",
"containerName": "",
"fileName": "/tests/cases/fourslash/a.ts",
"kind": "keyword",
"name": "boolean",
"textSpan": {
"start": 67,
"length": 7
},
"displayParts": [
{
"text": "boolean",
"kind": "keyword"
}
]
},
"references": [
{
"textSpan": {
"start": 67,
"length": 7
},
"fileName": "/tests/cases/fourslash/a.ts",
"isWriteAccess": false,
"isDefinition": false
},
{
"textSpan": {
"start": 77,
"length": 7
},
"fileName": "/tests/cases/fourslash/a.ts",
"isWriteAccess": false,
"isDefinition": false
}
]
}
]
// === /tests/cases/fourslash/a.ts ===
// const x: any = 0;
// const any = 2;
// const y: any = any;
// function f(b: boolean): boolean;
// type T = /*FIND ALL REFS*/[|never|]; type U = [|never|];
// function n(x: number): number;
// function o(x: object): object;
// function s(x: string): string;
// function sy(s: symbol): symbol;
// function v(v: void): void;
[
{
"definition": {
"containerKind": "",
"containerName": "",
"fileName": "/tests/cases/fourslash/a.ts",
"kind": "keyword",
"name": "never",
"textSpan": {
"start": 95,
"length": 5
},
"displayParts": [
{
"text": "never",
"kind": "keyword"
}
]
},
"references": [
{
"textSpan": {
"start": 95,
"length": 5
},
"fileName": "/tests/cases/fourslash/a.ts",
"isWriteAccess": false,
"isDefinition": false
},
{
"textSpan": {
"start": 111,
"length": 5
},
"fileName": "/tests/cases/fourslash/a.ts",
"isWriteAccess": false,
"isDefinition": false
}
]
}
]
// === /tests/cases/fourslash/a.ts ===
// const x: any = 0;
// const any = 2;
// const y: any = any;
// function f(b: boolean): boolean;
// type T = [|never|]; type U = /*FIND ALL REFS*/[|never|];
// function n(x: number): number;
// function o(x: object): object;
// function s(x: string): string;
// function sy(s: symbol): symbol;
// function v(v: void): void;
[
{
"definition": {
"containerKind": "",
"containerName": "",
"fileName": "/tests/cases/fourslash/a.ts",
"kind": "keyword",
"name": "never",
"textSpan": {
"start": 95,
"length": 5
},
"displayParts": [
{
"text": "never",
"kind": "keyword"
}
]
},
"references": [
{
"textSpan": {
"start": 95,
"length": 5
},
"fileName": "/tests/cases/fourslash/a.ts",
"isWriteAccess": false,
"isDefinition": false
},
{
"textSpan": {
"start": 111,
"length": 5
},
"fileName": "/tests/cases/fourslash/a.ts",
"isWriteAccess": false,
"isDefinition": false
}
]
}
]
// === /tests/cases/fourslash/a.ts ===
// const x: any = 0;
// const any = 2;
// const y: any = any;
// function f(b: boolean): boolean;
// type T = never; type U = never;
// function n(x: /*FIND ALL REFS*/[|number|]): [|number|];
// function o(x: object): object;
// function s(x: string): string;
// function sy(s: symbol): symbol;
// function v(v: void): void;
[
{
"definition": {
"containerKind": "",
"containerName": "",
"fileName": "/tests/cases/fourslash/a.ts",
"kind": "keyword",
"name": "number",
"textSpan": {
"start": 132,
"length": 6
},
"displayParts": [
{
"text": "number",
"kind": "keyword"
}
]
},
"references": [
{
"textSpan": {
"start": 132,
"length": 6
},
"fileName": "/tests/cases/fourslash/a.ts",
"isWriteAccess": false,
"isDefinition": false
},
{
"textSpan": {
"start": 141,
"length": 6
},
"fileName": "/tests/cases/fourslash/a.ts",
"isWriteAccess": false,
"isDefinition": false
}
]
}
]
// === /tests/cases/fourslash/a.ts ===
// const x: any = 0;
// const any = 2;
// const y: any = any;
// function f(b: boolean): boolean;
// type T = never; type U = never;
// function n(x: [|number|]): /*FIND ALL REFS*/[|number|];
// function o(x: object): object;
// function s(x: string): string;
// function sy(s: symbol): symbol;
// function v(v: void): void;
[
{
"definition": {
"containerKind": "",
"containerName": "",
"fileName": "/tests/cases/fourslash/a.ts",
"kind": "keyword",
"name": "number",
"textSpan": {
"start": 132,
"length": 6
},
"displayParts": [
{
"text": "number",
"kind": "keyword"
}
]
},
"references": [
{
"textSpan": {
"start": 132,
"length": 6
},
"fileName": "/tests/cases/fourslash/a.ts",
"isWriteAccess": false,
"isDefinition": false
},
{
"textSpan": {
"start": 141,
"length": 6
},
"fileName": "/tests/cases/fourslash/a.ts",
"isWriteAccess": false,
"isDefinition": false
}
]
}
]
// === /tests/cases/fourslash/a.ts ===
// const x: any = 0;
// const any = 2;
// const y: any = any;
// function f(b: boolean): boolean;
// type T = never; type U = never;
// function n(x: number): number;
// function o(x: /*FIND ALL REFS*/[|object|]): [|object|];
// function s(x: string): string;
// function sy(s: symbol): symbol;
// function v(v: void): void;
[
{
"definition": {
"containerKind": "",
"containerName": "",
"fileName": "/tests/cases/fourslash/a.ts",
"kind": "keyword",
"name": "object",
"textSpan": {
"start": 163,
"length": 6
},
"displayParts": [
{
"text": "object",
"kind": "keyword"
}
]
},
"references": [
{
"textSpan": {
"start": 163,
"length": 6
},
"fileName": "/tests/cases/fourslash/a.ts",
"isWriteAccess": false,
"isDefinition": false
},
{
"textSpan": {
"start": 172,
"length": 6
},
"fileName": "/tests/cases/fourslash/a.ts",
"isWriteAccess": false,
"isDefinition": false
}
]
}
]
// === /tests/cases/fourslash/a.ts ===
// const x: any = 0;
// const any = 2;
// const y: any = any;
// function f(b: boolean): boolean;
// type T = never; type U = never;
// function n(x: number): number;
// function o(x: [|object|]): /*FIND ALL REFS*/[|object|];
// function s(x: string): string;
// function sy(s: symbol): symbol;
// function v(v: void): void;
[
{
"definition": {
"containerKind": "",
"containerName": "",
"fileName": "/tests/cases/fourslash/a.ts",
"kind": "keyword",
"name": "object",
"textSpan": {
"start": 163,
"length": 6
},
"displayParts": [
{
"text": "object",
"kind": "keyword"
}
]
},
"references": [
{
"textSpan": {
"start": 163,
"length": 6
},
"fileName": "/tests/cases/fourslash/a.ts",
"isWriteAccess": false,
"isDefinition": false
},
{
"textSpan": {
"start": 172,
"length": 6
},
"fileName": "/tests/cases/fourslash/a.ts",
"isWriteAccess": false,
"isDefinition": false
}
]
}
]
// === /tests/cases/fourslash/a.ts ===
// const x: any = 0;
// const any = 2;
// const y: any = any;
// function f(b: boolean): boolean;
// type T = never; type U = never;
// function n(x: number): number;
// function o(x: object): object;
// function s(x: /*FIND ALL REFS*/[|string|]): [|string|];
// function sy(s: symbol): symbol;
// function v(v: void): void;
[
{
"definition": {
"containerKind": "",
"containerName": "",
"fileName": "/tests/cases/fourslash/a.ts",
"kind": "keyword",
"name": "string",
"textSpan": {
"start": 194,
"length": 6
},
"displayParts": [
{
"text": "string",
"kind": "keyword"
}
]
},
"references": [
{
"textSpan": {
"start": 194,
"length": 6
},
"fileName": "/tests/cases/fourslash/a.ts",
"isWriteAccess": false,
"isDefinition": false
},
{
"textSpan": {
"start": 203,
"length": 6
},
"fileName": "/tests/cases/fourslash/a.ts",
"isWriteAccess": false,
"isDefinition": false
}
]
}
]
// === /tests/cases/fourslash/a.ts ===
// const x: any = 0;
// const any = 2;
// const y: any = any;
// function f(b: boolean): boolean;
// type T = never; type U = never;
// function n(x: number): number;
// function o(x: object): object;
// function s(x: [|string|]): /*FIND ALL REFS*/[|string|];
// function sy(s: symbol): symbol;
// function v(v: void): void;
[
{
"definition": {
"containerKind": "",
"containerName": "",
"fileName": "/tests/cases/fourslash/a.ts",
"kind": "keyword",
"name": "string",
"textSpan": {
"start": 194,
"length": 6
},
"displayParts": [
{
"text": "string",
"kind": "keyword"
}
]
},
"references": [
{
"textSpan": {
"start": 194,
"length": 6
},
"fileName": "/tests/cases/fourslash/a.ts",
"isWriteAccess": false,
"isDefinition": false
},
{
"textSpan": {
"start": 203,
"length": 6
},
"fileName": "/tests/cases/fourslash/a.ts",
"isWriteAccess": false,
"isDefinition": false
}
]
}
]
// === /tests/cases/fourslash/a.ts ===
// const x: any = 0;
// const any = 2;
// const y: any = any;
// function f(b: boolean): boolean;
// type T = never; type U = never;
// function n(x: number): number;
// function o(x: object): object;
// function s(x: string): string;
// function sy(s: /*FIND ALL REFS*/[|symbol|]): [|symbol|];
// function v(v: void): void;
[
{
"definition": {
"containerKind": "",
"containerName": "",
"fileName": "/tests/cases/fourslash/a.ts",
"kind": "keyword",
"name": "symbol",
"textSpan": {
"start": 226,
"length": 6
},
"displayParts": [
{
"text": "symbol",
"kind": "keyword"
}
]
},
"references": [
{
"textSpan": {
"start": 226,
"length": 6
},
"fileName": "/tests/cases/fourslash/a.ts",
"isWriteAccess": false,
"isDefinition": false
},
{
"textSpan": {
"start": 235,
"length": 6
},
"fileName": "/tests/cases/fourslash/a.ts",
"isWriteAccess": false,
"isDefinition": false
}
]
}
]
// === /tests/cases/fourslash/a.ts ===
// const x: any = 0;
// const any = 2;
// const y: any = any;
// function f(b: boolean): boolean;
// type T = never; type U = never;
// function n(x: number): number;
// function o(x: object): object;
// function s(x: string): string;
// function sy(s: [|symbol|]): /*FIND ALL REFS*/[|symbol|];
// function v(v: void): void;
[
{
"definition": {
"containerKind": "",
"containerName": "",
"fileName": "/tests/cases/fourslash/a.ts",
"kind": "keyword",
"name": "symbol",
"textSpan": {
"start": 226,
"length": 6
},
"displayParts": [
{
"text": "symbol",
"kind": "keyword"
}
]
},
"references": [
{
"textSpan": {
"start": 226,
"length": 6
},
"fileName": "/tests/cases/fourslash/a.ts",
"isWriteAccess": false,
"isDefinition": false
},
{
"textSpan": {
"start": 235,
"length": 6
},
"fileName": "/tests/cases/fourslash/a.ts",
"isWriteAccess": false,
"isDefinition": false
}
]
}
]
// === /tests/cases/fourslash/a.ts ===
// const x: any = 0;
// const any = 2;
// const y: any = any;
// function f(b: boolean): boolean;
// type T = never; type U = never;
// function n(x: number): number;
// function o(x: object): object;
// function s(x: string): string;
// function sy(s: symbol): symbol;
// function v(v: /*FIND ALL REFS*/[|void|]): [|void|];
[
{
"definition": {
"containerKind": "",
"containerName": "",
"fileName": "/tests/cases/fourslash/a.ts",
"kind": "keyword",
"name": "void",
"textSpan": {
"start": 257,
"length": 4
},
"displayParts": [
{
"text": "void",
"kind": "keyword"
}
]
},
"references": [
{
"textSpan": {
"start": 257,
"length": 4
},
"fileName": "/tests/cases/fourslash/a.ts",
"isWriteAccess": false,
"isDefinition": false
},
{
"textSpan": {
"start": 264,
"length": 4
},
"fileName": "/tests/cases/fourslash/a.ts",
"isWriteAccess": false,
"isDefinition": false
}
]
}
]
// === /tests/cases/fourslash/a.ts ===
// const x: any = 0;
// const any = 2;
// const y: any = any;
// function f(b: boolean): boolean;
// type T = never; type U = never;
// function n(x: number): number;
// function o(x: object): object;
// function s(x: string): string;
// function sy(s: symbol): symbol;
// function v(v: [|void|]): /*FIND ALL REFS*/[|void|];
[
{
"definition": {
"containerKind": "",
"containerName": "",
"fileName": "/tests/cases/fourslash/a.ts",
"kind": "keyword",
"name": "void",
"textSpan": {
"start": 257,
"length": 4
},
"displayParts": [
{
"text": "void",
"kind": "keyword"
}
]
},
"references": [
{
"textSpan": {
"start": 257,
"length": 4
},
"fileName": "/tests/cases/fourslash/a.ts",
"isWriteAccess": false,
"isDefinition": false
},
{
"textSpan": {
"start": 264,
"length": 4
},
"fileName": "/tests/cases/fourslash/a.ts",
"isWriteAccess": false,
"isDefinition": false
}
]
}
]
// === /tests/cases/fourslash/a.ts ===
// const x: [|any|] = 0;
// const any = 2;
// const y: [|any|] = any;
// function f(b: boolean): boolean;
// type T = never; type U = never;
// function n(x: number): number;
// function o(x: object): object;
// function s(x: string): string;
// function sy(s: symbol): symbol;
// function v(v: void): void;
// === /tests/cases/fourslash/b.ts ===
// const z: /*FIND ALL REFS*/[|any|] = 0;
[
{
"definition": {
"containerKind": "",
"containerName": "",
"fileName": "/tests/cases/fourslash/a.ts",
"kind": "keyword",
"name": "any",
"textSpan": {
"start": 9,
"length": 3
},
"displayParts": [
{
"text": "any",
"kind": "keyword"
}
]
},
"references": [
{
"textSpan": {
"start": 9,
"length": 3
},
"fileName": "/tests/cases/fourslash/a.ts",
"isWriteAccess": false,
"isDefinition": false
},
{
"textSpan": {
"start": 42,
"length": 3
},
"fileName": "/tests/cases/fourslash/a.ts",
"isWriteAccess": false,
"isDefinition": false
},
{
"textSpan": {
"start": 9,
"length": 3
},
"fileName": "/tests/cases/fourslash/b.ts",
"isWriteAccess": false,
"isDefinition": false
}
]
}
]

View File

@ -0,0 +1,195 @@
// === /tests/cases/fourslash/a.ts ===
// interface A {
// /*FIND ALL REFS*/[|foo|]: string;
// }
// === /tests/cases/fourslash/b.ts ===
// ///<reference path='a.ts'/>
//
// function foo(x: A) {
// x.[|foo|]
// }
[
{
"definition": {
"containerKind": "",
"containerName": "",
"fileName": "/tests/cases/fourslash/a.ts",
"kind": "property",
"name": "(property) A.foo: string",
"textSpan": {
"start": 18,
"length": 3
},
"displayParts": [
{
"text": "(",
"kind": "punctuation"
},
{
"text": "property",
"kind": "text"
},
{
"text": ")",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "A",
"kind": "interfaceName"
},
{
"text": ".",
"kind": "punctuation"
},
{
"text": "foo",
"kind": "propertyName"
},
{
"text": ":",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "string",
"kind": "keyword"
}
],
"contextSpan": {
"start": 18,
"length": 12
}
},
"references": [
{
"textSpan": {
"start": 18,
"length": 3
},
"fileName": "/tests/cases/fourslash/a.ts",
"contextSpan": {
"start": 18,
"length": 12
},
"isWriteAccess": false,
"isDefinition": true
},
{
"textSpan": {
"start": 56,
"length": 3
},
"fileName": "/tests/cases/fourslash/b.ts",
"isWriteAccess": false,
"isDefinition": false
}
]
}
]
// === /tests/cases/fourslash/a.ts ===
// interface A {
// [|foo|]: string;
// }
// === /tests/cases/fourslash/b.ts ===
// ///<reference path='a.ts'/>
//
// function foo(x: A) {
// x./*FIND ALL REFS*/[|foo|]
// }
[
{
"definition": {
"containerKind": "",
"containerName": "",
"fileName": "/tests/cases/fourslash/a.ts",
"kind": "property",
"name": "(property) A.foo: string",
"textSpan": {
"start": 18,
"length": 3
},
"displayParts": [
{
"text": "(",
"kind": "punctuation"
},
{
"text": "property",
"kind": "text"
},
{
"text": ")",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "A",
"kind": "interfaceName"
},
{
"text": ".",
"kind": "punctuation"
},
{
"text": "foo",
"kind": "propertyName"
},
{
"text": ":",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "string",
"kind": "keyword"
}
],
"contextSpan": {
"start": 18,
"length": 12
}
},
"references": [
{
"textSpan": {
"start": 18,
"length": 3
},
"fileName": "/tests/cases/fourslash/a.ts",
"contextSpan": {
"start": 18,
"length": 12
},
"isWriteAccess": false,
"isDefinition": true
},
{
"textSpan": {
"start": 56,
"length": 3
},
"fileName": "/tests/cases/fourslash/b.ts",
"isWriteAccess": false,
"isDefinition": false
}
]
}
]

View File

@ -0,0 +1,197 @@
// === /tests/cases/fourslash/a.ts ===
// interface A {
// /*FIND ALL REFS*/[|foo|]: string;
// }
// === /tests/cases/fourslash/b.ts ===
// ///<reference path='a.ts'/>
//
//
// function foo(x: A) {
// x.[|foo|]
// }
[
{
"definition": {
"containerKind": "",
"containerName": "",
"fileName": "/tests/cases/fourslash/a.ts",
"kind": "property",
"name": "(property) A.foo: string",
"textSpan": {
"start": 18,
"length": 3
},
"displayParts": [
{
"text": "(",
"kind": "punctuation"
},
{
"text": "property",
"kind": "text"
},
{
"text": ")",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "A",
"kind": "interfaceName"
},
{
"text": ".",
"kind": "punctuation"
},
{
"text": "foo",
"kind": "propertyName"
},
{
"text": ":",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "string",
"kind": "keyword"
}
],
"contextSpan": {
"start": 18,
"length": 12
}
},
"references": [
{
"textSpan": {
"start": 18,
"length": 3
},
"fileName": "/tests/cases/fourslash/a.ts",
"contextSpan": {
"start": 18,
"length": 12
},
"isWriteAccess": false,
"isDefinition": true
},
{
"textSpan": {
"start": 57,
"length": 3
},
"fileName": "/tests/cases/fourslash/b.ts",
"isWriteAccess": false,
"isDefinition": false
}
]
}
]
// === /tests/cases/fourslash/a.ts ===
// interface A {
// [|foo|]: string;
// }
// === /tests/cases/fourslash/b.ts ===
// ///<reference path='a.ts'/>
//
//
// function foo(x: A) {
// x./*FIND ALL REFS*/[|foo|]
// }
[
{
"definition": {
"containerKind": "",
"containerName": "",
"fileName": "/tests/cases/fourslash/a.ts",
"kind": "property",
"name": "(property) A.foo: string",
"textSpan": {
"start": 18,
"length": 3
},
"displayParts": [
{
"text": "(",
"kind": "punctuation"
},
{
"text": "property",
"kind": "text"
},
{
"text": ")",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "A",
"kind": "interfaceName"
},
{
"text": ".",
"kind": "punctuation"
},
{
"text": "foo",
"kind": "propertyName"
},
{
"text": ":",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "string",
"kind": "keyword"
}
],
"contextSpan": {
"start": 18,
"length": 12
}
},
"references": [
{
"textSpan": {
"start": 18,
"length": 3
},
"fileName": "/tests/cases/fourslash/a.ts",
"contextSpan": {
"start": 18,
"length": 12
},
"isWriteAccess": false,
"isDefinition": true
},
{
"textSpan": {
"start": 57,
"length": 3
},
"fileName": "/tests/cases/fourslash/b.ts",
"isWriteAccess": false,
"isDefinition": false
}
]
}
]

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,290 @@
// === /tests/cases/fourslash/jsDocServices.ts ===
// interface I {}
//
// /**
// * @param /*FIND ALL REFS*/[|foo|] I pity the foo
// */
// function f([|foo|]: I) {
// return [|foo|];
// }
[
{
"definition": {
"containerKind": "",
"containerName": "",
"fileName": "/tests/cases/fourslash/jsDocServices.ts",
"kind": "parameter",
"name": "(parameter) foo: I",
"textSpan": {
"start": 64,
"length": 3
},
"displayParts": [
{
"text": "(",
"kind": "punctuation"
},
{
"text": "parameter",
"kind": "text"
},
{
"text": ")",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "foo",
"kind": "parameterName"
},
{
"text": ":",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "I",
"kind": "interfaceName"
}
],
"contextSpan": {
"start": 64,
"length": 6
}
},
"references": [
{
"textSpan": {
"start": 30,
"length": 3
},
"fileName": "/tests/cases/fourslash/jsDocServices.ts",
"isWriteAccess": false,
"isDefinition": false
},
{
"textSpan": {
"start": 64,
"length": 3
},
"fileName": "/tests/cases/fourslash/jsDocServices.ts",
"contextSpan": {
"start": 64,
"length": 6
},
"isWriteAccess": true,
"isDefinition": true
},
{
"textSpan": {
"start": 85,
"length": 3
},
"fileName": "/tests/cases/fourslash/jsDocServices.ts",
"isWriteAccess": false,
"isDefinition": false
}
]
}
]
// === /tests/cases/fourslash/jsDocServices.ts ===
// interface I {}
//
// /**
// * @param [|foo|] I pity the foo
// */
// function f(/*FIND ALL REFS*/[|foo|]: I) {
// return [|foo|];
// }
[
{
"definition": {
"containerKind": "",
"containerName": "",
"fileName": "/tests/cases/fourslash/jsDocServices.ts",
"kind": "parameter",
"name": "(parameter) foo: I",
"textSpan": {
"start": 64,
"length": 3
},
"displayParts": [
{
"text": "(",
"kind": "punctuation"
},
{
"text": "parameter",
"kind": "text"
},
{
"text": ")",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "foo",
"kind": "parameterName"
},
{
"text": ":",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "I",
"kind": "interfaceName"
}
],
"contextSpan": {
"start": 64,
"length": 6
}
},
"references": [
{
"textSpan": {
"start": 30,
"length": 3
},
"fileName": "/tests/cases/fourslash/jsDocServices.ts",
"isWriteAccess": false,
"isDefinition": false
},
{
"textSpan": {
"start": 64,
"length": 3
},
"fileName": "/tests/cases/fourslash/jsDocServices.ts",
"contextSpan": {
"start": 64,
"length": 6
},
"isWriteAccess": true,
"isDefinition": true
},
{
"textSpan": {
"start": 85,
"length": 3
},
"fileName": "/tests/cases/fourslash/jsDocServices.ts",
"isWriteAccess": false,
"isDefinition": false
}
]
}
]
// === /tests/cases/fourslash/jsDocServices.ts ===
// interface I {}
//
// /**
// * @param [|foo|] I pity the foo
// */
// function f([|foo|]: I) {
// return /*FIND ALL REFS*/[|foo|];
// }
[
{
"definition": {
"containerKind": "",
"containerName": "",
"fileName": "/tests/cases/fourslash/jsDocServices.ts",
"kind": "parameter",
"name": "(parameter) foo: I",
"textSpan": {
"start": 64,
"length": 3
},
"displayParts": [
{
"text": "(",
"kind": "punctuation"
},
{
"text": "parameter",
"kind": "text"
},
{
"text": ")",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "foo",
"kind": "parameterName"
},
{
"text": ":",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "I",
"kind": "interfaceName"
}
],
"contextSpan": {
"start": 64,
"length": 6
}
},
"references": [
{
"textSpan": {
"start": 30,
"length": 3
},
"fileName": "/tests/cases/fourslash/jsDocServices.ts",
"isWriteAccess": false,
"isDefinition": false
},
{
"textSpan": {
"start": 64,
"length": 3
},
"fileName": "/tests/cases/fourslash/jsDocServices.ts",
"contextSpan": {
"start": 64,
"length": 6
},
"isWriteAccess": true,
"isDefinition": true
},
{
"textSpan": {
"start": 85,
"length": 3
},
"fileName": "/tests/cases/fourslash/jsDocServices.ts",
"isWriteAccess": false,
"isDefinition": false
}
]
}
]

View File

@ -0,0 +1,241 @@
// === /tests/cases/fourslash/a.js ===
// /**
// * Doc comment
// * @typedef [|Product|]
// * @property {string} title
// */
// /**
// * @type {/*FIND ALL REFS*/[|Product|]}
// */
// const product = null;
[
{
"definition": {
"containerKind": "",
"containerName": "",
"fileName": "/tests/cases/fourslash/a.js",
"kind": "type",
"name": "type Product = {\n title: string;\n}",
"textSpan": {
"start": 31,
"length": 7
},
"displayParts": [
{
"text": "type",
"kind": "keyword"
},
{
"text": " ",
"kind": "space"
},
{
"text": "Product",
"kind": "aliasName"
},
{
"text": " ",
"kind": "space"
},
{
"text": "=",
"kind": "operator"
},
{
"text": " ",
"kind": "space"
},
{
"text": "{",
"kind": "punctuation"
},
{
"text": "\n",
"kind": "lineBreak"
},
{
"text": " ",
"kind": "space"
},
{
"text": "title",
"kind": "propertyName"
},
{
"text": ":",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "string",
"kind": "keyword"
},
{
"text": ";",
"kind": "punctuation"
},
{
"text": "\n",
"kind": "lineBreak"
},
{
"text": "}",
"kind": "punctuation"
}
],
"contextSpan": {
"start": 22,
"length": 46
}
},
"references": [
{
"textSpan": {
"start": 31,
"length": 7
},
"fileName": "/tests/cases/fourslash/a.js",
"contextSpan": {
"start": 22,
"length": 46
},
"isWriteAccess": true,
"isDefinition": true
},
{
"textSpan": {
"start": 85,
"length": 7
},
"fileName": "/tests/cases/fourslash/a.js",
"isWriteAccess": false,
"isDefinition": false
}
]
}
]
// === /tests/cases/fourslash/a.js ===
// /**
// * Doc comment
// * @typedef /*FIND ALL REFS*/[|Product|]
// * @property {string} title
// */
// /**
// * @type {[|Product|]}
// */
// const product = null;
[
{
"definition": {
"containerKind": "",
"containerName": "",
"fileName": "/tests/cases/fourslash/a.js",
"kind": "type",
"name": "type Product = {\n title: string;\n}",
"textSpan": {
"start": 31,
"length": 7
},
"displayParts": [
{
"text": "type",
"kind": "keyword"
},
{
"text": " ",
"kind": "space"
},
{
"text": "Product",
"kind": "aliasName"
},
{
"text": " ",
"kind": "space"
},
{
"text": "=",
"kind": "operator"
},
{
"text": " ",
"kind": "space"
},
{
"text": "{",
"kind": "punctuation"
},
{
"text": "\n",
"kind": "lineBreak"
},
{
"text": " ",
"kind": "space"
},
{
"text": "title",
"kind": "propertyName"
},
{
"text": ":",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "string",
"kind": "keyword"
},
{
"text": ";",
"kind": "punctuation"
},
{
"text": "\n",
"kind": "lineBreak"
},
{
"text": "}",
"kind": "punctuation"
}
],
"contextSpan": {
"start": 22,
"length": 46
}
},
"references": [
{
"textSpan": {
"start": 31,
"length": 7
},
"fileName": "/tests/cases/fourslash/a.js",
"contextSpan": {
"start": 22,
"length": 46
},
"isWriteAccess": true,
"isDefinition": true
},
{
"textSpan": {
"start": 85,
"length": 7
},
"fileName": "/tests/cases/fourslash/a.js",
"isWriteAccess": false,
"isDefinition": false
}
]
}
]

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -7,9 +7,9 @@
////
//// }
////
//// [|public /**/[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}start|](){
//// public /*1*/start(){
//// return this;
//// }|]
//// }
////
//// public stop(){
//// return this;
@ -20,9 +20,11 @@
////import Second = require("./findAllRefsOnDefinition-import");
////
////var second = new Second.Test()
////second.[|start|]();
////second./*2*/start();
////second.stop();
let count = 1;
checkRefs();
cancellation.setCancelled();
@ -33,5 +35,5 @@ cancellation.resetCancelled();
checkRefs();
function checkRefs() {
verify.singleReferenceGroup("(method) Test.start(): this", "start");
verify.baselineFindAllReferencesMulti(count++, '1');
}

View File

@ -3,28 +3,28 @@
/// <reference path='fourslash.ts'/>
// @Filename: a.ts
////const x: [|any|] = 0;
////const x: /*1*/[|any|] = 0;
////const any = 2;
////const y: [|any|] = any;
////const y: /*2*/[|any|] = any;
////function f(b: [|boolean|]): [|boolean|];
////function f(b: /*3*/[|boolean|]): /*4*/[|boolean|];
////type T = [|never|]; type U = [|never|];
////type T = /*5*/[|never|]; type U = /*6*/[|never|];
////function n(x: [|number|]): [|number|];
////function n(x: /*7*/[|number|]): /*8*/[|number|];
////function o(x: [|object|]): [|object|];
////function o(x: /*9*/[|object|]): /*10*/[|object|];
////function s(x: [|string|]): [|string|];
////function s(x: /*11*/[|string|]): /*12*/[|string|];
////function sy(s: [|symbol|]): [|symbol|];
////function sy(s: /*13*/[|symbol|]): /*14*/[|symbol|];
////function v(v: [|void|]): [|void|];
////function v(v: /*15*/[|void|]): /*16*/[|void|];
// @Filename: b.ts
// const z: [|any|] = 0;
//// const z: /*17*/[|any|] = 0;
test.rangesByText().forEach((ranges, text) => verify.singleReferenceGroup(text, ranges));
verify.baselineFindAllReferences('1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17');
verify.rangesWithSameTextAreDocumentHighlights();
goTo.rangeStart(test.ranges()[0]);

View File

@ -2,19 +2,19 @@
// @Filename: a.ts
////interface A {
//// [|[|{| "isDefinition": true, "contextRangeIndex": 0 |}foo|]: string;|]
//// /*1*/foo: string;
////}
// @Filename: b.ts
///////<reference path='a.ts'/>
/////**/
////function foo(x: A) {
//// x.[|foo|]
//// x./*2*/foo
////}
verify.singleReferenceGroup("(property) A.foo: string", "foo");
verify.baselineFindAllReferencesMulti(1, '1', '2');
goTo.marker("");
edit.insert("\n");
verify.singleReferenceGroup("(property) A.foo: string", "foo");
verify.baselineFindAllReferencesMulti(2, '1', '2');

View File

@ -6,27 +6,30 @@
////namespace JSX {
//// export interface Element { }
//// export interface IntrinsicElements {
//// [|[|{| "isDefinition": true, "contextRangeIndex": 0 |}div|]: any;|]
//// [|[|/*1*/div|]: any;|]
//// }
////}
////
////[|const [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 2 |}Comp|] = () =>
//// [|<[|{| "contextRangeIndex": 4 |}div|]>
////[|const [|/*6*/Comp|] = () =>
//// [|<[|/*2*/div|]>
//// Some content
//// [|<[|{| "contextRangeIndex": 6 |}div|]>More content</[|{| "contextRangeIndex": 6 |}div|]>|]
//// </[|{| "contextRangeIndex": 4 |}div|]>|];|]
//// [|<[|/*3*/div|]>More content</[|/*4*/div|]>|]
//// </[|/*5*/div|]>|];|]
////
////const x = [|<[|{| "contextRangeIndex": 10 |}Comp|]>
////const x = [|<[|/*7*/Comp|]>
//// Content
////</[|{| "contextRangeIndex": 10 |}Comp|]>|];
////</[|/*8*/Comp|]>|];
const [d0Def, d0, c0Def, c0, d1Def, d1, d2Def, d2, d3, d4, c1Def, c1, c2] = test.ranges();
const allD = [d0, d1, d2, d3, d4];
const allC = [c0, c1, c2];
verify.singleReferenceGroup("(property) JSX.IntrinsicElements.div: any", allD);
verify.singleReferenceGroup("const Comp: () => JSX.Element", allC);
verify.baselineFindAllReferences(
// div occurrences
'1', '2', '3', '4', '5',
// Comp occurrences
'6', '7', '8');
// For document highlights, we will just do tag matching if on a tag. Otherwise we find-all-references.
verify.documentHighlightsOf(d0, [d0, d1, d2, d3, d4]);

View File

@ -322,6 +322,7 @@ declare namespace FourSlashInterface {
verifyGetEmitOutputForCurrentFile(expected: string): void;
verifyGetEmitOutputContentsForCurrentFile(expected: ts.OutputFile[]): void;
baselineFindAllReferences(...markerNames: string[]): void;
baselineFindAllReferencesMulti(seq: number, ...markerNames: string[]): void;
baselineGetFileReferences(fileName: string): void;
symbolAtLocation(startRange: Range, ...declarationRanges: Range[]): void;
typeOfSymbolAtLocation(range: Range, symbol: any, expected: string): void;

View File

@ -7,8 +7,8 @@
/////**
//// * @param /*use*/[|foo|] I pity the foo
//// */
////function f([|[|/*def*/{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 1 |}foo|]: I|]) {
//// return [|foo|];
////function f([|[|/*def*/{| "contextRangeIndex": 1 |}foo|]: I|]) {
//// return /*use2*/[|foo|];
////}
const [r0, r1Def, r1, r2] = test.ranges();
@ -20,6 +20,6 @@ verify.goToType("use", "I");
goTo.marker("use");
verify.quickInfoIs("(parameter) foo: I", "I pity the foo");
verify.singleReferenceGroup("(parameter) foo: I", ranges);
verify.baselineFindAllReferences("use", "def", "use2");
verify.rangesAreDocumentHighlights(ranges);
verify.rangesAreRenameLocations(ranges);

View File

@ -5,7 +5,7 @@
/////**
//// * Doc comment
//// * [|@typedef /*def*/[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}Product|]
//// * [|@typedef /*def*/[|{| "contextRangeIndex": 0 |}Product|]
//// * @property {string} title
//// |]*/
@ -25,5 +25,5 @@ verify.goToDefinition("use", "def");
verify.rangesAreOccurrences(/*isWriteAccesss*/ undefined, ranges);
verify.rangesAreDocumentHighlights(ranges);
verify.singleReferenceGroup(desc, ranges);
verify.baselineFindAllReferences("use", "def");
verify.rangesAreRenameLocations(ranges);

View File

@ -1,66 +1,66 @@
/// <reference path='fourslash.ts'/>
// @Filename: localGetReferences_1.ts
////// Comment Refence Test: g/*1*/lobalVar
////// Comment Refence Test: g/*43*/lobalVar
////// References to a variable declared in global.
////[|var [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}globalVar|]: number = 2;|]
/////*1*/var /*2*/globalVar: number = 2;
////
////class fooCls {
//// // References to static variable declared in a class.
//// [|static [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 2 |}clsSVar|] = 1;|]
//// /*3*/static /*4*/clsSVar = 1;
//// // References to a variable declared in a class.
//// [|[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 4 |}clsVar|] = 1;|]
//// /*5*/clsVar = 1;
////
//// constructor ([|public [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 6 |}clsParam|]: number|]) {
//// constructor (/*6*/public /*7*/clsParam: number) {
//// //Increments
//// [|{| "isWriteAccess": true |}globalVar|]++;
//// this.[|{| "isWriteAccess": true |}clsVar|]++;
//// fooCls.[|{| "isWriteAccess": true |}clsSVar|]++;
//// /*8*/globalVar++;
//// this./*9*/clsVar++;
//// fooCls./*10*/clsSVar++;
//// // References to a class parameter.
//// this.[|{| "isWriteAccess": true |}clsParam|]++;
//// this./*11*/clsParam++;
//// modTest.modVar++;
//// }
////}
////
////// References to a function parameter.
////[|function [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 12 |}foo|]([|[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 14 |}x|]: number|]) {
/////*12*/function /*13*/foo(/*14*/x: number) {
//// // References to a variable declared in a function.
//// [|var [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 16 |}fnVar|] = 1;|]
//// /*15*/var /*16*/fnVar = 1;
////
//// //Increments
//// fooCls.[|{| "isWriteAccess": true |}clsSVar|]++;
//// [|{| "isWriteAccess": true |}globalVar|]++;
//// fooCls./*17*/clsSVar++;
//// /*18*/globalVar++;
//// modTest.modVar++;
//// [|{| "isWriteAccess": true |}fnVar|]++;
//// /*19*/fnVar++;
////
//// //Return
//// return [|{| "isWriteAccess": true |}x|]++;
////}|]
//// return /*20*/x++;
////}
////
////module modTest {
//// //Declare
//// export var modVar:number;
////
//// //Increments
//// [|{| "isWriteAccess": true |}globalVar|]++;
//// fooCls.[|{| "isWriteAccess": true |}clsSVar|]++;
//// /*21*/globalVar++;
//// fooCls./*22*/clsSVar++;
//// modVar++;
////
//// class testCls {
//// static boo = [|foo|];
//// static boo = /*23*/foo;
//// }
////
//// function testFn(){
//// static boo = [|foo|];
//// static boo = /*24*/foo;
////
//// //Increments
//// [|{| "isWriteAccess": true |}globalVar|]++;
//// fooCls.[|{| "isWriteAccess": true |}clsSVar|]++;
//// /*25*/globalVar++;
//// fooCls./*26*/clsSVar++;
//// modVar++;
//// }
////
//// module testMod {
//// var boo = [|foo|];
//// var boo = /*27*/foo;
//// }
////}
////
@ -69,26 +69,26 @@
////
//////Arguments
////// References to a class argument.
////clsTest = new fooCls([|globalVar|]);
////clsTest = new fooCls(/*28*/globalVar);
////// References to a function argument.
////[|foo|]([|globalVar|]);
/////*29*/foo(/*30*/globalVar);
////
//////Increments
////fooCls.[|{| "isWriteAccess": true |}clsSVar|]++;
////fooCls./*31*/clsSVar++;
////modTest.modVar++;
////[|{| "isWriteAccess": true |}globalVar|] = [|globalVar|] + [|globalVar|];
/////*32*/globalVar = /*33*/globalVar + /*34*/globalVar;
////
//////ETC - Other cases
////[|{| "isWriteAccess": true |}globalVar|] = 3;
/////*35*/globalVar = 3;
////// References to illegal assignment.
////[|{| "isWriteAccess": true |}foo|] = [|foo|] + 1;
/////*3*/err = err++;
/////*4*/
/////*36*/foo = /*37*/foo + 1;
/////*44*/err = err++;
/////*45*/
//////Shadowed fn Parameter
////function shdw([|[|{| "isWriteAccess": true, "isDefinition": true, "shadow": true, "contextRangeIndex": 39 |}globalVar|]: number|]) {
////function shdw(/*38*/globalVar: number) {
//// //Increments
//// [|{| "isWriteAccess": true, "shadow": true |}globalVar|]++;
//// return [|{| "shadow": true |}globalVar|];
//// /*39*/globalVar++;
//// return /*40*/globalVar;
////}
////
//////Remotes
@ -117,12 +117,12 @@
////array.forEach(
////
////
////function([|{| "isWriteAccess": true, "isDefinition": true |}str|]) {
////function(/*41*/str) {
////
////
////
//// // Reference misses function parameter.
//// return [|str|] + " ";
//// return /*42*/str + " ";
////
////});
@ -185,55 +185,9 @@
//// }
////}
// References to comment / unresolved symbol / no context
verify.baselineFindAllReferences('1', '3', '4')
test.rangesByText().forEach((ranges, text) => {
switch (text) {
case "var globalVar: number = 2;":
case "static clsSVar = 1;":
case "clsVar = 1;":
case "public clsParam: number":
case `function foo(x: number) {
// References to a variable declared in a function.
var fnVar = 1;
//Increments
fooCls.clsSVar++;
globalVar++;
modTest.modVar++;
fnVar++;
//Return
return x++;
}`:
case "x: number":
case "var fnVar = 1;":
case "globalVar: number":
return;
}
if (text === "globalVar") {
verify.singleReferenceGroup("(parameter) globalVar: number", ranges.filter(isShadow));
verify.singleReferenceGroup("var globalVar: number", ranges.filter(r => !isShadow(r)));
return;
}
const definition = (() => {
switch (text) {
case "fnVar": return "(local var) fnVar: number";
case "clsSVar": return "(property) fooCls.clsSVar: number";
case "clsVar": return "(property) fooCls.clsVar: number";
case "clsParam": return "(property) fooCls.clsParam: number";
case "foo": return "function foo(x: number): number";
case "x": return "(parameter) x: number";
case "str": return "(parameter) str: string";
default: throw new Error(text);
}
})();
verify.singleReferenceGroup(definition, ranges);
});
function isShadow(r) {
return r.marker && r.marker.data && r.marker.data.shadow;
}
verify.baselineFindAllReferences(
'1', '2', '3', '4', '5', '6', '7', '8', '9', '10',
'11', '12', '13', '14', '15', '16', '17', '18', '19', '20',
'21', '22', '23', '24', '25', '26', '27', '28', '29', '30',
'31', '32', '33', '34', '35', '36', '37', '38', '39', '40',
'41', '42', '43', '44', '45');

View File

@ -86,19 +86,19 @@
////
//////Remotes
//////Type test
////var remoteclsTest: [|remotefooCls|];
////var remoteclsTest: /*1*/remotefooCls;
////
//////Arguments
////remoteclsTest = new [|remotefooCls|]([|remoteglobalVar|]);
////remotefoo([|remoteglobalVar|]);
////remoteclsTest = new /*2*/remotefooCls(/*3*/remoteglobalVar);
////remotefoo(/*4*/remoteglobalVar);
////
//////Increments
////[|remotefooCls|].[|{| "isWriteAccess": true |}remoteclsSVar|]++;
/////*5*/remotefooCls./*6*/remoteclsSVar++;
////remotemodTest.remotemodVar++;
////[|{| "isWriteAccess": true |}remoteglobalVar|] = [|remoteglobalVar|] + [|remoteglobalVar|];
/////*7*/remoteglobalVar = /*8*/remoteglobalVar + /*9*/remoteglobalVar;
////
//////ETC - Other cases
////[|{| "isWriteAccess": true |}remoteglobalVar|] = 3;
/////*10*/remoteglobalVar = 3;
////
//////Find References misses method param
////var
@ -119,30 +119,30 @@
////});
// @Filename: remoteGetReferences_2.ts
////[|var [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 10 |}remoteglobalVar|]: number = 2;|]
/////*11*/var /*12*/remoteglobalVar: number = 2;
////
////[|class [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 12 |}remotefooCls|] {
/////*13*/class /*14*/remotefooCls {
//// //Declare
//// [|[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 14 |}remoteclsVar|] = 1;|]
//// [|static [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 16 |}remoteclsSVar|] = 1;|]
//// /*15*/remoteclsVar = 1;
//// /*16*/static /*17*/remoteclsSVar = 1;
////
//// constructor(public remoteclsParam: number) {
//// //Increments
//// [|{| "isWriteAccess": true |}remoteglobalVar|]++;
//// this.[|{| "isWriteAccess": true |}remoteclsVar|]++;
//// [|remotefooCls|].[|{| "isWriteAccess": true |}remoteclsSVar|]++;
//// /*18*/remoteglobalVar++;
//// this./*19*/remoteclsVar++;
//// /*20*/remotefooCls./*21*/remoteclsSVar++;
//// this.remoteclsParam++;
//// remotemodTest.remotemodVar++;
//// }
////}|]
////}
////
////function remotefoo(remotex: number) {
//// //Declare
//// var remotefnVar = 1;
////
//// //Increments
//// [|remotefooCls|].[|{| "isWriteAccess": true |}remoteclsSVar|]++;
//// [|{| "isWriteAccess": true |}remoteglobalVar|]++;
//// /*22*/remotefooCls./*23*/remoteclsSVar++;
//// /*24*/remoteglobalVar++;
//// remotemodTest.remotemodVar++;
//// remotefnVar++;
////
@ -155,8 +155,8 @@
//// export var remotemodVar: number;
////
//// //Increments
//// [|{| "isWriteAccess": true |}remoteglobalVar|]++;
//// [|remotefooCls|].[|{| "isWriteAccess": true |}remoteclsSVar|]++;
//// /*25*/remoteglobalVar++;
//// /*26*/remotefooCls./*27*/remoteclsSVar++;
//// remotemodVar++;
////
//// class remotetestCls {
@ -167,8 +167,8 @@
//// static remoteboo = remotefoo;
////
//// //Increments
//// [|{| "isWriteAccess": true |}remoteglobalVar|]++;
//// [|remotefooCls|].[|{| "isWriteAccess": true |}remoteclsSVar|]++;
//// /*28*/remoteglobalVar++;
//// /*29*/remotefooCls./*30*/remoteclsSVar++;
//// remotemodVar++;
//// }
////
@ -177,36 +177,7 @@
//// }
////}
test.rangesByText().forEach((ranges, text) => {
// Definitions
if (text === "var remoteglobalVar: number = 2;" ||
text === `class remotefooCls {
//Declare
remoteclsVar = 1;
static remoteclsSVar = 1;
constructor(public remoteclsParam: number) {
//Increments
remoteglobalVar++;
this.remoteclsVar++;
remotefooCls.remoteclsSVar++;
this.remoteclsParam++;
remotemodTest.remotemodVar++;
}
}` ||
text == "remoteclsVar = 1;" ||
text === "static remoteclsSVar = 1;"
) return;
const definition = (() => {
switch (text) {
case "remotefooCls": return "class remotefooCls";
case "remoteglobalVar": return "var remoteglobalVar: number";
case "remoteclsSVar": return "(property) remotefooCls.remoteclsSVar: number";
case "remoteclsVar": return "(property) remotefooCls.remoteclsVar: number";
default: throw new Error(text);
}
})();
verify.singleReferenceGroup(definition, ranges);
});
verify.baselineFindAllReferences(
'1', '2', '3', '4', '5', '6', '7', '8', '9', '10',
'11', '12', '13', '14', '15', '16', '17', '18', '19', '20',
'21', '22', '23', '24', '25', '26', '27', '28', '29', '30');