diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 721647df0c..3deddf1f2c 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -452,7 +452,8 @@ namespace FourSlash { } private messageAtLastKnownMarker(message: string) { - return "Marker: " + this.lastKnownMarker + "\n" + message; + const locationDescription = this.lastKnownMarker ? this.lastKnownMarker : this.getLineColStringAtPosition(this.currentCaretPosition); + return `At ${locationDescription}: ${message}`; } private assertionMessageAtLastKnownMarker(msg: string) { @@ -562,7 +563,7 @@ namespace FourSlash { } public verifyGoToDefinitionIs(endMarker: string | string[]) { - this.verifyGoToXWorker(endMarker instanceof Array ? endMarker : [endMarker], () => this.getGoToDefinition()); + this.verifyGoToXWorker(toArray(endMarker), () => this.getGoToDefinition()); } public verifyGoToDefinition(arg0: any, endMarkerNames?: string | string[]) { @@ -582,7 +583,7 @@ namespace FourSlash { if (endMarkerNames) { this.verifyGoToXPlain(arg0, endMarkerNames, getDefs); } - else if (arg0 instanceof Array) { + else if (ts.isArray(arg0)) { const pairs: [string | string[], string | string[]][] = arg0; for (const [start, end] of pairs) { this.verifyGoToXPlain(start, end, getDefs); @@ -599,13 +600,8 @@ namespace FourSlash { } private verifyGoToXPlain(startMarkerNames: string | string[], endMarkerNames: string | string[], getDefs: () => ts.DefinitionInfo[] | undefined) { - if (startMarkerNames instanceof Array) { - for (const start of startMarkerNames) { - this.verifyGoToXSingle(start, endMarkerNames, getDefs); - } - } - else { - this.verifyGoToXSingle(startMarkerNames, endMarkerNames, getDefs); + for (const start of toArray(startMarkerNames)) { + this.verifyGoToXSingle(start, endMarkerNames, getDefs); } } @@ -617,7 +613,7 @@ namespace FourSlash { private verifyGoToXSingle(startMarkerName: string, endMarkerNames: string | string[], getDefs: () => ts.DefinitionInfo[] | undefined) { this.goToMarker(startMarkerName); - this.verifyGoToXWorker(endMarkerNames instanceof Array ? endMarkerNames : [endMarkerNames], getDefs); + this.verifyGoToXWorker(toArray(endMarkerNames), getDefs); } private verifyGoToXWorker(endMarkers: string[], getDefs: () => ts.DefinitionInfo[] | undefined) { @@ -899,8 +895,74 @@ namespace FourSlash { } } - public verifyRangesWithSameTextReferenceEachOther() { - this.rangesByText().forEach(ranges => this.verifyRangesReferenceEachOther(ranges)); + public verifyReferenceGroups(startRanges: Range | Range[], parts: Array<{ definition: string, ranges: Range[] }>): void { + interface ReferenceJson { definition: string; ranges: ts.ReferenceEntry[]; } + type ReferencesJson = ReferenceJson[]; + const fullExpected = parts.map(({ definition, ranges }) => ({ definition, ranges: ranges.map(rangeToReferenceEntry) })); + + for (const startRange of toArray(startRanges)) { + this.goToRangeStart(startRange); + const fullActual = this.findReferencesAtCaret().map(({ definition, references }) => ({ + definition: definition.displayParts.map(d => d.text).join(""), + ranges: references + })); + this.assertObjectsEqual(fullActual, fullExpected); + } + + function rangeToReferenceEntry(r: Range) { + let { isWriteAccess, isDefinition } = (r.marker && r.marker.data) || { isWriteAccess: false, isDefinition: false }; + isWriteAccess = isWriteAccess || false; isDefinition = isDefinition || false; + return { fileName: r.fileName, textSpan: { start: r.start, length: r.end - r.start }, isWriteAccess, isDefinition } + } + } + + public verifyNoReferences(markerNameOrRange?: string | Range) { + if (markerNameOrRange) { + if (typeof markerNameOrRange === "string") { + this.goToMarker(markerNameOrRange); + } + else { + this.goToRangeStart(markerNameOrRange); + } + } + + const refs = this.getReferencesAtCaret(); + if (refs && refs.length) { + console.log(refs); + this.raiseError("Expected getReferences to fail"); + } + } + + public verifySingleReferenceGroup(definition: string, ranges?: Range[]) { + ranges = ranges || this.getRanges(); + this.verifyReferenceGroups(ranges, [{ definition, ranges }]); + } + + private assertObjectsEqual(fullActual: T, fullExpected: T, msgPrefix = ""): void { + const recur = (actual: U, expected: U, path: string) => { + const fail = (msg: string) => { + console.log("Expected:", stringify(fullExpected)); + console.log("Actual: ", stringify(fullActual)); + this.raiseError(`${msgPrefix}At ${path}: ${msg}`); + }; + + for (const key in actual) if (ts.hasProperty(actual as any, key)) { + const ak = actual[key], ek = expected[key]; + if (typeof ak === "object" && typeof ek === "object") { + recur(ak, ek, path ? path + "." + key : key); + } + else if (ak !== ek) { + fail(`Expected '${key}' to be '${ek}', got '${ak}'`); + } + } + for (const key in expected) if (ts.hasProperty(expected as any, key)) { + if (!ts.hasProperty(actual as any, key)) { + fail(`${msgPrefix}Missing property '${key}'`); + } + } + }; + recur(fullActual, fullExpected, ""); + } public verifyDisplayPartsOfReferencedSymbol(expected: ts.SymbolDisplayPart[]) { @@ -974,7 +1036,7 @@ namespace FourSlash { public verifyQuickInfos(namesAndTexts: { [name: string]: string | [string, string] }) { for (const name in namesAndTexts) if (ts.hasProperty(namesAndTexts, name)) { const text = namesAndTexts[name]; - if (text instanceof Array) { + if (ts.isArray(text)) { assert(text.length === 2); const [expectedText, expectedDocumentation] = text; this.verifyQuickInfoAt(name, expectedText, expectedDocumentation); @@ -1411,13 +1473,6 @@ namespace FourSlash { Harness.IO.log(membersString); } - public printReferences() { - const references = this.getReferencesAtCaret(); - ts.forEach(references, entry => { - Harness.IO.log(stringify(entry)); - }); - } - public printContext() { ts.forEach(this.languageServiceAdapterHost.getFilenames(), Harness.IO.log); } @@ -3082,6 +3137,10 @@ ${code} } return ts.arrayFrom(set.keys()); } + + function toArray(x: T | T[]): T[] { + return ts.isArray(x) ? x : [x]; + } } namespace FourSlashInterface { @@ -3346,6 +3405,18 @@ namespace FourSlashInterface { this.state.verifyReferencesOf(start, references); } + public referenceGroups(startRanges: FourSlash.Range[], parts: Array<{ definition: string, ranges: FourSlash.Range[] }>) { + this.state.verifyReferenceGroups(startRanges, parts); + } + + public noReferences(markerNameOrRange?: string | FourSlash.Range) { + this.state.verifyNoReferences(markerNameOrRange); + } + + public singleReferenceGroup(definition: string, ranges?: FourSlash.Range[]) { + this.state.verifySingleReferenceGroup(definition, ranges); + } + public rangesReferenceEachOther(ranges?: FourSlash.Range[]) { this.state.verifyRangesReferenceEachOther(ranges); } @@ -3354,10 +3425,6 @@ namespace FourSlashInterface { this.state.verifyDisplayPartsOfReferencedSymbol(expected); } - public rangesWithSameTextReferenceEachOther() { - this.state.verifyRangesWithSameTextReferenceEachOther(); - } - public currentParameterHelpArgumentNameIs(name: string) { this.state.verifyCurrentParameterHelpName(name); } @@ -3660,10 +3727,6 @@ namespace FourSlashInterface { this.state.printNavigationBar(); } - public printReferences() { - this.state.printReferences(); - } - public printContext() { this.state.printContext(); } diff --git a/src/services/findAllReferences.ts b/src/services/findAllReferences.ts index 28474839cf..cd1477c444 100644 --- a/src/services/findAllReferences.ts +++ b/src/services/findAllReferences.ts @@ -5,6 +5,10 @@ namespace ts.FindAllReferences { return getReferencedSymbolsForNode(typeChecker, cancellationToken, node, sourceFiles, findInStrings, findInComments, isForRename); } + export function convertReferences(referenceSymbols: ReferencedSymbol[]): ReferenceEntry[] { + return referenceSymbols && flatMap(referenceSymbols, r => r.references); + } + export function getReferencedSymbolsForNode(typeChecker: TypeChecker, cancellationToken: CancellationToken, node: Node, sourceFiles: SourceFile[], findInStrings?: boolean, findInComments?: boolean, isForRename?: boolean, implementations?: boolean): ReferencedSymbol[] | undefined { if (!implementations) { const special = getReferencedSymbolsSpecial(node, sourceFiles, typeChecker, cancellationToken); @@ -411,7 +415,6 @@ namespace ts.FindAllReferences { textSpan: createTextSpan(0, 1), displayParts: [{ text: name, kind: ScriptElementKind.keyword }] } - const references: ReferenceEntry[] = []; for (const sourceFile of sourceFiles) { cancellationToken.throwIfCancellationRequested(); @@ -1316,20 +1319,6 @@ namespace ts.FindAllReferences { return meaning; } - export function convertReferences(referenceSymbols: ReferencedSymbol[]): ReferenceEntry[] { - if (!referenceSymbols) { - return undefined; - } - - const referenceEntries: ReferenceEntry[] = []; - - for (const referenceSymbol of referenceSymbols) { - addRange(referenceEntries, referenceSymbol.references); - } - - return referenceEntries; - } - function isImplementation(node: Node): boolean { if (!node) { return false; diff --git a/src/services/services.ts b/src/services/services.ts index b3e3093cdd..b83995e31e 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -1415,7 +1415,6 @@ namespace ts { function findReferences(fileName: string, position: number): ReferencedSymbol[] { const referencedSymbols = findReferencedSymbols(fileName, position, /*findInStrings*/ false, /*findInComments*/ false, /*isForRename*/false); - // Only include referenced symbols that have a valid definition. return filter(referencedSymbols, rs => !!rs.definition); } @@ -2015,9 +2014,5 @@ namespace ts { throw new Error("getDefaultLibFilePath is only supported when consumed as a node module. "); } - function initializeServices() { - objectAllocator = getServicesObjectAllocator(); - } - - initializeServices(); + objectAllocator = getServicesObjectAllocator(); } diff --git a/tests/cases/fourslash/ambientShorthandFindAllRefs.ts b/tests/cases/fourslash/ambientShorthandFindAllRefs.ts index 2f0dbf914e..06bc6e9478 100644 --- a/tests/cases/fourslash/ambientShorthandFindAllRefs.ts +++ b/tests/cases/fourslash/ambientShorthandFindAllRefs.ts @@ -4,9 +4,18 @@ ////declare module "jquery"; // @Filename: user.ts -////import {[|x|]} from "jquery"; +////import {[|{| "isWriteAccess": true, "isDefinition": true |}x|]} from "jquery"; // @Filename: user2.ts -////import {[|x|]} from "jquery"; +////import {[|{| "isWriteAccess": true, "isDefinition": true |}x|]} from "jquery"; -verify.rangesReferenceEachOther(); +const ranges = test.ranges(); +const [r0, r1] = ranges; +verify.referenceGroups(r0, [ + { definition: "import x", ranges: [r0] }, + { definition: 'module "jquery"', ranges: [r1] } +]); +verify.referenceGroups(r1, [ + { definition: 'module "jquery"', ranges: [r0] }, + { definition: "import x", ranges: [r1] } +]); diff --git a/tests/cases/fourslash/cancellationWhenfindingAllRefsOnDefinition.ts b/tests/cases/fourslash/cancellationWhenfindingAllRefsOnDefinition.ts index d3d18b2dab..8f80c871eb 100644 --- a/tests/cases/fourslash/cancellationWhenfindingAllRefsOnDefinition.ts +++ b/tests/cases/fourslash/cancellationWhenfindingAllRefsOnDefinition.ts @@ -7,7 +7,7 @@ //// //// } //// -//// public /**/[|start|](){ +//// public /**/[|{| "isWriteAccess": true, "isDefinition": true |}start|](){ //// return this; //// } //// @@ -23,11 +23,21 @@ ////second.[|start|](); ////second.stop(); -verify.rangesReferenceEachOther(); +checkRefs(); cancellation.setCancelled(); -verifyOperationIsCancelled(() => verify.rangesReferenceEachOther()); +verifyOperationIsCancelled(checkRefs); // verify that internal state is still correct cancellation.resetCancelled(); -verify.rangesReferenceEachOther(); +checkRefs(); + +function checkRefs() { + const ranges = test.ranges(); + const [r0, r1] = ranges; + verify.referenceGroups(r0, [{ definition: "(method) Test.start(): this", ranges }]); + verify.referenceGroups(r1, [ + { definition: "(method) Second.Test.start(): Second.Test", ranges: [r0] }, + { definition: "(method) Second.Test.start(): Second.Test", ranges: [r1] } + ]); +} diff --git a/tests/cases/fourslash/findAllReferencesOfConstructor.ts b/tests/cases/fourslash/findAllReferencesOfConstructor.ts index b25508a60d..dcdc23bdc7 100644 --- a/tests/cases/fourslash/findAllReferencesOfConstructor.ts +++ b/tests/cases/fourslash/findAllReferencesOfConstructor.ts @@ -41,6 +41,6 @@ ////class d extends a.C { constructor() { [|super|](); } const ranges = test.ranges(); -for (const ctr of ranges.slice(0, 3)) { - verify.referencesOf(ctr, ranges); -} +const [r0, r1, r2] = ranges; +verify.referenceGroups([r0, r2], [{ definition: "constructor C(n: number): C (+1 overload)", ranges }]); +verify.referenceGroups(r1, [{ definition: "constructor C(): C (+1 overload)", ranges }]); diff --git a/tests/cases/fourslash/findAllReferencesOfConstructor_badOverload.ts b/tests/cases/fourslash/findAllReferencesOfConstructor_badOverload.ts index 77479bad11..bb8b62a146 100644 --- a/tests/cases/fourslash/findAllReferencesOfConstructor_badOverload.ts +++ b/tests/cases/fourslash/findAllReferencesOfConstructor_badOverload.ts @@ -5,4 +5,4 @@ //// [|constructor|](){} ////} -verify.rangesReferenceEachOther(); +verify.singleReferenceGroup("constructor C(n: number): C"); diff --git a/tests/cases/fourslash/findAllRefsForComputedProperties.ts b/tests/cases/fourslash/findAllRefsForComputedProperties.ts index 065d34c6fc..72c49104de 100644 --- a/tests/cases/fourslash/findAllRefsForComputedProperties.ts +++ b/tests/cases/fourslash/findAllRefsForComputedProperties.ts @@ -1,16 +1,26 @@ /// - ////interface I { -//// ["[|prop1|]"]: () => void; +//// ["[|{| "isDefinition": true |}prop1|]"]: () => void; ////} //// ////class C implements I { -//// ["[|prop1|]"]: any; +//// ["[|{| "isDefinition": true |}prop1|]"]: any; ////} //// ////var x: I = { -//// ["[|prop1|]"]: function () { }, +//// ["[|{| "isDefinition": true |}prop1|]"]: function () { }, ////} -verify.rangesReferenceEachOther(); +const ranges = test.ranges(); +const [r0, r1, r2] = ranges; +verify.referenceGroups(r0, [{ definition: '(property) I[["prop1"]]: () => void', ranges }]); +verify.referenceGroups(r1, [ + { definition: '(property) I[["prop1"]]: () => void', ranges: [r0, r2] }, + { definition: '(property) C[["prop1"]]: any', ranges: [r1] } +]); +verify.referenceGroups(r2, [ + { definition: '(property) I[["prop1"]]: () => void', ranges: [r0, r1] }, + { definition: '(property) ["prop1"]: () => void', ranges: [r2] } +]); + diff --git a/tests/cases/fourslash/findAllRefsForComputedProperties2.ts b/tests/cases/fourslash/findAllRefsForComputedProperties2.ts index 37a9bd8470..4a7a17047e 100644 --- a/tests/cases/fourslash/findAllRefsForComputedProperties2.ts +++ b/tests/cases/fourslash/findAllRefsForComputedProperties2.ts @@ -1,15 +1,25 @@ /// ////interface I { -//// [[|42|]](): void; +//// [[|{| "isDefinition": true |}42|]](): void; ////} //// ////class C implements I { -//// [[|42|]]: any; +//// [[|{| "isDefinition": true |}42|]]: any; ////} //// ////var x: I = { -//// ["[|42|]"]: function () { } +//// ["[|{| "isDefinition": true |}42|]"]: function () { } ////} -verify.rangesReferenceEachOther(); +const ranges = test.ranges(); +const [r0, r1, r2] = ranges; +verify.referenceGroups(r0, [{ definition: "(method) I[[42]](): void", ranges }]); +verify.referenceGroups(r1, [ + { definition: "(method) I[[42]](): void", ranges: [r0, r2] }, + { definition: "(property) C[[42]]: any", ranges: [r1] } +]); +verify.referenceGroups(r2, [ + { definition: "(method) I[[42]](): void", ranges: [r0, r1] }, + { definition: '(property) ["42"]: () => void', ranges: [r2] } +]); diff --git a/tests/cases/fourslash/findAllRefsForDefaultExport.ts b/tests/cases/fourslash/findAllRefsForDefaultExport.ts index a27227b907..c518bb8f59 100644 --- a/tests/cases/fourslash/findAllRefsForDefaultExport.ts +++ b/tests/cases/fourslash/findAllRefsForDefaultExport.ts @@ -1,11 +1,11 @@ /// // @Filename: a.ts -////export default function /*def*/[|f|]() {} +////export default function /*def*/[|{| "isWriteAccess": true, "isDefinition": true |}f|]() {} // @Filename: b.ts -////import [|g|] from "./a"; +////import [|{| "isWriteAccess": true, "isDefinition": true |}g|] from "./a"; /////*ref*/[|g|](); -verify.rangesReferenceEachOther(); +verify.singleReferenceGroup("function f(): void"); verify.goToDefinition("ref", "def"); diff --git a/tests/cases/fourslash/findAllRefsForDefaultExport01.ts b/tests/cases/fourslash/findAllRefsForDefaultExport01.ts index 39079294a3..c04550e54f 100644 --- a/tests/cases/fourslash/findAllRefsForDefaultExport01.ts +++ b/tests/cases/fourslash/findAllRefsForDefaultExport01.ts @@ -1,10 +1,13 @@ /// -////export default class [|DefaultExportedClass|] { +////export default class [|{| "isWriteAccess": true, "isDefinition": true |}DefaultExportedClass|] { ////} //// ////var x: [|DefaultExportedClass|]; //// ////var y = new [|DefaultExportedClass|]; -verify.rangesReferenceEachOther(); +const ranges = test.ranges(); +const [r0, r1, r2] = ranges; +verify.referenceGroups([r0, r1], [{ definition: "class DefaultExportedClass", ranges }]); +verify.referenceGroups(r2, [{ definition: "constructor DefaultExportedClass(): DefaultExportedClass", ranges }]); diff --git a/tests/cases/fourslash/findAllRefsForDefaultExport02.ts b/tests/cases/fourslash/findAllRefsForDefaultExport02.ts index 19f31ece9b..558bbd2de8 100644 --- a/tests/cases/fourslash/findAllRefsForDefaultExport02.ts +++ b/tests/cases/fourslash/findAllRefsForDefaultExport02.ts @@ -1,11 +1,22 @@ /// -////export default function [|DefaultExportedFunction|]() { -//// return [|DefaultExportedFunction|] +////export default function [|{| "isWriteAccess": true, "isDefinition": true |}DefaultExportedFunction|]() { +//// return [|DefaultExportedFunction|]; ////} //// ////var x: typeof [|DefaultExportedFunction|]; //// ////var y = [|DefaultExportedFunction|](); +//// +////namespace [|{| "isWriteAccess": true, "isDefinition": true |}DefaultExportedFunction|] { +////} -verify.rangesReferenceEachOther(); + +const ranges = test.ranges(); +const [r0, r1, r2, r3, r4] = ranges; +const fnRanges = [r0, r1, r2, r3]; +verify.singleReferenceGroup("function DefaultExportedFunction(): () => typeof DefaultExportedFunction", fnRanges); + +// The namespace and function do not merge, +// so the namespace should be all alone. +verify.singleReferenceGroup("namespace DefaultExportedFunction", [r4]); diff --git a/tests/cases/fourslash/findAllRefsForDefaultExport03.ts b/tests/cases/fourslash/findAllRefsForDefaultExport03.ts index b9bbfa14a6..d94043f401 100644 --- a/tests/cases/fourslash/findAllRefsForDefaultExport03.ts +++ b/tests/cases/fourslash/findAllRefsForDefaultExport03.ts @@ -1,6 +1,6 @@ /// -////function [|f|]() { +////function [|{| "isWriteAccess": true, "isDefinition": true |}f|]() { //// return 100; ////} //// @@ -10,8 +10,11 @@ //// ////var y = [|f|](); //// -////namespace [|f|] { +////namespace [|{| "isWriteAccess": true, "isDefinition": true |}f|] { //// var local = 100; ////} -verify.rangesReferenceEachOther(); +const ranges = test.ranges(); +const [r0, r1, r2, r3, r4] = ranges; +verify.referenceGroups([r0, r3], [{ definition: "function f(): number\nnamespace f", ranges }]); +verify.referenceGroups([r1, r2, r4], [{ definition: "namespace f\nfunction f(): number", ranges }]); diff --git a/tests/cases/fourslash/findAllRefsForDefaultExport04.ts b/tests/cases/fourslash/findAllRefsForDefaultExport04.ts deleted file mode 100644 index 44b7ee0a06..0000000000 --- a/tests/cases/fourslash/findAllRefsForDefaultExport04.ts +++ /dev/null @@ -1,23 +0,0 @@ -/// - -////function f() { -//// return 100; -////} -//// -////export default [|f|]; -//// -////var x: typeof f; -//// -////var y = f(); -//// -////namespace /**/[|f|] { -////} - -// The function 'f' and the namespace 'f' don't get merged, -// but the 'export default' site, includes both meanings. - -// Here we are testing whether the 'export default' -// site is included in the references to the namespace. - -goTo.marker(); -verify.referencesAre(test.ranges()); diff --git a/tests/cases/fourslash/findAllRefsForDefaultExport05.ts b/tests/cases/fourslash/findAllRefsForDefaultExport05.ts deleted file mode 100644 index 0f06792458..0000000000 --- a/tests/cases/fourslash/findAllRefsForDefaultExport05.ts +++ /dev/null @@ -1,23 +0,0 @@ -/// - -////function /**/[|f|]() { -//// return 100; -////} -//// -////export default [|f|]; -//// -////var x: typeof [|f|]; -//// -////var y = [|f|](); -//// -////namespace f { -////} - -// The function 'f' and the namespace 'f' don't get merged, -// but the 'export default' site, includes both meanings. - -// Here we are testing whether the 'export default' site -// and all value-uses of 'f' are included in the references to the function. - -goTo.marker(); -verify.referencesAre(test.ranges()); diff --git a/tests/cases/fourslash/findAllRefsForDefaultExport06.ts b/tests/cases/fourslash/findAllRefsForDefaultExport06.ts deleted file mode 100644 index cdd9b4f980..0000000000 --- a/tests/cases/fourslash/findAllRefsForDefaultExport06.ts +++ /dev/null @@ -1,23 +0,0 @@ -/// - -////function [|f|]() { -//// return 100; -////} -//// -////export default /**/[|f|]; -//// -////var x: typeof [|f|]; -//// -////var y = [|f|](); -//// -////namespace [|f|] { -////} - -// The function 'f' and the namespace 'f' don't get merged, -// but the 'export default' site, includes both meanings. - -// Here we are testing whether the 'export default' site -// and all value-uses of 'f' are included in the references to the function. - -goTo.marker(); -verify.referencesAre(test.ranges()); diff --git a/tests/cases/fourslash/findAllRefsForDefaultExport07.ts b/tests/cases/fourslash/findAllRefsForDefaultExport07.ts deleted file mode 100644 index 88d0a77502..0000000000 --- a/tests/cases/fourslash/findAllRefsForDefaultExport07.ts +++ /dev/null @@ -1,16 +0,0 @@ -/// - -////export default function DefaultExportedFunction() { -//// return DefaultExportedFunction -////} -//// -////var x: typeof DefaultExportedFunction; -//// -////var y = DefaultExportedFunction(); -//// -////namespace [|DefaultExportedFunction|] { -////} - -// The namespace and function do not merge, -// so the namespace should be all alone. -verify.rangesReferenceEachOther(); diff --git a/tests/cases/fourslash/findAllRefsForDefaultExport08.ts b/tests/cases/fourslash/findAllRefsForDefaultExport08.ts index b7ae7f4d53..b29060f609 100644 --- a/tests/cases/fourslash/findAllRefsForDefaultExport08.ts +++ b/tests/cases/fourslash/findAllRefsForDefaultExport08.ts @@ -7,10 +7,9 @@ //// ////var y = new DefaultExportedClass; //// -////namespace [|DefaultExportedClass|] { +////namespace [|{| "isWriteAccess": true, "isDefinition": true |}DefaultExportedClass|] { ////} // The namespace and class do not merge, // so the namespace should be all alone. - -verify.rangesReferenceEachOther(); +verify.singleReferenceGroup("namespace DefaultExportedClass"); diff --git a/tests/cases/fourslash/findAllRefsForFunctionExpression01.ts b/tests/cases/fourslash/findAllRefsForFunctionExpression01.ts index 35d5c45e3d..15ff0aca5c 100644 --- a/tests/cases/fourslash/findAllRefsForFunctionExpression01.ts +++ b/tests/cases/fourslash/findAllRefsForFunctionExpression01.ts @@ -1,7 +1,7 @@ /// // @Filename: file1.ts -////var foo = function [|foo|](a = [|foo|](), b = () => [|foo|]) { +////var foo = function [|{| "isWriteAccess": true, "isDefinition": true |}foo|](a = [|foo|](), b = () => [|foo|]) { //// [|foo|]([|foo|], [|foo|]); ////} @@ -9,4 +9,4 @@ /////// ////foo(); -verify.rangesReferenceEachOther(); +verify.singleReferenceGroup("(local function) foo(a?: void, b?: () => (a?: void, b?: any) => void): void"); diff --git a/tests/cases/fourslash/findAllRefsForMappedType.ts b/tests/cases/fourslash/findAllRefsForMappedType.ts index 38fb3a226c..a841c7e6e4 100644 --- a/tests/cases/fourslash/findAllRefsForMappedType.ts +++ b/tests/cases/fourslash/findAllRefsForMappedType.ts @@ -1,9 +1,19 @@ /// -////interface T { [|a|]: number }; +////interface T { [|{| "isWriteAccess": true, "isDefinition": true |}a|]: number }; ////type U = { [K in keyof T]: string }; ////type V = { [K in keyof U]: boolean }; -////const u: U = { [|a|]: "" } -////const v: V = { [|a|]: true } +////const u: U = { [|{| "isWriteAccess": true, "isDefinition": true |}a|]: "" } +////const v: V = { [|{| "isWriteAccess": true, "isDefinition": true |}a|]: true } -verify.rangesReferenceEachOther(); +const ranges = test.ranges(); +const [r0, r1, r2] = ranges; +verify.referenceGroups(r0, [{ definition: "(property) T.a: number", ranges }]); +verify.referenceGroups(r1, [ + { definition: "(property) T.a: number", ranges: [r0, r2] }, + { definition: "(property) a: string", ranges: [r1] } +]); +verify.referenceGroups(r2, [ + { definition: "(property) T.a: number", ranges: [r0, r1] }, + { definition: "(property) a: boolean", ranges: [r2] } +]); diff --git a/tests/cases/fourslash/findAllRefsForObjectLiteralProperties.ts b/tests/cases/fourslash/findAllRefsForObjectLiteralProperties.ts index cea4db81ea..125a11f19c 100644 --- a/tests/cases/fourslash/findAllRefsForObjectLiteralProperties.ts +++ b/tests/cases/fourslash/findAllRefsForObjectLiteralProperties.ts @@ -1,11 +1,17 @@ /// ////var x = { -//// [|property|]: {} +//// [|{| "isWriteAccess": true, "isDefinition": true |}property|]: {} ////}; //// ////x.[|property|]; //// ////let {[|property|]: pVar} = x; -verify.rangesReferenceEachOther(); +const ranges = test.ranges(); +const [r0, r1, r2] = ranges; +verify.referenceGroups(r0, [{ definition: "(property) property: {}", ranges }]); +verify.referenceGroups([r1, r2], [ + { definition: "(property) property: {}", ranges: [r0] }, + { definition: "(property) property: {}", ranges: [r1, r2] } +]); diff --git a/tests/cases/fourslash/findAllRefsForObjectSpread.ts b/tests/cases/fourslash/findAllRefsForObjectSpread.ts index 05c83491f6..a65f18ef57 100644 --- a/tests/cases/fourslash/findAllRefsForObjectSpread.ts +++ b/tests/cases/fourslash/findAllRefsForObjectSpread.ts @@ -1,14 +1,21 @@ /// -////interface A1 { [|a|]: string }; -////interface A2 { [|a|]?: number }; +////interface A1 { [|{| "isWriteAccess": true, "isDefinition": true |}a|]: string }; +////interface A2 { [|{| "isWriteAccess": true, "isDefinition": true |}a|]?: number }; ////let a1: A1; ////let a2: A2; ////let a12 = { ...a1, ...a2 }; ////a12.[|a|]; const ranges = test.ranges(); +const [r0, r1, r2] = ranges; + // members of spread types only refer to themselves and the resulting property -verify.referencesOf(ranges[0], [ranges[0], ranges[2]]); -verify.referencesOf(ranges[1], [ranges[1], ranges[2]]); +verify.referenceGroups(r0, [{ definition: "(property) A1.a: string", ranges: [r0, r2] }]); +verify.referenceGroups(r1, [{ definition: "(property) A2.a: number", ranges: [r1, r2] }]); + // but the resulting property refers to everything -verify.referencesOf(ranges[2], ranges); +verify.referenceGroups(r2, [ + { definition: "(property) A1.a: string", ranges: [r0] }, + { definition: "(property) A2.a: number", ranges: [r1] }, + { definition: "(property) a: string | number", ranges: [r2] } +]); diff --git a/tests/cases/fourslash/findAllRefsForRest.ts b/tests/cases/fourslash/findAllRefsForRest.ts index 65d6a3c60e..026451d68b 100644 --- a/tests/cases/fourslash/findAllRefsForRest.ts +++ b/tests/cases/fourslash/findAllRefsForRest.ts @@ -1,11 +1,11 @@ /// ////interface Gen { //// x: number -//// [|parent|]: Gen; +//// [|{| "isWriteAccess": true, "isDefinition": true |}parent|]: Gen; //// millenial: string; ////} ////let t: Gen; ////var { x, ...rest } = t; ////rest.[|parent|]; -verify.rangesReferenceEachOther(); +verify.singleReferenceGroup("(property) Gen.parent: Gen"); diff --git a/tests/cases/fourslash/findAllRefsForStringLiteralTypes.ts b/tests/cases/fourslash/findAllRefsForStringLiteralTypes.ts index 45e981d8a8..e450102c12 100644 --- a/tests/cases/fourslash/findAllRefsForStringLiteralTypes.ts +++ b/tests/cases/fourslash/findAllRefsForStringLiteralTypes.ts @@ -3,4 +3,4 @@ ////type Options = "[|option 1|]" | "option 2"; ////let myOption: Options = "[|option 1|]"; -verify.rangesReferenceEachOther(); +verify.singleReferenceGroup('"option 1"'); diff --git a/tests/cases/fourslash/findAllRefsForUMDModuleAlias1.ts b/tests/cases/fourslash/findAllRefsForUMDModuleAlias1.ts index 4177e15453..99ca347eac 100644 --- a/tests/cases/fourslash/findAllRefsForUMDModuleAlias1.ts +++ b/tests/cases/fourslash/findAllRefsForUMDModuleAlias1.ts @@ -4,10 +4,10 @@ //// export function doThing(): string; //// export function doTheOtherThing(): void; -//// export as namespace [|myLib|]; +//// export as namespace [|{| "isWriteAccess": true, "isDefinition": true |}myLib|]; // @Filename: 1.ts //// /// //// [|myLib|].doThing(); -verify.rangesReferenceEachOther(); +verify.singleReferenceGroup("export namespace myLib"); diff --git a/tests/cases/fourslash/findAllRefsForVariableInExtendsClause01.ts b/tests/cases/fourslash/findAllRefsForVariableInExtendsClause01.ts index dd8fb1026c..d40cb009f1 100644 --- a/tests/cases/fourslash/findAllRefsForVariableInExtendsClause01.ts +++ b/tests/cases/fourslash/findAllRefsForVariableInExtendsClause01.ts @@ -1,6 +1,6 @@ /// -////var [|Base|] = class { }; +////var [|{| "isWriteAccess": true, "isDefinition": true |}Base|] = class { }; ////class C extends [|Base|] { } -verify.rangesReferenceEachOther(); +verify.singleReferenceGroup("var Base: typeof (Anonymous class)"); diff --git a/tests/cases/fourslash/findAllRefsForVariableInExtendsClause02.ts b/tests/cases/fourslash/findAllRefsForVariableInExtendsClause02.ts index 3fc41358df..5685df0c4e 100644 --- a/tests/cases/fourslash/findAllRefsForVariableInExtendsClause02.ts +++ b/tests/cases/fourslash/findAllRefsForVariableInExtendsClause02.ts @@ -1,9 +1,9 @@ /// -////interface [|Base|] { } +////interface [|{| "isWriteAccess": true, "isDefinition": true |}Base|] { } ////namespace n { //// var Base = class { }; //// interface I extends [|Base|] { } ////} -verify.rangesReferenceEachOther(); +verify.singleReferenceGroup("interface Base"); diff --git a/tests/cases/fourslash/findAllRefsForVariableInImplementsClause01.ts b/tests/cases/fourslash/findAllRefsForVariableInImplementsClause01.ts index f8326eade5..419b828d0b 100644 --- a/tests/cases/fourslash/findAllRefsForVariableInImplementsClause01.ts +++ b/tests/cases/fourslash/findAllRefsForVariableInImplementsClause01.ts @@ -3,5 +3,4 @@ ////var Base = class { }; ////class C extends Base implements /**/Base { } -goTo.marker(); -verify.referencesAre([]); +verify.noReferences(""); diff --git a/tests/cases/fourslash/findAllRefsInClassExpression.ts b/tests/cases/fourslash/findAllRefsInClassExpression.ts index f874bcbcb5..b83d8992b4 100644 --- a/tests/cases/fourslash/findAllRefsInClassExpression.ts +++ b/tests/cases/fourslash/findAllRefsInClassExpression.ts @@ -1,8 +1,14 @@ /// -////interface I { [|boom|](): void; } +////interface I { [|{| "isWriteAccess": true, "isDefinition": true |}boom|](): void; } ////new class C implements I { -//// [|boom|](){} +//// [|{| "isWriteAccess": true, "isDefinition": true |}boom|](){} ////} -verify.rangesReferenceEachOther(); +const ranges = test.ranges(); +const [r0, r1] = ranges; +verify.referenceGroups(r0, [{ definition: "(method) I.boom(): void", ranges }]); +verify.referenceGroups(r1, [ + { definition: "(method) I.boom(): void", ranges: [r0] }, + { definition: "(method) C.boom(): void", ranges: [r1] } +]); diff --git a/tests/cases/fourslash/findAllRefsInheritedProperties1.ts b/tests/cases/fourslash/findAllRefsInheritedProperties1.ts index 358ba3f249..41acc117f9 100644 --- a/tests/cases/fourslash/findAllRefsInheritedProperties1.ts +++ b/tests/cases/fourslash/findAllRefsInheritedProperties1.ts @@ -1,8 +1,8 @@ /// //// class class1 extends class1 { -//// [|doStuff|]() { } -//// [|propName|]: string; +//// [|{| "isWriteAccess": true, "isDefinition": true |}doStuff|]() { } +//// [|{| "isWriteAccess": true, "isDefinition": true |}propName|]: string; //// } //// //// var v: class1; @@ -10,7 +10,9 @@ //// v.[|propName|]; const [r0, r1, r2, r3] = test.ranges(); -verify.referencesOf(r0, [r0, r2]); -verify.referencesOf(r1, [r1, r3]); -verify.referencesOf(r2, [r0, r2]); -verify.referencesOf(r3, [r1, r3]); +verify.referenceGroups(r0, [{ definition: "(method) class1.doStuff(): void", ranges: [r0, r2] }]); +verify.referenceGroups(r2, [ + { definition: "(method) class1.doStuff(): void", ranges: [r0] }, + { definition: "(method) class1.doStuff(): void", ranges: [r2] } +]); +verify.singleReferenceGroup("(property) class1.propName: string", [r1, r3]); diff --git a/tests/cases/fourslash/findAllRefsInheritedProperties2.ts b/tests/cases/fourslash/findAllRefsInheritedProperties2.ts index 9fe36fbb48..23badd64d4 100644 --- a/tests/cases/fourslash/findAllRefsInheritedProperties2.ts +++ b/tests/cases/fourslash/findAllRefsInheritedProperties2.ts @@ -1,8 +1,8 @@ /// //// interface interface1 extends interface1 { -//// [|doStuff|](): void; // r0 -//// [|propName|]: string; // r1 +//// [|{| "isWriteAccess": true, "isDefinition": true |}doStuff|](): void; // r0 +//// [|{| "isWriteAccess": true, "isDefinition": true |}propName|]: string; // r1 //// } //// //// var v: interface1; @@ -10,7 +10,5 @@ //// v.[|propName|]; // r3 const [r0, r1, r2, r3] = test.ranges(); -verify.referencesOf(r0, [r0, r2]); -verify.referencesOf(r1, [r1, r3]); -verify.referencesOf(r2, [r0, r2]); -verify.referencesOf(r3, [r1, r3]); +verify.singleReferenceGroup("(method) interface1.doStuff(): void", [r0, r2]); +verify.singleReferenceGroup("(property) interface1.propName: string", [r1, r3]); diff --git a/tests/cases/fourslash/findAllRefsInheritedProperties3.ts b/tests/cases/fourslash/findAllRefsInheritedProperties3.ts index 772fb78a2e..cc82e4a4e4 100644 --- a/tests/cases/fourslash/findAllRefsInheritedProperties3.ts +++ b/tests/cases/fourslash/findAllRefsInheritedProperties3.ts @@ -1,28 +1,40 @@ /// //// class class1 extends class1 { -//// [|doStuff|]() { } // r0 -//// [|propName|]: string; // r1 +//// [|{| "isWriteAccess": true, "isDefinition": true |}doStuff|]() { } // r0 +//// [|{| "isWriteAccess": true, "isDefinition": true |}propName|]: string; // r1 //// } //// interface interface1 extends interface1 { -//// [|doStuff|](): void; // r2 -//// [|propName|]: string; // r3 +//// [|{| "isWriteAccess": true, "isDefinition": true |}doStuff|](): void; // r2 +//// [|{| "isWriteAccess": true, "isDefinition": true |}propName|]: string; // r3 //// } //// class class2 extends class1 implements interface1 { -//// [|doStuff|]() { } // r4 -//// [|propName|]: string; // r5 +//// [|{| "isWriteAccess": true, "isDefinition": true |}doStuff|]() { } // r4 +//// [|{| "isWriteAccess": true, "isDefinition": true |}propName|]: string; // r5 //// } -//// +//// //// var v: class2; -//// v.[|propName|]; // r6 -//// v.[|doStuff|](); // r7 +//// v.[|doStuff|](); // r6 +//// v.[|propName|]; // r7 const [r0, r1, r2, r3, r4, r5, r6, r7] = test.ranges(); -verify.referencesOf(r0, [r0, r4, r7]); -verify.referencesOf(r1, [r1, r5, r6]); -verify.referencesOf(r2, [r2, r4, r7]); -verify.referencesOf(r3, [r3, r5, r6]); -verify.referencesOf(r4, [r0, r2, r4, r7]); -verify.referencesOf(r5, [r1, r3, r5, r6]); -verify.referencesOf(r6, [r1, r3, r5, r6]); -verify.referencesOf(r7, [r0, r2, r4, r7]); +verify.referenceGroups(r0, [{ definition: "(method) class1.doStuff(): void", ranges: [r0, r4, r6] }]); +verify.referenceGroups(r1, [{ definition: "(property) class1.propName: string", ranges: [r1, r5, r7] }]); +verify.referenceGroups(r2, [{ definition: "(method) interface1.doStuff(): void", ranges: [r2, r4, r6] }]); +verify.referenceGroups(r3, [{ definition: "(property) interface1.propName: string", ranges: [r3, r5, r7] }]); +verify.referenceGroups(r4, [ + { definition: "(method) class1.doStuff(): void", ranges: [r0] }, + { definition: "(method) interface1.doStuff(): void", ranges: [r2] }, + { definition: "(method) class2.doStuff(): void", ranges: [r4, r6] } +]); +verify.referenceGroups([r5, r7], [ + { definition: "(property) class1.propName: string", ranges: [r1] }, + { definition: "(property) interface1.propName: string", ranges: [r3] }, + { definition: "(property) class2.propName: string", ranges: [r5, r7] } +]); +verify.referenceGroups(r6, [ + { definition: "(method) class1.doStuff(): void", ranges: [r0] }, + { definition: "(method) interface1.doStuff(): void", ranges: [r2] }, + { definition: "(method) class2.doStuff(): void", ranges: [r4] }, + { definition: "(method) class2.doStuff(): void", ranges: [r6] } +]); diff --git a/tests/cases/fourslash/findAllRefsInheritedProperties4.ts b/tests/cases/fourslash/findAllRefsInheritedProperties4.ts index 1ecb85bfae..e2d8887bbe 100644 --- a/tests/cases/fourslash/findAllRefsInheritedProperties4.ts +++ b/tests/cases/fourslash/findAllRefsInheritedProperties4.ts @@ -1,12 +1,12 @@ /// //// interface C extends D { -//// [|prop0|]: string; // r0 -//// [|prop1|]: number; // r1 +//// [|{| "isWriteAccess": true, "isDefinition": true |}prop0|]: string; // r0 +//// [|{| "isWriteAccess": true, "isDefinition": true |}prop1|]: number; // r1 //// } //// //// interface D extends C { -//// [|prop0|]: string; // r2 +//// [|{| "isWriteAccess": true, "isDefinition": true |}prop0|]: string; // r2 //// } //// //// var d: D; @@ -14,8 +14,9 @@ //// d.[|prop1|]; // r4 const [r0, r1, r2, r3, r4] = test.ranges(); -verify.referencesOf(r0, [r0, r2, r3]); -verify.referencesOf(r1, [r1]); -verify.referencesOf(r2, [r0, r2, r3]); -verify.referencesOf(r3, [r0, r2, r3]); -verify.referencesOf(r4, []); +verify.referenceGroups([r0, r2, r3], [ + { definition: "(property) C.prop0: string", ranges: [r0] }, + { definition: "(property) D.prop0: string", ranges: [r2, r3] } +]); +verify.singleReferenceGroup("(property) C.prop1: number", [r1]); +verify.noReferences(r4); diff --git a/tests/cases/fourslash/findAllRefsInheritedProperties5.ts b/tests/cases/fourslash/findAllRefsInheritedProperties5.ts index 6d6dbb392b..c534a9d6aa 100644 --- a/tests/cases/fourslash/findAllRefsInheritedProperties5.ts +++ b/tests/cases/fourslash/findAllRefsInheritedProperties5.ts @@ -1,12 +1,12 @@ /// //// class C extends D { -//// [|prop0|]: string; // r0 -//// [|prop1|]: number; // r1 +//// [|{| "isWriteAccess": true, "isDefinition": true |}prop0|]: string; // r0 +//// [|{| "isWriteAccess": true, "isDefinition": true |}prop1|]: number; // r1 //// } //// //// class D extends C { -//// [|prop0|]: string; // r2 +//// [|{| "isWriteAccess": true, "isDefinition": true |}prop0|]: string; // r2 //// } //// //// var d: D; @@ -14,8 +14,7 @@ //// d.[|prop1|]; // r4 const [r0, r1, r2, r3, r4] = test.ranges(); -verify.referencesOf(r0, [r0]); -verify.referencesOf(r1, [r1]); -verify.referencesOf(r2, [r2, r3]); -verify.referencesOf(r3, [r2, r3]); -verify.referencesOf(r4, []); +verify.singleReferenceGroup("(property) C.prop0: string", [r0]); +verify.singleReferenceGroup("(property) C.prop1: number", [r1]); +verify.singleReferenceGroup("(property) D.prop0: string", [r2, r3]); +verify.noReferences(r4); diff --git a/tests/cases/fourslash/findAllRefsInsideTemplates1.ts b/tests/cases/fourslash/findAllRefsInsideTemplates1.ts index 9ab4c62423..8d41961c6f 100644 --- a/tests/cases/fourslash/findAllRefsInsideTemplates1.ts +++ b/tests/cases/fourslash/findAllRefsInsideTemplates1.ts @@ -1,6 +1,6 @@ /// -////var [|x|] = 10; +////var [|{| "isWriteAccess": true, "isDefinition": true |}x|] = 10; ////var y = `${ [|x|] } ${ [|x|] }` -verify.rangesReferenceEachOther(); +verify.singleReferenceGroup("var x: number"); diff --git a/tests/cases/fourslash/findAllRefsInsideTemplates2.ts b/tests/cases/fourslash/findAllRefsInsideTemplates2.ts index 63265eb944..24a4a7c131 100644 --- a/tests/cases/fourslash/findAllRefsInsideTemplates2.ts +++ b/tests/cases/fourslash/findAllRefsInsideTemplates2.ts @@ -1,6 +1,6 @@ /// -////function [|f|](...rest: any[]) { } +////function [|{| "isWriteAccess": true, "isDefinition": true |}f|](...rest: any[]) { } ////[|f|] `${ [|f|] } ${ [|f|] }` -verify.rangesReferenceEachOther(); +verify.singleReferenceGroup("function f(...rest: any[]): void"); diff --git a/tests/cases/fourslash/findAllRefsInsideWithBlock.ts b/tests/cases/fourslash/findAllRefsInsideWithBlock.ts index c95925ff86..5293624809 100644 --- a/tests/cases/fourslash/findAllRefsInsideWithBlock.ts +++ b/tests/cases/fourslash/findAllRefsInsideWithBlock.ts @@ -1,12 +1,12 @@ /// -////var [|x|] = 0; +////var [|{| "isWriteAccess": true, "isDefinition": true |}x|] = 0; //// ////with ({}) { //// var y = x; // Reference of x here should not be picked //// /*2*/y++; // also reference for y should be ignored ////} //// -////[|x|] = [|x|] + 1; +////[|{| "isWriteAccess": true |}x|] = [|x|] + 1; -verify.rangesReferenceEachOther(); +verify.singleReferenceGroup("var x: number"); diff --git a/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName01.ts b/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName01.ts index 895b2168b2..d11bcee506 100644 --- a/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName01.ts +++ b/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName01.ts @@ -1,11 +1,11 @@ /// ////interface I { -//// [|property1|]: number; +//// [|{| "isWriteAccess": true, "isDefinition": true |}property1|]: number; //// property2: string; ////} //// ////var foo: I; ////var { [|property1|]: prop1 } = foo; -verify.rangesReferenceEachOther(); +verify.singleReferenceGroup("(property) I.property1: number"); diff --git a/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName02.ts b/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName02.ts index 67a31f33d1..6ad98df9cd 100644 --- a/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName02.ts +++ b/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName02.ts @@ -1,11 +1,11 @@ /// ////interface I { -//// [|property1|]: number; +//// [|{| "isWriteAccess": true, "isDefinition": true |}property1|]: number; //// property2: string; ////} //// ////var foo: I; ////var { [|property1|]: {} } = foo; -verify.rangesReferenceEachOther(); +verify.singleReferenceGroup("(property) I.property1: number"); diff --git a/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName03.ts b/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName03.ts index 40ecf0139a..520dbc8e1e 100644 --- a/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName03.ts +++ b/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName03.ts @@ -1,11 +1,17 @@ /// ////interface I { -//// [|property1|]: number; +//// [|{| "isWriteAccess": true, "isDefinition": true |}property1|]: number; //// property2: string; ////} //// ////var foo: I; -////var [{ [|property1|]: prop1 }, { [|property1|], property2 } ] = [foo, foo]; +////var [{ [|property1|]: prop1 }, { [|{| "isWriteAccess": true, "isDefinition": true |}property1|], property2 } ] = [foo, foo]; -verify.rangesReferenceEachOther(); +const ranges = test.ranges(); +const [r0, r1, r2] = ranges; +verify.referenceGroups([r0, r1], [{ definition: "(property) I.property1: number", ranges }]); +verify.referenceGroups(r2, [ + { definition: "(property) I.property1: number", ranges: [r0, r1] }, + { definition: "var property1: number", ranges: [r2] } +]); diff --git a/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName04.ts b/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName04.ts index 5696d242fe..f25fff9da2 100644 --- a/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName04.ts +++ b/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName04.ts @@ -1,15 +1,22 @@ /// ////interface I { -//// [|property1|]: number; +//// [|{| "isWriteAccess": true, "isDefinition": true |}property1|]: number; //// property2: string; ////} //// ////function f({ [|property1|]: p1 }: I, -//// { [|property1|] }: I, +//// { [|{| "isWriteAccess": true, "isDefinition": true |}property1|] }: I, //// { property1: p2 }) { //// //// return [|property1|] + 1; ////} -verify.rangesReferenceEachOther(); +const ranges = test.ranges(); +const [r0, r1, r2, r3] = ranges; +verify.referenceGroups([r0, r1], [{ definition: "(property) I.property1: number", ranges }]); +verify.referenceGroups([r2, r3], [ + { definition: "(property) I.property1: number", ranges: [r0, r1] }, + { definition: "var property1: number", ranges: [r2, r3] } +]); + diff --git a/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName05.ts b/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName05.ts index e33c73ff83..f4e7bd70f7 100644 --- a/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName05.ts +++ b/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName05.ts @@ -10,4 +10,4 @@ ////} goTo.marker(); -verify.referencesAre([]); \ No newline at end of file +verify.noReferences(""); \ No newline at end of file diff --git a/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName06.ts b/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName06.ts index 8be45ac87e..c589dccacb 100644 --- a/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName06.ts +++ b/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName06.ts @@ -1,22 +1,29 @@ /// ////interface I { -//// [|property1|]: number; +//// [|{| "isWriteAccess": true, "isDefinition": true |}property1|]: number; //// property2: string; ////} //// ////var elems: I[]; ////for (let { [|property1|]: p } of elems) { ////} -////for (let { [|property1|] } of elems) { +////for (let { [|{| "isWriteAccess": true, "isDefinition": true |}property1|] } of elems) { ////} ////for (var { [|property1|]: p1 } of elems) { ////} ////var p2; -////for ({ [|property1|] : p2 } of elems) { +////for ({ [|{| "isWriteAccess": true, "isDefinition": true |}property1|] : p2 } of elems) { ////} -// Note: if this test ever changes, consider updating -// 'quickInfoForObjectBindingElementPropertyName05.ts' - -verify.rangesReferenceEachOther(); +const ranges = test.ranges(); +const [r0, r1, r2, r3, r4] = ranges; +verify.referenceGroups([r0, r1, r3], [{ definition: "(property) I.property1: number", ranges }]); +verify.referenceGroups(r2, [ + { definition: "(property) I.property1: number", ranges: [r0, r1, r3, r4] }, + { definition: "let property1: number", ranges: [r2] } +]); +verify.referenceGroups(r4, [ + { definition: "(property) I.property1: number", ranges: [r0, r1, r2, r3] }, + { definition: "(property) property1: I", ranges: [r4] } +]); diff --git a/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName07.ts b/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName07.ts index 96f414dc06..f9415ab6a8 100644 --- a/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName07.ts +++ b/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName07.ts @@ -2,6 +2,12 @@ ////let p, b; //// -////p, [{ [|a|]: p, b }] = [{ [|a|]: 10, b: true }]; +////p, [{ [|{| "isWriteAccess": true, "isDefinition": true |}a|]: p, b }] = [{ [|{| "isWriteAccess": true, "isDefinition": true |}a|]: 10, b: true }]; -verify.rangesReferenceEachOther(); +const ranges = test.ranges(); +const [r0, r1] = ranges; +verify.referenceGroups(r0, [{ definition: "(property) a: any", ranges }]); +verify.referenceGroups(r1, [ + { definition: "(property) a: any", ranges: [r0] }, + { definition: "(property) a: number", ranges: [r1] } +]); diff --git a/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName09.ts b/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName09.ts deleted file mode 100644 index 5696d242fe..0000000000 --- a/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName09.ts +++ /dev/null @@ -1,15 +0,0 @@ -/// - -////interface I { -//// [|property1|]: number; -//// property2: string; -////} -//// -////function f({ [|property1|]: p1 }: I, -//// { [|property1|] }: I, -//// { property1: p2 }) { -//// -//// return [|property1|] + 1; -////} - -verify.rangesReferenceEachOther(); diff --git a/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName10.ts b/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName10.ts index 6ffa4b03b6..1c79d326db 100644 --- a/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName10.ts +++ b/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName10.ts @@ -1,11 +1,11 @@ /// ////interface Recursive { -//// [|next|]?: Recursive; +//// [|{| "isWriteAccess": true, "isDefinition": true |}next|]?: Recursive; //// value: any; ////} //// ////function f ({ [|next|]: { [|next|]: x} }: Recursive) { ////} -verify.rangesReferenceEachOther(); +verify.singleReferenceGroup("(property) Recursive.next: Recursive"); diff --git a/tests/cases/fourslash/findAllRefsOfConstructor_withModifier.ts b/tests/cases/fourslash/findAllRefsOfConstructor_withModifier.ts index 0954945a54..061903e703 100644 --- a/tests/cases/fourslash/findAllRefsOfConstructor_withModifier.ts +++ b/tests/cases/fourslash/findAllRefsOfConstructor_withModifier.ts @@ -6,5 +6,4 @@ ////var x = new [|X|](); const ranges = test.ranges(); -const ctr = ranges[0]; -verify.referencesOf(ctr, ranges); +verify.referenceGroups(ranges[0], [{ definition: "constructor X(): X", ranges }]); diff --git a/tests/cases/fourslash/findAllRefsOnDecorators.ts b/tests/cases/fourslash/findAllRefsOnDecorators.ts index b58e15b957..95bf107201 100644 --- a/tests/cases/fourslash/findAllRefsOnDecorators.ts +++ b/tests/cases/fourslash/findAllRefsOnDecorators.ts @@ -1,7 +1,7 @@ /// // @Filename: a.ts -////function [|decorator|](target) { +////function [|{| "isWriteAccess": true, "isDefinition": true |}decorator|](target) { //// return target; ////} ////[|decorator|](); @@ -13,4 +13,4 @@ //// method() {} ////} -verify.rangesReferenceEachOther(); +verify.singleReferenceGroup("function decorator(target: any): any"); diff --git a/tests/cases/fourslash/findAllRefsOnDefinition.ts b/tests/cases/fourslash/findAllRefsOnDefinition.ts index cb82980760..7d136efc42 100644 --- a/tests/cases/fourslash/findAllRefsOnDefinition.ts +++ b/tests/cases/fourslash/findAllRefsOnDefinition.ts @@ -7,7 +7,7 @@ //// //// } //// -//// public [|start|](){ +//// public [|{| "isWriteAccess": true, "isDefinition": true |}start|](){ //// return this; //// } //// @@ -23,4 +23,10 @@ ////second.[|start|](); ////second.stop(); -verify.rangesReferenceEachOther(); +const ranges = test.ranges(); +const [r0, r1] = ranges; +verify.referenceGroups(r0, [{ definition: "(method) Test.start(): this", ranges }]); +verify.referenceGroups(r1, [ + { definition: "(method) Second.Test.start(): Second.Test", ranges: [r0] }, + { definition: "(method) Second.Test.start(): Second.Test", ranges: [r1] }, +]); diff --git a/tests/cases/fourslash/findAllRefsOnDefinition2.ts b/tests/cases/fourslash/findAllRefsOnDefinition2.ts index 8edfd7f8cd..6d2438a124 100644 --- a/tests/cases/fourslash/findAllRefsOnDefinition2.ts +++ b/tests/cases/fourslash/findAllRefsOnDefinition2.ts @@ -3,7 +3,7 @@ //@Filename: findAllRefsOnDefinition2-import.ts ////export module Test{ //// -//// export interface [|start|] { } +//// export interface [|{| "isWriteAccess": true, "isDefinition": true |}start|] { } //// //// export interface stop { } ////} @@ -14,4 +14,8 @@ ////var start: Second.Test.[|start|]; ////var stop: Second.Test.stop; -verify.rangesReferenceEachOther(); +const ranges = test.ranges(); +const [r0, r1] = ranges; +verify.referenceGroups(r0, [{ definition: "interface Test.start", ranges }]); +verify.referenceGroups(r1, [{ definition: "interface Second.Test.start", ranges }]); + diff --git a/tests/cases/fourslash/findAllRefsOnImportAliases.ts b/tests/cases/fourslash/findAllRefsOnImportAliases.ts index cd258e8031..7574e11625 100644 --- a/tests/cases/fourslash/findAllRefsOnImportAliases.ts +++ b/tests/cases/fourslash/findAllRefsOnImportAliases.ts @@ -1,15 +1,18 @@ /// //@Filename: a.ts -////export class [|Class|] { +////export class [|{| "isWriteAccess": true, "isDefinition": true |}Class|] { ////} //@Filename: b.ts -////import { [|Class|] } from "./a"; +////import { [|{| "isWriteAccess": true, "isDefinition": true |}Class|] } from "./a"; //// ////var c = new [|Class|](); //@Filename: c.ts -////export { [|Class|] } from "./a"; +////export { [|{| "isWriteAccess": true, "isDefinition": true |}Class|] } from "./a"; -verify.rangesReferenceEachOther(); +const ranges = test.ranges(); +const [r0, r1, r2, r3] = ranges; +verify.referenceGroups([r0, r1, r3], [{ definition: "class Class", ranges }]); +verify.referenceGroups(r2, [{ definition: "constructor Class(): Class", ranges }]); diff --git a/tests/cases/fourslash/findAllRefsOnImportAliases2.ts b/tests/cases/fourslash/findAllRefsOnImportAliases2.ts index 67c4d14b5d..a21d2da4c0 100644 --- a/tests/cases/fourslash/findAllRefsOnImportAliases2.ts +++ b/tests/cases/fourslash/findAllRefsOnImportAliases2.ts @@ -1,15 +1,23 @@ /// //@Filename: a.ts -////export class [|Class|] { +////export class [|{| "isWriteAccess": true, "isDefinition": true |}Class|] { ////} //@Filename: b.ts -////import { [|Class|] as [|C2|] } from "./a"; +////import { [|{| "isWriteAccess": true, "isDefinition": true |}Class|] as [|{| "isWriteAccess": true, "isDefinition": true |}C2|] } from "./a"; //// ////var c = new [|C2|](); //@Filename: c.ts -////export { [|Class|] as [|C3|] } from "./a"; +////export { [|{| "isWriteAccess": true, "isDefinition": true |}Class|] as [|{| "isWriteAccess": true, "isDefinition": true |}C3|] } from "./a"; -verify.rangesWithSameTextReferenceEachOther(); +const ranges = test.rangesByText(); +verify.singleReferenceGroup("class Class", ranges.get("Class")); + +const c2s = ranges.get("C2"); +const [c2_0, c2_1] = c2s; +verify.referenceGroups(c2_0, [{ definition: "import C2", ranges: c2s }]); +verify.referenceGroups(c2_1, [{ definition: "(alias) new C2(): C2\nimport C2", ranges: c2s }]); + +verify.singleReferenceGroup("import C3", ranges.get("C3")); diff --git a/tests/cases/fourslash/findAllRefsOnPrivateParameterProperty1.ts b/tests/cases/fourslash/findAllRefsOnPrivateParameterProperty1.ts index 3b8b5084a6..df33f2888e 100644 --- a/tests/cases/fourslash/findAllRefsOnPrivateParameterProperty1.ts +++ b/tests/cases/fourslash/findAllRefsOnPrivateParameterProperty1.ts @@ -1,7 +1,7 @@ /// ////class ABCD { -//// constructor(private x: number, public y: number, private [|z|]: number) { +//// constructor(private x: number, public y: number, private [|{| "isWriteAccess": true, "isDefinition": true |}z|]: number) { //// } //// //// func() { @@ -9,4 +9,4 @@ //// } ////} -verify.rangesReferenceEachOther(); +verify.singleReferenceGroup("(property) ABCD.z: number"); diff --git a/tests/cases/fourslash/findAllRefsParameterPropertyDeclaration1.ts b/tests/cases/fourslash/findAllRefsParameterPropertyDeclaration1.ts index 8f30e3cc85..fa1254118a 100644 --- a/tests/cases/fourslash/findAllRefsParameterPropertyDeclaration1.ts +++ b/tests/cases/fourslash/findAllRefsParameterPropertyDeclaration1.ts @@ -1,10 +1,15 @@ /// //// class Foo { -//// constructor(private [|privateParam|]: number) { +//// constructor(private [|{| "isWriteAccess": true, "isDefinition": true |}privateParam|]: number) { //// let localPrivate = [|privateParam|]; //// this.[|privateParam|] += 10; //// } //// } -verify.rangesReferenceEachOther(); +const ranges = test.ranges(); +const [r0, r1, r2] = ranges; +verify.referenceGroups(ranges, [ + { definition: "(property) Foo.privateParam: number", ranges: [r0, r2] }, + { definition: "(parameter) privateParam: number", ranges: [r1] } +]); diff --git a/tests/cases/fourslash/findAllRefsParameterPropertyDeclaration2.ts b/tests/cases/fourslash/findAllRefsParameterPropertyDeclaration2.ts index d9656e8b5c..45d814f909 100644 --- a/tests/cases/fourslash/findAllRefsParameterPropertyDeclaration2.ts +++ b/tests/cases/fourslash/findAllRefsParameterPropertyDeclaration2.ts @@ -1,10 +1,15 @@ /// //// class Foo { -//// constructor(public [|publicParam|]: number) { +//// constructor(public [|{| "isWriteAccess": true, "isDefinition": true |}publicParam|]: number) { //// let localPublic = [|publicParam|]; //// this.[|publicParam|] += 10; //// } //// } -verify.rangesReferenceEachOther(); +const ranges = test.ranges(); +const [r0, r1, r2] = ranges; +verify.referenceGroups(ranges, [ + { definition: "(property) Foo.publicParam: number", ranges: [r0, r2] }, + { definition: "(parameter) publicParam: number", ranges: [r1] } +]); diff --git a/tests/cases/fourslash/findAllRefsParameterPropertyDeclaration3.ts b/tests/cases/fourslash/findAllRefsParameterPropertyDeclaration3.ts index dc48ffedb2..3520fecb8a 100644 --- a/tests/cases/fourslash/findAllRefsParameterPropertyDeclaration3.ts +++ b/tests/cases/fourslash/findAllRefsParameterPropertyDeclaration3.ts @@ -1,10 +1,15 @@ /// //// class Foo { -//// constructor(protected [|protectedParam|]: number) { +//// constructor(protected [|{| "isWriteAccess": true, "isDefinition": true |}protectedParam|]: number) { //// let localProtected = [|protectedParam|]; //// this.[|protectedParam|] += 10; //// } //// } -verify.rangesReferenceEachOther(); +const ranges = test.ranges(); +const [r0, r1, r2] = ranges; +verify.referenceGroups(ranges, [ + { definition: "(property) Foo.protectedParam: number", ranges: [r0, r2] }, + { definition: "(parameter) protectedParam: number", ranges: [r1] } +]); diff --git a/tests/cases/fourslash/findAllRefsPrimitive.ts b/tests/cases/fourslash/findAllRefsPrimitive.ts index 51c463843e..bf704c6ae7 100644 --- a/tests/cases/fourslash/findAllRefsPrimitive.ts +++ b/tests/cases/fourslash/findAllRefsPrimitive.ts @@ -24,7 +24,7 @@ // @Filename: b.ts // const z: [|any|] = 0; -verify.rangesWithSameTextReferenceEachOther(); +test.rangesByText().forEach((ranges, text) => verify.singleReferenceGroup(text, ranges)); verify.rangesWithSameTextAreDocumentHighlights(); goTo.rangeStart(test.ranges()[0]); diff --git a/tests/cases/fourslash/findAllRefsPropertyContextuallyTypedByTypeParam01.ts b/tests/cases/fourslash/findAllRefsPropertyContextuallyTypedByTypeParam01.ts index f5b0143ac4..dec6575ebc 100644 --- a/tests/cases/fourslash/findAllRefsPropertyContextuallyTypedByTypeParam01.ts +++ b/tests/cases/fourslash/findAllRefsPropertyContextuallyTypedByTypeParam01.ts @@ -1,12 +1,12 @@ /// ////interface IFoo { -//// [|a|]: string; +//// [|{| "isWriteAccess": true, "isDefinition": true |}a|]: string; ////} ////class C { //// method() { //// var x: T = { -//// [|a|]: "" +//// [|{| "isWriteAccess": true, "isDefinition": true |}a|]: "" //// }; //// x.[|a|]; //// } @@ -14,7 +14,17 @@ //// //// ////var x: IFoo = { -//// [|a|]: "ss" +//// [|{| "isWriteAccess": true, "isDefinition": true |}a|]: "ss" ////}; -verify.rangesReferenceEachOther(); +const ranges = test.ranges(); +const [r0, r1, r2, r3] = ranges; +verify.referenceGroups([r0, r2], [{ definition: "(property) IFoo.a: string", ranges }]); +verify.referenceGroups(r1, [ + { definition: "(property) IFoo.a: string", ranges: [r0, r2, r3] }, + { definition: "(property) a: string", ranges: [r1] } +]); +verify.referenceGroups(r3, [ + { definition: "(property) IFoo.a: string", ranges: [r0, r1, r2] }, + { definition: "(property) a: string", ranges: [r3] } +]); diff --git a/tests/cases/fourslash/findAllRefsThisKeyword.ts b/tests/cases/fourslash/findAllRefsThisKeyword.ts index f08a70ccf6..6f5374f902 100644 --- a/tests/cases/fourslash/findAllRefsThisKeyword.ts +++ b/tests/cases/fourslash/findAllRefsThisKeyword.ts @@ -2,9 +2,9 @@ // @noLib: true ////[|this|]; -////function f([|this|]) { +////function f([|{| "isWriteAccess": true, "isDefinition": true |}this|]) { //// return [|this|]; -//// function g([|this|]) { return [|this|]; } +//// function g([|{| "isWriteAccess": true, "isDefinition": true |}this|]) { return [|this|]; } ////} ////class C { //// static x() { @@ -21,13 +21,19 @@ //// } ////} ////// These are *not* real uses of the 'this' keyword, they are identifiers. -////const x = { [|this|]: 0 } +////const x = { [|{| "isWriteAccess": true, "isDefinition": true |}this|]: 0 } ////x.[|this|]; const [global, f0, f1, g0, g1, x, y, constructor, method, propDef, propUse] = test.ranges(); verify.referencesOf(global, [global]); -verify.rangesReferenceEachOther([f0, f1]); -verify.rangesReferenceEachOther([g0, g1]); -verify.rangesReferenceEachOther([x, y]); -verify.rangesReferenceEachOther([constructor, method]); -verify.rangesReferenceEachOther([propDef, propUse]); +verify.referenceGroups(f0, [{ definition: "(parameter) this: any", ranges: [f0, f1] }]); +verify.referenceGroups(f1, [{ definition: "this: any", ranges: [f0, f1] }]); +verify.referenceGroups(g0, [{ definition: "(parameter) this: any", ranges: [g0, g1] }]); +verify.referenceGroups(g1, [{ definition: "this: any", ranges: [g0, g1] }]); +verify.singleReferenceGroup("this: typeof C", [x, y]); +verify.singleReferenceGroup("this: this", [constructor, method]); +verify.referenceGroups(propDef, [{ definition: "(property) this: number", ranges: [propDef, propUse] }]); +verify.referenceGroups(propUse, [ + { definition: "(property) this: number", ranges: [propDef] }, + { definition: "(property) this: number", ranges: [propUse] }, +]); diff --git a/tests/cases/fourslash/findAllRefsWithLeadingUnderscoreNames1.ts b/tests/cases/fourslash/findAllRefsWithLeadingUnderscoreNames1.ts index 7cc47ee34e..d2baf7c96b 100644 --- a/tests/cases/fourslash/findAllRefsWithLeadingUnderscoreNames1.ts +++ b/tests/cases/fourslash/findAllRefsWithLeadingUnderscoreNames1.ts @@ -1,10 +1,16 @@ /// ////class Foo { -//// public [|_bar|]() { return 0; } +//// public [|{| "isWriteAccess": true, "isDefinition": true |}_bar|]() { return 0; } ////} //// ////var x: Foo; ////x.[|_bar|]; -verify.rangesReferenceEachOther(); +const ranges = test.ranges(); +const [r0, r1] = ranges; +verify.referenceGroups(r0, [{ definition: "(method) Foo._bar(): number", ranges }]); +verify.referenceGroups(r1, [ + { definition: "(method) Foo._bar(): number", ranges: [r0] }, + { definition: "(method) Foo._bar(): number", ranges: [r1] } +]); diff --git a/tests/cases/fourslash/findAllRefsWithLeadingUnderscoreNames2.ts b/tests/cases/fourslash/findAllRefsWithLeadingUnderscoreNames2.ts index d1449016b5..3f5cd9ddbe 100644 --- a/tests/cases/fourslash/findAllRefsWithLeadingUnderscoreNames2.ts +++ b/tests/cases/fourslash/findAllRefsWithLeadingUnderscoreNames2.ts @@ -1,10 +1,16 @@ /// ////class Foo { -//// public [|__bar|]() { return 0; } +//// public [|{| "isWriteAccess": true, "isDefinition": true |}__bar|]() { return 0; } ////} //// ////var x: Foo; ////x.[|__bar|]; -verify.rangesReferenceEachOther(); +const ranges = test.ranges(); +const [r0, r1] = ranges; +verify.referenceGroups(r0, [{ definition: "(method) Foo.__bar(): number", ranges }]); +verify.referenceGroups(r1, [ + { definition: "(method) Foo.__bar(): number", ranges: [r0] }, + { definition: "(method) Foo.__bar(): number", ranges: [r1] } +]); diff --git a/tests/cases/fourslash/findAllRefsWithLeadingUnderscoreNames3.ts b/tests/cases/fourslash/findAllRefsWithLeadingUnderscoreNames3.ts index e0d6f7f345..e187006532 100644 --- a/tests/cases/fourslash/findAllRefsWithLeadingUnderscoreNames3.ts +++ b/tests/cases/fourslash/findAllRefsWithLeadingUnderscoreNames3.ts @@ -1,10 +1,16 @@ /// ////class Foo { -//// public [|___bar|]() { return 0; } +//// public [|{| "isWriteAccess": true, "isDefinition": true |}___bar|]() { return 0; } ////} //// ////var x: Foo; ////x.[|___bar|]; -verify.rangesReferenceEachOther(); +const ranges = test.ranges(); +const [r0, r1] = ranges; +verify.referenceGroups(r0, [{ definition: "(method) Foo.___bar(): number", ranges }]); +verify.referenceGroups(r1, [ + { definition: "(method) Foo.___bar(): number", ranges: [r0] }, + { definition: "(method) Foo.___bar(): number", ranges: [r1] } +]); diff --git a/tests/cases/fourslash/findAllRefsWithLeadingUnderscoreNames4.ts b/tests/cases/fourslash/findAllRefsWithLeadingUnderscoreNames4.ts index 5a8de54db4..74eef0ae98 100644 --- a/tests/cases/fourslash/findAllRefsWithLeadingUnderscoreNames4.ts +++ b/tests/cases/fourslash/findAllRefsWithLeadingUnderscoreNames4.ts @@ -1,10 +1,16 @@ /// ////class Foo { -//// public [|____bar|]() { return 0; } +//// public [|{| "isWriteAccess": true, "isDefinition": true |}____bar|]() { return 0; } ////} //// ////var x: Foo; ////x.[|____bar|]; -verify.rangesReferenceEachOther(); +const ranges = test.ranges(); +const [r0, r1] = ranges; +verify.referenceGroups(r0, [{ definition: "(method) Foo.____bar(): number", ranges }]); +verify.referenceGroups(r1, [ + { definition: "(method) Foo.____bar(): number", ranges: [r0] }, + { definition: "(method) Foo.____bar(): number", ranges: [r1] } +]); diff --git a/tests/cases/fourslash/findAllRefsWithLeadingUnderscoreNames5.ts b/tests/cases/fourslash/findAllRefsWithLeadingUnderscoreNames5.ts index 4ab28f164f..d54b48bf66 100644 --- a/tests/cases/fourslash/findAllRefsWithLeadingUnderscoreNames5.ts +++ b/tests/cases/fourslash/findAllRefsWithLeadingUnderscoreNames5.ts @@ -3,7 +3,7 @@ ////class Foo { //// public _bar; //// public __bar; -//// public [|___bar|]; +//// public [|{| "isWriteAccess": true, "isDefinition": true |}___bar|]; //// public ____bar; ////} //// @@ -13,4 +13,4 @@ ////x.[|___bar|]; ////x.____bar; -verify.rangesReferenceEachOther(); +verify.singleReferenceGroup("(property) Foo.___bar: any"); diff --git a/tests/cases/fourslash/findAllRefsWithLeadingUnderscoreNames6.ts b/tests/cases/fourslash/findAllRefsWithLeadingUnderscoreNames6.ts index 191b0bdbc1..39bc1d73ca 100644 --- a/tests/cases/fourslash/findAllRefsWithLeadingUnderscoreNames6.ts +++ b/tests/cases/fourslash/findAllRefsWithLeadingUnderscoreNames6.ts @@ -2,7 +2,7 @@ ////class Foo { //// public _bar; -//// public [|__bar|]; +//// public [|{| "isWriteAccess": true, "isDefinition": true |}__bar|]; //// public ___bar; //// public ____bar; ////} @@ -13,4 +13,4 @@ ////x.___bar; ////x.____bar; -verify.rangesReferenceEachOther(); +verify.singleReferenceGroup("(property) Foo.__bar: any"); diff --git a/tests/cases/fourslash/findAllRefsWithLeadingUnderscoreNames7.ts b/tests/cases/fourslash/findAllRefsWithLeadingUnderscoreNames7.ts index f357819309..dac42f4fc7 100644 --- a/tests/cases/fourslash/findAllRefsWithLeadingUnderscoreNames7.ts +++ b/tests/cases/fourslash/findAllRefsWithLeadingUnderscoreNames7.ts @@ -1,7 +1,7 @@ /// -////function [|__foo|]() { +////function [|{| "isWriteAccess": true, "isDefinition": true |}__foo|]() { //// [|__foo|](); ////} -verify.rangesReferenceEachOther(); +verify.singleReferenceGroup("function __foo(): void"); diff --git a/tests/cases/fourslash/findAllRefsWithLeadingUnderscoreNames8.ts b/tests/cases/fourslash/findAllRefsWithLeadingUnderscoreNames8.ts index 15c66f4e7c..8c92275e27 100644 --- a/tests/cases/fourslash/findAllRefsWithLeadingUnderscoreNames8.ts +++ b/tests/cases/fourslash/findAllRefsWithLeadingUnderscoreNames8.ts @@ -1,7 +1,7 @@ /// -////(function [|__foo|]() { +////(function [|{| "isWriteAccess": true, "isDefinition": true |}__foo|]() { //// [|__foo|](); ////}) -verify.rangesReferenceEachOther(); +verify.singleReferenceGroup("(local function) __foo(): void"); diff --git a/tests/cases/fourslash/findAllRefsWithLeadingUnderscoreNames9.ts b/tests/cases/fourslash/findAllRefsWithLeadingUnderscoreNames9.ts index cc33b618c4..bc5799e61c 100644 --- a/tests/cases/fourslash/findAllRefsWithLeadingUnderscoreNames9.ts +++ b/tests/cases/fourslash/findAllRefsWithLeadingUnderscoreNames9.ts @@ -1,7 +1,7 @@ /// -////(function [|___foo|]() { +////(function [|{| "isWriteAccess": true, "isDefinition": true |}___foo|]() { //// [|___foo|](); ////}) -verify.rangesReferenceEachOther(); +verify.singleReferenceGroup("(local function) ___foo(): void"); diff --git a/tests/cases/fourslash/findAllRefsWithShorthandPropertyAssignment.ts b/tests/cases/fourslash/findAllRefsWithShorthandPropertyAssignment.ts index 0dc050602c..544a3238e3 100644 --- a/tests/cases/fourslash/findAllRefsWithShorthandPropertyAssignment.ts +++ b/tests/cases/fourslash/findAllRefsWithShorthandPropertyAssignment.ts @@ -1,14 +1,19 @@ /// -//// var [|name|] = "Foo"; +//// var [|{| "isWriteAccess": true, "isDefinition": true |}name|] = "Foo"; //// -//// var obj = { [|name|] }; -//// var obj1 = { [|name|]:[|name|] }; +//// var obj = { [|{| "isWriteAccess": true, "isDefinition": true |}name|] }; +//// var obj1 = { [|{| "isWriteAccess": true, "isDefinition": true |}name|]:[|name|] }; //// obj.[|name|]; const [r0, r1, r2, r3, r4] = test.ranges(); -verify.referencesOf(r0, [r0, r1, r3]); -verify.referencesOf(r1, [r0, r1, r3, r4]); -verify.referencesOf(r2, [r2]); -verify.referencesOf(r3, [r0, r1, r3]); -verify.referencesOf(r4, [r1, r4]); +verify.referenceGroups([r0, r3], [{ definition: "var name: string", ranges: [r0, r1, r3] }]); +verify.referenceGroups(r1, [ + { definition: "var name: string", ranges: [r0, r3] }, + { definition: "(property) name: string", ranges: [r1, r4] } +]); +verify.singleReferenceGroup("(property) name: string", [r2]); +verify.referenceGroups(r4, [ + { definition: "(property) name: string", ranges: [r1] }, + { definition: "(property) name: string", ranges: [r4] }, +]); diff --git a/tests/cases/fourslash/findAllRefsWithShorthandPropertyAssignment2.ts b/tests/cases/fourslash/findAllRefsWithShorthandPropertyAssignment2.ts index 59ba87fabb..d4f758696f 100644 --- a/tests/cases/fourslash/findAllRefsWithShorthandPropertyAssignment2.ts +++ b/tests/cases/fourslash/findAllRefsWithShorthandPropertyAssignment2.ts @@ -1,16 +1,22 @@ /// -//// var [|dx|] = "Foo"; +//// var [|{| "isWriteAccess": true, "isDefinition": true |}dx|] = "Foo"; //// -//// module M { export var [|dx|]; } +//// module M { export var [|{| "isWriteAccess": true, "isDefinition": true |}dx|]; } //// module M { //// var z = 100; -//// export var y = { [|dx|], z }; +//// export var y = { [|{| "isWriteAccess": true, "isDefinition": true |}dx|], z }; //// } //// M.y.[|dx|]; const [r0, r1, r2, r3] = test.ranges(); -verify.referencesOf(r0, [r0]); -verify.referencesOf(r1, [r1, r2]); -verify.referencesOf(r2, [r1, r2, r3]); -verify.referencesOf(r3, [r2, r3]); +verify.singleReferenceGroup("var dx: string", [r0]); +verify.referenceGroups(r1, [{ definition: "var M.dx: any", ranges: [r1, r2] }]); +verify.referenceGroups(r2, [ + { definition: "var M.dx: any", ranges: [r1] }, + { definition: "(property) dx: any", ranges: [r2, r3] } +]); +verify.referenceGroups(r3, [ + { definition: "(property) dx: any", ranges: [r2] }, + { definition: "(property) dx: any", ranges: [r3] } +]); diff --git a/tests/cases/fourslash/findReferencesAcrossMultipleProjects.ts b/tests/cases/fourslash/findReferencesAcrossMultipleProjects.ts index a9915fc4b3..f9feb5ddb6 100644 --- a/tests/cases/fourslash/findReferencesAcrossMultipleProjects.ts +++ b/tests/cases/fourslash/findReferencesAcrossMultipleProjects.ts @@ -1,14 +1,14 @@ /// //@Filename: a.ts -////var [|x|]: number; +////var [|{| "isWriteAccess": true, "isDefinition": true |}x|]: number; //@Filename: b.ts /////// -////[|x|]++; +////[|{| "isWriteAccess": true |}x|]++; //@Filename: c.ts /////// -////[|x|]++; +////[|{| "isWriteAccess": true |}x|]++; -verify.rangesReferenceEachOther(); +verify.singleReferenceGroup("var x: number"); diff --git a/tests/cases/fourslash/findReferencesAfterEdit.ts b/tests/cases/fourslash/findReferencesAfterEdit.ts index 6140ca9a76..2d57e78c63 100644 --- a/tests/cases/fourslash/findReferencesAfterEdit.ts +++ b/tests/cases/fourslash/findReferencesAfterEdit.ts @@ -2,7 +2,7 @@ // @Filename: a.ts ////interface A { -//// [|foo|]: string; +//// [|{| "isWriteAccess": true, "isDefinition": true |}foo|]: string; ////} // @Filename: b.ts @@ -12,9 +12,9 @@ //// x.[|foo|] ////} -verify.rangesReferenceEachOther(); +verify.singleReferenceGroup("(property) A.foo: string"); goTo.marker(""); edit.insert("\r\n"); -verify.rangesReferenceEachOther(); +verify.singleReferenceGroup("(property) A.foo: string"); diff --git a/tests/cases/fourslash/findReferencesJSXTagName.ts b/tests/cases/fourslash/findReferencesJSXTagName.ts index 24760046eb..5f8bc3a475 100644 --- a/tests/cases/fourslash/findReferencesJSXTagName.ts +++ b/tests/cases/fourslash/findReferencesJSXTagName.ts @@ -1,14 +1,16 @@ /// // @Filename: index.tsx -////import { [|SubmissionComp|] } from "./RedditSubmission" +////import { [|{| "isWriteAccess": true, "isDefinition": true |}SubmissionComp|] } from "./RedditSubmission" ////function displaySubreddit(subreddit: string) { //// let components = submissions //// .map((value, index) => <[|SubmissionComp|] key={ index } elementPosition= { index } {...value.data} />); ////} // @Filename: RedditSubmission.ts -////export const [|SubmissionComp|] = (submission: SubmissionProps) => +////export const [|{| "isWriteAccess": true, "isDefinition": true |}SubmissionComp|] = (submission: SubmissionProps) => ////
; -verify.rangesReferenceEachOther(); +const ranges = test.ranges(); +const [r0, r1, r2] = ranges; +verify.referenceGroups(ranges, [{ definition: "const SubmissionComp: (submission: any) => any", ranges: [r2, r0, r1] }]); diff --git a/tests/cases/fourslash/findReferencesJSXTagName2.ts b/tests/cases/fourslash/findReferencesJSXTagName2.ts index 4ce08647c5..a8882b6008 100644 --- a/tests/cases/fourslash/findReferencesJSXTagName2.ts +++ b/tests/cases/fourslash/findReferencesJSXTagName2.ts @@ -1,7 +1,9 @@ /// // @Filename: index.tsx -////const [|obj|] = {Component: () =>
}; +////const [|{| "isWriteAccess": true, "isDefinition": true |}obj|] = {Component: () =>
}; ////const element = <[|obj|].Component/>; -verify.rangesReferenceEachOther(); +verify.singleReferenceGroup(`const obj: { + Component: () => any; +}`); diff --git a/tests/cases/fourslash/fourslash.ts b/tests/cases/fourslash/fourslash.ts index 6685bbc19c..c613204f53 100644 --- a/tests/cases/fourslash/fourslash.ts +++ b/tests/cases/fourslash/fourslash.ts @@ -182,18 +182,19 @@ declare namespace FourSlashInterface { goToType(startMarkerNames: string | string[], endMarkerNames: string | string[]): void; verifyGetEmitOutputForCurrentFile(expected: string): void; verifyGetEmitOutputContentsForCurrentFile(expected: ts.OutputFile[]): void; + noReferences(markerNameOrRange?: string | Range): void; /** - * Asserts that the given ranges are the references from the current position. - * If ranges have markers, those markers may have "isDefinition" and "isWriteAccess" data - * (otherwise these properties pf the reference are not tested). - * Order of ranges does not matter. - */ - referencesAre(ranges: Range[]): void; - /** + * @deprecated, prefer 'referenceGroups' * Like `referencesAre`, but goes to `start` first. * `start` should be included in `references`. */ referencesOf(start: Range, references: Range[]): void; + /** + * For each of startRanges, asserts the ranges that are referenced from there. + * This uses the 'findReferences' command instead of 'getReferencesAtPosition', so references are grouped by their definition. + */ + referenceGroups(startRanges: Range | Range[], parts: Array<{ definition: string, ranges: Range[] }>): void; + singleReferenceGroup(definition: string, ranges?: Range[]): void; rangesAreOccurrences(isWriteAccess?: boolean): void; rangesAreRenameLocations(findInStrings?: boolean, findInComments?: boolean): void; /** @@ -202,7 +203,6 @@ declare namespace FourSlashInterface { */ rangesReferenceEachOther(ranges?: Range[]): void; findReferencesDefinitionDisplayPartsAtCaretAre(expected: ts.SymbolDisplayPart[]): void; - rangesWithSameTextReferenceEachOther(): void; currentParameterHelpArgumentNameIs(name: string): void; currentParameterSpanIs(parameter: string): void; currentParameterHelpArgumentDocCommentIs(docComment: string): void; diff --git a/tests/cases/fourslash/getOccurrencesIsDefinitionOfArrowFunction.ts b/tests/cases/fourslash/getOccurrencesIsDefinitionOfArrowFunction.ts index 57b4c14ffb..b1acb76ad2 100644 --- a/tests/cases/fourslash/getOccurrencesIsDefinitionOfArrowFunction.ts +++ b/tests/cases/fourslash/getOccurrencesIsDefinitionOfArrowFunction.ts @@ -1,5 +1,5 @@ /// -////var [|{| "isDefinition": true |}f|] = x => x + 1; -////[|{| "isDefinition": false |}f|](12); +////var [|{| "isWriteAccess": true, "isDefinition": true |}f|] = x => x + 1; +////[|f|](12); -verify.rangesReferenceEachOther(); +verify.singleReferenceGroup("var f: (x: any) => any"); diff --git a/tests/cases/fourslash/getOccurrencesIsDefinitionOfBindingPattern.ts b/tests/cases/fourslash/getOccurrencesIsDefinitionOfBindingPattern.ts index e60921ec3b..7725b2e94f 100644 --- a/tests/cases/fourslash/getOccurrencesIsDefinitionOfBindingPattern.ts +++ b/tests/cases/fourslash/getOccurrencesIsDefinitionOfBindingPattern.ts @@ -1,5 +1,5 @@ /// -////const { [|{| "isDefinition": true |}x|], y } = { x: 1, y: 2 }; +////const { [|{| "isWriteAccess": true, "isDefinition": true |}x|], y } = { x: 1, y: 2 }; ////const z = [|{| "isDefinition": false |}x|]; -verify.rangesReferenceEachOther(); +verify.singleReferenceGroup("const x: number"); diff --git a/tests/cases/fourslash/getOccurrencesIsDefinitionOfClass.ts b/tests/cases/fourslash/getOccurrencesIsDefinitionOfClass.ts index 0a3c2e4231..b39c11dfe6 100644 --- a/tests/cases/fourslash/getOccurrencesIsDefinitionOfClass.ts +++ b/tests/cases/fourslash/getOccurrencesIsDefinitionOfClass.ts @@ -1,10 +1,13 @@ /// -////class [|{| "isDefinition": true |}C|] { +////class [|{| "isWriteAccess": true, "isDefinition": true |}C|] { //// n: number; //// constructor() { //// this.n = 12; //// } ////} -////let c = new [|{| "isDefinition": false |}C|](); +////let c = new [|C|](); -verify.rangesReferenceEachOther(); +const ranges = test.ranges(); +const [r0, r1] = ranges; +verify.referenceGroups(r0, [{ definition: "class C", ranges }]); +verify.referenceGroups(r1, [{ definition: "constructor C(): C", ranges }]); diff --git a/tests/cases/fourslash/getOccurrencesIsDefinitionOfComputedProperty.ts b/tests/cases/fourslash/getOccurrencesIsDefinitionOfComputedProperty.ts index 81df97eff2..27c34e5660 100644 --- a/tests/cases/fourslash/getOccurrencesIsDefinitionOfComputedProperty.ts +++ b/tests/cases/fourslash/getOccurrencesIsDefinitionOfComputedProperty.ts @@ -1,7 +1,9 @@ /// -////let o = { ["/**/[|{| "isDefinition": true |}foo|]"]: 12 }; -////let y = o.[|{| "isDefinition": false |}foo|]; -////let z = o['[|{| "isDefinition": false |}foo|]']; +////let o = { ["[|{| "isDefinition": true |}foo|]"]: 12 }; +////let y = o.[|foo|]; +////let z = o['[|foo|]']; -goTo.marker(); -verify.referencesAre(test.ranges()); +const ranges = test.ranges(); +const [r0, r1, r2] = ranges; +verify.referenceGroups(r0, [{ definition: '(property) ["foo"]: number', ranges }]); +verify.referenceGroups([r1, r2], []); // TODO: fix diff --git a/tests/cases/fourslash/getOccurrencesIsDefinitionOfEnum.ts b/tests/cases/fourslash/getOccurrencesIsDefinitionOfEnum.ts index 5b77bf6158..325674d8ee 100644 --- a/tests/cases/fourslash/getOccurrencesIsDefinitionOfEnum.ts +++ b/tests/cases/fourslash/getOccurrencesIsDefinitionOfEnum.ts @@ -1,8 +1,8 @@ /// -////enum [|{| "isDefinition": true |}E|] { +////enum [|{| "isWriteAccess": true, "isDefinition": true |}E|] { //// First, //// Second ////} -////let first = [|{| "isDefinition": false |}E|].First; +////let first = [|E|].First; -verify.rangesReferenceEachOther(); +verify.singleReferenceGroup("enum E"); diff --git a/tests/cases/fourslash/getOccurrencesIsDefinitionOfExport.ts b/tests/cases/fourslash/getOccurrencesIsDefinitionOfExport.ts index 759df4fa38..9cdfb0aa0f 100644 --- a/tests/cases/fourslash/getOccurrencesIsDefinitionOfExport.ts +++ b/tests/cases/fourslash/getOccurrencesIsDefinitionOfExport.ts @@ -1,8 +1,8 @@ /// // @Filename: m.ts -////export var [|{| "isDefinition": true |}x|] = 12; +////export var [|{| "isWriteAccess": true, "isDefinition": true |}x|] = 12; // @Filename: main.ts -////import { [|{| "isDefinition": true |}x|] } from "./m"; -////const y = [|{| "isDefinition": false |}x|]; +////import { [|{| "isWriteAccess": true, "isDefinition": true |}x|] } from "./m"; +////const y = [|x|]; -verify.rangesReferenceEachOther(); +verify.singleReferenceGroup("var x: number"); diff --git a/tests/cases/fourslash/getOccurrencesIsDefinitionOfFunction.ts b/tests/cases/fourslash/getOccurrencesIsDefinitionOfFunction.ts index 357ef088d6..4c91bc08ef 100644 --- a/tests/cases/fourslash/getOccurrencesIsDefinitionOfFunction.ts +++ b/tests/cases/fourslash/getOccurrencesIsDefinitionOfFunction.ts @@ -1,6 +1,6 @@ /// -////function [|{| "isDefinition": true |}func|](x: number) { +////function [|{| "isWriteAccess": true, "isDefinition": true |}func|](x: number) { ////} -////[|{| "isDefinition": false |}func|](x) +////[|func|](x) -verify.rangesReferenceEachOther(); +verify.singleReferenceGroup("function func(x: number): void"); diff --git a/tests/cases/fourslash/getOccurrencesIsDefinitionOfInterface.ts b/tests/cases/fourslash/getOccurrencesIsDefinitionOfInterface.ts index b7117995d8..826890c4da 100644 --- a/tests/cases/fourslash/getOccurrencesIsDefinitionOfInterface.ts +++ b/tests/cases/fourslash/getOccurrencesIsDefinitionOfInterface.ts @@ -1,7 +1,7 @@ /// -////interface [|{| "isDefinition": true |}I|] { +////interface [|{| "isWriteAccess": true, "isDefinition": true |}I|] { //// p: number; ////} -////let i: [|{| "isDefinition": false |}I|] = { p: 12 }; +////let i: [|I|] = { p: 12 }; -verify.rangesReferenceEachOther(); +verify.singleReferenceGroup("interface I"); diff --git a/tests/cases/fourslash/getOccurrencesIsDefinitionOfInterfaceClassMerge.ts b/tests/cases/fourslash/getOccurrencesIsDefinitionOfInterfaceClassMerge.ts index b0506490c7..0e949ca649 100644 --- a/tests/cases/fourslash/getOccurrencesIsDefinitionOfInterfaceClassMerge.ts +++ b/tests/cases/fourslash/getOccurrencesIsDefinitionOfInterfaceClassMerge.ts @@ -1,16 +1,19 @@ /// -////interface [|{| "isDefinition": true |}Numbers|] { +////interface [|{| "isWriteAccess": true, "isDefinition": true |}Numbers|] { //// p: number; ////} -////interface [|{| "isDefinition": true |}Numbers|] { +////interface [|{| "isWriteAccess": true, "isDefinition": true |}Numbers|] { //// m: number; ////} -////class [|{| "isDefinition": true |}Numbers|] { +////class [|{| "isWriteAccess": true, "isDefinition": true |}Numbers|] { //// f(n: number) { //// return this.p + this.m + n; //// } ////} -////let i: [|{| "isDefinition": false |}Numbers|] = new [|{| "isDefinition": false |}Numbers|](); +////let i: [|Numbers|] = new [|Numbers|](); ////let x = i.f(i.p + i.m); -verify.rangesReferenceEachOther(); +const ranges = test.ranges(); +const [r0, r1, r2, r3, r4] = ranges; +verify.referenceGroups([r0, r1, r2, r3], [{ definition: "class Numbers\ninterface Numbers", ranges }]); +verify.referenceGroups(r4, [{ definition: "constructor Numbers(): Numbers", ranges }]); diff --git a/tests/cases/fourslash/getOccurrencesIsDefinitionOfNamespace.ts b/tests/cases/fourslash/getOccurrencesIsDefinitionOfNamespace.ts index ff1cf00fa9..04d00e6c19 100644 --- a/tests/cases/fourslash/getOccurrencesIsDefinitionOfNamespace.ts +++ b/tests/cases/fourslash/getOccurrencesIsDefinitionOfNamespace.ts @@ -1,7 +1,7 @@ /// -////namespace [|{| "isDefinition": true |}Numbers|] { +////namespace [|{| "isWriteAccess": true, "isDefinition": true |}Numbers|] { //// export var n = 12; ////} -////let x = [|{| "isDefinition": false |}Numbers|].n + 1; +////let x = [|Numbers|].n + 1; -verify.rangesReferenceEachOther(); +verify.singleReferenceGroup("namespace Numbers"); diff --git a/tests/cases/fourslash/getOccurrencesIsDefinitionOfNumberNamedProperty.ts b/tests/cases/fourslash/getOccurrencesIsDefinitionOfNumberNamedProperty.ts index a041dab435..c603f398e5 100644 --- a/tests/cases/fourslash/getOccurrencesIsDefinitionOfNumberNamedProperty.ts +++ b/tests/cases/fourslash/getOccurrencesIsDefinitionOfNumberNamedProperty.ts @@ -1,5 +1,11 @@ /// ////let o = { [|{| "isDefinition": true |}1|]: 12 }; -////let y = o[[|{| "isDefinition": false |}1|]]; +////let y = o[[|1|]]; -verify.rangesReferenceEachOther(); +const ranges = test.ranges(); +const [r0, r1] = ranges; +verify.referenceGroups(r0, [{ definition: "(property) 1: number", ranges }]); +verify.referenceGroups(r1, [ + { definition: "(property) 1: number", ranges: [r0] }, + { definition: "(property) 1: number", ranges: [r1] } +]); diff --git a/tests/cases/fourslash/getOccurrencesIsDefinitionOfParameter.ts b/tests/cases/fourslash/getOccurrencesIsDefinitionOfParameter.ts index cdcc47014f..8afa67bfe6 100644 --- a/tests/cases/fourslash/getOccurrencesIsDefinitionOfParameter.ts +++ b/tests/cases/fourslash/getOccurrencesIsDefinitionOfParameter.ts @@ -1,6 +1,6 @@ /// -////function f([|{| "isDefinition": true |}x|]: number) { -//// return [|{| "isDefinition": false |}x|] + 1 +////function f([|{| "isWriteAccess": true, "isDefinition": true |}x|]: number) { +//// return [|x|] + 1 ////} -verify.rangesReferenceEachOther(); +verify.singleReferenceGroup("(parameter) x: number"); diff --git a/tests/cases/fourslash/getOccurrencesIsDefinitionOfStringNamedProperty.ts b/tests/cases/fourslash/getOccurrencesIsDefinitionOfStringNamedProperty.ts index 383cf49a2e..43fe0c571f 100644 --- a/tests/cases/fourslash/getOccurrencesIsDefinitionOfStringNamedProperty.ts +++ b/tests/cases/fourslash/getOccurrencesIsDefinitionOfStringNamedProperty.ts @@ -1,5 +1,11 @@ /// ////let o = { "[|{| "isDefinition": true |}x|]": 12 }; -////let y = o.[|{| "isDefinition": false |}x|]; +////let y = o.[|x|]; -verify.rangesReferenceEachOther(); +const ranges = test.ranges(); +const [r0, r1] = ranges; +verify.referenceGroups(r0, [{ definition: '(property) "x": number', ranges }]); +verify.referenceGroups(r1, [ + { definition: '(property) "x": number', ranges: [r0] }, + { definition: '(property) "x": number', ranges: [r1] }, +]); diff --git a/tests/cases/fourslash/getOccurrencesIsDefinitionOfTypeAlias.ts b/tests/cases/fourslash/getOccurrencesIsDefinitionOfTypeAlias.ts index 2bd66830c6..18a4ec0396 100644 --- a/tests/cases/fourslash/getOccurrencesIsDefinitionOfTypeAlias.ts +++ b/tests/cases/fourslash/getOccurrencesIsDefinitionOfTypeAlias.ts @@ -1,5 +1,5 @@ /// -////type [|{| "isDefinition": true |}Alias|]= number; -////let n: [|{| "isDefinition": false |}Alias|] = 12; +////type [|{| "isWriteAccess": true, "isDefinition": true |}Alias|]= number; +////let n: [|Alias|] = 12; -verify.rangesReferenceEachOther(); +verify.singleReferenceGroup("type Alias = number"); diff --git a/tests/cases/fourslash/getOccurrencesIsDefinitionOfVariable.ts b/tests/cases/fourslash/getOccurrencesIsDefinitionOfVariable.ts index 78529186ad..2faf5b53e1 100644 --- a/tests/cases/fourslash/getOccurrencesIsDefinitionOfVariable.ts +++ b/tests/cases/fourslash/getOccurrencesIsDefinitionOfVariable.ts @@ -1,20 +1,20 @@ /// -////var [|{| "isDefinition": true |}x|] = 0; -////var assignmentRightHandSide = [|{| "isDefinition": false |}x|]; -////var assignmentRightHandSide2 = 1 + [|{| "isDefinition": false |}x|]; +////var [|{| "isWriteAccess": true, "isDefinition": true |}x|] = 0; +////var assignmentRightHandSide = [|x|]; +////var assignmentRightHandSide2 = 1 + [|x|]; //// -////[|{| "isDefinition": false |}x|] = 1; -////[|{| "isDefinition": false |}x|] = [|{| "isDefinition": false |}x|] + [|{| "isDefinition": false |}x|]; +////[|{| "isWriteAccess": true |}x|] = 1; +////[|{| "isWriteAccess": true |}x|] = [|x|] + [|x|]; //// -////[|{| "isDefinition": false |}x|] == 1; -////[|{| "isDefinition": false |}x|] <= 1; +////[|x|] == 1; +////[|x|] <= 1; //// -////var preIncrement = ++[|{| "isDefinition": false |}x|]; -////var postIncrement = [|{| "isDefinition": false |}x|]++; -////var preDecrement = --[|{| "isDefinition": false |}x|]; -////var postDecrement = [|{| "isDefinition": false |}x|]--; +////var preIncrement = ++[|{| "isWriteAccess": true |}x|]; +////var postIncrement = [|{| "isWriteAccess": true |}x|]++; +////var preDecrement = --[|{| "isWriteAccess": true |}x|]; +////var postDecrement = [|{| "isWriteAccess": true |}x|]--; //// -////[|{| "isDefinition": false |}x|] += 1; -////[|{| "isDefinition": false |}x|] <<= 1; +////[|{| "isWriteAccess": true |}x|] += 1; +////[|{| "isWriteAccess": true |}x|] <<= 1; -verify.rangesReferenceEachOther(); +verify.singleReferenceGroup("var x: number"); diff --git a/tests/cases/fourslash/hoverOverComment.ts b/tests/cases/fourslash/hoverOverComment.ts index 653eaedfcb..fd1a7fcd9d 100644 --- a/tests/cases/fourslash/hoverOverComment.ts +++ b/tests/cases/fourslash/hoverOverComment.ts @@ -7,4 +7,4 @@ goTo.marker(); verify.quickInfoIs(""); verify.goToDefinitionIs([]); -verify.referencesAre([]); +verify.noReferences(); diff --git a/tests/cases/fourslash/localGetReferences.ts b/tests/cases/fourslash/localGetReferences.ts index d8e64be1ad..4648471648 100644 --- a/tests/cases/fourslash/localGetReferences.ts +++ b/tests/cases/fourslash/localGetReferences.ts @@ -3,17 +3,17 @@ // @Filename: localGetReferences_1.ts ////// Comment Refence Test: g/*1*/lobalVar ////// References to a variable declared in global. -////var [|globalVar|]: number = 2; +////var [|{| "isWriteAccess": true, "isDefinition": true |}globalVar|]: number = 2; //// ////class fooCls { //// // References to static variable declared in a class. -//// static [|clsSVar|] = 1; +//// static [|{| "isWriteAccess": true, "isDefinition": true |}clsSVar|] = 1; //// // References to a variable declared in a class. -//// [|clsVar|] = 1; +//// [|{| "isWriteAccess": true, "isDefinition": true |}clsVar|] = 1; //// -//// constructor (public [|clsParam|]: number) { +//// constructor (public [|{| "isWriteAccess": true, "isDefinition": true |}clsParam|]: number) { //// //Increments -//// [|globalVar|]++; +//// [|{| "isWriteAccess": true |}globalVar|]++; //// this.[|clsVar|]++; //// fooCls.[|clsSVar|]++; //// // References to a class parameter. @@ -23,18 +23,18 @@ ////} //// ////// References to a function parameter. -////function [|foo|]([|x|]: number) { +////function [|{| "isWriteAccess": true, "isDefinition": true |}foo|]([|{| "isWriteAccess": true, "isDefinition": true |}x|]: number) { //// // References to a variable declared in a function. -//// var [|fnVar|] = 1; +//// var [|{| "isWriteAccess": true, "isDefinition": true |}fnVar|] = 1; //// //// //Increments //// fooCls.[|clsSVar|]++; -//// [|globalVar|]++; +//// [|{| "isWriteAccess": true |}globalVar|]++; //// modTest.modVar++; -//// [|fnVar|]++; +//// [|{| "isWriteAccess": true |}fnVar|]++; //// //// //Return -//// return [|x|]++; +//// return [|{| "isWriteAccess": true |}x|]++; ////} //// ////module modTest { @@ -42,7 +42,7 @@ //// export var modVar:number; //// //// //Increments -//// [|globalVar|]++; +//// [|{| "isWriteAccess": true |}globalVar|]++; //// fooCls.[|clsSVar|]++; //// modVar++; //// @@ -54,7 +54,7 @@ //// static boo = [|foo|]; //// //// //Increments -//// [|globalVar|]++; +//// [|{| "isWriteAccess": true |}globalVar|]++; //// fooCls.[|clsSVar|]++; //// modVar++; //// } @@ -76,18 +76,18 @@ //////Increments ////fooCls.[|clsSVar|]++; ////modTest.modVar++; -////[|globalVar|] = [|globalVar|] + [|globalVar|]; +////[|{| "isWriteAccess": true |}globalVar|] = [|globalVar|] + [|globalVar|]; //// //////ETC - Other cases -////[|globalVar|] = 3; +////[|{| "isWriteAccess": true |}globalVar|] = 3; ////// References to illegal assignment. -////[|foo|] = [|foo|] + 1; +////[|{| "isWriteAccess": true |}foo|] = [|foo|] + 1; /////*3*/err = err++; /////*4*/ //////Shadowed fn Parameter -////function shdw([|{| "shadow": true |}globalVar|]: number) { +////function shdw([|{| "isWriteAccess": true, "isDefinition": true, "shadow": true |}globalVar|]: number) { //// //Increments -//// [|{| "shadow": true |}globalVar|]++; +//// [|{| "isWriteAccess": true, "shadow": true |}globalVar|]++; //// return [|{| "shadow": true |}globalVar|]; ////} //// @@ -117,7 +117,7 @@ ////array.forEach( //// //// -////function([|str|]) { +////function([|{| "isWriteAccess": true, "isDefinition": true |}str|]) { //// //// //// @@ -187,24 +187,36 @@ // References to comment. goTo.marker("1"); -verify.referencesAre([]); +verify.noReferences(); // References to unresolved symbol. goTo.marker("3"); -verify.referencesAre([]); +verify.noReferences(); // References to no context. goTo.marker("4"); -verify.referencesAre([]); +verify.noReferences(); -const rangesByText = test.rangesByText(); -rangesByText.forEach((ranges, text) => { +test.rangesByText().forEach((ranges, text) => { if (text === "globalVar") { - verify.rangesReferenceEachOther(ranges.filter(isShadow)); - verify.rangesReferenceEachOther(ranges.filter(r => !isShadow(r))); - } else { - verify.rangesReferenceEachOther(ranges); + 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) { diff --git a/tests/cases/fourslash/quickInfoForRequire.ts b/tests/cases/fourslash/quickInfoForRequire.ts index 26b0371fe0..e97810401f 100644 --- a/tests/cases/fourslash/quickInfoForRequire.ts +++ b/tests/cases/fourslash/quickInfoForRequire.ts @@ -6,5 +6,6 @@ //@Filename: quickInfoForRequire_input.ts ////import a = require("./AA/B/*1*/B"); -verify.quickInfoAt("1", "module a"); -verify.referencesAre([]); \ No newline at end of file +goTo.marker("1"); +verify.quickInfoIs("module a"); +verify.noReferences(); diff --git a/tests/cases/fourslash/referenceInParameterPropertyDeclaration.ts b/tests/cases/fourslash/referenceInParameterPropertyDeclaration.ts index 68a9f73b1d..79bf617286 100644 --- a/tests/cases/fourslash/referenceInParameterPropertyDeclaration.ts +++ b/tests/cases/fourslash/referenceInParameterPropertyDeclaration.ts @@ -2,19 +2,26 @@ // @Filename: file1.ts //// class Foo { -//// constructor(private [|privateParam|]: number, -//// public [|publicParam|]: string, -//// protected [|protectedParam|]: boolean) { -//// +//// constructor(private [|{| "isWriteAccess": true, "isDefinition": true, "type": "number" |}privateParam|]: number, +//// public [|{| "isWriteAccess": true, "isDefinition": true, "type": "string" |}publicParam|]: string, +//// protected [|{| "isWriteAccess": true, "isDefinition": true, "type": "boolean" |}protectedParam|]: boolean) { +//// //// let localPrivate = [|privateParam|]; //// this.[|privateParam|] += 10; -//// +//// //// let localPublic = [|publicParam|]; //// this.[|publicParam|] += " Hello!"; -//// +//// //// let localProtected = [|protectedParam|]; //// this.[|protectedParam|] = false; //// } //// } -verify.rangesWithSameTextReferenceEachOther(); +test.rangesByText().forEach((ranges, text) => { + const [r0, r1, r2] = ranges; + const type = r0.marker.data.type; + verify.referenceGroups(ranges, [ + { definition: `(property) Foo.${text}: ${type}`, ranges: [r0, r2] }, + { definition: `(parameter) ${text}: ${type}`, ranges: [r1] } + ]); +}); diff --git a/tests/cases/fourslash/referenceToClass.ts b/tests/cases/fourslash/referenceToClass.ts index 3e523487bd..d6d2171507 100644 --- a/tests/cases/fourslash/referenceToClass.ts +++ b/tests/cases/fourslash/referenceToClass.ts @@ -3,7 +3,7 @@ // Class references should work across file and not find local variables. // @Filename: referenceToClass_1.ts -////class [|foo|] { +////class [|{| "isWriteAccess": true, "isDefinition": true |}foo|] { //// public n: [|foo|]; //// public foo: number; ////} @@ -20,4 +20,7 @@ // @Filename: referenceToClass_2.ts ////var k: [|foo|]; -verify.rangesReferenceEachOther(); +const ranges = test.ranges(); +const [r0, r1, r2, r3, r4, r5] = ranges; +verify.referenceGroups([r0, r1, r2, r4, r5], [{ definition: "class foo", ranges }]); +verify.referenceGroups(r3, [{ definition: "constructor foo(): foo", ranges }]); diff --git a/tests/cases/fourslash/referencesBloomFilters.ts b/tests/cases/fourslash/referencesBloomFilters.ts index 7d99ccdfd3..c9f290db0d 100644 --- a/tests/cases/fourslash/referencesBloomFilters.ts +++ b/tests/cases/fourslash/referencesBloomFilters.ts @@ -3,7 +3,7 @@ // Ensure BloomFilter building logic is correct, by having one reference per file // @Filename: declaration.ts -////var container = { [|searchProp|] : 1 }; +////var container = { [|{| "isWriteAccess": true, "isDefinition": true |}searchProp|] : 1 }; // @Filename: expression.ts ////function blah() { return (1 + 2 + container.[|searchProp|]()) === 2; }; @@ -12,6 +12,16 @@ ////function blah2() { container["[|searchProp|]"] }; // @Filename: redeclaration.ts -////container = { "[|searchProp|]" : 18 }; +////container = { "[|{| "isDefinition": true |}searchProp|]" : 18 }; -verify.rangesReferenceEachOther(); +const ranges = test.ranges(); +const [r0, r1, r2, r3] = ranges; +verify.referenceGroups(r0, [{ definition: "(property) searchProp: number", ranges }]); +verify.referenceGroups([r1, r2], [ + { definition: "(property) searchProp: number", ranges: [r0, r3] }, + { definition: "(property) searchProp: number", ranges: [r1, r2] } +]); +verify.referenceGroups(r3, [ + { definition: "(property) searchProp: number", ranges: [r0, r1, r2] }, + { definition: '(property) "searchProp": number', ranges: [r3] } +]); diff --git a/tests/cases/fourslash/referencesBloomFilters2.ts b/tests/cases/fourslash/referencesBloomFilters2.ts index c42e5d4eaf..daf60d0dd0 100644 --- a/tests/cases/fourslash/referencesBloomFilters2.ts +++ b/tests/cases/fourslash/referencesBloomFilters2.ts @@ -3,7 +3,7 @@ // Ensure BloomFilter building logic is correct, by having one reference per file // @Filename: declaration.ts -////var container = { [|42|]: 1 }; +////var container = { [|{| "isDefinition": true |}42|]: 1 }; // @Filename: expression.ts ////function blah() { return (container[[|42|]]) === 2; }; @@ -12,6 +12,16 @@ ////function blah2() { container["[|42|]"] }; // @Filename: redeclaration.ts -////container = { "[|42|]" : 18 }; +////container = { "[|{| "isDefinition": true |}42|]" : 18 }; -verify.rangesReferenceEachOther(); +const ranges = test.ranges(); +const [r0, r1, r2, r3] = ranges; +verify.referenceGroups(r0, [{ definition: "(property) 42: number", ranges }]); +verify.referenceGroups([r1, r2], [ + { definition: "(property) 42: number", ranges: [r0, r3] }, + { definition: "(property) 42: number", ranges: [r1, r2] } +]); +verify.referenceGroups(r3, [ + { definition: "(property) 42: number", ranges: [r0, r1, r2] }, + { definition: '(property) "42": number', ranges: [r3] } +]); diff --git a/tests/cases/fourslash/referencesBloomFilters3.ts b/tests/cases/fourslash/referencesBloomFilters3.ts index 9703baceb1..0dd5c64526 100644 --- a/tests/cases/fourslash/referencesBloomFilters3.ts +++ b/tests/cases/fourslash/referencesBloomFilters3.ts @@ -4,9 +4,9 @@ // @Filename: declaration.ts -////enum Test { "[|42|]" = 1 }; +////enum Test { "[|{| "isDefinition": true |}42|]" = 1 }; // @Filename: expression.ts ////(Test[[|42|]]); -verify.rangesReferenceEachOther(); +verify.singleReferenceGroup('(enum member) Test["42"] = 1'); diff --git a/tests/cases/fourslash/referencesForAmbients.ts b/tests/cases/fourslash/referencesForAmbients.ts index da3f3f43aa..58e4d6e59a 100644 --- a/tests/cases/fourslash/referencesForAmbients.ts +++ b/tests/cases/fourslash/referencesForAmbients.ts @@ -1,11 +1,11 @@ /// -////declare module "[|foo|]" { -//// var [|f|]: number; +////declare module "[|{| "isDefinition": true |}foo|]" { +//// var [|{| "isWriteAccess": true, "isDefinition": true |}f|]: number; ////} //// -////declare module "[|bar|]" { -//// export import [|foo|] = require("[|foo|]"); +////declare module "[|{| "isDefinition": true |}bar|]" { +//// export import [|{| "isWriteAccess": true, "isDefinition": true |}foo|] = require("[|foo|]"); //// var f2: typeof [|foo|].[|f|]; ////} //// @@ -15,7 +15,7 @@ ////} const [moduleFoo0, f0, moduleBar0, foo0, moduleFoo1, foo1, f1, moduleBar1, foo2] = test.ranges(); -verify.rangesReferenceEachOther([moduleFoo0, moduleFoo1]); -verify.rangesReferenceEachOther([moduleBar0, moduleBar1]); -verify.rangesReferenceEachOther([foo0, foo1, foo2]); -verify.rangesReferenceEachOther([f0, f1]); +verify.singleReferenceGroup('module "foo"', [moduleFoo0, moduleFoo1]); +verify.singleReferenceGroup('module "bar"', [moduleBar0, moduleBar1]); +verify.singleReferenceGroup('import foo = require("foo")', [foo0, foo1, foo2]); +verify.singleReferenceGroup("var f: number", [f0, f1]); diff --git a/tests/cases/fourslash/referencesForClassLocal.ts b/tests/cases/fourslash/referencesForClassLocal.ts index bdde0e7f12..4108c060a3 100644 --- a/tests/cases/fourslash/referencesForClassLocal.ts +++ b/tests/cases/fourslash/referencesForClassLocal.ts @@ -5,7 +5,7 @@ ////var n = 14; //// ////class foo { -//// private [|n|] = 0; +//// private [|{| "isWriteAccess": true, "isDefinition": true |}n|] = 0; //// //// public bar() { //// this.[|n|] = 9; @@ -20,4 +20,4 @@ //// } ////} -verify.rangesReferenceEachOther(); +verify.singleReferenceGroup("(property) foo.n: number"); diff --git a/tests/cases/fourslash/referencesForClassMembers.ts b/tests/cases/fourslash/referencesForClassMembers.ts index 0208b13589..0db4ebb087 100644 --- a/tests/cases/fourslash/referencesForClassMembers.ts +++ b/tests/cases/fourslash/referencesForClassMembers.ts @@ -1,16 +1,36 @@ /// ////class Base { -//// [|a|]: number; -//// [|method|](): void { } +//// [|{| "isWriteAccess": true, "isDefinition": true |}a|]: number; +//// [|{| "isWriteAccess": true, "isDefinition": true |}method|](): void { } ////} ////class MyClass extends Base { -//// [|a|]; -//// [|method|]() { } +//// [|{| "isWriteAccess": true, "isDefinition": true |}a|]; +//// [|{| "isWriteAccess": true, "isDefinition": true |}method|]() { } ////} //// ////var c: MyClass; ////c.[|a|]; ////c.[|method|](); -verify.rangesWithSameTextReferenceEachOther(); +const ranges = test.rangesByText(); +const properties = ranges.get("a"); +const [a0, a1, a2] = properties; +verify.referenceGroups(a0, [{ definition: "(property) Base.a: number", ranges: properties }]); +verify.referenceGroups([a1, a2], [ + { definition: "(property) Base.a: number", ranges: [a0] }, + { definition: "(property) MyClass.a: any", ranges: [a1, a2] } +]); + +const methods = ranges.get("method"); +const [m0, m1, m2] = methods; +verify.referenceGroups(m0, [{ definition: "(method) Base.method(): void", ranges: methods }]); +verify.referenceGroups(m1, [ + { definition: "(method) Base.method(): void", ranges: [m0] }, + { definition: "(method) MyClass.method(): void", ranges: [m1, m2] } +]); +verify.referenceGroups(m2, [ + { definition: "(method) Base.method(): void", ranges: [m0] }, + { definition: "(method) MyClass.method(): void", ranges: [m1] }, + { definition: "(method) MyClass.method(): void", ranges: [m2] } +]); diff --git a/tests/cases/fourslash/referencesForClassMembersExtendingAbstractClass.ts b/tests/cases/fourslash/referencesForClassMembersExtendingAbstractClass.ts index 46115f9da1..b5be77a73b 100644 --- a/tests/cases/fourslash/referencesForClassMembersExtendingAbstractClass.ts +++ b/tests/cases/fourslash/referencesForClassMembersExtendingAbstractClass.ts @@ -1,16 +1,36 @@ /// ////abstract class Base { -//// abstract [|a|]: number; -//// abstract [|method|](): void; +//// abstract [|{| "isWriteAccess": true, "isDefinition": true |}a|]: number; +//// abstract [|{| "isWriteAccess": true, "isDefinition": true |}method|](): void; ////} ////class MyClass extends Base { -//// [|a|]; -//// [|method|]() { } +//// [|{| "isWriteAccess": true, "isDefinition": true |}a|]; +//// [|{| "isWriteAccess": true, "isDefinition": true |}method|]() { } ////} //// ////var c: MyClass; ////c.[|a|]; ////c.[|method|](); -verify.rangesWithSameTextReferenceEachOther(); +const ranges = test.rangesByText(); +const properties = ranges.get("a"); +const [a0, a1, a2] = properties; +verify.referenceGroups(a0, [{ definition: "(property) Base.a: number", ranges: properties }]); +verify.referenceGroups([a1, a2], [ + { definition: "(property) Base.a: number", ranges: [a0] }, + { definition: "(property) MyClass.a: any", ranges: [a1, a2] } +]); + +const methods = ranges.get("method"); +const [m0, m1, m2] = methods; +verify.referenceGroups(m0, [{ definition: "(method) Base.method(): void", ranges: methods }]); +verify.referenceGroups(m1, [ + { definition: "(method) Base.method(): void", ranges: [m0] }, + { definition: "(method) MyClass.method(): void", ranges: [m1, m2] } +]); +verify.referenceGroups(m2, [ + { definition: "(method) Base.method(): void", ranges: [m0] }, + { definition: "(method) MyClass.method(): void", ranges: [m1] }, + { definition: "(method) MyClass.method(): void", ranges: [m2] } +]); diff --git a/tests/cases/fourslash/referencesForClassMembersExtendingGenericClass.ts b/tests/cases/fourslash/referencesForClassMembersExtendingGenericClass.ts index 2b701f25cc..3e453663f6 100644 --- a/tests/cases/fourslash/referencesForClassMembersExtendingGenericClass.ts +++ b/tests/cases/fourslash/referencesForClassMembersExtendingGenericClass.ts @@ -1,16 +1,36 @@ /// ////class Base { -//// [|a|]: this; -//// [|method|](a?:T, b?:U): this { } +//// [|{| "isWriteAccess": true, "isDefinition": true |}a|]: this; +//// [|{| "isWriteAccess": true, "isDefinition": true |}method|](a?:T, b?:U): this { } ////} ////class MyClass extends Base { -//// [|a|]; -//// [|method|]() { } +//// [|{| "isWriteAccess": true, "isDefinition": true |}a|]; +//// [|{| "isWriteAccess": true, "isDefinition": true |}method|]() { } ////} //// ////var c: MyClass; ////c.[|a|]; ////c.[|method|](); -verify.rangesWithSameTextReferenceEachOther(); +const ranges = test.rangesByText(); +const properties = ranges.get("a"); +const [a0, a1, a2] = properties; +verify.referenceGroups(a0, [{ definition: "(property) Base.a: this", ranges: properties }]); +verify.referenceGroups([a1, a2], [ + { definition: "(property) Base.a: this", ranges: [a0] }, + { definition: "(property) MyClass.a: any", ranges: [a1, a2] } +]); + +const methods = ranges.get("method"); +const [m0, m1, m2] = methods; +verify.referenceGroups(m0, [{ definition: "(method) Base.method(a?: T, b?: U): this", ranges: methods }]); +verify.referenceGroups(m1, [ + { definition: "(method) Base.method(): void", ranges: [m0] }, + { definition: "(method) MyClass.method(): void", ranges: [m1, m2] } +]); +verify.referenceGroups(m2, [ + { definition: "(method) Base.method(a?: T, b?: U): this", ranges: [m0] }, + { definition: "(method) MyClass.method(): void", ranges: [m1] }, + { definition: "(method) MyClass.method(): void", ranges: [m2] } +]); diff --git a/tests/cases/fourslash/referencesForClassParameter.ts b/tests/cases/fourslash/referencesForClassParameter.ts index ce383b3650..e1a33dc5ac 100644 --- a/tests/cases/fourslash/referencesForClassParameter.ts +++ b/tests/cases/fourslash/referencesForClassParameter.ts @@ -7,7 +7,7 @@ ////class p { } //// ////class foo { -//// constructor (public [|p|]: any) { +//// constructor (public [|{| "isWriteAccess": true, "isDefinition": true |}p|]: any) { //// } //// //// public f(p) { @@ -19,4 +19,10 @@ ////var n = new foo(undefined); ////n.[|p|] = null; -verify.rangesReferenceEachOther(); +const ranges = test.ranges(); +const [r0, r1, r2] = ranges; +verify.referenceGroups([r0, r1], [{ definition: "(property) foo.p: any", ranges }]); +verify.referenceGroups(r2, [ + { definition: "(property) foo.p: any", ranges: [r0, r1] }, + { definition: "(property) foo.p: any", ranges: [r2] } +]); diff --git a/tests/cases/fourslash/referencesForContextuallyTypedObjectLiteralProperties.ts b/tests/cases/fourslash/referencesForContextuallyTypedObjectLiteralProperties.ts index 65bd7eebfb..7d6bc05cf3 100644 --- a/tests/cases/fourslash/referencesForContextuallyTypedObjectLiteralProperties.ts +++ b/tests/cases/fourslash/referencesForContextuallyTypedObjectLiteralProperties.ts @@ -1,28 +1,36 @@ /// -////interface IFoo { [|xy|]: number; } +////interface IFoo { [|{| "isWriteAccess": true, "isDefinition": true |}xy|]: number; } //// ////// Assignment -////var a1: IFoo = { [|xy|]: 0 }; -////var a2: IFoo = { [|xy|]: 0 }; +////var a1: IFoo = { [|{| "isWriteAccess": true, "isDefinition": true |}xy|]: 0 }; +////var a2: IFoo = { [|{| "isWriteAccess": true, "isDefinition": true |}xy|]: 0 }; //// ////// Function call ////function consumer(f: IFoo) { } -////consumer({ [|xy|]: 1 }); +////consumer({ [|{| "isWriteAccess": true, "isDefinition": true |}xy|]: 1 }); //// -////// Type cast -////var c = { [|xy|]: 0 }; +////// Type cast +////var c = { [|{| "isWriteAccess": true, "isDefinition": true |}xy|]: 0 }; //// ////// Array literal -////var ar: IFoo[] = [{ [|xy|]: 1 }, { [|xy|]: 2 }]; +////var ar: IFoo[] = [{ [|{| "isWriteAccess": true, "isDefinition": true |}xy|]: 1 }, { [|{| "isWriteAccess": true, "isDefinition": true |}xy|]: 2 }]; //// ////// Nested object literal -////var ob: { ifoo: IFoo } = { ifoo: { [|xy|]: 0 } }; +////var ob: { ifoo: IFoo } = { ifoo: { [|{| "isWriteAccess": true, "isDefinition": true |}xy|]: 0 } }; //// ////// Widened type -////var w: IFoo = { [|xy|]: undefined }; +////var w: IFoo = { [|{| "isWriteAccess": true, "isDefinition": true, "type": "undefined" |}xy|]: undefined }; //// ////// Untped -- should not be included ////var u = { xy: 0 }; -verify.rangesReferenceEachOther(); +const ranges = test.ranges(); +verify.referenceGroups(ranges[0], [{ definition: "(property) IFoo.xy: number", ranges }]); +for (const range of ranges.slice(1)) { + const type = range.marker.data.type || "number"; + verify.referenceGroups(range, [ + { definition: "(property) IFoo.xy: number", ranges: ranges.filter(r => r !== range) }, + { definition: `(property) xy: ${type}`, ranges: [range] } + ]); +} diff --git a/tests/cases/fourslash/referencesForContextuallyTypedUnionProperties.ts b/tests/cases/fourslash/referencesForContextuallyTypedUnionProperties.ts index c0e4a5f90e..d79d4097ee 100644 --- a/tests/cases/fourslash/referencesForContextuallyTypedUnionProperties.ts +++ b/tests/cases/fourslash/referencesForContextuallyTypedUnionProperties.ts @@ -2,33 +2,33 @@ ////interface A { //// a: number; -//// [|common|]: string; +//// [|{| "isWriteAccess": true, "isDefinition": true |}common|]: string; ////} //// ////interface B { //// b: number; -//// [|common|]: number; +//// [|{| "isWriteAccess": true, "isDefinition": true |}common|]: number; ////} //// ////// Assignment -////var v1: A | B = { a: 0, [|common|]: "" }; -////var v2: A | B = { b: 0, [|common|]: 3 }; +////var v1: A | B = { a: 0, [|{| "isWriteAccess": true, "isDefinition": true, "type": "string" |}common|]: "" }; +////var v2: A | B = { b: 0, [|{| "isWriteAccess": true, "isDefinition": true, "type": "number" |}common|]: 3 }; //// ////// Function call ////function consumer(f: A | B) { } -////consumer({ a: 0, b: 0, [|common|]: 1 }); +////consumer({ a: 0, b: 0, [|{| "isWriteAccess": true, "isDefinition": true, "type": "number" |}common|]: 1 }); //// -////// Type cast -////var c = { [|common|]: 0, b: 0 }; +////// Type cast +////var c = { [|{| "isWriteAccess": true, "isDefinition": true, "type": "number" |}common|]: 0, b: 0 }; //// ////// Array literal -////var ar: Array = [{ a: 0, [|common|]: "" }, { b: 0, [|common|]: 0 }]; +////var ar: Array = [{ a: 0, [|{| "isWriteAccess": true, "isDefinition": true, "type": "string" |}common|]: "" }, { b: 0, [|{| "isWriteAccess": true, "isDefinition": true, "type": "number" |}common|]: 0 }]; //// ////// Nested object literal -////var ob: { aorb: A|B } = { aorb: { b: 0, [|common|]: 0 } }; +////var ob: { aorb: A|B } = { aorb: { b: 0, [|{| "isWriteAccess": true, "isDefinition": true, "type": "number" |}common|]: 0 } }; //// ////// Widened type -////var w: A|B = { a:0, [|common|]: undefined }; +////var w: A|B = { a:0, [|{| "isWriteAccess": true, "isDefinition": true, "type": "undefined" |}common|]: undefined }; //// ////// Untped -- should not be included ////var u1 = { a: 0, b: 0, common: "" }; @@ -36,8 +36,14 @@ const all = test.ranges(); const [aCommon, bCommon, ...unionRefs] = all; -verify.referencesOf(aCommon, [aCommon, ...unionRefs]); -verify.referencesOf(bCommon, [bCommon, ...unionRefs]); -for (const ref of unionRefs) { - verify.referencesOf(ref, all); -} +verify.referenceGroups(aCommon, [{ definition: "(property) A.common: string", ranges: [aCommon, ...unionRefs] }]); +verify.referenceGroups(bCommon, [{ definition: "(property) B.common: number", ranges: [bCommon, ...unionRefs] }]); + +unionRefs.forEach((unionRef, idx) => { + const type = unionRef.marker.data.type; + verify.referenceGroups(unionRef, [ + { definition: "(property) A.common: string", ranges: all.filter(x => x !== bCommon && x !== unionRef) }, + { definition: "(property) B.common: number", ranges: [bCommon] }, + { definition: `(property) common: ${type}`, ranges: [unionRef] } + ]); +}); diff --git a/tests/cases/fourslash/referencesForContextuallyTypedUnionProperties2.ts b/tests/cases/fourslash/referencesForContextuallyTypedUnionProperties2.ts index de9ffbfd3b..2c48e353b0 100644 --- a/tests/cases/fourslash/referencesForContextuallyTypedUnionProperties2.ts +++ b/tests/cases/fourslash/referencesForContextuallyTypedUnionProperties2.ts @@ -6,32 +6,40 @@ ////} //// ////interface B { -//// [|b|]: number; +//// [|{| "isWriteAccess": true, "isDefinition": true |}b|]: number; //// common: number; ////} //// ////// Assignment ////var v1: A | B = { a: 0, common: "" }; -////var v2: A | B = { [|b|]: 0, common: 3 }; +////var v2: A | B = { [|{| "isWriteAccess": true, "isDefinition": true, "type": "number" |}b|]: 0, common: 3 }; //// ////// Function call ////function consumer(f: A | B) { } -////consumer({ a: 0, [|b|]: 0, common: 1 }); +////consumer({ a: 0, [|{| "isWriteAccess": true, "isDefinition": true, "type": "number" |}b|]: 0, common: 1 }); //// -////// Type cast -////var c = { common: 0, [|b|]: 0 }; +////// Type cast +////var c = { common: 0, [|{| "isWriteAccess": true, "isDefinition": true, "type": "number" |}b|]: 0 }; //// ////// Array literal -////var ar: Array = [{ a: 0, common: "" }, { [|b|]: 0, common: 0 }]; +////var ar: Array = [{ a: 0, common: "" }, { [|{| "isWriteAccess": true, "isDefinition": true, "type": "number" |}b|]: 0, common: 0 }]; //// ////// Nested object literal -////var ob: { aorb: A|B } = { aorb: { [|b|]: 0, common: 0 } }; +////var ob: { aorb: A|B } = { aorb: { [|{| "isWriteAccess": true, "isDefinition": true, "type": "number" |}b|]: 0, common: 0 } }; //// ////// Widened type -////var w: A|B = { [|b|]:undefined, common: undefined }; +////var w: A|B = { [|{| "isWriteAccess": true, "isDefinition": true, "type": "undefined" |}b|]:undefined, common: undefined }; //// ////// Untped -- should not be included ////var u1 = { a: 0, b: 0, common: "" }; ////var u2 = { b: 0, common: 0 }; -verify.rangesReferenceEachOther(); +const ranges = test.ranges(); +verify.referenceGroups(ranges[0], [{ definition: "(property) B.b: number", ranges }]); +for (const reference of ranges.slice(1)) { + const type = reference.marker.data.type; + verify.referenceGroups(reference, [ + { definition: "(property) B.b: number", ranges: ranges.filter(r => r !== reference) }, + { definition: `(property) b: ${type}`, ranges: [reference] } + ]); +} diff --git a/tests/cases/fourslash/referencesForEnums.ts b/tests/cases/fourslash/referencesForEnums.ts index 3b979bc509..68face36d0 100644 --- a/tests/cases/fourslash/referencesForEnums.ts +++ b/tests/cases/fourslash/referencesForEnums.ts @@ -1,9 +1,9 @@ /// ////enum E { -//// [|value1|] = 1, -//// "[|value2|]" = [|value1|], -//// [|111|] = 11 +//// [|{| "isWriteAccess": true, "isDefinition": true |}value1|] = 1, +//// "[|{| "isDefinition": true |}value2|]" = [|value1|], +//// [|{| "isDefinition": true |}111|] = 11 ////} //// ////E.[|value1|]; @@ -11,4 +11,7 @@ ////E.[|value2|]; ////E[[|111|]]; -verify.rangesWithSameTextReferenceEachOther(); +const r = test.rangesByText(); +verify.singleReferenceGroup("(enum member) E.value1 = 1", r.get("value1")); +verify.singleReferenceGroup("(enum member) E[\"value2\"] = 1", r.get("value2")); +verify.singleReferenceGroup("(enum member) E[111] = 11", r.get("111")); diff --git a/tests/cases/fourslash/referencesForExportedValues.ts b/tests/cases/fourslash/referencesForExportedValues.ts index 315d0b1b58..ff00f84426 100644 --- a/tests/cases/fourslash/referencesForExportedValues.ts +++ b/tests/cases/fourslash/referencesForExportedValues.ts @@ -1,7 +1,7 @@ /// ////module M { -//// export var [|variable|] = 0; +//// export var [|{| "isWriteAccess": true, "isDefinition": true |}variable|] = 0; //// //// // local use //// var x = [|variable|]; @@ -10,4 +10,4 @@ ////// external use ////M.[|variable|] -verify.rangesReferenceEachOther(); +verify.singleReferenceGroup("var M.variable: number"); diff --git a/tests/cases/fourslash/referencesForExternalModuleNames.ts b/tests/cases/fourslash/referencesForExternalModuleNames.ts index ee783c8bd7..5e01eae353 100644 --- a/tests/cases/fourslash/referencesForExternalModuleNames.ts +++ b/tests/cases/fourslash/referencesForExternalModuleNames.ts @@ -3,7 +3,7 @@ // Global interface reference. // @Filename: referencesForGlobals_1.ts -////declare module "[|foo|]" { +////declare module "[|{| "isDefinition": true |}foo|]" { //// var f: number; ////} @@ -11,4 +11,7 @@ // @Filename: referencesForGlobals_2.ts ////import f = require("[|foo|]"); -verify.rangesReferenceEachOther(); +const ranges = test.ranges(); +const [r0, r1] = ranges; +verify.referenceGroups(r0, [{ definition: 'module "foo"', ranges }]); +verify.referenceGroups(r1, [{ definition: 'module f', ranges }]); diff --git a/tests/cases/fourslash/referencesForFunctionOverloads.ts b/tests/cases/fourslash/referencesForFunctionOverloads.ts index d6873643cd..7afa5a2013 100644 --- a/tests/cases/fourslash/referencesForFunctionOverloads.ts +++ b/tests/cases/fourslash/referencesForFunctionOverloads.ts @@ -2,9 +2,9 @@ // Function overloads should be highlighted together. -////function [|foo|](x: string); -////function [|foo|](x: string, y: number) { +////function [|{| "isWriteAccess": true, "isDefinition": true |}foo|](x: string); +////function [|{| "isWriteAccess": true, "isDefinition": true |}foo|](x: string, y: number) { //// [|foo|]('', 43); ////} -verify.rangesReferenceEachOther(); +verify.singleReferenceGroup("function foo(x: string): any"); diff --git a/tests/cases/fourslash/referencesForFunctionParameter.ts b/tests/cases/fourslash/referencesForFunctionParameter.ts index 64d33ca9a6..24582a68e0 100644 --- a/tests/cases/fourslash/referencesForFunctionParameter.ts +++ b/tests/cases/fourslash/referencesForFunctionParameter.ts @@ -3,9 +3,9 @@ ////var x; ////var n; //// -////function n(x: number, [|n|]: number) { -//// [|n|] = 32; +////function n(x: number, [|{| "isWriteAccess": true, "isDefinition": true |}n|]: number) { +//// [|{| "isWriteAccess": true |}n|] = 32; //// x = [|n|]; ////} -verify.rangesReferenceEachOther(); +verify.singleReferenceGroup("(parameter) n: number"); diff --git a/tests/cases/fourslash/referencesForGlobals.ts b/tests/cases/fourslash/referencesForGlobals.ts index f4d7c47976..dc5bc4deb6 100644 --- a/tests/cases/fourslash/referencesForGlobals.ts +++ b/tests/cases/fourslash/referencesForGlobals.ts @@ -3,7 +3,7 @@ // Global variable reference. // @Filename: referencesForGlobals_1.ts -////var [|global|] = 2; +////var [|{| "isWriteAccess": true, "isDefinition": true |}global|] = 2; //// ////class foo { //// constructor (public global) { } @@ -25,4 +25,4 @@ // @Filename: referencesForGlobals_2.ts ////var m = [|global|]; -verify.rangesReferenceEachOther(); +verify.singleReferenceGroup("var global: number"); diff --git a/tests/cases/fourslash/referencesForGlobals2.ts b/tests/cases/fourslash/referencesForGlobals2.ts index 7c6baf5bf6..e08be585c7 100644 --- a/tests/cases/fourslash/referencesForGlobals2.ts +++ b/tests/cases/fourslash/referencesForGlobals2.ts @@ -3,11 +3,11 @@ // Global class reference. // @Filename: referencesForGlobals_1.ts -////class [|globalClass|] { +////class [|{| "isWriteAccess": true, "isDefinition": true |}globalClass|] { //// public f() { } ////} // @Filename: referencesForGlobals_2.ts ////var c = [|globalClass|](); -verify.rangesReferenceEachOther(); +verify.singleReferenceGroup("class globalClass"); diff --git a/tests/cases/fourslash/referencesForGlobals3.ts b/tests/cases/fourslash/referencesForGlobals3.ts index 67e209aaad..38edddc825 100644 --- a/tests/cases/fourslash/referencesForGlobals3.ts +++ b/tests/cases/fourslash/referencesForGlobals3.ts @@ -3,11 +3,11 @@ // Global interface reference. // @Filename: referencesForGlobals_1.ts -////interface [|globalInterface|] { +////interface [|{| "isWriteAccess": true, "isDefinition": true |}globalInterface|] { //// f(); ////} // @Filename: referencesForGlobals_2.ts ////var i: [|globalInterface|]; -verify.rangesReferenceEachOther(); +verify.singleReferenceGroup("interface globalInterface"); diff --git a/tests/cases/fourslash/referencesForGlobals4.ts b/tests/cases/fourslash/referencesForGlobals4.ts index d7acfbd2df..b835646169 100644 --- a/tests/cases/fourslash/referencesForGlobals4.ts +++ b/tests/cases/fourslash/referencesForGlobals4.ts @@ -3,11 +3,11 @@ // Global module reference. // @Filename: referencesForGlobals_1.ts -////module [|globalModule|] { +////module [|{| "isWriteAccess": true, "isDefinition": true |}globalModule|] { //// export f() { }; ////} // @Filename: referencesForGlobals_2.ts ////var m = [|globalModule|]; -verify.rangesReferenceEachOther(); +verify.singleReferenceGroup("namespace globalModule"); diff --git a/tests/cases/fourslash/referencesForGlobals5.ts b/tests/cases/fourslash/referencesForGlobals5.ts index 4db2410f63..d7dd930474 100644 --- a/tests/cases/fourslash/referencesForGlobals5.ts +++ b/tests/cases/fourslash/referencesForGlobals5.ts @@ -7,9 +7,9 @@ //// export var x; ////} //// -////import [|globalAlias|] = globalModule; +////import [|{| "isWriteAccess": true, "isDefinition": true |}globalAlias|] = globalModule; // @Filename: referencesForGlobals_2.ts ////var m = [|globalAlias|]; -verify.rangesReferenceEachOther(); +verify.singleReferenceGroup("import globalAlias = globalModule"); diff --git a/tests/cases/fourslash/referencesForGlobalsInExternalModule.ts b/tests/cases/fourslash/referencesForGlobalsInExternalModule.ts index c2f7042040..5047a2f12a 100644 --- a/tests/cases/fourslash/referencesForGlobalsInExternalModule.ts +++ b/tests/cases/fourslash/referencesForGlobalsInExternalModule.ts @@ -2,20 +2,28 @@ // Global variable reference. -////var [|topLevelVar|] = 2; +////var [|{| "isWriteAccess": true, "isDefinition": true |}topLevelVar|] = 2; ////var topLevelVar2 = [|topLevelVar|]; //// -////class [|topLevelClass|] { } +////class [|{| "isWriteAccess": true, "isDefinition": true |}topLevelClass|] { } ////var c = new [|topLevelClass|](); //// -////interface [|topLevelInterface|] { } +////interface [|{| "isWriteAccess": true, "isDefinition": true |}topLevelInterface|] { } ////var i: [|topLevelInterface|]; //// -////module [|topLevelModule|] { +////module [|{| "isWriteAccess": true, "isDefinition": true |}topLevelModule|] { //// export var x; ////} ////var x = [|topLevelModule|].x; //// ////export = x; -verify.rangesWithSameTextReferenceEachOther(); +const ranges = test.rangesByText(); +verify.singleReferenceGroup("var topLevelVar: number", ranges.get("topLevelVar")); + +const topLevelClass = ranges.get("topLevelClass"); +verify.referenceGroups(topLevelClass[0], [{ definition: "class topLevelClass", ranges: topLevelClass }]); +verify.referenceGroups(topLevelClass[1], [{ definition: "constructor topLevelClass(): topLevelClass", ranges: topLevelClass }]); + +verify.singleReferenceGroup("interface topLevelInterface", ranges.get("topLevelInterface")); +verify.singleReferenceGroup("namespace topLevelModule", ranges.get("topLevelModule")); diff --git a/tests/cases/fourslash/referencesForIllegalAssignment.ts b/tests/cases/fourslash/referencesForIllegalAssignment.ts index 59cb6f4f27..f65cd5bf1a 100644 --- a/tests/cases/fourslash/referencesForIllegalAssignment.ts +++ b/tests/cases/fourslash/referencesForIllegalAssignment.ts @@ -2,13 +2,13 @@ ////f/*1*/oo = fo/*2*/o; -////var [|bar|] = function () { }; -////[|bar|] = [|bar|] + 1; +////var [|{| "isWriteAccess": true, "isDefinition": true |}bar|] = function () { }; +////[|{| "isWriteAccess": true |}bar|] = [|bar|] + 1; goTo.marker("1"); -verify.referencesAre([]); +verify.noReferences(); goTo.marker("2"); -verify.referencesAre([]); +verify.noReferences(); -verify.rangesReferenceEachOther(); +verify.singleReferenceGroup("var bar: () => void"); diff --git a/tests/cases/fourslash/referencesForImports.ts b/tests/cases/fourslash/referencesForImports.ts index 0203bcee09..54cbb0f115 100644 --- a/tests/cases/fourslash/referencesForImports.ts +++ b/tests/cases/fourslash/referencesForImports.ts @@ -5,11 +5,11 @@ //// export = $; ////} -////import [|$|] = require("jquery"); +////import [|{| "isWriteAccess": true, "isDefinition": true |}$|] = require("jquery"); ////[|$|]("a"); -////import [|$|] = require("jquery"); +////import [|{| "isWriteAccess": true, "isDefinition": true |}$|] = require("jquery"); const [r0, r1, r2] = test.ranges(); -verify.rangesReferenceEachOther([r0, r1]); -verify.referencesOf(r2, [r2]); +verify.singleReferenceGroup('import $ = require("jquery")', [r0, r1]); +verify.singleReferenceGroup('import $ = require("jquery")', [r2]); diff --git a/tests/cases/fourslash/referencesForIndexProperty.ts b/tests/cases/fourslash/referencesForIndexProperty.ts index 49d12c2581..dba2549e41 100644 --- a/tests/cases/fourslash/referencesForIndexProperty.ts +++ b/tests/cases/fourslash/referencesForIndexProperty.ts @@ -3,12 +3,14 @@ // References a class property using string index access ////class Foo { -//// [|property|]: number; -//// [|method|](): void { } +//// [|{| "isWriteAccess": true, "isDefinition": true |}property|]: number; +//// [|{| "isWriteAccess": true, "isDefinition": true |}method|](): void { } ////} //// ////var f: Foo; ////f["[|property|]"]; ////f["[|method|]"]; -verify.rangesWithSameTextReferenceEachOther(); +const ranges = test.rangesByText(); +verify.singleReferenceGroup("(property) Foo.property: number", ranges.get("property")); +verify.singleReferenceGroup("(method) Foo.method(): void", ranges.get("method")); diff --git a/tests/cases/fourslash/referencesForIndexProperty2.ts b/tests/cases/fourslash/referencesForIndexProperty2.ts index 35c9d7cdd6..a4d5c75a90 100644 --- a/tests/cases/fourslash/referencesForIndexProperty2.ts +++ b/tests/cases/fourslash/referencesForIndexProperty2.ts @@ -5,4 +5,4 @@ ////var a; ////a["[|blah|]"]; -verify.rangesReferenceEachOther(); +verify.singleReferenceGroup('"blah"'); diff --git a/tests/cases/fourslash/referencesForIndexProperty3.ts b/tests/cases/fourslash/referencesForIndexProperty3.ts index 1fdee9b660..a2e008c937 100644 --- a/tests/cases/fourslash/referencesForIndexProperty3.ts +++ b/tests/cases/fourslash/referencesForIndexProperty3.ts @@ -3,7 +3,7 @@ // References to a property of the apparent type using string indexer ////interface Object { -//// [|toMyString|](); +//// [|{| "isWriteAccess": true, "isDefinition": true |}toMyString|](); ////} //// ////var y: Object; @@ -12,4 +12,4 @@ ////var x = {}; ////x["[|toMyString|]"](); -verify.rangesReferenceEachOther(); +verify.singleReferenceGroup("(method) Object.toMyString(): any"); diff --git a/tests/cases/fourslash/referencesForInheritedProperties.ts b/tests/cases/fourslash/referencesForInheritedProperties.ts index 19fef4066e..c2674fe1fe 100644 --- a/tests/cases/fourslash/referencesForInheritedProperties.ts +++ b/tests/cases/fourslash/referencesForInheritedProperties.ts @@ -1,15 +1,15 @@ /// ////interface interface1 { -//// [|doStuff|](): void; +//// [|{| "isWriteAccess": true, "isDefinition": true |}doStuff|](): void; ////} //// ////interface interface2 extends interface1{ -//// [|doStuff|](): void; +//// [|{| "isWriteAccess": true, "isDefinition": true |}doStuff|](): void; ////} //// ////class class1 implements interface2 { -//// [|doStuff|]() { +//// [|{| "isWriteAccess": true, "isDefinition": true |}doStuff|]() { //// //// } ////} @@ -21,4 +21,21 @@ ////var v: class2; ////v.[|doStuff|](); -verify.rangesWithSameTextReferenceEachOther(); +const ranges = test.ranges(); +const [r0, r1, r2, r3] = ranges; +verify.referenceGroups(r0, [{ definition: "(method) interface1.doStuff(): void", ranges }]); +verify.referenceGroups(r1, [ + { definition: "(method) interface1.doStuff(): void", ranges: [r0] }, + { definition: "(method) interface2.doStuff(): void", ranges: [r1, r2, r3] } +]); +verify.referenceGroups(r2, [ + { definition: "(method) interface1.doStuff(): void", ranges: [r0] }, + { definition: "(method) interface2.doStuff(): void", ranges: [r1] }, + { definition: "(method) class1.doStuff(): void", ranges: [r2, r3] } +]); +verify.referenceGroups(r3, [ + { definition: "(method) interface1.doStuff(): void", ranges: [r0] }, + { definition: "(method) interface2.doStuff(): void", ranges: [r1] }, + { definition: "(method) class1.doStuff(): void", ranges: [r2] }, + { definition: "(method) class1.doStuff(): void", ranges: [r3] } +]); diff --git a/tests/cases/fourslash/referencesForInheritedProperties2.ts b/tests/cases/fourslash/referencesForInheritedProperties2.ts index 33a7f26aae..0f89a9aa74 100644 --- a/tests/cases/fourslash/referencesForInheritedProperties2.ts +++ b/tests/cases/fourslash/referencesForInheritedProperties2.ts @@ -3,18 +3,18 @@ // extends statement in a diffrent declaration ////interface interface1 { -//// [|doStuff|](): void; +//// [|{| "isWriteAccess": true, "isDefinition": true |}doStuff|](): void; ////} //// ////interface interface2 { -//// [|doStuff|](): void; +//// [|{| "isWriteAccess": true, "isDefinition": true |}doStuff|](): void; ////} //// ////interface interface2 extends interface1 { ////} //// ////class class1 implements interface2 { -//// [|doStuff|]() { +//// [|{| "isWriteAccess": true, "isDefinition": true |}doStuff|]() { //// //// } ////} @@ -26,4 +26,21 @@ ////var v: class2; ////v.[|doStuff|](); -verify.rangesReferenceEachOther(); +const ranges = test.ranges(); +const [r0, r1, r2, r3] = ranges; +verify.referenceGroups(r0, [{ definition: "(method) interface1.doStuff(): void", ranges }]); +verify.referenceGroups(r1, [ + { definition: "(method) interface1.doStuff(): void", ranges: [r0] }, + { definition: "(method) interface2.doStuff(): void", ranges: [r1, r2, r3] } +]); +verify.referenceGroups(r2, [ + { definition: "(method) interface1.doStuff(): void", ranges: [r0] }, + { definition: "(method) interface2.doStuff(): void", ranges: [r1] }, + { definition: "(method) class1.doStuff(): void", ranges: [r2, r3] } +]); +verify.referenceGroups(r3, [ + { definition: "(method) interface1.doStuff(): void", ranges: [r0] }, + { definition: "(method) interface2.doStuff(): void", ranges: [r1] }, + { definition: "(method) class1.doStuff(): void", ranges: [r2] }, + { definition: "(method) class1.doStuff(): void", ranges: [r3] } +]); diff --git a/tests/cases/fourslash/referencesForInheritedProperties3.ts b/tests/cases/fourslash/referencesForInheritedProperties3.ts index 3a2d11da69..c6c870ca35 100644 --- a/tests/cases/fourslash/referencesForInheritedProperties3.ts +++ b/tests/cases/fourslash/referencesForInheritedProperties3.ts @@ -1,12 +1,14 @@ /// //// interface interface1 extends interface1 { -//// [|doStuff|](): void; -//// [|propName|]: string; +//// [|{| "isWriteAccess": true, "isDefinition": true |}doStuff|](): void; +//// [|{| "isWriteAccess": true, "isDefinition": true |}propName|]: string; //// } //// //// var v: interface1; //// v.[|propName|]; //// v.[|doStuff|](); -verify.rangesWithSameTextReferenceEachOther(); +const ranges = test.rangesByText(); +verify.singleReferenceGroup("(method) interface1.doStuff(): void", ranges.get("doStuff")); +verify.singleReferenceGroup("(property) interface1.propName: string", ranges.get("propName")); diff --git a/tests/cases/fourslash/referencesForInheritedProperties4.ts b/tests/cases/fourslash/referencesForInheritedProperties4.ts index 96010d0508..8a822ec523 100644 --- a/tests/cases/fourslash/referencesForInheritedProperties4.ts +++ b/tests/cases/fourslash/referencesForInheritedProperties4.ts @@ -1,12 +1,21 @@ /// //// class class1 extends class1 { -//// [|doStuff|]() { } -//// [|propName|]: string; +//// [|{| "isWriteAccess": true, "isDefinition": true |}doStuff|]() { } +//// [|{| "isWriteAccess": true, "isDefinition": true |}propName|]: string; //// } //// //// var c: class1; //// c.[|doStuff|](); //// c.[|propName|]; -verify.rangesWithSameTextReferenceEachOther(); +const ranges = test.rangesByText(); +const [r0, r1] = ranges.get("doStuff"); +verify.referenceGroups(r0, [ + { definition: "(method) class1.doStuff(): void", ranges: [r0, r1] }, +]); +verify.referenceGroups(r1, [ + { definition: "(method) class1.doStuff(): void", ranges: [r0] }, + { definition: "(method) class1.doStuff(): void", ranges: [r1] }, +]); +verify.singleReferenceGroup("(property) class1.propName: string", ranges.get("propName")); diff --git a/tests/cases/fourslash/referencesForInheritedProperties5.ts b/tests/cases/fourslash/referencesForInheritedProperties5.ts index bbb86f0def..7a5cff0ad2 100644 --- a/tests/cases/fourslash/referencesForInheritedProperties5.ts +++ b/tests/cases/fourslash/referencesForInheritedProperties5.ts @@ -1,16 +1,28 @@ /// //// interface interface1 extends interface1 { -//// [|doStuff|](): void; -//// [|propName|]: string; +//// [|{| "isWriteAccess": true, "isDefinition": true |}doStuff|](): void; +//// [|{| "isWriteAccess": true, "isDefinition": true |}propName|]: string; //// } //// interface interface2 extends interface1 { -//// [|doStuff|](): void; -//// [|propName|]: string; +//// [|{| "isWriteAccess": true, "isDefinition": true |}doStuff|](): void; +//// [|{| "isWriteAccess": true, "isDefinition": true |}propName|]: string; //// } //// //// var v: interface1; //// v.[|propName|]; //// v.[|doStuff|](); -verify.rangesWithSameTextReferenceEachOther(); +const ranges = test.rangesByText(); +const [m0, m1, m2] = ranges.get("doStuff"); +const [p0, p1, p2] = ranges.get("propName"); +verify.referenceGroups([m0, m2], [{ definition: "(method) interface1.doStuff(): void", ranges: [m0, m1, m2] }]); +verify.referenceGroups(m1, [ + { definition: "(method) interface1.doStuff(): void", ranges: [m0, m2] }, + { definition: "(method) interface2.doStuff(): void", ranges: [m1] } +]); +verify.referenceGroups([p0, p2], [{ definition: "(property) interface1.propName: string", ranges: [p0, p1, p2] }]); +verify.referenceGroups(p1, [ + { definition: "(property) interface1.propName: string", ranges: [p0, p2] }, + { definition: "(property) interface2.propName: string", ranges: [p1] } +]); diff --git a/tests/cases/fourslash/referencesForInheritedProperties6.ts b/tests/cases/fourslash/referencesForInheritedProperties6.ts index ff008cceb4..a39dc085c7 100644 --- a/tests/cases/fourslash/referencesForInheritedProperties6.ts +++ b/tests/cases/fourslash/referencesForInheritedProperties6.ts @@ -1,16 +1,27 @@ /// //// class class1 extends class1 { -//// [|doStuff|]() { } -//// [|propName|]: string; +//// [|{| "isWriteAccess": true, "isDefinition": true |}doStuff|]() { } +//// [|{| "isWriteAccess": true, "isDefinition": true |}propName|]: string; //// } //// class class2 extends class1 { -//// [|doStuff|]() { } -//// [|propName|]: string; +//// [|{| "isWriteAccess": true, "isDefinition": true |}doStuff|]() { } +//// [|{| "isWriteAccess": true, "isDefinition": true |}propName|]: string; //// } //// //// var v: class2; //// v.[|propName|]; //// v.[|doStuff|](); -verify.rangesWithSameTextReferenceEachOther(); +const ranges = test.rangesByText(); +const [m0, m1, m2] = ranges.get("doStuff"); +verify.referenceGroups(m0, [{ definition: "(method) class1.doStuff(): void", ranges: [m0, m1, m2] }]); +verify.referenceGroups(m1, [ + { definition: "(method) class1.doStuff(): void", ranges: [m0] }, + { definition: "(method) class2.doStuff(): void", ranges: [m1, m2] } +]); +verify.referenceGroups(m2, [ + { definition: "(method) class1.doStuff(): void", ranges: [m0] }, + { definition: "(method) class2.doStuff(): void", ranges: [m1] }, + { definition: "(method) class2.doStuff(): void", ranges: [m2] } +]); diff --git a/tests/cases/fourslash/referencesForInheritedProperties7.ts b/tests/cases/fourslash/referencesForInheritedProperties7.ts index ec92a06f0a..4911cbefd5 100644 --- a/tests/cases/fourslash/referencesForInheritedProperties7.ts +++ b/tests/cases/fourslash/referencesForInheritedProperties7.ts @@ -1,30 +1,40 @@ /// //// class class1 extends class1 { -//// [|doStuff|]() { } -//// [|propName|]: string; +//// [|{| "isWriteAccess": true, "isDefinition": true |}doStuff|]() { } +//// [|{| "isWriteAccess": true, "isDefinition": true |}propName|]: string; //// } //// interface interface1 extends interface1 { -//// [|doStuff|](): void; -//// [|propName|]: string; +//// [|{| "isWriteAccess": true, "isDefinition": true |}doStuff|](): void; +//// [|{| "isWriteAccess": true, "isDefinition": true |}propName|]: string; //// } //// class class2 extends class1 implements interface1 { -//// [|doStuff|]() { } -//// [|propName|]: string; +//// [|{| "isWriteAccess": true, "isDefinition": true |}doStuff|]() { } +//// [|{| "isWriteAccess": true, "isDefinition": true |}propName|]: string; //// } //// //// var v: class2; -//// v.[|propName|]; //// v.[|doStuff|](); +//// v.[|propName|]; const [r0, r1, r2, r3, r4, r5, r6, r7] = test.ranges(); -verify.referencesOf(r0, [r0, r4, r7]); -verify.referencesOf(r1, [r1, r5, r6]); -verify.referencesOf(r2, [r2, r4, r7]); -verify.referencesOf(r3, [r3, r5, r6]); -const allDoStuff = [r0, r2, r4, r7]; -verify.referencesOf(r4, allDoStuff); -const allPropName = [r1, r3, r5, r6]; -verify.referencesOf(r5, allPropName); -verify.referencesOf(r6, allPropName); -verify.referencesOf(r7, allDoStuff); +verify.referenceGroups(r0, [{ definition: "(method) class1.doStuff(): void", ranges: [r0, r4, r6] }]); +verify.referenceGroups(r1, [{ definition: "(property) class1.propName: string", ranges: [r1, r5, r7] }]); +verify.referenceGroups(r2, [{ definition: "(method) interface1.doStuff(): void", ranges: [r2, r4, r6] }]); +verify.referenceGroups(r3, [{ definition: "(property) interface1.propName: string", ranges: [r3, r5, r7] }]); +verify.referenceGroups(r4, [ + { definition: "(method) class1.doStuff(): void", ranges: [r0] }, + { definition: "(method) interface1.doStuff(): void", ranges: [r2] }, + { definition: "(method) class2.doStuff(): void", ranges: [r4, r6] } +]); +verify.referenceGroups([r5, r7], [ + { definition: "(property) class1.propName: string", ranges: [r1] }, + { definition: "(property) interface1.propName: string", ranges: [r3] }, + { definition: "(property) class2.propName: string", ranges: [r5, r7] } +]); +verify.referenceGroups(r6, [ + { definition: "(method) class1.doStuff(): void", ranges: [r0] }, + { definition: "(method) interface1.doStuff(): void", ranges: [r2] }, + { definition: "(method) class2.doStuff(): void", ranges: [r4] }, + { definition: "(method) class2.doStuff(): void", ranges: [r6] } +]); diff --git a/tests/cases/fourslash/referencesForInheritedProperties8.ts b/tests/cases/fourslash/referencesForInheritedProperties8.ts index 964309fc47..d0d94b49b5 100644 --- a/tests/cases/fourslash/referencesForInheritedProperties8.ts +++ b/tests/cases/fourslash/referencesForInheritedProperties8.ts @@ -1,16 +1,19 @@ /// //// interface C extends D { -//// [|propD|]: number; +//// [|{| "isWriteAccess": true, "isDefinition": true |}propD|]: number; //// } //// interface D extends C { -//// [|propD|]: string; -//// [|propC|]: number; +//// [|{| "isWriteAccess": true, "isDefinition": true |}propD|]: string; +//// [|{| "isWriteAccess": true, "isDefinition": true |}propC|]: number; //// } //// var d: D; //// d.[|propD|]; //// d.[|propC|]; const [d0, d1, c0, d2, c1] = test.ranges(); -verify.rangesReferenceEachOther([d0, d1, d2]); -verify.rangesReferenceEachOther([c0, c1]); +verify.referenceGroups([d0, d1, d2], [ + { definition: "(property) C.propD: number", ranges: [d0] }, + { definition: "(property) D.propD: string", ranges: [d1, d2] }, +]); +verify.singleReferenceGroup("(property) D.propC: number", [c0, c1]); diff --git a/tests/cases/fourslash/referencesForInheritedProperties9.ts b/tests/cases/fourslash/referencesForInheritedProperties9.ts index 7d4330d0aa..27bc164a8f 100644 --- a/tests/cases/fourslash/referencesForInheritedProperties9.ts +++ b/tests/cases/fourslash/referencesForInheritedProperties9.ts @@ -1,16 +1,16 @@ /// //// class D extends C { -//// [|prop1|]: string; +//// [|{| "isWriteAccess": true, "isDefinition": true |}prop1|]: string; //// } -//// +//// //// class C extends D { -//// [|prop1|]: string; +//// [|{| "isWriteAccess": true, "isDefinition": true |}prop1|]: string; //// } -//// +//// //// var c: C; //// c.[|prop1|]; const [r0, r1, r2] = test.ranges(); -verify.referencesOf(r0, [r0]); -verify.rangesReferenceEachOther([r1, r2]); +verify.singleReferenceGroup("(property) D.prop1: string", [r0]); +verify.singleReferenceGroup("(property) C.prop1: string", [r1, r2]); diff --git a/tests/cases/fourslash/referencesForLabel.ts b/tests/cases/fourslash/referencesForLabel.ts index 14b58fd1d9..1abcafda0f 100644 --- a/tests/cases/fourslash/referencesForLabel.ts +++ b/tests/cases/fourslash/referencesForLabel.ts @@ -11,5 +11,5 @@ ////var label = "label"; const [r0, r1, r2, r3] = test.ranges(); -verify.rangesReferenceEachOther([r0, r1, r2]); -verify.referencesOf(r3, [r3]); +verify.singleReferenceGroup("label", [r0, r1, r2]); +verify.singleReferenceGroup("label", [r3]); diff --git a/tests/cases/fourslash/referencesForLabel2.ts b/tests/cases/fourslash/referencesForLabel2.ts index 841e35ad70..6f3721431e 100644 --- a/tests/cases/fourslash/referencesForLabel2.ts +++ b/tests/cases/fourslash/referencesForLabel2.ts @@ -8,5 +8,4 @@ //// if (true) continue label; ////} -goTo.marker(); -verify.referencesAre([]); +verify.noReferences(""); diff --git a/tests/cases/fourslash/referencesForLabel3.ts b/tests/cases/fourslash/referencesForLabel3.ts index fb7a51f858..13622eb90c 100644 --- a/tests/cases/fourslash/referencesForLabel3.ts +++ b/tests/cases/fourslash/referencesForLabel3.ts @@ -6,5 +6,4 @@ //// var label = "label"; ////} -const [label] = test.ranges(); -verify.referencesOf(label, [label]); +verify.singleReferenceGroup("label"); diff --git a/tests/cases/fourslash/referencesForLabel4.ts b/tests/cases/fourslash/referencesForLabel4.ts index 5462500f53..2ff159bc75 100644 --- a/tests/cases/fourslash/referencesForLabel4.ts +++ b/tests/cases/fourslash/referencesForLabel4.ts @@ -8,4 +8,4 @@ //// } ////} -verify.rangesReferenceEachOther(); +verify.singleReferenceGroup("label"); diff --git a/tests/cases/fourslash/referencesForLabel5.ts b/tests/cases/fourslash/referencesForLabel5.ts index 48d5aab04c..bc986e3350 100644 --- a/tests/cases/fourslash/referencesForLabel5.ts +++ b/tests/cases/fourslash/referencesForLabel5.ts @@ -13,5 +13,5 @@ //// } const [outer1, outer2, inner1, inner2, outer3] = test.ranges(); -verify.rangesReferenceEachOther([outer1, outer2, outer3]); -verify.rangesReferenceEachOther([inner1, inner2]); +verify.singleReferenceGroup("label", [outer1, outer2, outer3]); +verify.singleReferenceGroup("label", [inner1, inner2]); diff --git a/tests/cases/fourslash/referencesForLabel6.ts b/tests/cases/fourslash/referencesForLabel6.ts index aea4580575..0255c07943 100644 --- a/tests/cases/fourslash/referencesForLabel6.ts +++ b/tests/cases/fourslash/referencesForLabel6.ts @@ -7,6 +7,6 @@ //// break labelc; ////} -const [a, b, useB] = test.ranges(); -verify.referencesOf(a, [a]); -verify.rangesReferenceEachOther([b, useB]); +const ranges = test.rangesByText(); +verify.singleReferenceGroup("labela", ranges.get("labela")); +verify.singleReferenceGroup("labelb", ranges.get("labelb")); diff --git a/tests/cases/fourslash/referencesForMergedDeclarations.ts b/tests/cases/fourslash/referencesForMergedDeclarations.ts index 8a0a5d4c68..3e2fe8e4b2 100644 --- a/tests/cases/fourslash/referencesForMergedDeclarations.ts +++ b/tests/cases/fourslash/referencesForMergedDeclarations.ts @@ -1,13 +1,13 @@ /// -////interface [|Foo|] { +////interface [|{| "isWriteAccess": true, "isDefinition": true |}Foo|] { ////} //// -////module [|Foo|] { +////module [|{| "isWriteAccess": true, "isDefinition": true |}Foo|] { //// export interface Bar { } ////} //// -////function [|Foo|](): void { +////function [|{| "isWriteAccess": true, "isDefinition": true |}Foo|](): void { ////} //// ////var f1: [|Foo|].Bar; @@ -15,6 +15,7 @@ ////[|Foo|].bind(this); const [type1, namespace1, value1, namespace2, type2, value2] = test.ranges(); -verify.rangesReferenceEachOther([type1, type2]); -verify.rangesReferenceEachOther([namespace1, namespace2]); -verify.rangesReferenceEachOther([value1, value2]); +verify.singleReferenceGroup("interface Foo\nnamespace Foo\nfunction Foo(): void", [type1, type2]); +verify.singleReferenceGroup("namespace Foo\nfunction Foo(): void", [namespace1, namespace2]); +verify.referenceGroups(value1, [{ definition: "function Foo(): void\nnamespace Foo", ranges: [value1, value2] }]); +verify.referenceGroups(value2, [{ definition: "namespace Foo\nfunction Foo(): void", ranges: [value1, value2] }]); diff --git a/tests/cases/fourslash/referencesForMergedDeclarations2.ts b/tests/cases/fourslash/referencesForMergedDeclarations2.ts index 75d485002a..5cf9234511 100644 --- a/tests/cases/fourslash/referencesForMergedDeclarations2.ts +++ b/tests/cases/fourslash/referencesForMergedDeclarations2.ts @@ -6,9 +6,9 @@ //// ////function ATest() { } //// -////import [|alias|] = ATest; // definition +////import [|{| "isWriteAccess": true, "isDefinition": true |}alias|] = ATest; // definition //// ////var a: [|alias|].Bar; // namespace ////[|alias|].call(this); // value -verify.rangesReferenceEachOther(); +verify.singleReferenceGroup("import alias = ATest"); diff --git a/tests/cases/fourslash/referencesForMergedDeclarations3.ts b/tests/cases/fourslash/referencesForMergedDeclarations3.ts index 181d68e79b..5ce024258e 100644 --- a/tests/cases/fourslash/referencesForMergedDeclarations3.ts +++ b/tests/cases/fourslash/referencesForMergedDeclarations3.ts @@ -1,13 +1,13 @@ /// -// class and uninstanciated module +// class and uninstantiated module -////class [|testClass|] { +////class [|{| "isWriteAccess": true, "isDefinition": true |}testClass|] { //// static staticMethod() { } //// method() { } ////} //// -////module [|testClass|] { +////module [|{| "isWriteAccess": true, "isDefinition": true |}testClass|] { //// export interface Bar { //// //// } @@ -21,5 +21,7 @@ ////new [|testClass|](); const [class0, module0, class1, module1, class2, class3, class4, class5] = test.ranges(); -verify.rangesReferenceEachOther([module0, module1]); -verify.rangesReferenceEachOther([class0, class1, class2, class3, class4, class5]); +verify.singleReferenceGroup("class testClass\nnamespace testClass", [module0, module1]); +const classes = [class0, class1, class2, class3, class4, class5]; +verify.referenceGroups(classes.slice(0, 5), [{ definition: "class testClass\nnamespace testClass", ranges: classes }]); +verify.referenceGroups(class5, [{ definition: "constructor testClass(): testClass\nnamespace testClass", ranges: classes }]); diff --git a/tests/cases/fourslash/referencesForMergedDeclarations4.ts b/tests/cases/fourslash/referencesForMergedDeclarations4.ts index d35cbea745..55eb331dd9 100644 --- a/tests/cases/fourslash/referencesForMergedDeclarations4.ts +++ b/tests/cases/fourslash/referencesForMergedDeclarations4.ts @@ -1,13 +1,13 @@ /// -// class and instanciated module +// class and instantiated module -////class [|testClass|] { +////class [|{| "isWriteAccess": true, "isDefinition": true |}testClass|] { //// static staticMethod() { } //// method() { } ////} //// -////module [|testClass|] { +////module [|{| "isWriteAccess": true, "isDefinition": true |}testClass|] { //// export interface Bar { //// //// } @@ -22,4 +22,6 @@ ////[|testClass|].s; ////new [|testClass|](); -verify.rangesReferenceEachOther(); +const ranges = test.ranges(); +verify.referenceGroups(ranges.slice(0, 8), [{ definition: "class testClass\nnamespace testClass", ranges }]); +verify.referenceGroups(ranges[8], [{ definition: "constructor testClass(): testClass\nnamespace testClass", ranges }]); diff --git a/tests/cases/fourslash/referencesForMergedDeclarations5.ts b/tests/cases/fourslash/referencesForMergedDeclarations5.ts index 8fe33ca31e..8cf597333b 100644 --- a/tests/cases/fourslash/referencesForMergedDeclarations5.ts +++ b/tests/cases/fourslash/referencesForMergedDeclarations5.ts @@ -1,10 +1,14 @@ /// -////interface [|Foo|] { } -////module [|Foo|] { export interface Bar { } } -////function [|Foo|]() { } +////interface [|{| "isWriteAccess": true, "isDefinition": true |}Foo|] { } +////module [|{| "isWriteAccess": true, "isDefinition": true |}Foo|] { export interface Bar { } } +////function [|{| "isWriteAccess": true, "isDefinition": true |}Foo|]() { } //// ////export = [|Foo|]; -const [r0, r1, r2, r3] = test.ranges(); -verify.referencesOf(r3, [r0, r1, r2, r3]); +const ranges = test.ranges(); +const [r0, r1, r2, r3] = ranges; +verify.referenceGroups(r0, [{ definition: "interface Foo\nnamespace Foo\nfunction Foo(): void", ranges: [r0, r3] }]); +verify.referenceGroups(r1, [{ definition: "namespace Foo\nfunction Foo(): void", ranges: [r1, r3] }]); +verify.referenceGroups(r2, [{ definition: "function Foo(): void\nnamespace Foo", ranges: [r2, r3] }]); +verify.referenceGroups(r3, [{ definition: "interface Foo\nnamespace Foo\nfunction Foo(): void", ranges }]); diff --git a/tests/cases/fourslash/referencesForMergedDeclarations6.ts b/tests/cases/fourslash/referencesForMergedDeclarations6.ts index e4b5b9111c..79ee0128ab 100644 --- a/tests/cases/fourslash/referencesForMergedDeclarations6.ts +++ b/tests/cases/fourslash/referencesForMergedDeclarations6.ts @@ -1,7 +1,7 @@ /// ////interface Foo { } -////module [|Foo|] { +////module [|{| "isWriteAccess": true, "isDefinition": true |}Foo|] { //// export interface Bar { } //// export module Bar { export interface Baz { } } //// export function Bar() { } @@ -10,4 +10,4 @@ ////// module ////import a1 = [|Foo|]; -verify.rangesReferenceEachOther(); +verify.singleReferenceGroup("namespace Foo"); diff --git a/tests/cases/fourslash/referencesForMergedDeclarations7.ts b/tests/cases/fourslash/referencesForMergedDeclarations7.ts index bc56b5d6f9..66acffde98 100644 --- a/tests/cases/fourslash/referencesForMergedDeclarations7.ts +++ b/tests/cases/fourslash/referencesForMergedDeclarations7.ts @@ -2,13 +2,17 @@ ////interface Foo { } ////module Foo { -//// export interface [|Bar|] { } -//// export module [|Bar|] { export interface Baz { } } -//// export function [|Bar|]() { } +//// export interface [|{| "isWriteAccess": true, "isDefinition": true |}Bar|] { } +//// export module [|{| "isWriteAccess": true, "isDefinition": true |}Bar|] { export interface Baz { } } +//// export function [|{| "isWriteAccess": true, "isDefinition": true |}Bar|]() { } ////} //// ////// module, value and type ////import a2 = Foo.[|Bar|]; -const [r0, r1, r2, r3] = test.ranges(); -verify.referencesOf(r3, [r0, r1, r2, r3]); +const ranges = test.ranges(); +const [r0, r1, r2, r3] = ranges; +verify.referenceGroups(r0, [{ definition: "interface Foo.Bar\nnamespace Foo.Bar\nfunction Foo.Bar(): void", ranges: [r0, r3] }]); +verify.referenceGroups(r1, [{ definition: "namespace Foo.Bar\nfunction Foo.Bar(): void", ranges: [r1, r3] }]); +verify.referenceGroups(r2, [{ definition: "function Foo.Bar(): void\nnamespace Foo.Bar", ranges: [r2, r3] }]); +verify.referenceGroups(r3, [{ definition: "interface Foo.Bar\nnamespace Foo.Bar\nfunction Foo.Bar(): void", ranges }]); diff --git a/tests/cases/fourslash/referencesForMergedDeclarations8.ts b/tests/cases/fourslash/referencesForMergedDeclarations8.ts index b5b1428b7c..742561e21c 100644 --- a/tests/cases/fourslash/referencesForMergedDeclarations8.ts +++ b/tests/cases/fourslash/referencesForMergedDeclarations8.ts @@ -3,11 +3,11 @@ ////interface Foo { } ////module Foo { //// export interface Bar { } -//// export module [|Bar|] { export interface Baz { } } +//// export module [|{| "isWriteAccess": true, "isDefinition": true |}Bar|] { export interface Baz { } } //// export function Bar() { } ////} //// ////// module ////import a3 = Foo.[|Bar|].Baz; -verify.rangesReferenceEachOther(); +verify.singleReferenceGroup("namespace Foo.Bar\nfunction Foo.Bar(): void"); diff --git a/tests/cases/fourslash/referencesForNoContext.ts b/tests/cases/fourslash/referencesForNoContext.ts index 4631ce50c1..2ea5765616 100644 --- a/tests/cases/fourslash/referencesForNoContext.ts +++ b/tests/cases/fourslash/referencesForNoContext.ts @@ -21,14 +21,4 @@ //// } ////} -goTo.marker("1"); -verify.referencesAre([]); - -goTo.marker("2"); -verify.referencesAre([]); - -goTo.marker("3"); -verify.referencesAre([]); - -goTo.marker("4"); -verify.referencesAre([]); +goTo.eachMarker(() => verify.noReferences()); diff --git a/tests/cases/fourslash/referencesForNumericLiteralPropertyNames.ts b/tests/cases/fourslash/referencesForNumericLiteralPropertyNames.ts index 5e6e817209..effa4abc16 100644 --- a/tests/cases/fourslash/referencesForNumericLiteralPropertyNames.ts +++ b/tests/cases/fourslash/referencesForNumericLiteralPropertyNames.ts @@ -1,12 +1,23 @@ /// ////class Foo { -//// public [|12|]: any; +//// public [|{| "isDefinition": true |}12|]: any; ////} //// ////var x: Foo; ////x[[|12|]]; -////x = { "[|12|]": 0 }; -////x = { [|12|]: 0 }; +////x = { "[|{| "isDefinition": true |}12|]": 0 }; +////x = { [|{| "isDefinition": true |}12|]: 0 }; -verify.rangesReferenceEachOther(); +//verify.singleReferenceGroup("(property) Foo[12]: any"); +const ranges = test.ranges(); +const [r0, r1, r2, r3] = ranges; +verify.referenceGroups([r0, r1], [{ definition: "(property) Foo[12]: any", ranges }]); +verify.referenceGroups(r2, [ + { definition: "(property) Foo[12]: any", ranges: [r0, r1, r3] }, + { definition: "(property) \"12\": number", ranges: [r2] } +]); +verify.referenceGroups(r3, [ + { definition: "(property) Foo[12]: any", ranges: [r0, r1, r2] }, + { definition: "(property) 12: number", ranges: [r3] } +]); diff --git a/tests/cases/fourslash/referencesForObjectLiteralProperties.ts b/tests/cases/fourslash/referencesForObjectLiteralProperties.ts index f2a815e845..ea7c20829a 100644 --- a/tests/cases/fourslash/referencesForObjectLiteralProperties.ts +++ b/tests/cases/fourslash/referencesForObjectLiteralProperties.ts @@ -2,10 +2,16 @@ // References to an object literal property -////var x = { [|add|]: 0, b: "string" }; +////var x = { [|{| "isWriteAccess": true, "isDefinition": true |}add|]: 0, b: "string" }; ////x["[|add|]"]; ////x.[|add|]; ////var y = x; ////y.[|add|]; -verify.rangesReferenceEachOther(); +const ranges = test.ranges(); +const [r0, r1, r2, r3] = ranges; +verify.referenceGroups(r0, [{ definition: "(property) add: number", ranges }]); +verify.referenceGroups([r1, r2, r3], [ + { definition: "(property) add: number", ranges: [r0] }, + { definition: "(property) add: number", ranges: [r1, r2, r3] } +]); diff --git a/tests/cases/fourslash/referencesForOverrides.ts b/tests/cases/fourslash/referencesForOverrides.ts index 4896bd1cd3..5ce6bc5ed0 100644 --- a/tests/cases/fourslash/referencesForOverrides.ts +++ b/tests/cases/fourslash/referencesForOverrides.ts @@ -3,59 +3,59 @@ ////module FindRef3 { //// module SimpleClassTest { //// export class Foo { -//// public [|foo|](): void { +//// public [|{| "isWriteAccess": true, "isDefinition": true |}foo|](): void { //// } //// } //// export class Bar extends Foo { -//// public [|foo|](): void { +//// public [|{| "isWriteAccess": true, "isDefinition": true |}foo|](): void { //// } //// } //// } //// //// module SimpleInterfaceTest { //// export interface IFoo { -//// [|ifoo|](): void; +//// [|{| "isWriteAccess": true, "isDefinition": true |}ifoo|](): void; //// } //// export interface IBar extends IFoo { -//// [|ifoo|](): void; +//// [|{| "isWriteAccess": true, "isDefinition": true |}ifoo|](): void; //// } //// } //// //// module SimpleClassInterfaceTest { //// export interface IFoo { -//// [|icfoo|](): void; +//// [|{| "isWriteAccess": true, "isDefinition": true |}icfoo|](): void; //// } //// export class Bar implements IFoo { -//// public [|icfoo|](): void { +//// public [|{| "isWriteAccess": true, "isDefinition": true |}icfoo|](): void { //// } //// } //// } //// //// module Test { //// export interface IBase { -//// [|field|]: string; -//// [|method|](): void; +//// [|{| "isWriteAccess": true, "isDefinition": true |}field|]: string; +//// [|{| "isWriteAccess": true, "isDefinition": true |}method|](): void; //// } //// //// export interface IBlah extends IBase { -//// [|field|]: string; +//// [|{| "isWriteAccess": true, "isDefinition": true |}field|]: string; //// } //// //// export interface IBlah2 extends IBlah { -//// [|field|]: string; +//// [|{| "isWriteAccess": true, "isDefinition": true |}field|]: string; //// } //// //// export interface IDerived extends IBlah2 { -//// [|method|](): void; +//// [|{| "isWriteAccess": true, "isDefinition": true |}method|](): void; //// } //// //// export class Bar implements IDerived { -//// public [|field|]: string; -//// public [|method|](): void { } +//// public [|{| "isWriteAccess": true, "isDefinition": true |}field|]: string; +//// public [|{| "isWriteAccess": true, "isDefinition": true |}method|](): void { } //// } //// //// export class BarBlah extends Bar { -//// public [|field|]: string; +//// public [|{| "isWriteAccess": true, "isDefinition": true |}field|]: string; //// } //// } //// @@ -75,4 +75,67 @@ //// } ////} -verify.rangesWithSameTextReferenceEachOther(); +const ranges = test.rangesByText(); + +const fooRanges = ranges.get("foo"); +const [foo0, foo1, foo2] = fooRanges; +verify.referenceGroups(foo0, [{ definition: "(method) SimpleClassTest.Foo.foo(): void", ranges: fooRanges }]); +verify.referenceGroups([foo1, foo2], [ + { definition: "(method) SimpleClassTest.Foo.foo(): void", ranges: [foo0] }, + { definition: "(method) SimpleClassTest.Bar.foo(): void", ranges: [foo1, foo2] } +]); + +const ifooRanges = ranges.get("ifoo"); +const [ifoo0, ifoo1, ifoo2] = ifooRanges; +verify.referenceGroups(ifoo0, [{ definition: "(method) SimpleInterfaceTest.IFoo.ifoo(): void", ranges: ifooRanges }]); +verify.referenceGroups([ifoo1, ifoo2], [ + { definition: "(method) SimpleInterfaceTest.IFoo.ifoo(): void", ranges: [ifoo0] }, + { definition: "(method) SimpleInterfaceTest.IBar.ifoo(): void", ranges: [ifoo1, ifoo2] } +]); + +const icfooRanges = ranges.get("icfoo"); +const [icfoo0, icfoo1, icfoo2] = icfooRanges; +verify.referenceGroups(icfoo0, [{ definition: "(method) SimpleClassInterfaceTest.IFoo.icfoo(): void", ranges: icfooRanges }]); +verify.referenceGroups([icfoo1, icfoo2], [ + { definition: "(method) SimpleClassInterfaceTest.IFoo.icfoo(): void", ranges: [icfoo0] }, + { definition: "(method) SimpleClassInterfaceTest.Bar.icfoo(): void", ranges: [icfoo1, icfoo2] } +]); + +const fieldRanges = ranges.get("field"); +const [field0, field1, field2, field3, field4, field5] = fieldRanges; +verify.referenceGroups(field0, [{ definition: "(property) Test.IBase.field: string", ranges: fieldRanges }]); +verify.referenceGroups(field1, [ + { definition: "(property) Test.IBase.field: string", ranges: [field0] }, + { definition: "(property) Test.IBlah.field: string", ranges: fieldRanges.slice(1) } +]); +verify.referenceGroups(field2, [ + { definition: "(property) Test.IBase.field: string", ranges: [field0] }, + { definition: "(property) Test.IBlah.field: string", ranges: [field1] }, + { definition: "(property) Test.IBlah2.field: string", ranges: fieldRanges.slice(2) } +]); +verify.referenceGroups(field3, [ + { definition: "(property) Test.IBase.field: string", ranges: [field0] }, + { definition: "(property) Test.IBlah.field: string", ranges: [field1] }, + { definition: "(property) Test.IBlah2.field: string", ranges: [field2] }, + { definition: "(property) Test.Bar.field: string", ranges: fieldRanges.slice(3) } +]); +verify.referenceGroups([field4, field5], [ + { definition: "(property) Test.IBase.field: string", ranges: [field0] }, + { definition: "(property) Test.IBlah.field: string", ranges: [field1] }, + { definition: "(property) Test.IBlah2.field: string", ranges: [field2] }, + { definition: "(property) Test.Bar.field: string", ranges: [field3] }, + { definition: "(property) Test.BarBlah.field: string", ranges: fieldRanges.slice(4) } +]); + +const methodRanges = ranges.get("method"); +const [method0, method1, method2, method3] = methodRanges; +verify.referenceGroups(method0, [{ definition: "(method) Test.IBase.method(): void", ranges: methodRanges }]); +verify.referenceGroups(method1, [ + { definition: "(method) Test.IBase.method(): void", ranges: [method0] }, + { definition: "(method) Test.IDerived.method(): void", ranges: methodRanges.slice(1) } +]); +verify.referenceGroups([method2, method3], [ + { definition: "(method) Test.IBase.method(): void", ranges: [method0] }, + { definition: "(method) Test.IDerived.method(): void", ranges: [method1] }, + { definition: "(method) Test.Bar.method(): void", ranges: methodRanges.slice(2) } +]); diff --git a/tests/cases/fourslash/referencesForPropertiesOfGenericType.ts b/tests/cases/fourslash/referencesForPropertiesOfGenericType.ts index a8b08eae50..a92ac90978 100644 --- a/tests/cases/fourslash/referencesForPropertiesOfGenericType.ts +++ b/tests/cases/fourslash/referencesForPropertiesOfGenericType.ts @@ -1,7 +1,7 @@ /// ////interface IFoo { -//// [|doSomething|](v: T): T; +//// [|{| "isWriteAccess": true, "isDefinition": true |}doSomething|](v: T): T; ////} //// ////var x: IFoo; @@ -10,4 +10,14 @@ ////var y: IFoo; ////y.[|doSomething|](12); -verify.rangesReferenceEachOther(); +const ranges = test.ranges(); +const [r0, r1, r2] = ranges; +verify.referenceGroups(r0, [{ definition: "(method) IFoo.doSomething(v: T): T", ranges }]); +verify.referenceGroups(r1, [ + { definition: "(method) IFoo.doSomething(v: string): string", ranges: [r0, r2] }, + { definition: "(method) IFoo.doSomething(v: string): string", ranges: [r1] } +]); +verify.referenceGroups(r2, [ + { definition: "(method) IFoo.doSomething(v: number): number", ranges: [r0, r1] }, + { definition: "(method) IFoo.doSomething(v: number): number", ranges: [r2] } +]); diff --git a/tests/cases/fourslash/referencesForStatic.ts b/tests/cases/fourslash/referencesForStatic.ts index c659400670..17c33daac3 100644 --- a/tests/cases/fourslash/referencesForStatic.ts +++ b/tests/cases/fourslash/referencesForStatic.ts @@ -6,7 +6,7 @@ ////var n = 43; //// ////class foo { -//// static [|n|] = ''; +//// static [|{| "isWriteAccess": true, "isDefinition": true |}n|] = ''; //// //// public bar() { //// foo.[|n|] = "'"; @@ -30,4 +30,4 @@ // @Filename: referencesOnStatic_2.ts ////var q = foo.[|n|]; -verify.rangesReferenceEachOther(); +verify.singleReferenceGroup("(property) foo.n: string"); diff --git a/tests/cases/fourslash/referencesForStaticsAndMembersWithSameNames.ts b/tests/cases/fourslash/referencesForStaticsAndMembersWithSameNames.ts index cada3e0fcf..1e393ef676 100644 --- a/tests/cases/fourslash/referencesForStaticsAndMembersWithSameNames.ts +++ b/tests/cases/fourslash/referencesForStaticsAndMembersWithSameNames.ts @@ -3,12 +3,12 @@ ////module FindRef4 { //// module MixedStaticsClassTest { //// export class Foo { -//// [|bar|]: Foo; -//// static [|bar|]: Foo; +//// [|{| "isWriteAccess": true, "isDefinition": true |}bar|]: Foo; +//// static [|{| "isWriteAccess": true, "isDefinition": true |}bar|]: Foo; //// -//// public [|foo|](): void { +//// public [|{| "isWriteAccess": true, "isDefinition": true |}foo|](): void { //// } -//// public static [|foo|](): void { +//// public static [|{| "isWriteAccess": true, "isDefinition": true |}foo|](): void { //// } //// } //// } @@ -28,13 +28,16 @@ const [fooBar, fooStaticBar, fooFoo, fooStaticFoo, xFoo, xBar, staticFoo, staticBar] = test.ranges(); // References to a member method with the same name as a static. -verify.referencesOf(fooFoo, [fooFoo, xFoo]); +verify.singleReferenceGroup("(method) MixedStaticsClassTest.Foo.foo(): void", [fooFoo, xFoo]); // References to a static method with the same name as a member. -verify.referencesOf(fooStaticFoo, [fooStaticFoo, staticFoo]); +verify.singleReferenceGroup("(method) MixedStaticsClassTest.Foo.foo(): void", [fooStaticFoo, staticFoo]); // References to a member property with the same name as a static. -verify.referencesOf(fooBar, [fooBar, xBar]); +//verify.singleReferenceGroup("(property) MixedStaticsClassTest.Foo.bar: Foo", [fooBar, xBar]); +verify.referenceGroups(fooBar, [{ definition: "(property) MixedStaticsClassTest.Foo.bar: Foo", ranges: [fooBar, xBar] }]); +verify.referenceGroups(xBar, [{ definition: "(property) MixedStaticsClassTest.Foo.bar: MixedStaticsClassTest.Foo", ranges: [fooBar, xBar] }]); // References to a static property with the same name as a member. -verify.referencesOf(fooStaticBar, [fooStaticBar, staticBar]); +verify.referenceGroups(fooStaticBar, [{ definition: "(property) MixedStaticsClassTest.Foo.bar: Foo", ranges: [fooStaticBar, staticBar] }]); +verify.referenceGroups(staticBar, [{ definition: "(property) MixedStaticsClassTest.Foo.bar: MixedStaticsClassTest.Foo", ranges: [fooStaticBar, staticBar] }]); diff --git a/tests/cases/fourslash/referencesForStringLiteralPropertyNames.ts b/tests/cases/fourslash/referencesForStringLiteralPropertyNames.ts index 2db0325d32..e9be352f81 100644 --- a/tests/cases/fourslash/referencesForStringLiteralPropertyNames.ts +++ b/tests/cases/fourslash/referencesForStringLiteralPropertyNames.ts @@ -1,13 +1,23 @@ /// ////class Foo { -//// public "[|ss|]": any; +//// public "[|{| "isDefinition": true |}ss|]": any; ////} //// ////var x: Foo; ////x.[|ss|]; ////x["[|ss|]"]; -////x = { "[|ss|]": 0 }; -////x = { [|ss|]: 0 }; +////x = { "[|{| "isDefinition": true |}ss|]": 0 }; +////x = { [|{| "isWriteAccess": true, "isDefinition": true |}ss|]: 0 }; -verify.rangesReferenceEachOther(); +const ranges = test.ranges(); +const [r0, r1, r2, r3, r4] = ranges; +verify.referenceGroups([r0, r1, r2], [{ definition: '(property) Foo["ss"]: any', ranges }]); +verify.referenceGroups(r3, [ + { definition: '(property) Foo["ss"]: any', ranges: [r0, r1, r2, r4] }, + { definition: '(property) "ss": number', ranges: [r3] } +]); +verify.referenceGroups(r4, [ + { definition: '(property) Foo["ss"]: any', ranges: [r0, r1, r2, r3] }, + { definition: '(property) ss: number', ranges: [r4] } +]); diff --git a/tests/cases/fourslash/referencesForStringLiteralPropertyNames2.ts b/tests/cases/fourslash/referencesForStringLiteralPropertyNames2.ts index 275a2b2756..6fbb0b8507 100644 --- a/tests/cases/fourslash/referencesForStringLiteralPropertyNames2.ts +++ b/tests/cases/fourslash/referencesForStringLiteralPropertyNames2.ts @@ -1,10 +1,17 @@ /// ////class Foo { -//// "[|blah|]"() { return 0; } +//// "[|{| "isDefinition": true |}blah|]"() { return 0; } ////} //// ////var x: Foo; ////x.[|blah|]; -verify.rangesReferenceEachOther(); +//verify.singleReferenceGroup('(method) Foo["blah"](): number'); +const ranges = test.ranges(); +const [r0, r1] = ranges; +verify.referenceGroups(r0, [{ definition: '(method) Foo["blah"](): number', ranges }]); +verify.referenceGroups(r1, [ + { definition: '(method) Foo["blah"](): number', ranges: [r0] }, + { definition: '(method) Foo["blah"](): number', ranges: [r1] } +]); diff --git a/tests/cases/fourslash/referencesForStringLiteralPropertyNames3.ts b/tests/cases/fourslash/referencesForStringLiteralPropertyNames3.ts index 55a067ae8c..d4e12a67af 100644 --- a/tests/cases/fourslash/referencesForStringLiteralPropertyNames3.ts +++ b/tests/cases/fourslash/referencesForStringLiteralPropertyNames3.ts @@ -1,11 +1,17 @@ /// ////class Foo2 { -//// get "[|42|]"() { return 0; } -//// set [|42|](n) { } +//// get "[|{| "isDefinition": true |}42|]"() { return 0; } +//// set [|{| "isDefinition": true |}42|](n) { } ////} //// ////var y: Foo2; ////y[[|42|]]; -verify.rangesReferenceEachOther(); +const ranges = test.ranges(); +const [r0, r1, r2] = ranges; +verify.referenceGroups([r0, r1], [{ definition: '(property) Foo2["42"]: number', ranges }]); +verify.referenceGroups(r2, [ + { definition: '(property) Foo2["42"]: number', ranges: [r0, r1] }, + { definition: '(property) Foo2["42"]: number', ranges: [r2] }, +]); diff --git a/tests/cases/fourslash/referencesForStringLiteralPropertyNames4.ts b/tests/cases/fourslash/referencesForStringLiteralPropertyNames4.ts index 34cad8f11e..efe8972f2c 100644 --- a/tests/cases/fourslash/referencesForStringLiteralPropertyNames4.ts +++ b/tests/cases/fourslash/referencesForStringLiteralPropertyNames4.ts @@ -1,7 +1,13 @@ /// -////var x = { "[|someProperty|]": 0 } +////var x = { "[|{| "isDefinition": true |}someProperty|]": 0 } ////x["[|someProperty|]"] = 3; -////x./*1*/[|someProperty|] = 5; +////x.[|someProperty|] = 5; -verify.rangesReferenceEachOther(); +const ranges = test.ranges(); +const [r0, r1, r2] = ranges; +verify.referenceGroups(r0, [{ definition: '(property) "someProperty": number', ranges }]); +verify.referenceGroups([r1, r2], [ + { definition: '(property) "someProperty": number', ranges: [r0] }, + { definition: '(property) "someProperty": number', ranges: [r1, r2] }, +]); diff --git a/tests/cases/fourslash/referencesForUnionProperties.ts b/tests/cases/fourslash/referencesForUnionProperties.ts index 07eebeb5f7..9757007734 100644 --- a/tests/cases/fourslash/referencesForUnionProperties.ts +++ b/tests/cases/fourslash/referencesForUnionProperties.ts @@ -1,16 +1,16 @@ /// ////interface One { -//// common: { [|a|]: number; }; +//// common: { [|{| "isWriteAccess": true, "isDefinition": true |}a|]: number; }; ////} //// ////interface Base { -//// [|a|]: string; +//// [|{| "isWriteAccess": true, "isDefinition": true |}a|]: string; //// b: string; ////} //// ////interface HasAOrB extends Base { -//// [|a|]: string; +//// [|{| "isWriteAccess": true, "isDefinition": true |}a|]: string; //// b: string; ////} //// @@ -23,7 +23,15 @@ ////x.common.[|a|]; const [one, base, hasAOrB, x] = test.ranges(); -verify.referencesOf(one, [one, x]); -verify.referencesOf(base, [base, hasAOrB, x]); -verify.referencesOf(hasAOrB, [base, hasAOrB, x]); -verify.referencesOf(x, [one, base, hasAOrB, x]); +verify.referenceGroups(one, [{ definition: "(property) a: number", ranges: [one, x] }]); +verify.referenceGroups(base, [{ definition: "(property) Base.a: string", ranges: [base, hasAOrB, x] }]); +verify.referenceGroups(hasAOrB, [ + { definition: "(property) Base.a: string", ranges: [base] }, + { definition: "(property) HasAOrB.a: string", ranges: [hasAOrB, x] } +]); +verify.referenceGroups(x, [ + { definition: "(property) a: number", ranges: [one] }, + { definition: "(property) Base.a: string", ranges: [base] }, + { definition: "(property) HasAOrB.a: string", ranges: [hasAOrB] }, + { definition: "(property) a: string | number", ranges: [x] } +]); diff --git a/tests/cases/fourslash/referencesInComment.ts b/tests/cases/fourslash/referencesInComment.ts index eabf74d2f2..674ee41a8d 100644 --- a/tests/cases/fourslash/referencesInComment.ts +++ b/tests/cases/fourslash/referencesInComment.ts @@ -5,4 +5,4 @@ ////class foo { } ////var bar = 0; -goTo.eachMarker(() => verify.referencesAre([])); +goTo.eachMarker(() => verify.noReferences()); diff --git a/tests/cases/fourslash/remoteGetReferences.ts b/tests/cases/fourslash/remoteGetReferences.ts index d9b6c6e852..292864f9ed 100644 --- a/tests/cases/fourslash/remoteGetReferences.ts +++ b/tests/cases/fourslash/remoteGetReferences.ts @@ -95,10 +95,10 @@ //////Increments ////[|remotefooCls|].[|remoteclsSVar|]++; ////remotemodTest.remotemodVar++; -////[|remoteglobalVar|] = [|remoteglobalVar|] + [|remoteglobalVar|]; +////[|{| "isWriteAccess": true |}remoteglobalVar|] = [|remoteglobalVar|] + [|remoteglobalVar|]; //// //////ETC - Other cases -////[|remoteglobalVar|] = 3; +////[|{| "isWriteAccess": true |}remoteglobalVar|] = 3; //// //////Find References misses method param ////var @@ -119,16 +119,16 @@ ////}); // @Filename: remoteGetReferences_2.ts -////var [|remoteglobalVar|]: number = 2; +////var [|{| "isWriteAccess": true, "isDefinition": true |}remoteglobalVar|]: number = 2; //// -////class [|remotefooCls|] { +////class [|{| "isWriteAccess": true, "isDefinition": true |}remotefooCls|] { //// //Declare -//// [|remoteclsVar|] = 1; -//// static [|remoteclsSVar|] = 1; +//// [|{| "isWriteAccess": true, "isDefinition": true |}remoteclsVar|] = 1; +//// static [|{| "isWriteAccess": true, "isDefinition": true |}remoteclsSVar|] = 1; //// //// constructor(public remoteclsParam: number) { //// //Increments -//// [|remoteglobalVar|]++; +//// [|{| "isWriteAccess": true |}remoteglobalVar|]++; //// this.[|remoteclsVar|]++; //// [|remotefooCls|].[|remoteclsSVar|]++; //// this.remoteclsParam++; @@ -142,7 +142,7 @@ //// //// //Increments //// [|remotefooCls|].[|remoteclsSVar|]++; -//// [|remoteglobalVar|]++; +//// [|{| "isWriteAccess": true |}remoteglobalVar|]++; //// remotemodTest.remotemodVar++; //// remotefnVar++; //// @@ -155,7 +155,7 @@ //// export var remotemodVar: number; //// //// //Increments -//// [|remoteglobalVar|]++; +//// [|{| "isWriteAccess": true |}remoteglobalVar|]++; //// [|remotefooCls|].[|remoteclsSVar|]++; //// remotemodVar++; //// @@ -167,7 +167,7 @@ //// static remoteboo = remotefoo; //// //// //Increments -//// [|remoteglobalVar|]++; +//// [|{| "isWriteAccess": true |}remoteglobalVar|]++; //// [|remotefooCls|].[|remoteclsSVar|]++; //// remotemodVar++; //// } @@ -177,4 +177,24 @@ //// } ////} -verify.rangesWithSameTextReferenceEachOther(); +test.rangesByText().forEach((ranges, text) => { + 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); + } + })(); + + if (text === "remotefooCls") { + verify.referenceGroups([ranges[0], ...ranges.slice(2)], [{ definition, ranges }]); + verify.referenceGroups(ranges[1], [ + { definition: "constructor remotefooCls(remoteclsParam: number): remotefooCls", ranges} + ]); + } + else { + verify.singleReferenceGroup(definition, ranges); + } +}); diff --git a/tests/cases/fourslash/renameDefaultImport.ts b/tests/cases/fourslash/renameDefaultImport.ts index ff297ffa14..bcac46d7a6 100644 --- a/tests/cases/fourslash/renameDefaultImport.ts +++ b/tests/cases/fourslash/renameDefaultImport.ts @@ -1,21 +1,23 @@ /// // @Filename: B.ts -////export default class /*1*/[|B|] { +////export default class /*1*/[|{| "isWriteAccess": true, "isDefinition": true |}B|] { //// test() { //// } ////} // @Filename: A.ts -////import [|B|] from "./B"; +////import [|{| "isWriteAccess": true, "isDefinition": true |}B|] from "./B"; ////let b = new [|B|](); ////b.test(); goTo.marker("1"); verify.occurrencesAtPositionCount(1); -const [C, B0, B1] = test.ranges(); -verify.rangesReferenceEachOther(); +const ranges = test.ranges(); +const [C, B0, B1] = ranges; +verify.referenceGroups([C, B0], [{ definition: "class B", ranges }]); +verify.referenceGroups(B1, [{ definition: "constructor B(): B", ranges }]); goTo.rangeStart(C); verify.renameLocations(false, false, [C, B0, B1]); diff --git a/tests/cases/fourslash/renameDefaultImportDifferentName.ts b/tests/cases/fourslash/renameDefaultImportDifferentName.ts index be968c9b88..590c81c650 100644 --- a/tests/cases/fourslash/renameDefaultImportDifferentName.ts +++ b/tests/cases/fourslash/renameDefaultImportDifferentName.ts @@ -1,21 +1,23 @@ /// // @Filename: B.ts -////export default class /*1*/[|C|] { +////export default class /*1*/[|{| "isWriteAccess": true, "isDefinition": true |}C|] { //// test() { //// } ////} // @Filename: A.ts -////import [|B|] from "./B"; +////import [|{| "isWriteAccess": true, "isDefinition": true |}B|] from "./B"; ////let b = new [|B|](); ////b.test(); goTo.marker("1"); verify.occurrencesAtPositionCount(1); -const [C, B0, B1] = test.ranges(); -verify.rangesReferenceEachOther(); +const ranges = test.ranges(); +const [C, B0, B1] = ranges; +verify.referenceGroups([C, B0], [{ definition: "class C", ranges }]); +verify.referenceGroups(B1, [{ definition: "constructor C(): B", ranges }]); goTo.rangeStart(C); verify.renameLocations(false, false, [C, B0, B1]); diff --git a/tests/cases/fourslash/renameImportAndExportInDiffFiles.ts b/tests/cases/fourslash/renameImportAndExportInDiffFiles.ts index e982d6a4c7..656a48f24d 100644 --- a/tests/cases/fourslash/renameImportAndExportInDiffFiles.ts +++ b/tests/cases/fourslash/renameImportAndExportInDiffFiles.ts @@ -1,10 +1,10 @@ /// // @Filename: a.ts -////export var [|a|]; +////export var [|{| "isWriteAccess": true, "isDefinition": true |}a|]; // @Filename: b.ts -////import { [|a|] } from './a'; -////export { [|a|] }; +////import { [|{| "isWriteAccess": true, "isDefinition": true |}a|] } from './a'; +////export { [|{| "isWriteAccess": true, "isDefinition": true |}a|] }; -verify.rangesReferenceEachOther(); +verify.singleReferenceGroup("var a: any"); diff --git a/tests/cases/fourslash/shims-pp/getReferencesAtPosition.ts b/tests/cases/fourslash/shims-pp/getReferencesAtPosition.ts index cb82980760..fa9a510d5a 100644 --- a/tests/cases/fourslash/shims-pp/getReferencesAtPosition.ts +++ b/tests/cases/fourslash/shims-pp/getReferencesAtPosition.ts @@ -1,4 +1,4 @@ -/// +/// //@Filename: findAllRefsOnDefinition-import.ts ////export class Test{ @@ -7,7 +7,7 @@ //// //// } //// -//// public [|start|](){ +//// public [|{| "isWriteAccess": true, "isDefinition": true |}start|](){ //// return this; //// } //// @@ -23,4 +23,10 @@ ////second.[|start|](); ////second.stop(); -verify.rangesReferenceEachOther(); +const ranges = test.ranges(); +const [r0, r1] = ranges; +verify.referenceGroups(r0, [{ definition: "(method) Test.start(): this", ranges }]); +verify.referenceGroups(r1, [ + { definition: "(method) Second.Test.start(): Second.Test", ranges: [r0] }, + { definition: "(method) Second.Test.start(): Second.Test", ranges: [r1] } +]); diff --git a/tests/cases/fourslash/shims/getReferencesAtPosition.ts b/tests/cases/fourslash/shims/getReferencesAtPosition.ts index cb82980760..fa9a510d5a 100644 --- a/tests/cases/fourslash/shims/getReferencesAtPosition.ts +++ b/tests/cases/fourslash/shims/getReferencesAtPosition.ts @@ -1,4 +1,4 @@ -/// +/// //@Filename: findAllRefsOnDefinition-import.ts ////export class Test{ @@ -7,7 +7,7 @@ //// //// } //// -//// public [|start|](){ +//// public [|{| "isWriteAccess": true, "isDefinition": true |}start|](){ //// return this; //// } //// @@ -23,4 +23,10 @@ ////second.[|start|](); ////second.stop(); -verify.rangesReferenceEachOther(); +const ranges = test.ranges(); +const [r0, r1] = ranges; +verify.referenceGroups(r0, [{ definition: "(method) Test.start(): this", ranges }]); +verify.referenceGroups(r1, [ + { definition: "(method) Second.Test.start(): Second.Test", ranges: [r0] }, + { definition: "(method) Second.Test.start(): Second.Test", ranges: [r1] } +]); diff --git a/tests/cases/fourslash/untypedModuleImport.ts b/tests/cases/fourslash/untypedModuleImport.ts index da6473cf99..1854010d5b 100644 --- a/tests/cases/fourslash/untypedModuleImport.ts +++ b/tests/cases/fourslash/untypedModuleImport.ts @@ -4,7 +4,7 @@ ////{} // @Filename: a.ts -////import /*foo*/[|foo|] from /*fooModule*/"foo"; +////import /*foo*/[|{| "isWriteAccess": true, "isDefinition": true |}foo|] from /*fooModule*/"foo"; ////[|foo|](); goTo.file("a.ts"); @@ -13,9 +13,9 @@ verify.numberOfErrorsInCurrentFile(0); goTo.marker("fooModule"); verify.goToDefinitionIs([]); verify.quickInfoIs(""); -verify.referencesAre([]) +verify.noReferences(); goTo.marker("foo"); verify.goToDefinitionIs([]); verify.quickInfoIs("import foo"); -verify.rangesReferenceEachOther(); +verify.singleReferenceGroup("import foo");