diff --git a/src/harness/client.ts b/src/harness/client.ts index d223f9f5fe3a5..4f8e84dcdaf03 100644 --- a/src/harness/client.ts +++ b/src/harness/client.ts @@ -395,8 +395,15 @@ namespace ts.server { const locations: RenameLocation[] = []; for (const entry of body.locs) { const fileName = entry.file; - for (const { start, end, ...prefixSuffixText } of entry.locs) { - locations.push({ textSpan: this.decodeSpan({ start, end }, fileName), fileName, ...prefixSuffixText }); + for (const { start, end, contextStart, contextEnd, ...prefixSuffixText } of entry.locs) { + locations.push({ + textSpan: this.decodeSpan({ start, end }, fileName), + fileName, + ...(contextStart !== undefined ? + { contextSpan: this.decodeSpan({ start: contextStart, end: contextEnd! }, fileName) } : + undefined), + ...prefixSuffixText + }); } } diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 345709ca550df..17f6c587f80d1 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -42,6 +42,7 @@ namespace FourSlash { * is a range with `text in range` "selected". */ ranges: Range[]; + rangesByText?: ts.MultiMap; } export interface Marker { @@ -955,12 +956,15 @@ namespace FourSlash { const fullExpected = ts.map(parts, ({ definition, ranges }) => ({ definition: typeof definition === "string" ? definition : { ...definition, range: ts.createTextSpanFromRange(definition.range) }, references: ranges.map(r => { - const { isWriteAccess = false, isDefinition = false, isInString } = (r.marker && r.marker.data || {}) as { isWriteAccess?: boolean, isDefinition?: boolean, isInString?: true }; + const { isWriteAccess = false, isDefinition = false, isInString, contextRangeIndex } = (r.marker && r.marker.data || {}) as { isWriteAccess?: boolean, isDefinition?: boolean, isInString?: true, contextRangeIndex?: number }; return { fileName: r.fileName, textSpan: ts.createTextSpanFromRange(r), isWriteAccess, isDefinition, + ...(contextRangeIndex !== undefined ? + { contextSpan: ts.createTextSpanFromRange(this.getRanges()[contextRangeIndex]) } : + undefined), ...(isInString ? { isInString: true } : undefined), }; }), @@ -997,8 +1001,8 @@ namespace FourSlash { assert.deepEqual | undefined>(refs, expected); } - public verifySingleReferenceGroup(definition: FourSlashInterface.ReferenceGroupDefinition, ranges?: Range[]) { - ranges = ranges || this.getRanges(); + public verifySingleReferenceGroup(definition: FourSlashInterface.ReferenceGroupDefinition, ranges?: Range[] | string) { + ranges = ts.isString(ranges) ? this.rangesByText().get(ranges)! : ranges || this.getRanges(); this.verifyReferenceGroups(ranges, [{ definition, ranges }]); } @@ -1011,7 +1015,7 @@ Actual: ${stringify(fullActual)}`); }; if ((actual === undefined) !== (expected === undefined)) { - fail(`Expected ${expected}, got ${actual}`); + fail(`Expected ${stringify(expected)}, got ${stringify(actual)}`); } for (const key in actual) { @@ -1021,7 +1025,7 @@ Actual: ${stringify(fullActual)}`); recur(ak, ek, path ? path + "." + key : key); } else if (ak !== ek) { - fail(`Expected '${key}' to be '${ek}', got '${ak}'`); + fail(`Expected '${key}' to be '${stringify(ek)}', got '${stringify(ak)}'`); } } } @@ -1189,7 +1193,15 @@ Actual: ${stringify(fullActual)}`); locations && ts.sort(locations, (r1, r2) => ts.compareStringsCaseSensitive(r1.fileName, r2.fileName) || r1.textSpan.start - r2.textSpan.start); assert.deepEqual(sort(references), sort(ranges.map((rangeOrOptions): ts.RenameLocation => { const { range, ...prefixSuffixText } = "range" in rangeOrOptions ? rangeOrOptions : { range: rangeOrOptions }; - return { fileName: range.fileName, textSpan: ts.createTextSpanFromRange(range), ...prefixSuffixText }; + const { contextRangeIndex } = (range.marker && range.marker.data || {}) as { contextRangeIndex?: number; }; + return { + fileName: range.fileName, + textSpan: ts.createTextSpanFromRange(range), + ...(contextRangeIndex !== undefined ? + { contextSpan: ts.createTextSpanFromRange(this.getRanges()[contextRangeIndex]) } : + undefined), + ...prefixSuffixText + }; }))); } } @@ -1844,6 +1856,7 @@ Actual: ${stringify(fullActual)}`); range.end = updatePosition(range.end, editStart, editEnd, newText); } } + this.testData.rangesByText = undefined; } private removeWhitespace(text: string): string { @@ -2026,7 +2039,9 @@ Actual: ${stringify(fullActual)}`); } public rangesByText(): ts.Map { + if (this.testData.rangesByText) return this.testData.rangesByText; const result = ts.createMultiMap(); + this.testData.rangesByText = result; for (const range of this.getRanges()) { const text = this.rangeText(range); result.add(text, range); @@ -2714,8 +2729,8 @@ Actual: ${stringify(fullActual)}`); return this.languageService.getDocumentHighlights(this.activeFile.fileName, this.currentCaretPosition, filesToSearch); } - public verifyRangesAreOccurrences(isWriteAccess?: boolean) { - const ranges = this.getRanges(); + public verifyRangesAreOccurrences(isWriteAccess?: boolean, ranges?: Range[]) { + ranges = ranges || this.getRanges(); for (const r of ranges) { this.goToRangeStart(r); this.verifyOccurrencesAtPositionListCount(ranges.length); @@ -2725,8 +2740,13 @@ Actual: ${stringify(fullActual)}`); } } - public verifyRangesWithSameTextAreRenameLocations() { - this.rangesByText().forEach(ranges => this.verifyRangesAreRenameLocations(ranges)); + public verifyRangesWithSameTextAreRenameLocations(...texts: string[]) { + if (texts.length) { + texts.forEach(text => this.verifyRangesAreRenameLocations(this.rangesByText().get(text)!)); + } + else { + this.rangesByText().forEach(ranges => this.verifyRangesAreRenameLocations(ranges)); + } } public verifyRangesWithSameTextAreDocumentHighlights() { @@ -3971,7 +3991,7 @@ namespace FourSlashInterface { this.state.verifyGetReferencesForServerTest(expected); } - public singleReferenceGroup(definition: ReferenceGroupDefinition, ranges?: FourSlash.Range[]) { + public singleReferenceGroup(definition: ReferenceGroupDefinition, ranges?: FourSlash.Range[] | string) { this.state.verifySingleReferenceGroup(definition, ranges); } @@ -4093,12 +4113,12 @@ namespace FourSlashInterface { this.state.verifyOccurrencesAtPositionListCount(expectedCount); } - public rangesAreOccurrences(isWriteAccess?: boolean) { - this.state.verifyRangesAreOccurrences(isWriteAccess); + public rangesAreOccurrences(isWriteAccess?: boolean, ranges?: FourSlash.Range[]) { + this.state.verifyRangesAreOccurrences(isWriteAccess, ranges); } - public rangesWithSameTextAreRenameLocations() { - this.state.verifyRangesWithSameTextAreRenameLocations(); + public rangesWithSameTextAreRenameLocations(...texts: string[]) { + this.state.verifyRangesWithSameTextAreRenameLocations(...texts); } public rangesAreRenameLocations(options?: FourSlash.Range[] | { findInStrings?: boolean, findInComments?: boolean, ranges?: FourSlash.Range[] }) { diff --git a/src/server/protocol.ts b/src/server/protocol.ts index 486208c2819d7..2650cd5d7652b 100644 --- a/src/server/protocol.ts +++ b/src/server/protocol.ts @@ -872,8 +872,16 @@ namespace ts.server.protocol { file: string; } + export interface TextSpanWithContext extends TextSpan { + contextStart?: Location; + contextEnd?: Location; + } + + export interface FileSpanWithContext extends FileSpan, TextSpanWithContext { + } + export interface DefinitionInfoAndBoundSpan { - definitions: ReadonlyArray; + definitions: ReadonlyArray; textSpan: TextSpan; } @@ -881,7 +889,7 @@ namespace ts.server.protocol { * Definition response message. Gives text range for definition. */ export interface DefinitionResponse extends Response { - body?: FileSpan[]; + body?: FileSpanWithContext[]; } export interface DefinitionInfoAndBoundSpanReponse extends Response { @@ -892,14 +900,14 @@ namespace ts.server.protocol { * Definition response message. Gives text range for definition. */ export interface TypeDefinitionResponse extends Response { - body?: FileSpan[]; + body?: FileSpanWithContext[]; } /** * Implementation response message. Gives text range for implementations. */ export interface ImplementationResponse extends Response { - body?: FileSpan[]; + body?: FileSpanWithContext[]; } /** @@ -942,7 +950,7 @@ namespace ts.server.protocol { } /** @deprecated */ - export interface OccurrencesResponseItem extends FileSpan { + export interface OccurrencesResponseItem extends FileSpanWithContext { /** * True if the occurrence is a write location, false otherwise. */ @@ -972,7 +980,7 @@ namespace ts.server.protocol { /** * Span augmented with extra information that denotes the kind of the highlighting to be used for span. */ - export interface HighlightSpan extends TextSpan { + export interface HighlightSpan extends TextSpanWithContext { kind: HighlightSpanKind; } @@ -1007,7 +1015,7 @@ namespace ts.server.protocol { command: CommandTypes.References; } - export interface ReferencesResponseItem extends FileSpan { + export interface ReferencesResponseItem extends FileSpanWithContext { /** Text of line containing the reference. Including this * with the response avoids latency of editor loading files * to show text of reference line (the server already has @@ -1150,7 +1158,7 @@ namespace ts.server.protocol { locs: RenameTextSpan[]; } - export interface RenameTextSpan extends TextSpan { + export interface RenameTextSpan extends TextSpanWithContext { readonly prefixText?: string; readonly suffixText?: string; } diff --git a/src/server/session.ts b/src/server/session.ts index 2e9d6948b1a5c..5064b5295600f 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -354,13 +354,17 @@ namespace ts.server { defaultProject, initialLocation, ({ project, location }, getMappedLocation) => { - for (const outputReferencedSymbol of project.getLanguageService().findReferences(location.fileName, location.pos) || emptyArray) { + for (const outputReferencedSymbol of project.getLanguageService().findReferences(location.fileName, location.pos) || emptyArray) { const mappedDefinitionFile = getMappedLocation(project, documentSpanLocation(outputReferencedSymbol.definition)); - const definition: ReferencedSymbolDefinitionInfo = mappedDefinitionFile === undefined ? outputReferencedSymbol.definition : { - ...outputReferencedSymbol.definition, - textSpan: createTextSpan(mappedDefinitionFile.pos, outputReferencedSymbol.definition.textSpan.length), - fileName: mappedDefinitionFile.fileName, - }; + const definition: ReferencedSymbolDefinitionInfo = mappedDefinitionFile === undefined ? + outputReferencedSymbol.definition : + { + ...outputReferencedSymbol.definition, + textSpan: createTextSpan(mappedDefinitionFile.pos, outputReferencedSymbol.definition.textSpan.length), + fileName: mappedDefinitionFile.fileName, + contextSpan: getMappedContextSpan(outputReferencedSymbol.definition, project) + }; + let symbolToAddTo = find(outputs, o => documentSpansEqual(o.definition, definition)); if (!symbolToAddTo) { symbolToAddTo = { definition, references: [] }; @@ -481,9 +485,39 @@ namespace ts.server { return { fileName, pos: textSpan.start }; } - function getMappedLocation(location: DocumentPosition, projectService: ProjectService, project: Project): DocumentPosition | undefined { + function getMappedLocation(location: DocumentPosition, project: Project): DocumentPosition | undefined { const mapsTo = project.getSourceMapper().tryGetSourcePosition(location); - return mapsTo && projectService.fileExists(toNormalizedPath(mapsTo.fileName)) ? mapsTo : undefined; + return mapsTo && project.projectService.fileExists(toNormalizedPath(mapsTo.fileName)) ? mapsTo : undefined; + } + + function getMappedDocumentSpan(documentSpan: DocumentSpan, project: Project): DocumentSpan | undefined { + const newPosition = getMappedLocation(documentSpanLocation(documentSpan), project); + if (!newPosition) return undefined; + return { + fileName: newPosition.fileName, + textSpan: { + start: newPosition.pos, + length: documentSpan.textSpan.length + }, + originalFileName: documentSpan.fileName, + originalTextSpan: documentSpan.textSpan, + contextSpan: getMappedContextSpan(documentSpan, project), + originalContextSpan: documentSpan.contextSpan + }; + } + + function getMappedContextSpan(documentSpan: DocumentSpan, project: Project): TextSpan | undefined { + const contextSpanStart = documentSpan.contextSpan && getMappedLocation( + { fileName: documentSpan.fileName, pos: documentSpan.contextSpan.start }, + project + ); + const contextSpanEnd = documentSpan.contextSpan && getMappedLocation( + { fileName: documentSpan.fileName, pos: documentSpan.contextSpan.start + documentSpan.contextSpan.length }, + project + ); + return contextSpanStart && contextSpanEnd ? + { start: contextSpanStart.pos, length: contextSpanEnd.pos - contextSpanStart.pos } : + undefined; } export interface SessionOptions { @@ -937,7 +971,7 @@ namespace ts.server { : diagnostics.map(d => formatDiag(file, project, d)); } - private getDefinition(args: protocol.FileLocationRequestArgs, simplifiedResult: boolean): ReadonlyArray | ReadonlyArray { + private getDefinition(args: protocol.FileLocationRequestArgs, simplifiedResult: boolean): ReadonlyArray | ReadonlyArray { const { file, project } = this.getFileAndProject(args); const position = this.getPositionInFile(args, file); const definitions = this.mapDefinitionInfoLocations(project.getLanguageService().getDefinitionAtPosition(file, position) || emptyArray, project); @@ -946,19 +980,13 @@ namespace ts.server { private mapDefinitionInfoLocations(definitions: ReadonlyArray, project: Project): ReadonlyArray { return definitions.map((info): DefinitionInfo => { - const newLoc = getMappedLocation(documentSpanLocation(info), this.projectService, project); - return !newLoc ? info : { + const newDocumentSpan = getMappedDocumentSpan(info, project); + return !newDocumentSpan ? info : { + ...newDocumentSpan, containerKind: info.containerKind, containerName: info.containerName, - fileName: newLoc.fileName, kind: info.kind, name: info.name, - textSpan: { - start: newLoc.pos, - length: info.textSpan.length - }, - originalFileName: info.fileName, - originalTextSpan: info.textSpan, }; }); } @@ -983,7 +1011,7 @@ namespace ts.server { if (simplifiedResult) { return { definitions: this.mapDefinitionInfo(definitions, project), - textSpan: this.toLocationTextSpan(textSpan, scriptInfo) + textSpan: toProcolTextSpan(textSpan, scriptInfo) }; } @@ -998,8 +1026,8 @@ namespace ts.server { return project.getLanguageService().getEmitOutput(file); } - private mapDefinitionInfo(definitions: ReadonlyArray, project: Project): ReadonlyArray { - return definitions.map(def => this.toFileSpan(def.fileName, def.textSpan, project)); + private mapDefinitionInfo(definitions: ReadonlyArray, project: Project): ReadonlyArray { + return definitions.map(def => this.toFileSpanWithContext(def.fileName, def.textSpan, def.contextSpan, project)); } /* @@ -1017,7 +1045,9 @@ namespace ts.server { fileName: def.originalFileName, textSpan: def.originalTextSpan, targetFileName: def.fileName, - targetTextSpan: def.textSpan + targetTextSpan: def.textSpan, + contextSpan: def.originalContextSpan, + targetContextSpan: def.contextSpan }; } return def; @@ -1035,7 +1065,15 @@ namespace ts.server { }; } - private getTypeDefinition(args: protocol.FileLocationRequestArgs): ReadonlyArray { + private toFileSpanWithContext(fileName: string, textSpan: TextSpan, contextSpan: TextSpan | undefined, project: Project): protocol.FileSpanWithContext { + const fileSpan = this.toFileSpan(fileName, textSpan, project); + const context = contextSpan && this.toFileSpan(fileName, contextSpan, project); + return context ? + { ...fileSpan, contextStart: context.start, contextEnd: context.end } : + fileSpan; + } + + private getTypeDefinition(args: protocol.FileLocationRequestArgs): ReadonlyArray { const { file, project } = this.getFileAndProject(args); const position = this.getPositionInFile(args, file); @@ -1045,58 +1083,40 @@ namespace ts.server { private mapImplementationLocations(implementations: ReadonlyArray, project: Project): ReadonlyArray { return implementations.map((info): ImplementationLocation => { - const newLoc = getMappedLocation(documentSpanLocation(info), this.projectService, project); - return !newLoc ? info : { - fileName: newLoc.fileName, + const newDocumentSpan = getMappedDocumentSpan(info, project); + return !newDocumentSpan ? info : { + ...newDocumentSpan, kind: info.kind, displayParts: info.displayParts, - textSpan: { - start: newLoc.pos, - length: info.textSpan.length - }, - originalFileName: info.fileName, - originalTextSpan: info.textSpan, }; }); } - private getImplementation(args: protocol.FileLocationRequestArgs, simplifiedResult: boolean): ReadonlyArray | ReadonlyArray { + private getImplementation(args: protocol.FileLocationRequestArgs, simplifiedResult: boolean): ReadonlyArray | ReadonlyArray { const { file, project } = this.getFileAndProject(args); const position = this.getPositionInFile(args, file); const implementations = this.mapImplementationLocations(project.getLanguageService().getImplementationAtPosition(file, position) || emptyArray, project); - if (simplifiedResult) { - return implementations.map(({ fileName, textSpan }) => this.toFileSpan(fileName, textSpan, project)); - } - - return implementations.map(Session.mapToOriginalLocation); + return simplifiedResult ? + implementations.map(({ fileName, textSpan, contextSpan }) => this.toFileSpanWithContext(fileName, textSpan, contextSpan, project)) : + implementations.map(Session.mapToOriginalLocation); } private getOccurrences(args: protocol.FileLocationRequestArgs): ReadonlyArray { const { file, project } = this.getFileAndProject(args); - const position = this.getPositionInFile(args, file); - const occurrences = project.getLanguageService().getOccurrencesAtPosition(file, position); - - if (!occurrences) { - return emptyArray; - } - - return occurrences.map(occurrence => { - const { fileName, isWriteAccess, textSpan, isInString } = occurrence; - const scriptInfo = project.getScriptInfo(fileName)!; - const result: protocol.OccurrencesResponseItem = { - start: scriptInfo.positionToLineOffset(textSpan.start), - end: scriptInfo.positionToLineOffset(textSpanEnd(textSpan)), - file: fileName, - isWriteAccess, - }; - // no need to serialize the property if it is not true - if (isInString) { - result.isInString = isInString; - } - return result; - }); + return occurrences ? + occurrences.map(occurrence => { + const { fileName, isWriteAccess, textSpan, isInString, contextSpan } = occurrence; + const scriptInfo = project.getScriptInfo(fileName)!; + return { + ...toProtocolTextSpanWithContext(textSpan, contextSpan, scriptInfo), + file: fileName, + isWriteAccess, + ...(isInString ? { isInString } : undefined) + }; + }) : + emptyArray; } private getSyntacticDiagnosticsSync(args: protocol.SyntacticDiagnosticsSyncRequestArgs): ReadonlyArray | ReadonlyArray { @@ -1139,33 +1159,19 @@ namespace ts.server { const position = this.getPositionInFile(args, file); const documentHighlights = project.getLanguageService().getDocumentHighlights(file, position, args.filesToSearch); - if (!documentHighlights) { - return emptyArray; - } - - if (simplifiedResult) { - return documentHighlights.map(convertToDocumentHighlightsItem); - } - else { - return documentHighlights; - } - - function convertToDocumentHighlightsItem(documentHighlights: DocumentHighlights): protocol.DocumentHighlightsItem { - const { fileName, highlightSpans } = documentHighlights; + if (!documentHighlights) return emptyArray; + if (!simplifiedResult) return documentHighlights; + return documentHighlights.map(({ fileName, highlightSpans }) => { const scriptInfo = project.getScriptInfo(fileName)!; return { file: fileName, - highlightSpans: highlightSpans.map(convertHighlightSpan) + highlightSpans: highlightSpans.map(({ textSpan, kind, contextSpan }) => ({ + ...toProtocolTextSpanWithContext(textSpan, contextSpan, scriptInfo), + kind + })) }; - - function convertHighlightSpan(highlightSpan: HighlightSpan): protocol.HighlightSpan { - const { textSpan, kind } = highlightSpan; - const start = scriptInfo.positionToLineOffset(textSpan.start); - const end = scriptInfo.positionToLineOffset(textSpanEnd(textSpan)); - return { start, end, kind }; - } - } + }); } private setCompilerOptionsForInferredProjects(args: protocol.SetCompilerOptionsForInferredProjectsArgs): void { @@ -1258,7 +1264,7 @@ namespace ts.server { if (info.canRename) { const { canRename, fileToRename, displayName, fullDisplayName, kind, kindModifiers, triggerSpan } = info; return identity( - { canRename, fileToRename, displayName, fullDisplayName, kind, kindModifiers, triggerSpan: this.toLocationTextSpan(triggerSpan, scriptInfo) }); + { canRename, fileToRename, displayName, fullDisplayName, kind, kindModifiers, triggerSpan: toProcolTextSpan(triggerSpan, scriptInfo) }); } else { return info; @@ -1267,11 +1273,11 @@ namespace ts.server { private toSpanGroups(locations: ReadonlyArray): ReadonlyArray { const map = createMap(); - for (const { fileName, textSpan, originalTextSpan: _, originalFileName: _1, ...prefixSuffixText } of locations) { + for (const { fileName, textSpan, contextSpan, originalContextSpan: _2, originalTextSpan: _, originalFileName: _1, ...prefixSuffixText } of locations) { let group = map.get(fileName); if (!group) map.set(fileName, group = { file: fileName, locs: [] }); const scriptInfo = Debug.assertDefined(this.projectService.getScriptInfo(fileName)); - group.locs.push({ ...this.toLocationTextSpan(textSpan, scriptInfo), ...prefixSuffixText }); + group.locs.push({ ...toProtocolTextSpanWithContext(textSpan, contextSpan, scriptInfo), ...prefixSuffixText }); } return arrayFrom(map.values()); } @@ -1286,30 +1292,31 @@ namespace ts.server { { fileName: args.file, pos: position }, ); - if (simplifiedResult) { - const defaultProject = this.getDefaultProject(args); - const scriptInfo = defaultProject.getScriptInfoForNormalizedPath(file)!; - const nameInfo = defaultProject.getLanguageService().getQuickInfoAtPosition(file, position); - const symbolDisplayString = nameInfo ? displayPartsToString(nameInfo.displayParts) : ""; - const nameSpan = nameInfo && nameInfo.textSpan; - const symbolStartOffset = nameSpan ? scriptInfo.positionToLineOffset(nameSpan.start).offset : 0; - const symbolName = nameSpan ? scriptInfo.getSnapshot().getText(nameSpan.start, textSpanEnd(nameSpan)) : ""; - const refs: ReadonlyArray = flatMap(references, referencedSymbol => - referencedSymbol.references.map(({ fileName, textSpan, isWriteAccess, isDefinition }): protocol.ReferencesResponseItem => { - const scriptInfo = Debug.assertDefined(this.projectService.getScriptInfo(fileName)); - const start = scriptInfo.positionToLineOffset(textSpan.start); - const lineSpan = scriptInfo.lineToTextSpan(start.line - 1); - const lineText = scriptInfo.getSnapshot().getText(lineSpan.start, textSpanEnd(lineSpan)).replace(/\r|\n/g, ""); - return { ...toFileSpan(fileName, textSpan, scriptInfo), lineText, isWriteAccess, isDefinition }; - })); - const result: protocol.ReferencesResponseBody = { refs, symbolName, symbolStartOffset, symbolDisplayString }; - return result; - } - else { - return references; - } - } + if (!simplifiedResult) return references; + const defaultProject = this.getDefaultProject(args); + const scriptInfo = defaultProject.getScriptInfoForNormalizedPath(file)!; + const nameInfo = defaultProject.getLanguageService().getQuickInfoAtPosition(file, position); + const symbolDisplayString = nameInfo ? displayPartsToString(nameInfo.displayParts) : ""; + const nameSpan = nameInfo && nameInfo.textSpan; + const symbolStartOffset = nameSpan ? scriptInfo.positionToLineOffset(nameSpan.start).offset : 0; + const symbolName = nameSpan ? scriptInfo.getSnapshot().getText(nameSpan.start, textSpanEnd(nameSpan)) : ""; + const refs: ReadonlyArray = flatMap(references, referencedSymbol => + referencedSymbol.references.map(({ fileName, textSpan, contextSpan, isWriteAccess, isDefinition }): protocol.ReferencesResponseItem => { + const scriptInfo = Debug.assertDefined(this.projectService.getScriptInfo(fileName)); + const span = toProtocolTextSpanWithContext(textSpan, contextSpan, scriptInfo); + const lineSpan = scriptInfo.lineToTextSpan(span.start.line - 1); + const lineText = scriptInfo.getSnapshot().getText(lineSpan.start, textSpanEnd(lineSpan)).replace(/\r|\n/g, ""); + return { + file: fileName, + ...span, + lineText, + isWriteAccess, + isDefinition + }; + })); + return { refs, symbolName, symbolStartOffset, symbolDisplayString }; + } /** * @param fileName is the name of the file to be opened * @param fileContent is a version of the file content that is known to be more up to date than the one on disk @@ -1357,8 +1364,8 @@ namespace ts.server { if (simplifiedResult) { const scriptInfo = this.projectService.getScriptInfoForNormalizedPath(file)!; return spans.map(s => ({ - textSpan: this.toLocationTextSpan(s.textSpan, scriptInfo), - hintSpan: this.toLocationTextSpan(s.hintSpan, scriptInfo), + textSpan: toProcolTextSpan(s.textSpan, scriptInfo), + hintSpan: toProcolTextSpan(s.hintSpan, scriptInfo), bannerText: s.bannerText, autoCollapse: s.autoCollapse, kind: s.kind @@ -1547,7 +1554,7 @@ namespace ts.server { const entries = mapDefined(completions.entries, entry => { if (completions.isMemberCompletion || startsWith(entry.name.toLowerCase(), prefix.toLowerCase())) { const { name, kind, kindModifiers, sortText, insertText, replacementSpan, hasAction, source, isRecommended } = entry; - const convertedSpan = replacementSpan ? this.toLocationTextSpan(replacementSpan, scriptInfo) : undefined; + const convertedSpan = replacementSpan ? toProcolTextSpan(replacementSpan, scriptInfo) : undefined; // Use `hasAction || undefined` to avoid serializing `false`. return { name, kind, kindModifiers, sortText, insertText, replacementSpan: convertedSpan, hasAction: hasAction || undefined, source, isRecommended }; } @@ -1710,7 +1717,7 @@ namespace ts.server { text: item.text, kind: item.kind, kindModifiers: item.kindModifiers, - spans: item.spans.map(span => this.toLocationTextSpan(span, scriptInfo)), + spans: item.spans.map(span => toProcolTextSpan(span, scriptInfo)), childItems: this.mapLocationNavigationBarItems(item.childItems, scriptInfo), indent: item.indent })); @@ -1731,19 +1738,12 @@ namespace ts.server { text: tree.text, kind: tree.kind, kindModifiers: tree.kindModifiers, - spans: tree.spans.map(span => this.toLocationTextSpan(span, scriptInfo)), - nameSpan: tree.nameSpan && this.toLocationTextSpan(tree.nameSpan, scriptInfo), + spans: tree.spans.map(span => toProcolTextSpan(span, scriptInfo)), + nameSpan: tree.nameSpan && toProcolTextSpan(tree.nameSpan, scriptInfo), childItems: map(tree.childItems, item => this.toLocationNavigationTree(item, scriptInfo)) }; } - private toLocationTextSpan(span: TextSpan, scriptInfo: ScriptInfo): protocol.TextSpan { - return { - start: scriptInfo.positionToLineOffset(span.start), - end: scriptInfo.positionToLineOffset(textSpanEnd(span)) - }; - } - private getNavigationTree(args: protocol.FileRequestArgs, simplifiedResult: boolean): protocol.NavigationTree | NavigationTree | undefined { const { file, languageService } = this.getFileAndLanguageServiceForSyntacticOperation(args); const tree = languageService.getNavigationTree(file); @@ -2001,7 +2001,7 @@ namespace ts.server { return !spans ? undefined : simplifiedResult - ? spans.map(span => this.toLocationTextSpan(span, scriptInfo)) + ? spans.map(span => toProcolTextSpan(span, scriptInfo)) : spans; } @@ -2073,7 +2073,7 @@ namespace ts.server { private mapSelectionRange(selectionRange: SelectionRange, scriptInfo: ScriptInfo): protocol.SelectionRange { const result: protocol.SelectionRange = { - textSpan: this.toLocationTextSpan(selectionRange.textSpan, scriptInfo), + textSpan: toProcolTextSpan(selectionRange.textSpan, scriptInfo), }; if (selectionRange.parent) { result.parent = this.mapSelectionRange(selectionRange.parent, scriptInfo); @@ -2558,8 +2558,19 @@ namespace ts.server { readonly project: Project; } - function toFileSpan(fileName: string, textSpan: TextSpan, scriptInfo: ScriptInfo): protocol.FileSpan { - return { file: fileName, start: scriptInfo.positionToLineOffset(textSpan.start), end: scriptInfo.positionToLineOffset(textSpanEnd(textSpan)) }; + function toProcolTextSpan(textSpan: TextSpan, scriptInfo: ScriptInfo): protocol.TextSpan { + return { + start: scriptInfo.positionToLineOffset(textSpan.start), + end: scriptInfo.positionToLineOffset(textSpanEnd(textSpan)) + }; + } + + function toProtocolTextSpanWithContext(span: TextSpan, contextSpan: TextSpan | undefined, scriptInfo: ScriptInfo): protocol.TextSpanWithContext { + const textSpan = toProcolTextSpan(span, scriptInfo); + const contextTextSpan = contextSpan && toProcolTextSpan(contextSpan, scriptInfo); + return contextTextSpan ? + { ...textSpan, contextStart: contextTextSpan.start, contextEnd: contextTextSpan.end } : + textSpan; } function convertTextChangeToCodeEdit(change: TextChange, scriptInfo: ScriptInfoOrConfig): protocol.CodeEdit { diff --git a/src/services/findAllReferences.ts b/src/services/findAllReferences.ts index cf0046d2688fa..fbe33df92a52a 100644 --- a/src/services/findAllReferences.ts +++ b/src/services/findAllReferences.ts @@ -16,9 +16,15 @@ namespace ts.FindAllReferences { export const enum EntryKind { Span, Node, StringLiteral, SearchedLocalFoundProperty, SearchedPropertyFoundLocal } export type NodeEntryKind = EntryKind.Node | EntryKind.StringLiteral | EntryKind.SearchedLocalFoundProperty | EntryKind.SearchedPropertyFoundLocal; export type Entry = NodeEntry | SpanEntry; + export interface ContextWithStartAndEndNode { + start: Node; + end: Node; + } + export type ContextNode = Node | ContextWithStartAndEndNode; export interface NodeEntry { readonly kind: NodeEntryKind; readonly node: Node; + readonly context?: ContextNode; } export interface SpanEntry { readonly kind: EntryKind.Span; @@ -26,7 +32,143 @@ namespace ts.FindAllReferences { readonly textSpan: TextSpan; } export function nodeEntry(node: Node, kind: NodeEntryKind = EntryKind.Node): NodeEntry { - return { kind, node: (node as NamedDeclaration).name || node }; + return { + kind, + node: (node as NamedDeclaration).name || node, + context: getContextNodeForNodeEntry(node) + }; + } + + export function isContextWithStartAndEndNode(node: ContextNode): node is ContextWithStartAndEndNode { + return node && (node as Node).kind === undefined; + } + + function getContextNodeForNodeEntry(node: Node): ContextNode | undefined { + if (isDeclaration(node)) { + return getContextNode(node); + } + + if (!node.parent) return undefined; + + if (!isDeclaration(node.parent) && !isExportAssignment(node.parent)) { + // Special property assignment in javascript + if (isInJSFile(node)) { + const binaryExpression = isBinaryExpression(node.parent) ? + node.parent : + isPropertyAccessExpression(node.parent) && + isBinaryExpression(node.parent.parent) && + node.parent.parent.left === node.parent ? + node.parent.parent : + undefined; + if (binaryExpression && getAssignmentDeclarationKind(binaryExpression) !== AssignmentDeclarationKind.None) { + return getContextNode(binaryExpression); + } + } + + // Jsx Tags + if (isJsxOpeningElement(node.parent) || isJsxClosingElement(node.parent)) { + return node.parent.parent; + } + else if (isJsxSelfClosingElement(node.parent) || + isLabeledStatement(node.parent) || + isBreakOrContinueStatement(node.parent)) { + return node.parent; + } + else if (isStringLiteralLike(node)) { + const validImport = tryGetImportFromModuleSpecifier(node); + if (validImport) { + const declOrStatement = findAncestor(validImport, node => + isDeclaration(node) || + isStatement(node) || + isJSDocTag(node) + )! as NamedDeclaration | Statement | JSDocTag; + return isDeclaration(declOrStatement) ? + getContextNode(declOrStatement) : + declOrStatement; + } + } + + // Handle computed property name + const propertyName = findAncestor(node, isComputedPropertyName); + return propertyName ? + getContextNode(propertyName.parent) : + undefined; + } + + if (node.parent.name === node || // node is name of declaration, use parent + isConstructorDeclaration(node.parent) || + isExportAssignment(node.parent) || + // Property name of the import export specifier or binding pattern, use parent + ((isImportOrExportSpecifier(node.parent) || isBindingElement(node.parent)) + && node.parent.propertyName === node) || + // Is default export + (node.kind === SyntaxKind.DefaultKeyword && hasModifier(node.parent, ModifierFlags.ExportDefault))) { + return getContextNode(node.parent); + } + + return undefined; + } + + export function getContextNode(node: NamedDeclaration | BinaryExpression | ForInOrOfStatement | undefined): ContextNode | undefined { + if (!node) return undefined; + switch (node.kind) { + case SyntaxKind.VariableDeclaration: + return !isVariableDeclarationList(node.parent) || node.parent.declarations.length !== 1 ? + node : + isVariableStatement(node.parent.parent) ? + node.parent.parent : + isForInOrOfStatement(node.parent.parent) ? + getContextNode(node.parent.parent) : + node.parent; + + case SyntaxKind.BindingElement: + return getContextNode(node.parent.parent as NamedDeclaration); + + case SyntaxKind.ImportSpecifier: + return node.parent.parent.parent; + + case SyntaxKind.ExportSpecifier: + case SyntaxKind.NamespaceImport: + return node.parent.parent; + + case SyntaxKind.ImportClause: + return node.parent; + + case SyntaxKind.BinaryExpression: + return isExpressionStatement(node.parent) ? + node.parent : + node; + + case SyntaxKind.ForOfStatement: + case SyntaxKind.ForInStatement: + return { + start: (node as ForInOrOfStatement).initializer, + end: (node as ForInOrOfStatement).expression + }; + + case SyntaxKind.PropertyAssignment: + case SyntaxKind.ShorthandPropertyAssignment: + return isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent) ? + getContextNode( + findAncestor(node.parent, node => + isBinaryExpression(node) || isForInOrOfStatement(node) + ) as BinaryExpression | ForInOrOfStatement + ) : + node; + + default: + return node; + } + } + + export function toContextSpan(textSpan: TextSpan, sourceFile: SourceFile, context?: ContextNode): { contextSpan: TextSpan } | undefined { + if (!context) return undefined; + const contextSpan = isContextWithStartAndEndNode(context) ? + getTextSpan(context.start, sourceFile, context.end) : + getTextSpan(context, sourceFile); + return contextSpan.start !== textSpan.start || contextSpan.length !== textSpan.length ? + { contextSpan } : + undefined; } export interface Options { @@ -123,7 +265,16 @@ namespace ts.FindAllReferences { const { symbol } = def; const { displayParts, kind } = getDefinitionKindAndDisplayParts(symbol, checker, originalNode); const name = displayParts.map(p => p.text).join(""); - return { node: symbol.declarations ? getNameOfDeclaration(first(symbol.declarations)) || first(symbol.declarations) : originalNode, name, kind, displayParts }; + const declaration = symbol.declarations ? first(symbol.declarations) : undefined; + return { + node: declaration ? + getNameOfDeclaration(declaration) || declaration : + originalNode, + name, + kind, + displayParts, + context: getContextNode(declaration) + }; } case DefinitionKind.Label: { const { node } = def; @@ -150,9 +301,19 @@ namespace ts.FindAllReferences { } })(); - const { node, name, kind, displayParts } = info; + const { node, name, kind, displayParts, context } = info; const sourceFile = node.getSourceFile(); - return { containerKind: ScriptElementKind.unknown, containerName: "", fileName: sourceFile.fileName, kind, name, textSpan: getTextSpan(isComputedPropertyName(node) ? node.expression : node, sourceFile), displayParts }; + const textSpan = getTextSpan(isComputedPropertyName(node) ? node.expression : node, sourceFile); + return { + containerKind: ScriptElementKind.unknown, + containerName: "", + fileName: sourceFile.fileName, + kind, + name, + textSpan, + displayParts, + ...toContextSpan(textSpan, sourceFile, context) + }; } function getDefinitionKindAndDisplayParts(symbol: Symbol, checker: TypeChecker, node: Node): { displayParts: SymbolDisplayPart[], kind: ScriptElementKind } { @@ -168,14 +329,13 @@ namespace ts.FindAllReferences { } export function toReferenceEntry(entry: Entry): ReferenceEntry { - const { textSpan, fileName } = entryToDocumentSpan(entry); + const documentSpan = entryToDocumentSpan(entry); if (entry.kind === EntryKind.Span) { - return { textSpan, fileName, isWriteAccess: false, isDefinition: false }; + return { ...documentSpan, isWriteAccess: false, isDefinition: false }; } const { kind, node } = entry; return { - textSpan, - fileName, + ...documentSpan, isWriteAccess: isWriteAccessForReference(node), isDefinition: node.kind === SyntaxKind.DefaultKeyword || !!getDeclarationFromName(node) @@ -190,7 +350,12 @@ namespace ts.FindAllReferences { } else { const sourceFile = entry.node.getSourceFile(); - return { textSpan: getTextSpan(entry.node, sourceFile), fileName: sourceFile.fileName }; + const textSpan = getTextSpan(entry.node, sourceFile); + return { + textSpan, + fileName: sourceFile.fileName, + ...toContextSpan(textSpan, sourceFile, entry.context) + }; } } @@ -223,14 +388,16 @@ namespace ts.FindAllReferences { } function toImplementationLocation(entry: Entry, checker: TypeChecker): ImplementationLocation { + const documentSpan = entryToDocumentSpan(entry); if (entry.kind !== EntryKind.Span) { const { node } = entry; - const sourceFile = node.getSourceFile(); - return { textSpan: getTextSpan(node, sourceFile), fileName: sourceFile.fileName, ...implementationKindDisplayParts(node, checker) }; + return { + ...documentSpan, + ...implementationKindDisplayParts(node, checker) + }; } else { - const { textSpan, fileName } = entry; - return { textSpan, fileName, kind: ScriptElementKind.unknown, displayParts: [] }; + return { ...documentSpan, kind: ScriptElementKind.unknown, displayParts: [] }; } } @@ -257,26 +424,32 @@ namespace ts.FindAllReferences { } export function toHighlightSpan(entry: Entry): { fileName: string, span: HighlightSpan } { + const documentSpan = entryToDocumentSpan(entry); if (entry.kind === EntryKind.Span) { - const { fileName, textSpan } = entry; - return { fileName, span: { textSpan, kind: HighlightSpanKind.reference } }; + return { + fileName: documentSpan.fileName, + span: { + textSpan: documentSpan.textSpan, + kind: HighlightSpanKind.reference + } + }; } - const { node, kind } = entry; - const sourceFile = node.getSourceFile(); - const writeAccess = isWriteAccessForReference(node); + const writeAccess = isWriteAccessForReference(entry.node); const span: HighlightSpan = { - textSpan: getTextSpan(node, sourceFile), + textSpan: documentSpan.textSpan, kind: writeAccess ? HighlightSpanKind.writtenReference : HighlightSpanKind.reference, - isInString: kind === EntryKind.StringLiteral ? true : undefined, + isInString: entry.kind === EntryKind.StringLiteral ? true : undefined, + ...documentSpan.contextSpan && { contextSpan: documentSpan.contextSpan } }; - return { fileName: sourceFile.fileName, span }; + return { fileName: documentSpan.fileName, span }; } - function getTextSpan(node: Node, sourceFile: SourceFile): TextSpan { + function getTextSpan(node: Node, sourceFile: SourceFile, endNode?: Node): TextSpan { let start = node.getStart(sourceFile); - let end = node.getEnd(); + let end = (endNode || node).getEnd(); if (node.kind === SyntaxKind.StringLiteral) { + Debug.assert(endNode === undefined); start += 1; end -= 1; } diff --git a/src/services/goToDefinition.ts b/src/services/goToDefinition.ts index 8f495aadfe165..fbd0be91022f3 100644 --- a/src/services/goToDefinition.ts +++ b/src/services/goToDefinition.ts @@ -273,13 +273,19 @@ namespace ts.GoToDefinition { function createDefinitionInfoFromName(declaration: Declaration, symbolKind: ScriptElementKind, symbolName: string, containerName: string): DefinitionInfo { const name = getNameOfDeclaration(declaration) || declaration; const sourceFile = name.getSourceFile(); + const textSpan = createTextSpanFromNode(name, sourceFile); return { fileName: sourceFile.fileName, - textSpan: createTextSpanFromNode(name, sourceFile), + textSpan, kind: symbolKind, name: symbolName, containerKind: undefined!, // TODO: GH#18217 - containerName + containerName, + ...FindAllReferences.toContextSpan( + textSpan, + sourceFile, + FindAllReferences.getContextNode(declaration) + ) }; } diff --git a/src/services/services.ts b/src/services/services.ts index 6c882bbb28f0e..fab6f88b779e0 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -1544,13 +1544,17 @@ namespace ts { /// References and Occurrences function getOccurrencesAtPosition(fileName: string, position: number): ReadonlyArray | undefined { - return flatMap(getDocumentHighlights(fileName, position, [fileName]), entry => entry.highlightSpans.map(highlightSpan => ({ - fileName: entry.fileName, - textSpan: highlightSpan.textSpan, - isWriteAccess: highlightSpan.kind === HighlightSpanKind.writtenReference, - isDefinition: false, - isInString: highlightSpan.isInString, - }))); + return flatMap( + getDocumentHighlights(fileName, position, [fileName]), + entry => entry.highlightSpans.map(highlightSpan => ({ + fileName: entry.fileName, + textSpan: highlightSpan.textSpan, + isWriteAccess: highlightSpan.kind === HighlightSpanKind.writtenReference, + isDefinition: false, + ...highlightSpan.isInString && { isInString: true }, + ...highlightSpan.contextSpan && { contextSpan: highlightSpan.contextSpan } + })) + ); } function getDocumentHighlights(fileName: string, position: number, filesToSearch: ReadonlyArray): DocumentHighlights[] | undefined { @@ -1568,8 +1572,14 @@ namespace ts { const node = getTouchingPropertyName(sourceFile, position); if (isIdentifier(node) && (isJsxOpeningElement(node.parent) || isJsxClosingElement(node.parent)) && isIntrinsicJsxName(node.escapedText)) { const { openingElement, closingElement } = node.parent.parent; - return [openingElement, closingElement].map((node): RenameLocation => - ({ fileName: sourceFile.fileName, textSpan: createTextSpanFromNode(node.tagName, sourceFile) })); + return [openingElement, closingElement].map((node): RenameLocation => { + const textSpan = createTextSpanFromNode(node.tagName, sourceFile); + return { + fileName: sourceFile.fileName, + textSpan, + ...FindAllReferences.toContextSpan(textSpan, sourceFile, node.parent) + }; + }); } else { return getReferencesWorker(node, position, { findInStrings, findInComments, providePrefixAndSuffixTextForRename, isForRename: true }, diff --git a/src/services/types.ts b/src/services/types.ts index 8dee6c4f053c9..b97125734f7c5 100644 --- a/src/services/types.ts +++ b/src/services/types.ts @@ -613,6 +613,13 @@ namespace ts { */ originalTextSpan?: TextSpan; originalFileName?: string; + + /** + * If DocumentSpan.textSpan is the span for name of the declaration, + * then this is the span for relevant declaration + */ + contextSpan?: TextSpan; + originalContextSpan?: TextSpan; } export interface RenameLocation extends DocumentSpan { @@ -647,6 +654,7 @@ namespace ts { fileName?: string; isInString?: true; textSpan: TextSpan; + contextSpan?: TextSpan; kind: HighlightSpanKind; } diff --git a/src/services/utilities.ts b/src/services/utilities.ts index 5506b45d3808d..35fca7f0e65fa 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -1190,8 +1190,8 @@ namespace ts { return !!range && shouldBeReference === tripleSlashDirectivePrefixRegex.test(sourceFile.text.substring(range.pos, range.end)); } - export function createTextSpanFromNode(node: Node, sourceFile?: SourceFile): TextSpan { - return createTextSpanFromBounds(node.getStart(sourceFile), node.getEnd()); + export function createTextSpanFromNode(node: Node, sourceFile?: SourceFile, endNode?: Node): TextSpan { + return createTextSpanFromBounds(node.getStart(sourceFile), (endNode || node).getEnd()); } export function createTextRangeFromNode(node: Node, sourceFile: SourceFile): TextRange { diff --git a/src/testRunner/unittests/tsserver/declarationFileMaps.ts b/src/testRunner/unittests/tsserver/declarationFileMaps.ts index 200d7af0240b7..0f8af3c414eab 100644 --- a/src/testRunner/unittests/tsserver/declarationFileMaps.ts +++ b/src/testRunner/unittests/tsserver/declarationFileMaps.ts @@ -1,28 +1,43 @@ namespace ts.projectSystem { - function protocolFileSpanFromSubstring(file: File, substring: string, options?: SpanFromSubstringOptions): protocol.FileSpan { - return { file: file.path, ...protocolTextSpanFromSubstring(file.content, substring, options) }; + interface DocumentSpanFromSubstring { + file: File; + text: string; + options?: SpanFromSubstringOptions; + contextText?: string; + contextOptions?: SpanFromSubstringOptions; } - - function documentSpanFromSubstring(file: File, substring: string, options?: SpanFromSubstringOptions): DocumentSpan { - return { fileName: file.path, textSpan: textSpanFromSubstring(file.content, substring, options) }; + function documentSpanFromSubstring({ file, text, contextText, options, contextOptions }: DocumentSpanFromSubstring): DocumentSpan { + const contextSpan = contextText !== undefined ? documentSpanFromSubstring({ file, text: contextText, options: contextOptions }) : undefined; + return { + fileName: file.path, + textSpan: textSpanFromSubstring(file.content, text, options), + ...contextSpan && { contextSpan: contextSpan.textSpan } + }; } - function renameLocation(file: File, substring: string, options?: SpanFromSubstringOptions): RenameLocation { - return documentSpanFromSubstring(file, substring, options); + function renameLocation(input: DocumentSpanFromSubstring): RenameLocation { + return documentSpanFromSubstring(input); } - function makeReferenceItem(file: File, isDefinition: boolean, text: string, lineText: string, options?: SpanFromSubstringOptions): protocol.ReferencesResponseItem { + interface MakeReferenceItem extends DocumentSpanFromSubstring { + isDefinition: boolean; + lineText: string; + } + function makeReferenceItem({ isDefinition, lineText, ...rest }: MakeReferenceItem): protocol.ReferencesResponseItem { return { - ...protocolFileSpanFromSubstring(file, text, options), + ...protocolFileSpanWithContextFromSubstring(rest), isDefinition, isWriteAccess: isDefinition, lineText, }; } - function makeReferenceEntry(file: File, isDefinition: boolean, text: string, options?: SpanFromSubstringOptions): ReferenceEntry { + interface MakeReferenceEntry extends DocumentSpanFromSubstring { + isDefinition: boolean; + } + function makeReferenceEntry({ isDefinition, ...rest }: MakeReferenceEntry): ReferenceEntry { return { - ...documentSpanFromSubstring(file, text, options), + ...documentSpanFromSubstring(rest), isDefinition, isWriteAccess: isDefinition, isInString: undefined, @@ -190,7 +205,13 @@ namespace ts.projectSystem { it("goToDefinition", () => { const session = makeSampleProjects(); const response = executeSessionRequest(session, protocol.CommandTypes.Definition, protocolFileLocationFromSubstring(userTs, "fnA()")); - assert.deepEqual(response, [protocolFileSpanFromSubstring(aTs, "fnA")]); + assert.deepEqual(response, [ + protocolFileSpanWithContextFromSubstring({ + file: aTs, + text: "fnA", + contextText: "export function fnA() {}" + }) + ]); verifySingleInferredProject(session); }); @@ -199,7 +220,13 @@ namespace ts.projectSystem { const response = executeSessionRequest(session, protocol.CommandTypes.DefinitionAndBoundSpan, protocolFileLocationFromSubstring(userTs, "fnA()")); assert.deepEqual(response, { textSpan: protocolTextSpanFromSubstring(userTs.content, "fnA"), - definitions: [protocolFileSpanFromSubstring(aTs, "fnA")], + definitions: [ + protocolFileSpanWithContextFromSubstring({ + file: aTs, + text: "fnA", + contextText: "export function fnA() {}" + }) + ], }); verifySingleInferredProject(session); }); @@ -209,7 +236,13 @@ namespace ts.projectSystem { const response = executeSessionRequest(session, protocol.CommandTypes.DefinitionAndBoundSpan, protocolFileLocationFromSubstring(userTs, "fnA()")); assert.deepEqual(response, { textSpan: protocolTextSpanFromSubstring(userTs.content, "fnA"), - definitions: [protocolFileSpanFromSubstring(aTs, "fnA")], + definitions: [ + protocolFileSpanWithContextFromSubstring({ + file: aTs, + text: "fnA", + contextText: "export function fnA() {}" + }) + ], }); checkNumberOfProjects(session.getProjectService(), { configuredProjects: 1 }); verifyUserTsConfigProject(session); @@ -230,14 +263,25 @@ namespace ts.projectSystem { it("goToType", () => { const session = makeSampleProjects(); const response = executeSessionRequest(session, protocol.CommandTypes.TypeDefinition, protocolFileLocationFromSubstring(userTs, "instanceA")); - assert.deepEqual(response, [protocolFileSpanFromSubstring(aTs, "IfaceA")]); + assert.deepEqual(response, [ + protocolFileSpanWithContextFromSubstring({ + file: aTs, + text: "IfaceA", + contextText: "export interface IfaceA {}" + }) + ]); verifySingleInferredProject(session); }); it("goToImplementation", () => { const session = makeSampleProjects(); const response = executeSessionRequest(session, protocol.CommandTypes.Implementation, protocolFileLocationFromSubstring(userTs, "fnA()")); - assert.deepEqual(response, [protocolFileSpanFromSubstring(aTs, "fnA")]); + assert.deepEqual(response, [ + protocolFileSpanWithContextFromSubstring({ + file: aTs, + text: "fnA", + contextText: "export function fnA() {}" + })]); verifySingleInferredProject(session); }); @@ -245,7 +289,13 @@ namespace ts.projectSystem { const session = makeSampleProjects(); const response = executeSessionRequest(session, CommandNames.Definition, protocolFileLocationFromSubstring(userTs, "fnB()")); // bTs does not exist, so stick with bDts - assert.deepEqual(response, [protocolFileSpanFromSubstring(bDts, "fnB")]); + assert.deepEqual(response, [ + protocolFileSpanWithContextFromSubstring({ + file: bDts, + text: "fnB", + contextText: "export declare function fnB(): void;" + }) + ]); verifySingleInferredProject(session); }); @@ -254,7 +304,10 @@ namespace ts.projectSystem { const response = executeSessionRequest(session, CommandNames.Navto, { file: userTs.path, searchValue: "fn" }); assert.deepEqual | undefined>(response, [ { - ...protocolFileSpanFromSubstring(bDts, "export declare function fnB(): void;"), + ...protocolFileSpanFromSubstring({ + file: bDts, + text: "export declare function fnB(): void;" + }), name: "fnB", matchKind: "prefix", isCaseSensitive: true, @@ -262,7 +315,10 @@ namespace ts.projectSystem { kindModifiers: "export,declare", }, { - ...protocolFileSpanFromSubstring(userTs, "export function fnUser() { a.fnA(); b.fnB(); a.instanceA; }"), + ...protocolFileSpanFromSubstring({ + file: userTs, + text: "export function fnUser() { a.fnA(); b.fnB(); a.instanceA; }" + }), name: "fnUser", matchKind: "prefix", isCaseSensitive: true, @@ -270,7 +326,10 @@ namespace ts.projectSystem { kindModifiers: "export", }, { - ...protocolFileSpanFromSubstring(aTs, "export function fnA() {}"), + ...protocolFileSpanFromSubstring({ + file: aTs, + text: "export function fnA() {}" + }), name: "fnA", matchKind: "prefix", isCaseSensitive: true, @@ -282,9 +341,20 @@ namespace ts.projectSystem { verifyATsConfigOriginalProject(session); }); - const referenceATs = (aTs: File): protocol.ReferencesResponseItem => makeReferenceItem(aTs, /*isDefinition*/ true, "fnA", "export function fnA() {}"); + const referenceATs = (aTs: File): protocol.ReferencesResponseItem => makeReferenceItem({ + file: aTs, + isDefinition: true, + text: "fnA", + contextText: "export function fnA() {}", + lineText: "export function fnA() {}" + }); const referencesUserTs = (userTs: File): ReadonlyArray => [ - makeReferenceItem(userTs, /*isDefinition*/ false, "fnA", "export function fnUser() { a.fnA(); b.fnB(); a.instanceA; }"), + makeReferenceItem({ + file: userTs, + isDefinition: false, + text: "fnA", + lineText: "export function fnUser() { a.fnA(); b.fnB(); a.instanceA; }" + }), ]; it("findAllReferences", () => { @@ -325,7 +395,11 @@ namespace ts.projectSystem { assert.deepEqual>(responseFull, [ { definition: { - ...documentSpanFromSubstring(aTs, "fnA"), + ...documentSpanFromSubstring({ + file: aTs, + text: "fnA", + contextText: "export function fnA() {}" + }), kind: ScriptElementKind.functionElement, name: "function fnA(): void", containerKind: ScriptElementKind.unknown, @@ -342,8 +416,8 @@ namespace ts.projectSystem { ], }, references: [ - makeReferenceEntry(userTs, /*isDefinition*/ false, "fnA"), - makeReferenceEntry(aTs, /*isDefinition*/ true, "fnA"), + makeReferenceEntry({ file: userTs, /*isDefinition*/ isDefinition: false, text: "fnA" }), + makeReferenceEntry({ file: aTs, /*isDefinition*/ isDefinition: true, text: "fnA", contextText: "export function fnA() {}" }), ], }, ]); @@ -374,6 +448,12 @@ namespace ts.projectSystem { assert.deepEqual>(responseFull, [ { definition: { + ...documentSpanFromSubstring({ + file: aTs, + text: "f", + options: { index: 1 }, + contextText: "function f() {}" + }), containerKind: ScriptElementKind.unknown, containerName: "", displayParts: [ @@ -386,10 +466,8 @@ namespace ts.projectSystem { spacePart(), keywordPart(SyntaxKind.VoidKeyword), ], - fileName: aTs.path, kind: ScriptElementKind.functionElement, name: "function f(): void", - textSpan: { start: 9, length: 1 }, }, references: [ { @@ -399,13 +477,13 @@ namespace ts.projectSystem { isWriteAccess: false, textSpan: { start: 0, length: 1 }, }, - { - fileName: aTs.path, - isDefinition: true, - isInString: undefined, - isWriteAccess: true, - textSpan: { start: 9, length: 1 }, - }, + makeReferenceEntry({ + file: aTs, + text: "f", + options: { index: 1 }, + contextText: "function f() {}", + isDefinition: true + }) ], } ]); @@ -417,8 +495,19 @@ namespace ts.projectSystem { const response = executeSessionRequest(session, protocol.CommandTypes.References, protocolFileLocationFromSubstring(userTs, "fnB()")); assert.deepEqual(response, { refs: [ - makeReferenceItem(bDts, /*isDefinition*/ true, "fnB", "export declare function fnB(): void;"), - makeReferenceItem(userTs, /*isDefinition*/ false, "fnB", "export function fnUser() { a.fnA(); b.fnB(); a.instanceA; }"), + makeReferenceItem({ + file: bDts, + isDefinition: true, + text: "fnB", + contextText: "export declare function fnB(): void;", + lineText: "export declare function fnB(): void;" + }), + makeReferenceItem({ + file: userTs, + isDefinition: false, + text: "fnB", + lineText: "export function fnUser() { a.fnA(); b.fnB(); a.instanceA; }" + }), ], symbolName: "fnB", symbolStartOffset: protocolLocationFromSubstring(userTs.content, "fnB()").offset, @@ -429,11 +518,22 @@ namespace ts.projectSystem { const renameATs = (aTs: File): protocol.SpanGroup => ({ file: aTs.path, - locs: [protocolRenameSpanFromSubstring(aTs.content, "fnA")], + locs: [ + protocolRenameSpanFromSubstring({ + fileText: aTs.content, + text: "fnA", + contextText: "export function fnA() {}" + }) + ], }); const renameUserTs = (userTs: File): protocol.SpanGroup => ({ file: userTs.path, - locs: [protocolRenameSpanFromSubstring(userTs.content, "fnA")], + locs: [ + protocolRenameSpanFromSubstring({ + fileText: userTs.content, + text: "fnA" + }) + ], }); it("renameLocations", () => { @@ -477,8 +577,8 @@ namespace ts.projectSystem { const session = makeSampleProjects(); const response = executeSessionRequest(session, protocol.CommandTypes.RenameLocationsFull, protocolFileLocationFromSubstring(userTs, "fnA()")); assert.deepEqual>(response, [ - renameLocation(userTs, "fnA"), - renameLocation(aTs, "fnA"), + renameLocation({ file: userTs, text: "fnA" }), + renameLocation({ file: aTs, text: "fnA", contextText: "export function fnA() {}" }), ]); verifyATsConfigOriginalProject(session); }); @@ -499,11 +599,22 @@ namespace ts.projectSystem { locs: [ { file: bDts.path, - locs: [protocolRenameSpanFromSubstring(bDts.content, "fnB")], + locs: [ + protocolRenameSpanFromSubstring({ + fileText: bDts.content, + text: "fnB", + contextText: "export declare function fnB(): void;" + }) + ], }, { file: userTs.path, - locs: [protocolRenameSpanFromSubstring(userTs.content, "fnB")], + locs: [ + protocolRenameSpanFromSubstring({ + fileText: userTs.content, + text: "fnB" + }) + ], }, ], }); diff --git a/src/testRunner/unittests/tsserver/helpers.ts b/src/testRunner/unittests/tsserver/helpers.ts index b230e1755ca46..1c2383ab00443 100644 --- a/src/testRunner/unittests/tsserver/helpers.ts +++ b/src/testRunner/unittests/tsserver/helpers.ts @@ -512,13 +512,68 @@ namespace ts.projectSystem { return { start: toLocation(span.start), end: toLocation(textSpanEnd(span)) }; } - export function protocolRenameSpanFromSubstring( - str: string, - substring: string, - options?: SpanFromSubstringOptions, - prefixSuffixText?: { readonly prefixText?: string, readonly suffixText?: string }, - ): protocol.RenameTextSpan { - return { ...protocolTextSpanFromSubstring(str, substring, options), ...prefixSuffixText }; + export interface DocumentSpanFromSubstring { + file: File; + text: string; + options?: SpanFromSubstringOptions; + } + export function protocolFileSpanFromSubstring({ file, text, options }: DocumentSpanFromSubstring): protocol.FileSpan { + return { file: file.path, ...protocolTextSpanFromSubstring(file.content, text, options) }; + } + + interface FileSpanWithContextFromSubString { + file: File; + text: string; + options?: SpanFromSubstringOptions; + contextText?: string; + contextOptions?: SpanFromSubstringOptions; + } + export function protocolFileSpanWithContextFromSubstring({ contextText, contextOptions, ...rest }: FileSpanWithContextFromSubString): protocol.FileSpanWithContext { + const result = protocolFileSpanFromSubstring(rest); + const contextSpan = contextText !== undefined ? + protocolFileSpanFromSubstring({ file: rest.file, text: contextText, options: contextOptions }) : + undefined; + return contextSpan ? + { + ...result, + contextStart: contextSpan.start, + contextEnd: contextSpan.end + } : + result; + } + + export interface ProtocolTextSpanWithContextFromString { + fileText: string; + text: string; + options?: SpanFromSubstringOptions; + contextText?: string; + contextOptions?: SpanFromSubstringOptions; + } + export function protocolTextSpanWithContextFromSubstring({ fileText, text, options, contextText, contextOptions }: ProtocolTextSpanWithContextFromString): protocol.TextSpanWithContext { + const span = textSpanFromSubstring(fileText, text, options); + const toLocation = protocolToLocation(fileText); + const contextSpan = contextText !== undefined ? textSpanFromSubstring(fileText, contextText, contextOptions) : undefined; + return { + start: toLocation(span.start), + end: toLocation(textSpanEnd(span)), + ...contextSpan && { + contextStart: toLocation(contextSpan.start), + contextEnd: toLocation(textSpanEnd(contextSpan)) + } + }; + } + + export interface ProtocolRenameSpanFromSubstring extends ProtocolTextSpanWithContextFromString { + prefixSuffixText?: { + readonly prefixText?: string; + readonly suffixText?: string; + }; + } + export function protocolRenameSpanFromSubstring({ prefixSuffixText, ...rest }: ProtocolRenameSpanFromSubstring): protocol.RenameTextSpan { + return { + ...protocolTextSpanWithContextFromSubstring(rest), + ...prefixSuffixText + }; } export function textSpanFromSubstring(str: string, substring: string, options?: SpanFromSubstringOptions): TextSpan { diff --git a/src/testRunner/unittests/tsserver/projectReferences.ts b/src/testRunner/unittests/tsserver/projectReferences.ts index f07774cd43c1d..1b2e90bcd4f6f 100644 --- a/src/testRunner/unittests/tsserver/projectReferences.ts +++ b/src/testRunner/unittests/tsserver/projectReferences.ts @@ -69,21 +69,24 @@ namespace ts.projectSystem { openFilesForSession([containerCompositeExec[1]], session); const service = session.getProjectService(); checkNumberOfProjects(service, { configuredProjects: 1 }); - const locationOfMyConst = protocolLocationFromSubstring(containerCompositeExec[1].content, "myConst"); + const { file: myConstFile, start: myConstStart, end: myConstEnd } = protocolFileSpanFromSubstring({ + file: containerCompositeExec[1], + text: "myConst", + }); const response = session.executeCommandSeq({ command: protocol.CommandTypes.Rename, - arguments: { - file: containerCompositeExec[1].path, - ...locationOfMyConst - } + arguments: { file: myConstFile, ...myConstStart } }).response as protocol.RenameResponseBody; - - const myConstLen = "myConst".length; - const locationOfMyConstInLib = protocolLocationFromSubstring(containerLib[1].content, "myConst"); + const locationOfMyConstInLib = protocolFileSpanWithContextFromSubstring({ + file: containerLib[1], + text: "myConst", + contextText: "export const myConst = 30;" + }); + const { file: _, ...renameTextOfMyConstInLib } = locationOfMyConstInLib; assert.deepEqual(response.locs, [ - { file: containerCompositeExec[1].path, locs: [{ start: locationOfMyConst, end: { line: locationOfMyConst.line, offset: locationOfMyConst.offset + myConstLen } }] }, - { file: containerLib[1].path, locs: [{ start: locationOfMyConstInLib, end: { line: locationOfMyConstInLib.line, offset: locationOfMyConstInLib.offset + myConstLen } }] } + { file: myConstFile, locs: [{ start: myConstStart, end: myConstEnd }] }, + { file: locationOfMyConstInLib.file, locs: [renameTextOfMyConstInLib] } ]); }); }); @@ -169,7 +172,7 @@ fn5(); } function gotoDefintinionFromMainTs(fn: number): SessionAction { const textSpan = usageSpan(fn); - const definition: protocol.FileSpan = { file: dependencyTs.path, ...definitionSpan(fn) }; + const definition: protocol.FileSpan = { file: dependencyTs.path, ...declarationSpan(fn) }; const declareSpaceLength = "declare ".length; return { reqName: "goToDef", @@ -184,7 +187,13 @@ fn5(); }, expectedResponseNoMap: { // To the dts - definitions: [{ file: dtsPath, start: { line: fn, offset: definition.start.offset + declareSpaceLength }, end: { line: fn, offset: definition.end.offset + declareSpaceLength } }], + definitions: [{ + file: dtsPath, + start: { line: fn, offset: definition.start.offset + declareSpaceLength }, + end: { line: fn, offset: definition.end.offset + declareSpaceLength }, + contextStart: { line: fn, offset: 1 }, + contextEnd: { line: fn, offset: 37 } + }], textSpan }, expectedResponseNoDts: { @@ -195,18 +204,29 @@ fn5(); }; } - function definitionSpan(fn: number): protocol.TextSpan { - return { start: { line: fn, offset: 17 }, end: { line: fn, offset: 20 } }; + function declarationSpan(fn: number): protocol.TextSpanWithContext { + return { + start: { line: fn, offset: 17 }, + end: { line: fn, offset: 20 }, + contextStart: { line: fn, offset: 1 }, + contextEnd: { line: fn, offset: 26 } + }; } - function importSpan(fn: number): protocol.TextSpan { - return { start: { line: fn + 1, offset: 5 }, end: { line: fn + 1, offset: 8 } }; + function importSpan(fn: number): protocol.TextSpanWithContext { + return { + start: { line: fn + 1, offset: 5 }, + end: { line: fn + 1, offset: 8 }, + contextStart: { line: 1, offset: 1 }, + contextEnd: { line: 7, offset: 27 } + }; } function usageSpan(fn: number): protocol.TextSpan { return { start: { line: fn + 8, offset: 1 }, end: { line: fn + 8, offset: 4 } }; } function renameFromDependencyTs(fn: number): SessionAction { - const triggerSpan = definitionSpan(fn); + const defSpan = declarationSpan(fn); + const { contextStart: _, contextEnd: _1, ...triggerSpan } = defSpan; return { reqName: "rename", request: { @@ -224,7 +244,7 @@ fn5(); triggerSpan }, locs: [ - { file: dependencyTs.path, locs: [triggerSpan] } + { file: dependencyTs.path, locs: [defSpan] } ] } }; diff --git a/src/testRunner/unittests/tsserver/rename.ts b/src/testRunner/unittests/tsserver/rename.ts index f565524aded63..7849b36a3fce9 100644 --- a/src/testRunner/unittests/tsserver/rename.ts +++ b/src/testRunner/unittests/tsserver/rename.ts @@ -14,7 +14,16 @@ namespace ts.projectSystem { canRename: false, localizedErrorMessage: "You cannot rename this element." }, - locs: [{ file: bTs.path, locs: [protocolRenameSpanFromSubstring(bTs.content, "./a")] }], + locs: [{ + file: bTs.path, + locs: [ + protocolRenameSpanFromSubstring({ + fileText: bTs.content, + text: "./a", + contextText: bTs.content + }) + ] + }], }); // rename succeeds with allowRenameOfImportPath enabled in host @@ -30,7 +39,16 @@ namespace ts.projectSystem { kindModifiers: "", triggerSpan: protocolTextSpanFromSubstring(bTs.content, "a", { index: 1 }), }, - locs: [{ file: bTs.path, locs: [protocolRenameSpanFromSubstring(bTs.content, "./a")] }], + locs: [{ + file: bTs.path, + locs: [ + protocolRenameSpanFromSubstring({ + fileText: bTs.content, + text: "./a", + contextText: bTs.content + }) + ] + }], }); // rename succeeds with allowRenameOfImportPath enabled in file @@ -47,7 +65,16 @@ namespace ts.projectSystem { kindModifiers: "", triggerSpan: protocolTextSpanFromSubstring(bTs.content, "a", { index: 1 }), }, - locs: [{ file: bTs.path, locs: [protocolRenameSpanFromSubstring(bTs.content, "./a")] }], + locs: [{ + file: bTs.path, + locs: [ + protocolRenameSpanFromSubstring({ + fileText: bTs.content, + text: "./a", + contextText: bTs.content + }) + ] + }], }); }); @@ -73,8 +100,16 @@ namespace ts.projectSystem { { file: aTs.path, locs: [ - protocolRenameSpanFromSubstring(aTs.content, "x"), - protocolRenameSpanFromSubstring(aTs.content, "x", { index: 1 }), + protocolRenameSpanFromSubstring({ + fileText: aTs.content, + text: "x", + contextText: "const x = 0;" + }), + protocolRenameSpanFromSubstring({ + fileText: aTs.content, + text: "x", + options: { index: 1 } + }), ], }, ], @@ -97,8 +132,17 @@ namespace ts.projectSystem { { file: aTs.path, locs: [ - protocolRenameSpanFromSubstring(aTs.content, "x"), - protocolRenameSpanFromSubstring(aTs.content, "x", { index: 1 }, { prefixText: "x: " }), + protocolRenameSpanFromSubstring({ + fileText: aTs.content, + text: "x", + contextText: "const x = 0;" + }), + protocolRenameSpanFromSubstring({ + fileText: aTs.content, + text: "x", + options: { index: 1 }, + prefixSuffixText: { prefixText: "x: " } + }), ], }, ], @@ -122,8 +166,17 @@ namespace ts.projectSystem { { file: aTs.path, locs: [ - protocolRenameSpanFromSubstring(aTs.content, "x"), - protocolRenameSpanFromSubstring(aTs.content, "x", { index: 1 }, { prefixText: "x: " }), + protocolRenameSpanFromSubstring({ + fileText: aTs.content, + text: "x", + contextText: "const x = 0;" + }), + protocolRenameSpanFromSubstring({ + fileText: aTs.content, + text: "x", + options: { index: 1 }, + prefixSuffixText: { prefixText: "x: " } + }), ], }, ], @@ -154,8 +207,18 @@ namespace ts.projectSystem { { file: aTs.path, locs: [ - protocolRenameSpanFromSubstring(aTs.content, "x"), - protocolRenameSpanFromSubstring(aTs.content, "x", { index: 2 }, { suffixText: " as x" }), + protocolRenameSpanFromSubstring({ + fileText: aTs.content, + text: "x", + contextText: "const x = 1;" + }), + protocolRenameSpanFromSubstring({ + fileText: aTs.content, + text: "x", + options: { index: 2 }, + contextText: "export { x };", + prefixSuffixText: { suffixText: " as x" } + }), ], }, ], @@ -177,15 +240,32 @@ namespace ts.projectSystem { { file: bTs.path, locs: [ - protocolRenameSpanFromSubstring(bTs.content, "x"), - protocolRenameSpanFromSubstring(bTs.content, "x", { index: 1 }) + protocolRenameSpanFromSubstring({ + fileText: bTs.content, + text: "x", + contextText: `import { x } from "./a";` + }), + protocolRenameSpanFromSubstring({ + fileText: bTs.content, + text: "x", + options: { index: 1 }, + }) ] }, { file: aTs.path, locs: [ - protocolRenameSpanFromSubstring(aTs.content, "x"), - protocolRenameSpanFromSubstring(aTs.content, "x", { index: 2 }), + protocolRenameSpanFromSubstring({ + fileText: aTs.content, + text: "x", + contextText: "const x = 1;" + }), + protocolRenameSpanFromSubstring({ + fileText: aTs.content, + text: "x", + options: { index: 2 }, + contextText: "export { x };", + }), ], }, ], diff --git a/src/testRunner/unittests/tsserver/symLinks.ts b/src/testRunner/unittests/tsserver/symLinks.ts index e331c94ca1a69..c264bc2a6df09 100644 --- a/src/testRunner/unittests/tsserver/symLinks.ts +++ b/src/testRunner/unittests/tsserver/symLinks.ts @@ -58,10 +58,22 @@ namespace ts.projectSystem { assert.equal(aFile.content, bFile.content); const abLocs: protocol.RenameTextSpan[] = [ - protocolRenameSpanFromSubstring(aFile.content, "C"), - protocolRenameSpanFromSubstring(aFile.content, "C", { index: 1 }), + protocolRenameSpanFromSubstring({ + fileText: aFile.content, + text: "C", + contextText: `import {C} from "./c/fc";` + }), + protocolRenameSpanFromSubstring({ + fileText: aFile.content, + text: "C", + options: { index: 1 } + }), ]; - const span = protocolRenameSpanFromSubstring(cFile.content, "C"); + const span = protocolRenameSpanFromSubstring({ + fileText: cFile.content, + text: "C", + contextText: "export const C = 8" + }); const cLocs: protocol.RenameTextSpan[] = [span]; assert.deepEqual(response, { info: { diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index b73886dfa0945..cbab57b0644e8 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -5168,6 +5168,12 @@ declare namespace ts { */ originalTextSpan?: TextSpan; originalFileName?: string; + /** + * If DocumentSpan.textSpan is the span for name of the declaration, + * then this is the span for relevant declaration + */ + contextSpan?: TextSpan; + originalContextSpan?: TextSpan; } interface RenameLocation extends DocumentSpan { readonly prefixText?: string; @@ -5196,6 +5202,7 @@ declare namespace ts { fileName?: string; isInString?: true; textSpan: TextSpan; + contextSpan?: TextSpan; kind: HighlightSpanKind; } interface NavigateToItem { @@ -6489,15 +6496,21 @@ declare namespace ts.server.protocol { */ file: string; } + interface TextSpanWithContext extends TextSpan { + contextStart?: Location; + contextEnd?: Location; + } + interface FileSpanWithContext extends FileSpan, TextSpanWithContext { + } interface DefinitionInfoAndBoundSpan { - definitions: ReadonlyArray; + definitions: ReadonlyArray; textSpan: TextSpan; } /** * Definition response message. Gives text range for definition. */ interface DefinitionResponse extends Response { - body?: FileSpan[]; + body?: FileSpanWithContext[]; } interface DefinitionInfoAndBoundSpanReponse extends Response { body?: DefinitionInfoAndBoundSpan; @@ -6506,13 +6519,13 @@ declare namespace ts.server.protocol { * Definition response message. Gives text range for definition. */ interface TypeDefinitionResponse extends Response { - body?: FileSpan[]; + body?: FileSpanWithContext[]; } /** * Implementation response message. Gives text range for implementations. */ interface ImplementationResponse extends Response { - body?: FileSpan[]; + body?: FileSpanWithContext[]; } /** * Request to get brace completion for a location in the file. @@ -6549,7 +6562,7 @@ declare namespace ts.server.protocol { command: CommandTypes.Occurrences; } /** @deprecated */ - interface OccurrencesResponseItem extends FileSpan { + interface OccurrencesResponseItem extends FileSpanWithContext { /** * True if the occurrence is a write location, false otherwise. */ @@ -6575,7 +6588,7 @@ declare namespace ts.server.protocol { /** * Span augmented with extra information that denotes the kind of the highlighting to be used for span. */ - interface HighlightSpan extends TextSpan { + interface HighlightSpan extends TextSpanWithContext { kind: HighlightSpanKind; } /** @@ -6605,7 +6618,7 @@ declare namespace ts.server.protocol { interface ReferencesRequest extends FileLocationRequest { command: CommandTypes.References; } - interface ReferencesResponseItem extends FileSpan { + interface ReferencesResponseItem extends FileSpanWithContext { /** Text of line containing the reference. Including this * with the response avoids latency of editor loading files * to show text of reference line (the server already has @@ -6720,7 +6733,7 @@ declare namespace ts.server.protocol { /** The text spans in this group */ locs: RenameTextSpan[]; } - interface RenameTextSpan extends TextSpan { + interface RenameTextSpan extends TextSpanWithContext { readonly prefixText?: string; readonly suffixText?: string; } @@ -9077,6 +9090,7 @@ declare namespace ts.server { private mapDefinitionInfo; private static mapToOriginalLocation; private toFileSpan; + private toFileSpanWithContext; private getTypeDefinition; private mapImplementationLocations; private getImplementation; @@ -9134,7 +9148,6 @@ declare namespace ts.server { private mapLocationNavigationBarItems; private getNavigationBarItems; private toLocationNavigationTree; - private toLocationTextSpan; private getNavigationTree; private getNavigateToItems; private getFullNavigateToItems; diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index 6f75dbaf3fd0a..fd254a2fe5074 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -5168,6 +5168,12 @@ declare namespace ts { */ originalTextSpan?: TextSpan; originalFileName?: string; + /** + * If DocumentSpan.textSpan is the span for name of the declaration, + * then this is the span for relevant declaration + */ + contextSpan?: TextSpan; + originalContextSpan?: TextSpan; } interface RenameLocation extends DocumentSpan { readonly prefixText?: string; @@ -5196,6 +5202,7 @@ declare namespace ts { fileName?: string; isInString?: true; textSpan: TextSpan; + contextSpan?: TextSpan; kind: HighlightSpanKind; } interface NavigateToItem { diff --git a/tests/cases/fourslash/ambientShorthandFindAllRefs.ts b/tests/cases/fourslash/ambientShorthandFindAllRefs.ts index 14918f4a44999..3a0c30ef50750 100644 --- a/tests/cases/fourslash/ambientShorthandFindAllRefs.ts +++ b/tests/cases/fourslash/ambientShorthandFindAllRefs.ts @@ -4,13 +4,12 @@ ////declare module "jquery"; // @Filename: user.ts -////import {[|{| "isWriteAccess": true, "isDefinition": true |}x|]} from "jquery"; +////[|import {[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}x|]} from "jquery";|] // @Filename: user2.ts -////import {[|{| "isWriteAccess": true, "isDefinition": true |}x|]} from "jquery"; +////[|import {[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 2 |}x|]} from "jquery";|] -const ranges = test.ranges(); -const [r0, r1] = ranges; +const [r0Def, r0, r1Def, r1] = test.ranges(); // TODO: Want these to be in the same group, but that would require creating a symbol for `x`. verify.singleReferenceGroup("(alias) module \"jquery\"\nimport x", [r0]); verify.singleReferenceGroup("(alias) module \"jquery\"\nimport x", [r1]); \ No newline at end of file diff --git a/tests/cases/fourslash/cancellationWhenfindingAllRefsOnDefinition.ts b/tests/cases/fourslash/cancellationWhenfindingAllRefsOnDefinition.ts index 9334ab28b48bb..aafb491008b43 100644 --- a/tests/cases/fourslash/cancellationWhenfindingAllRefsOnDefinition.ts +++ b/tests/cases/fourslash/cancellationWhenfindingAllRefsOnDefinition.ts @@ -7,9 +7,9 @@ //// //// } //// -//// public /**/[|{| "isWriteAccess": true, "isDefinition": true |}start|](){ +//// [|public /**/[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}start|](){ //// return this; -//// } +//// }|] //// //// public stop(){ //// return this; @@ -33,5 +33,5 @@ cancellation.resetCancelled(); checkRefs(); function checkRefs() { - verify.singleReferenceGroup("(method) Test.start(): this"); + verify.singleReferenceGroup("(method) Test.start(): this", "start"); } diff --git a/tests/cases/fourslash/doubleUnderscoreRenames.ts b/tests/cases/fourslash/doubleUnderscoreRenames.ts index 5709be97b6f6b..5cfd87f1be675 100644 --- a/tests/cases/fourslash/doubleUnderscoreRenames.ts +++ b/tests/cases/fourslash/doubleUnderscoreRenames.ts @@ -1,12 +1,12 @@ /// // @Filename: fileA.ts -//// export function [|__foo|]() { -//// } +//// [|export function [|{| "contextRangeIndex": 0 |}__foo|]() { +//// }|] //// // @Filename: fileB.ts -//// import { [|__foo|] as bar } from "./fileA"; +//// [|import { [|{| "contextRangeIndex": 2 |}__foo|] as bar } from "./fileA";|] //// //// bar(); -verify.rangesAreRenameLocations(); +verify.rangesWithSameTextAreRenameLocations("__foo"); diff --git a/tests/cases/fourslash/duplicatePackageServices.ts b/tests/cases/fourslash/duplicatePackageServices.ts index 2ececda4e0633..34eafde8199f7 100644 --- a/tests/cases/fourslash/duplicatePackageServices.ts +++ b/tests/cases/fourslash/duplicatePackageServices.ts @@ -2,25 +2,25 @@ // @noImplicitReferences: true // @Filename: /node_modules/a/index.d.ts -////import [|{| "name": "useAX", "isWriteAccess": true, "isDefinition": true |}X|] from "x"; +////[|import [|{| "name": "useAX", "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}X|] from "x";|] ////export function a(x: [|X|]): void; // @Filename: /node_modules/a/node_modules/x/index.d.ts -////export default class /*defAX*/[|{| "isWriteAccess": true, "isDefinition": true |}X|] { +////[|export default class /*defAX*/[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 3 |}X|] { //// private x: number; -////} +////}|] // @Filename: /node_modules/a/node_modules/x/package.json ////{ "name": "x", "version": "1.2.3" } // @Filename: /node_modules/b/index.d.ts -////import [|{| "name": "useBX", "isWriteAccess": true, "isDefinition": true |}X|] from "x"; +////[|import [|{| "name": "useBX", "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 5 |}X|] from "x";|] ////export const b: [|X|]; // @Filename: /node_modules/b/node_modules/x/index.d.ts -////export default class /*defBX*/[|{| "isWriteAccess": true, "isDefinition": true |}X|] { +////[|export default class /*defBX*/[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 8 |}X|] { //// private x: number; -////} +////}|] // @Filename: /node_modules/b/node_modules/x/package.json ////{ "name": "x", "version": "1.2.3" } @@ -35,7 +35,7 @@ verify.numberOfErrorsInCurrentFile(0); verify.goToDefinition("useAX", "defAX"); verify.goToDefinition("useBX", "defAX"); -const [r0, r1, r2, r3, r4, r5] = test.ranges(); +const [r0Def, r0, r1, r2Def, r2, r3Def, r3, r4, r5Def, r5] = test.ranges(); const aImport = { definition: "(alias) class X\nimport X", ranges: [r0, r1] }; const def = { definition: "class X", ranges: [r2] }; const bImport = { definition: "(alias) class X\nimport X", ranges: [r3, r4] }; diff --git a/tests/cases/fourslash/esModuleInteropFindAllReferences.ts b/tests/cases/fourslash/esModuleInteropFindAllReferences.ts index 4e493e58c246e..842243c9b1bad 100644 --- a/tests/cases/fourslash/esModuleInteropFindAllReferences.ts +++ b/tests/cases/fourslash/esModuleInteropFindAllReferences.ts @@ -4,11 +4,11 @@ // @Filename: /abc.d.ts ////declare module "a" { -//// export const [|{| "isWriteAccess": true, "isDefinition": true |}x|]: number; +//// [|export const [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}x|]: number;|] ////} // @Filename: /b.ts ////import a from "a"; ////a.[|x|]; -verify.singleReferenceGroup("const x: number"); +verify.singleReferenceGroup("const x: number", "x"); diff --git a/tests/cases/fourslash/esModuleInteropFindAllReferences2.ts b/tests/cases/fourslash/esModuleInteropFindAllReferences2.ts index e55129a357c80..e70454f023a8c 100644 --- a/tests/cases/fourslash/esModuleInteropFindAllReferences2.ts +++ b/tests/cases/fourslash/esModuleInteropFindAllReferences2.ts @@ -6,10 +6,10 @@ // @Filename: /a.d.ts ////export as namespace abc; -////export const [|{| "isWriteAccess": true, "isDefinition": true |}x|]: number; +////[|export const [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}x|]: number;|] // @Filename: /b.ts ////import a from "./a"; ////a.[|x|]; -verify.singleReferenceGroup('const x: number'); +verify.singleReferenceGroup('const x: number', "x"); diff --git a/tests/cases/fourslash/findAllReferPropertyAccessExpressionHeritageClause.ts b/tests/cases/fourslash/findAllReferPropertyAccessExpressionHeritageClause.ts index 61dfb1c33bc9d..2b28656c58e1b 100644 --- a/tests/cases/fourslash/findAllReferPropertyAccessExpressionHeritageClause.ts +++ b/tests/cases/fourslash/findAllReferPropertyAccessExpressionHeritageClause.ts @@ -2,9 +2,9 @@ //// class B {} //// function foo() { -//// return {[|{| "isWriteAccess": true, "isDefinition": true |}B|]: B}; +//// return {[|[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}B|]: B|]}; //// } //// class C extends (foo()).[|B|] {} //// class C1 extends foo().[|B|] {} -verify.singleReferenceGroup("(property) B: typeof B"); +verify.singleReferenceGroup("(property) B: typeof B", "B"); diff --git a/tests/cases/fourslash/findAllReferencesDynamicImport1.ts b/tests/cases/fourslash/findAllReferencesDynamicImport1.ts index c2b6f359ba642..999704edd3eca 100644 --- a/tests/cases/fourslash/findAllReferencesDynamicImport1.ts +++ b/tests/cases/fourslash/findAllReferencesDynamicImport1.ts @@ -3,7 +3,7 @@ // @Filename: foo.ts //// export function foo() { return "foo"; } -//// import("[|./foo|]") -//// var x = import("[|./foo|]") +//// [|import("[|{| "contextRangeIndex": 0 |}./foo|]")|] +//// [|var x = import("[|{| "contextRangeIndex": 2 |}./foo|]")|] -verify.singleReferenceGroup('module "/tests/cases/fourslash/foo"'); +verify.singleReferenceGroup('module "/tests/cases/fourslash/foo"', "./foo"); diff --git a/tests/cases/fourslash/findAllReferencesDynamicImport2.ts b/tests/cases/fourslash/findAllReferencesDynamicImport2.ts index 6644a55ec1b92..987fccc219eac 100644 --- a/tests/cases/fourslash/findAllReferencesDynamicImport2.ts +++ b/tests/cases/fourslash/findAllReferencesDynamicImport2.ts @@ -1,12 +1,12 @@ /// // @Filename: foo.ts -//// export function [|{| "isWriteAccess": true, "isDefinition": true |}bar|]() { return "bar"; } +//// [|export function [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}bar|]() { return "bar"; }|] //// var x = import("./foo"); //// x.then(foo => { //// foo.[|bar|](); //// }) -verify.singleReferenceGroup("function bar(): string"); -verify.rangesAreRenameLocations(); +verify.singleReferenceGroup("function bar(): string", "bar"); +verify.rangesWithSameTextAreRenameLocations("bar"); diff --git a/tests/cases/fourslash/findAllReferencesDynamicImport3.ts b/tests/cases/fourslash/findAllReferencesDynamicImport3.ts index 371369ac39ce7..08160e403adad 100644 --- a/tests/cases/fourslash/findAllReferencesDynamicImport3.ts +++ b/tests/cases/fourslash/findAllReferencesDynamicImport3.ts @@ -1,10 +1,10 @@ /// // @Filename: foo.ts -////export function [|{| "isWriteAccess": true, "isDefinition": true |}bar|]() { return "bar"; } -////import('./foo').then(({ [|{| "isWriteAccess": true, "isDefinition": true |}bar|] }) => undefined); +////[|export function [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}bar|]() { return "bar"; }|] +////import('./foo').then(([|{ [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 2 |}bar|] }|]) => undefined); -const [r0, r1] = test.ranges(); +const [r0Def, r0, r1Def, r1] = test.ranges(); verify.referenceGroups(r0, [{ definition: "function bar(): string", ranges: [r0, r1] }]); verify.referenceGroups(r1, [ { definition: "function bar(): string", ranges: [r0] }, diff --git a/tests/cases/fourslash/findAllReferencesJSDocFunctionNew.ts b/tests/cases/fourslash/findAllReferencesJSDocFunctionNew.ts index b094714cefbbf..28e24da279192 100644 --- a/tests/cases/fourslash/findAllReferencesJSDocFunctionNew.ts +++ b/tests/cases/fourslash/findAllReferencesJSDocFunctionNew.ts @@ -1,8 +1,8 @@ /// // @allowJs: true // @Filename: Foo.js -/////** @type {function ([|{|"isWriteAccess": true, "isDefinition": true|}new|]: string, string): string} */ +/////** @type {function ([|[|{|"isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0|}new|]: string|], string): string} */ ////var f; -const [a0] = test.ranges(); +const [a0Def, a0] = test.ranges(); verify.singleReferenceGroup("(parameter) new: string", [a0]); diff --git a/tests/cases/fourslash/findAllReferencesOfConstructor.ts b/tests/cases/fourslash/findAllReferencesOfConstructor.ts index 3dffdeaffb95d..a952a2c6ee740 100644 --- a/tests/cases/fourslash/findAllReferencesOfConstructor.ts +++ b/tests/cases/fourslash/findAllReferencesOfConstructor.ts @@ -2,9 +2,9 @@ // @Filename: a.ts ////export class C { -//// [|constructor|](n: number); -//// [|constructor|](); -//// [|constructor|](n?: number){} +//// [|[|{| "contextRangeIndex": 0 |}constructor|](n: number);|] +//// [|[|{| "contextRangeIndex": 2 |}constructor|]();|] +//// [|[|{| "contextRangeIndex": 4 |}constructor|](n?: number){}|] //// static f() { //// this.f(); //// new [|this|](); @@ -40,8 +40,7 @@ ////new a.[|C|](); ////class d extends a.C { constructor() { [|super|](); } -const ranges = test.ranges(); -const [a0, a1, a2, a3, a4, b0, c0, d0, d1] = ranges; +const [a0Def, a0, a1Def, a1, a2Def, a2, a3, a4, b0, c0, d0, d1] = test.ranges(); verify.referenceGroups([a0, a2], defs("class C")); verify.referenceGroups(a1, defs("class C")); diff --git a/tests/cases/fourslash/findAllReferencesOfConstructor_badOverload.ts b/tests/cases/fourslash/findAllReferencesOfConstructor_badOverload.ts index 2c4857145e179..c343df86e7a7f 100644 --- a/tests/cases/fourslash/findAllReferencesOfConstructor_badOverload.ts +++ b/tests/cases/fourslash/findAllReferencesOfConstructor_badOverload.ts @@ -1,8 +1,8 @@ /// ////class C { -//// [|constructor|](n: number); -//// [|constructor|](){} +//// [|[|{| "contextRangeIndex": 0 |}constructor|](n: number);|] +//// [|[|{| "contextRangeIndex": 2 |}constructor|](){}|] ////} -verify.singleReferenceGroup("class C"); +verify.singleReferenceGroup("class C", "constructor"); diff --git a/tests/cases/fourslash/findAllReferencesOfJsonModule.ts b/tests/cases/fourslash/findAllReferencesOfJsonModule.ts index 36f700b09e6c2..7543d7a789949 100644 --- a/tests/cases/fourslash/findAllReferencesOfJsonModule.ts +++ b/tests/cases/fourslash/findAllReferencesOfJsonModule.ts @@ -5,10 +5,10 @@ // @esModuleInterop: true // @Filename: /foo.ts -////import [|{| "isWriteAccess": true, "isDefinition": true |}settings|] from "./settings.json"; +////[|import [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}settings|] from "./settings.json";|] ////[|settings|]; // @Filename: /settings.json //// {} -verify.singleReferenceGroup("import settings"); +verify.singleReferenceGroup("import settings", "settings"); diff --git a/tests/cases/fourslash/findAllReferencesUmdModuleAsGlobalConst.ts b/tests/cases/fourslash/findAllReferencesUmdModuleAsGlobalConst.ts index 464dcef1548ae..479d0d2b9b697 100644 --- a/tests/cases/fourslash/findAllReferencesUmdModuleAsGlobalConst.ts +++ b/tests/cases/fourslash/findAllReferencesUmdModuleAsGlobalConst.ts @@ -9,12 +9,12 @@ // @Filename: /node_modules/@types/three/index.d.ts ////export * from "./three-core"; -////export as namespace [|{| "isWriteAccess": true, "isDefinition": true |}THREE|]; +////[|export as namespace [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}THREE|];|] // @Filename: /typings/global.d.ts -////import * as _THREE from '[|three|]'; +////[|import * as _THREE from '[|{| "contextRangeIndex": 2 |}three|]';|] ////declare global { -//// const [|{| "isWriteAccess": true, "isDefinition": true |}THREE|]: typeof _THREE; +//// [|const [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 4 |}THREE|]: typeof _THREE;|] ////} // @Filename: /src/index.ts @@ -38,7 +38,8 @@ //// "files": ["/src/index.ts", "typings/global.d.ts"] ////} +const [r0Def, r0, r1Def, r1, r2Def, ...rest] = test.ranges(); // GH#29533 // TODO:: this should be var THREE: typeof import instead of module name as var but thats existing issue and repros with quickInfo too. verify.singleReferenceGroup(`module "/node_modules/@types/three/index" -var "/node_modules/@types/three/index": typeof import("/node_modules/@types/three/index")`); \ No newline at end of file +var "/node_modules/@types/three/index": typeof import("/node_modules/@types/three/index")`, [r0, r1, ...rest]); \ No newline at end of file diff --git a/tests/cases/fourslash/findAllRefsBadImport.ts b/tests/cases/fourslash/findAllRefsBadImport.ts index a54454ea365d9..33974bf36efa5 100644 --- a/tests/cases/fourslash/findAllRefsBadImport.ts +++ b/tests/cases/fourslash/findAllRefsBadImport.ts @@ -1,7 +1,7 @@ /// -////import { [|ab|] as [|{| "isWriteAccess": true, "isDefinition": true |}cd|] } from "doesNotExist"; +////[|import { [|{| "contextRangeIndex": 0 |}ab|] as [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}cd|] } from "doesNotExist";|] -const [r0, r1] = test.ranges(); +const [r0Def, r0, r1] = test.ranges(); verify.referenceGroups(r0, undefined); verify.singleReferenceGroup("import cd", [r1]); diff --git a/tests/cases/fourslash/findAllRefsClassExpression0.ts b/tests/cases/fourslash/findAllRefsClassExpression0.ts index e8d4aa671a304..cb5faf045c58b 100644 --- a/tests/cases/fourslash/findAllRefsClassExpression0.ts +++ b/tests/cases/fourslash/findAllRefsClassExpression0.ts @@ -1,15 +1,15 @@ /// // @Filename: /a.ts -////export = class [|{| "isWriteAccess": true, "isDefinition": true |}A|] { +////export = [|class [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}A|] { //// m() { [|A|]; } -////}; +////}|]; // @Filename: /b.ts -////import [|{| "isWriteAccess": true, "isDefinition": true |}A|] = require("./a"); +////[|import [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 3 |}A|] = require("./a");|] ////[|A|]; -const [r0, r1, r2, r3] = test.ranges(); +const [r0Def, r0, r1, r2Def, r2, r3] = test.ranges(); const defs = { definition: "(local class) A", ranges: [r0, r1] }; const imports = { definition: '(alias) (local class) A\nimport A = require("./a")', ranges: [r2, r3] }; verify.referenceGroups([r0, r1], [defs, imports]); diff --git a/tests/cases/fourslash/findAllRefsClassExpression1.ts b/tests/cases/fourslash/findAllRefsClassExpression1.ts index 64aad512a5ee6..bbf1405240857 100644 --- a/tests/cases/fourslash/findAllRefsClassExpression1.ts +++ b/tests/cases/fourslash/findAllRefsClassExpression1.ts @@ -3,13 +3,13 @@ // @allowJs: true // @Filename: /a.js -////module.exports = class [|{| "isWriteAccess": true, "isDefinition": true |}A|] {}; +////module.exports = [|class [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}A|] {}|]; // @Filename: /b.js -////import [|{| "isWriteAccess": true, "isDefinition": true |}A|] = require("./a"); +////[|import [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 2 |}A|] = require("./a");|] ////[|A|]; -const [r0, r1, r2] = test.ranges(); +const [r0Def, r0, r1Def, r1, r2] = test.ranges(); const defs = { definition: "(local class) A", ranges: [r0] }; const imports = { definition: '(alias) (local class) A\nimport A = require("./a")', ranges: [r1, r2] }; verify.referenceGroups([r0], [defs, imports]); diff --git a/tests/cases/fourslash/findAllRefsClassExpression2.ts b/tests/cases/fourslash/findAllRefsClassExpression2.ts index 1214e3f7c8856..bd0ee3a880462 100644 --- a/tests/cases/fourslash/findAllRefsClassExpression2.ts +++ b/tests/cases/fourslash/findAllRefsClassExpression2.ts @@ -3,13 +3,13 @@ // @allowJs: true // @Filename: /a.js -////exports.[|{| "isWriteAccess": true, "isDefinition": true |}A|] = class {}; +////[|exports.[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}A|] = class {};|] // @Filename: /b.js -////import { [|{| "isWriteAccess": true, "isDefinition": true |}A|] } from "./a"; +////[|import { [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 2 |}A|] } from "./a";|] ////[|A|]; -const [r0, r1, r2] = test.ranges(); +const [r0Def, r0, r1Def, r1, r2] = test.ranges(); const defs = { definition: "class A\n(property) A: typeof A", ranges: [r0] }; const imports = { definition: "(alias) class A\n(alias) (property) A: typeof A\nimport A", ranges: [r1, r2] }; verify.referenceGroups([r0], [defs, imports]); diff --git a/tests/cases/fourslash/findAllRefsClassWithStaticThisAccess.ts b/tests/cases/fourslash/findAllRefsClassWithStaticThisAccess.ts index f2c432abc7664..d67a239d06a7d 100644 --- a/tests/cases/fourslash/findAllRefsClassWithStaticThisAccess.ts +++ b/tests/cases/fourslash/findAllRefsClassWithStaticThisAccess.ts @@ -1,6 +1,6 @@ /// -////class [|{| "isWriteAccess": true, "isDefinition": true |}C|] { +////[|class [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}C|] { //// static s() { //// [|this|]; //// } @@ -10,9 +10,9 @@ //// function inner() { this; } //// class Inner { x = this; } //// } -////} +////}|] -const [r0, r1, r2] = test.ranges(); +const [r0Def, r0, r1, r2] = test.ranges(); verify.referenceGroups(r0, [{ definition: "class C", ranges: [r0, r1, r2] }]); verify.singleReferenceGroup("this: typeof C", [r1, r2]); diff --git a/tests/cases/fourslash/findAllRefsConstructorFunctions.ts b/tests/cases/fourslash/findAllRefsConstructorFunctions.ts index 77fa674f65bdf..a020380db7036 100644 --- a/tests/cases/fourslash/findAllRefsConstructorFunctions.ts +++ b/tests/cases/fourslash/findAllRefsConstructorFunctions.ts @@ -4,11 +4,11 @@ // @Filename: /a.js ////function f() { -//// this.[|{| "isWriteAccess": true, "isDefinition": true |}x|] = 0; +//// [|this.[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}x|] = 0;|] ////} ////f.prototype.setX = function() { -//// this.[|{| "isWriteAccess": true, "isDefinition": true |}x|] = 1; +//// [|this.[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 2 |}x|] = 1;|] ////} ////f.prototype.useX = function() { this.[|x|]; } -verify.singleReferenceGroup("(property) f.x: number"); +verify.singleReferenceGroup("(property) f.x: number", "x"); diff --git a/tests/cases/fourslash/findAllRefsDeclareClass.ts b/tests/cases/fourslash/findAllRefsDeclareClass.ts index 9ef813634a5a5..789a426940348 100644 --- a/tests/cases/fourslash/findAllRefsDeclareClass.ts +++ b/tests/cases/fourslash/findAllRefsDeclareClass.ts @@ -1,7 +1,7 @@ /// -////declare class [|{| "isWriteAccess": true, "isDefinition": true |}C|] { +////[|declare class [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}C|] { //// static m(): void; -////} +////}|] -verify.singleReferenceGroup("class C"); +verify.singleReferenceGroup("class C", "C"); diff --git a/tests/cases/fourslash/findAllRefsDefaultImport.ts b/tests/cases/fourslash/findAllRefsDefaultImport.ts index b981f50bd16b5..a485a8ec371e3 100644 --- a/tests/cases/fourslash/findAllRefsDefaultImport.ts +++ b/tests/cases/fourslash/findAllRefsDefaultImport.ts @@ -1,12 +1,12 @@ /// // @Filename: /a.ts -////export default function [|{| "isWriteAccess": true, "isDefinition": true |}a|]() {} +////[|export default function [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}a|]() {}|] // @Filename: /b.ts -////import [|{| "isWriteAccess": true, "isDefinition": true |}a|], * as ns from "./a"; +////[|import [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 2 |}a|], * as ns from "./a";|] -const [r0, r1] = test.ranges(); +const [r0Def, r0, r1Def, r1] = test.ranges(); const a: FourSlashInterface.ReferenceGroup = { definition: "function a(): void", ranges: [r0] }; const b: FourSlashInterface.ReferenceGroup = { definition: "(alias) function a(): void\nimport a", ranges: [r1] }; verify.referenceGroups(r0, [a, b]); diff --git a/tests/cases/fourslash/findAllRefsDefaultImportThroughNamespace.ts b/tests/cases/fourslash/findAllRefsDefaultImportThroughNamespace.ts index 722403f45cfbf..e9ab2cbd4ff2d 100644 --- a/tests/cases/fourslash/findAllRefsDefaultImportThroughNamespace.ts +++ b/tests/cases/fourslash/findAllRefsDefaultImportThroughNamespace.ts @@ -1,7 +1,7 @@ /// // @Filename: /a.ts -////export [|{| "isWriteAccess": true, "isDefinition": true |}default|] function [|{| "isWriteAccess": true, "isDefinition": true |}f|]() {} +////[|export [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}default|] function [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}f|]() {}|] // @Filename: /b.ts ////export import a = require("./a"); @@ -10,10 +10,10 @@ ////import { a } from "./b"; ////a.[|default|](); //// -////declare const x: { [|{| "isWriteAccess": true, "isDefinition": true |}default|]: number }; +////declare const x: { [|[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 4 |}default|]: number|] }; ////x.[|default|]; -const [r0, r1, r2, r3, r4] = test.ranges(); +const [r0Def, r0, r1, r2, r3Def, r3, r4] = test.ranges(); verify.referenceGroups([r0], [{ definition: "function f(): void", ranges: [r0, r2] }]); verify.singleReferenceGroup("function f(): void", [r1, r2]); diff --git a/tests/cases/fourslash/findAllRefsDefinition.ts b/tests/cases/fourslash/findAllRefsDefinition.ts index 7b7016e7049fe..73a88777cf594 100644 --- a/tests/cases/fourslash/findAllRefsDefinition.ts +++ b/tests/cases/fourslash/findAllRefsDefinition.ts @@ -1,9 +1,9 @@ /// -////const [|{| "isWriteAccess": true, "isDefinition": true |}x|] = 0; +////[|const [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}x|] = 0;|] ////[|x|]; -const ranges = test.ranges(); +const ranges = test.rangesByText().get("x"); verify.referenceGroups(ranges, [ { definition: { text: "const x: 0", range: ranges[0] }, diff --git a/tests/cases/fourslash/findAllRefsDestructureGeneric.ts b/tests/cases/fourslash/findAllRefsDestructureGeneric.ts index 3d7a84cb35a0f..09d9aff004b37 100644 --- a/tests/cases/fourslash/findAllRefsDestructureGeneric.ts +++ b/tests/cases/fourslash/findAllRefsDestructureGeneric.ts @@ -1,12 +1,12 @@ /// ////interface I { -//// [|{| "isDefinition": true |}x|]: boolean; +//// [|[|{| "isDefinition": true, "contextRangeIndex": 0 |}x|]: boolean;|] ////} ////declare const i: I; -////const { [|{| "isWriteAccess": true, "isDefinition": true |}x|] } = i; +////[|const { [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 2 |}x|] } = i;|] -const [r0, r1] = test.ranges(); +const [r0Def, r0, r1Def, r1] = test.ranges(); verify.referenceGroups(r0, [{ definition: "(property) I.x: boolean", ranges: [r0, r1] }]); verify.referenceGroups(r1, [ diff --git a/tests/cases/fourslash/findAllRefsDestructureGetter.ts b/tests/cases/fourslash/findAllRefsDestructureGetter.ts index 763d3cfb0e5ab..c1fdb0f111ece 100644 --- a/tests/cases/fourslash/findAllRefsDestructureGetter.ts +++ b/tests/cases/fourslash/findAllRefsDestructureGetter.ts @@ -1,14 +1,14 @@ /// ////class Test { -//// get [|{| "isDefinition": true, "isWriteAccess": true |}x|]() { return 0; } +//// [|get [|{| "isDefinition": true, "isWriteAccess": true, "contextRangeIndex": 0 |}x|]() { return 0; }|] //// -//// set [|{| "isDefinition": true, "isWriteAccess": true |}y|](a: number) {} +//// [|set [|{| "isDefinition": true, "isWriteAccess": true, "contextRangeIndex": 2 |}y|](a: number) {}|] ////} -////const { [|{| "isDefinition": true, "isWriteAccess": true |}x|], [|{| "isDefinition": true, "isWriteAccess": true |}y|] } = new Test(); +////[|const { [|{| "isDefinition": true, "isWriteAccess": true, "contextRangeIndex": 4 |}x|], [|{| "isDefinition": true, "isWriteAccess": true, "contextRangeIndex": 4 |}y|] } = new Test();|] ////[|x|]; [|y|]; -const [x0, y0, x1, y1, x2, y2] = test.ranges(); +const [x0Def, x0, y0Def, y0, xy1Def, x1, y1, x2, y2] = test.ranges(); verify.referenceGroups(x0, [{ definition: "(property) Test.x: number", ranges: [x0, x1] }]); verify.referenceGroups(x1, [ { definition: "(property) Test.x: number", ranges: [x0] }, diff --git a/tests/cases/fourslash/findAllRefsDestructureGetter2.ts b/tests/cases/fourslash/findAllRefsDestructureGetter2.ts index d26983a1091f1..58cf0013c911d 100644 --- a/tests/cases/fourslash/findAllRefsDestructureGetter2.ts +++ b/tests/cases/fourslash/findAllRefsDestructureGetter2.ts @@ -4,13 +4,13 @@ // @Filename: /a.ts ////class C { -//// get [|{| "isWriteAccess": true, "isDefinition": true |}g|](): number { return 0; } +//// [|get [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}g|](): number { return 0; }|] //// -//// set [|{| "isWriteAccess": true, "isDefinition": true |}s|](value: number) {} +//// [|set [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 2 |}s|](value: number) {}|] ////} -////const { [|{| "isWriteAccess": true, "isDefinition": true |}g|], [|{| "isWriteAccess": true, "isDefinition": true |}s|] } = new C(); +////[|const { [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 4 |}g|], [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 4 |}s|] } = new C();|] -const [g0, s0, g1, s1] = test.ranges(); +const [g0Def, g0, s0Def, s0, gs1Def, g1, s1] = test.ranges(); verify.quickInfoAt(g0, "(property) C.g: number"); verify.referenceGroups(g0, [{ definition: "(property) C.g: number", ranges: [g0, g1] }]); verify.referenceGroups(g1, [ diff --git a/tests/cases/fourslash/findAllRefsEnumAsNamespace.ts b/tests/cases/fourslash/findAllRefsEnumAsNamespace.ts index a065f355d1058..b8c6fc621056c 100644 --- a/tests/cases/fourslash/findAllRefsEnumAsNamespace.ts +++ b/tests/cases/fourslash/findAllRefsEnumAsNamespace.ts @@ -1,6 +1,6 @@ /// -////enum [|{| "isWriteAccess": true, "isDefinition": true |}E|] { A } +////[|enum [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}E|] { A }|] ////let e: [|E|].A; -verify.singleReferenceGroup("enum E"); +verify.singleReferenceGroup("enum E", "E"); diff --git a/tests/cases/fourslash/findAllRefsExportAsNamespace.ts b/tests/cases/fourslash/findAllRefsExportAsNamespace.ts index f6149f17d90bd..59b8792bc8824 100644 --- a/tests/cases/fourslash/findAllRefsExportAsNamespace.ts +++ b/tests/cases/fourslash/findAllRefsExportAsNamespace.ts @@ -3,19 +3,18 @@ // `export as namespace` results in global search. // @Filename: /node_modules/a/index.d.ts -////export function [|{| "isWriteAccess": true, "isDefinition": true |}f|](): void; +////[|export function [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}f|](): void;|] ////export as namespace A; // @Filename: /b.ts -////import { [|{| "isWriteAccess": true, "isDefinition": true |}f|] } from "a"; +////[|import { [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 2 |}f|] } from "a";|] // @Filename: /c.ts ////A.[|f|](); verify.noErrors(); -const ranges = test.ranges(); -const [r0, r1, r2] = ranges; +const [r0Def, r0, r1Def, r1, r2] = test.ranges(); const globals = { definition: "function f(): void", ranges: [r0, r2] }; const imports = { definition: "(alias) function f(): void\nimport f", ranges: [r1] }; diff --git a/tests/cases/fourslash/findAllRefsExportConstEqualToClass.ts b/tests/cases/fourslash/findAllRefsExportConstEqualToClass.ts index 6be7ea0bdba9b..e667a111efe70 100644 --- a/tests/cases/fourslash/findAllRefsExportConstEqualToClass.ts +++ b/tests/cases/fourslash/findAllRefsExportConstEqualToClass.ts @@ -1,13 +1,13 @@ /// // @Filename: /a.ts -////class [|{| "isWriteAccess": true, "isDefinition": true |}C|] {} -////export const [|{| "isWriteAccess": true, "isDefinition": true |}D|] = [|C|]; +////[|class [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}C|] {}|] +////[|export const [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 2 |}D|] = [|C|];|] // @Filename: /b.ts -////import { [|{| "isWriteAccess": true, "isDefinition": true |}D|] } from "./a"; +////[|import { [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 5 |}D|] } from "./a";|] -const [C0, D0, C1, D1] = test.ranges(); +const [C0Def, C0, D0Def, D0, C1, D1Def, D1] = test.ranges(); verify.singleReferenceGroup("class C", [C0, C1]); diff --git a/tests/cases/fourslash/findAllRefsExportDefaultClassConstructor.ts b/tests/cases/fourslash/findAllRefsExportDefaultClassConstructor.ts index 0f269bd5f5bcf..5a882023c22f6 100644 --- a/tests/cases/fourslash/findAllRefsExportDefaultClassConstructor.ts +++ b/tests/cases/fourslash/findAllRefsExportDefaultClassConstructor.ts @@ -1,5 +1,5 @@ ////export default class { -//// [|constructor|]() {} +//// [|[|{| "contextRangeIndex": 0 |}constructor|]() {}|] ////} -verify.singleReferenceGroup("class default"); +verify.singleReferenceGroup("class default", "constructor"); diff --git a/tests/cases/fourslash/findAllRefsExportEquals.ts b/tests/cases/fourslash/findAllRefsExportEquals.ts index 3580c8fe4ee2c..647023b43ff60 100644 --- a/tests/cases/fourslash/findAllRefsExportEquals.ts +++ b/tests/cases/fourslash/findAllRefsExportEquals.ts @@ -1,13 +1,13 @@ /// // @Filename: /a.ts -////type [|{| "isWriteAccess": true, "isDefinition": true |}T|] = number; -////[|export|] = [|T|]; +////[|type [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}T|] = number;|] +////[|[|{| "contextRangeIndex": 2 |}export|] = [|{| "contextRangeIndex": 2 |}T|];|] // @Filename: /b.ts -////import [|{| "isWriteAccess": true, "isDefinition": true |}T|] = require("[|./a|]"); +////[|import [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 5 |}T|] = require("[|{| "contextRangeIndex": 5 |}./a|]");|] -const [r0, r1, r2, r3, r4] = test.ranges(); +const [r0Def, r0, r12Def, r1, r2, r3Def, r3, r4] = test.ranges(); const mod = { definition: 'module "/a"', ranges: [r4, r1] }; const a = { definition: "type T = number", ranges: [r0, r2] }; const b = { definition: '(alias) type T = number\nimport T = require("./a")', ranges: [r3] }; diff --git a/tests/cases/fourslash/findAllRefsExportNotAtTopLevel.ts b/tests/cases/fourslash/findAllRefsExportNotAtTopLevel.ts index 7f9c258bbe2c4..96e342608934e 100644 --- a/tests/cases/fourslash/findAllRefsExportNotAtTopLevel.ts +++ b/tests/cases/fourslash/findAllRefsExportNotAtTopLevel.ts @@ -1,8 +1,8 @@ /// ////{ -//// export const [|{| "isWriteAccess": true, "isDefinition": true |}x|] = 0; +//// [|export const [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}x|] = 0;|] //// [|x|]; ////} -verify.singleReferenceGroup("const x: 0"); +verify.singleReferenceGroup("const x: 0", "x"); diff --git a/tests/cases/fourslash/findAllRefsForComputedProperties.ts b/tests/cases/fourslash/findAllRefsForComputedProperties.ts index 3c442b8b63a0b..90de1881b0027 100644 --- a/tests/cases/fourslash/findAllRefsForComputedProperties.ts +++ b/tests/cases/fourslash/findAllRefsForComputedProperties.ts @@ -1,20 +1,19 @@ /// ////interface I { -//// ["[|{| "isDefinition": true |}prop1|]"]: () => void; +//// [|["[|{| "isDefinition": true, "contextRangeIndex": 0 |}prop1|]"]: () => void;|] ////} //// ////class C implements I { -//// ["[|{| "isDefinition": true |}prop1|]"]: any; +//// [|["[|{| "isDefinition": true, "contextRangeIndex": 2 |}prop1|]"]: any;|] ////} //// ////var x: I = { -//// ["[|{| "isWriteAccess": true, "isDefinition": true |}prop1|]"]: function () { }, +//// [|["[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 4 |}prop1|]"]: function () { }|], ////} -const ranges = test.ranges(); -const [r0, r1, r2] = ranges; -verify.referenceGroups(ranges, [ +const [r0Def, r0, r1Def, r1, r2Def, r2] = test.ranges(); +verify.referenceGroups([r0, r1, r2], [ { definition: { text: '(property) I["prop1"]: () => void', range: r0 }, ranges: [r0, r2] }, { definition: { text: '(property) C["prop1"]: any', range: r1 }, ranges: [r1] }, ]); diff --git a/tests/cases/fourslash/findAllRefsForComputedProperties2.ts b/tests/cases/fourslash/findAllRefsForComputedProperties2.ts index 21f9d2c92bab3..5b7e73af9d32f 100644 --- a/tests/cases/fourslash/findAllRefsForComputedProperties2.ts +++ b/tests/cases/fourslash/findAllRefsForComputedProperties2.ts @@ -1,20 +1,19 @@ /// ////interface I { -//// [[|{| "isDefinition": true |}42|]](): void; +//// [|[[|{| "isDefinition": true, "contextRangeIndex": 0 |}42|]](): void;|] ////} //// ////class C implements I { -//// [[|{| "isDefinition": true |}42|]]: any; +//// [|[[|{| "isDefinition": true, "contextRangeIndex": 2 |}42|]]: any;|] ////} //// ////var x: I = { -//// ["[|{| "isWriteAccess": true, "isDefinition": true |}42|]"]: function () { } +//// [|["[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 4 |}42|]"]: function () { }|] ////} -const ranges = test.ranges(); -const [r0, r1, r2] = ranges; -verify.referenceGroups(ranges, [ +const [r0Def, r0, r1Def, r1, r2Def, r2] = test.ranges(); +verify.referenceGroups([r0, r1, r2], [ { definition: { text: '(method) I[42](): void', range: r0 }, ranges: [r0, r2] }, { definition: { text: '(property) C[42]: any', range: r1 }, ranges: [r1] }, ]); diff --git a/tests/cases/fourslash/findAllRefsForDefaultExport.ts b/tests/cases/fourslash/findAllRefsForDefaultExport.ts index 71c566a6f42f7..6e8bcb710b74f 100644 --- a/tests/cases/fourslash/findAllRefsForDefaultExport.ts +++ b/tests/cases/fourslash/findAllRefsForDefaultExport.ts @@ -1,17 +1,16 @@ /// // @Filename: a.ts -////export default function /*def*/[|{| "isWriteAccess": true, "isDefinition": true |}f|]() {} +////[|export default function /*def*/[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}f|]() {}|] // @Filename: b.ts -////import [|{| "isWriteAccess": true, "isDefinition": true |}g|] from "./a"; +////[|import [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 2 |}g|] from "./a";|] ////[|/*ref*/g|](); // @Filename: c.ts ////import { f } from "./a"; -const ranges = test.ranges(); -const [r0, r1, r2] = ranges; +const [r0Def, r0, r1Def, r1, r2] = test.ranges(); verify.referenceGroups(r0, [ { definition: "function f(): void", ranges: [r0] }, { definition: "(alias) function g(): void\nimport g", ranges: [r1, r2] } diff --git a/tests/cases/fourslash/findAllRefsForDefaultExport01.ts b/tests/cases/fourslash/findAllRefsForDefaultExport01.ts index 419262bd10f6b..4cb366d617396 100644 --- a/tests/cases/fourslash/findAllRefsForDefaultExport01.ts +++ b/tests/cases/fourslash/findAllRefsForDefaultExport01.ts @@ -1,10 +1,10 @@ /// -////export default class [|{| "isWriteAccess": true, "isDefinition": true |}DefaultExportedClass|] { -////} +////[|export default class [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}DefaultExportedClass|] { +////}|] //// ////var x: [|DefaultExportedClass|]; //// ////var y = new [|DefaultExportedClass|]; -verify.singleReferenceGroup("class DefaultExportedClass"); +verify.singleReferenceGroup("class DefaultExportedClass", "DefaultExportedClass"); diff --git a/tests/cases/fourslash/findAllRefsForDefaultExport02.ts b/tests/cases/fourslash/findAllRefsForDefaultExport02.ts index c664b47093836..e0f0ecdafabb5 100644 --- a/tests/cases/fourslash/findAllRefsForDefaultExport02.ts +++ b/tests/cases/fourslash/findAllRefsForDefaultExport02.ts @@ -1,19 +1,18 @@ /// -////export default function [|{| "isWriteAccess": true, "isDefinition": true |}DefaultExportedFunction|]() { +////[|export default function [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}DefaultExportedFunction|]() { //// return [|DefaultExportedFunction|]; -////} +////}|] //// ////var x: typeof [|DefaultExportedFunction|]; //// ////var y = [|DefaultExportedFunction|](); //// -////namespace [|{| "isWriteAccess": true, "isDefinition": true |}DefaultExportedFunction|] { -////} +////[|namespace [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 5 |}DefaultExportedFunction|] { +////}|] -const ranges = test.ranges(); -const [r0, r1, r2, r3, r4] = ranges; +const [r0Def, r0, r1, r2, r3, r4Def, r4] = test.ranges(); const fnRanges = [r0, r1, r2, r3]; verify.singleReferenceGroup("function DefaultExportedFunction(): () => typeof DefaultExportedFunction", fnRanges); diff --git a/tests/cases/fourslash/findAllRefsForDefaultExport03.ts b/tests/cases/fourslash/findAllRefsForDefaultExport03.ts index 75cbe556e36f2..3ad604e228207 100644 --- a/tests/cases/fourslash/findAllRefsForDefaultExport03.ts +++ b/tests/cases/fourslash/findAllRefsForDefaultExport03.ts @@ -1,17 +1,17 @@ /// -////function [|{| "isWriteAccess": true, "isDefinition": true |}f|]() { +////[|function [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}f|]() { //// return 100; -////} +////}|] //// -////export default [|f|]; +////[|export default [|{| "contextRangeIndex": 2 |}f|];|] //// ////var x: typeof [|f|]; //// ////var y = [|f|](); //// -////namespace [|{| "isWriteAccess": true, "isDefinition": true |}f|] { +////[|namespace [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 6 |}f|] { //// var local = 100; -////} +////}|] -verify.singleReferenceGroup("namespace f\nfunction f(): number"); +verify.singleReferenceGroup("namespace f\nfunction f(): number", "f"); diff --git a/tests/cases/fourslash/findAllRefsForDefaultExport04.ts b/tests/cases/fourslash/findAllRefsForDefaultExport04.ts index 279f2bd1e81f9..3e3bb1b625b33 100644 --- a/tests/cases/fourslash/findAllRefsForDefaultExport04.ts +++ b/tests/cases/fourslash/findAllRefsForDefaultExport04.ts @@ -1,14 +1,14 @@ /// // @Filename: /a.ts -////const [|{| "isWriteAccess": true, "isDefinition": true |}a|] = 0; -////export [|{| "isWriteAccess": true, "isDefinition": true |}default|] [|a|]; +////[|const [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}a|] = 0;|] +////[|export [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 2 |}default|] [|{| "contextRangeIndex": 2 |}a|];|] // @Filename: /b.ts -////import [|{| "isWriteAccess": true, "isDefinition": true |}a|] from "./a"; +////[|import [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 5 |}a|] from "./a";|] ////[|a|]; -const [r0, r1, r2, r3, r4] = test.ranges(); +const [r0Def, r0, r1Def, r1, r2, r3Def, r3, r4] = test.ranges(); verify.referenceGroups([r0, r2], [ { definition: "const a: 0", ranges: [r0, r2] }, { definition: "(alias) const a: 0\nimport a", ranges: [r3, r4] } diff --git a/tests/cases/fourslash/findAllRefsForDefaultExport08.ts b/tests/cases/fourslash/findAllRefsForDefaultExport08.ts index 5583ba34c9555..250944ff2493f 100644 --- a/tests/cases/fourslash/findAllRefsForDefaultExport08.ts +++ b/tests/cases/fourslash/findAllRefsForDefaultExport08.ts @@ -7,11 +7,11 @@ //// ////var y = new DefaultExportedClass; //// -////namespace [|{| "isWriteAccess": true, "isDefinition": true |}DefaultExportedClass|] { -////} +////[|namespace [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}DefaultExportedClass|] { +////}|] verify.noErrors(); // The namespace and class do not merge, // so the namespace should be all alone. -verify.singleReferenceGroup("class DefaultExportedClass\nnamespace DefaultExportedClass"); +verify.singleReferenceGroup("class DefaultExportedClass\nnamespace DefaultExportedClass", "DefaultExportedClass"); diff --git a/tests/cases/fourslash/findAllRefsForDefaultExportAnonymous.ts b/tests/cases/fourslash/findAllRefsForDefaultExportAnonymous.ts index 3beb5b5942415..a2098b2471312 100644 --- a/tests/cases/fourslash/findAllRefsForDefaultExportAnonymous.ts +++ b/tests/cases/fourslash/findAllRefsForDefaultExportAnonymous.ts @@ -1,12 +1,12 @@ /// // @Filename: /a.ts -////export [|{| "isWriteAccess": true, "isDefinition": true |}default|] function() {} +////[|export [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}default|] function() {}|] // @Filename: /b.ts -////import [|{| "isWriteAccess": true, "isDefinition": true |}f|] from "./a"; +////[|import [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 2 |}f|] from "./a";|] -const [r0, r1] = test.ranges(); +const [r0Def, r0, r1Def, r1] = test.ranges(); verify.referenceGroups(r0, [ { definition: "function default(): void", ranges: [r0] }, { definition: "import f", ranges: [r1] }, diff --git a/tests/cases/fourslash/findAllRefsForDefaultExport_anonymous.ts b/tests/cases/fourslash/findAllRefsForDefaultExport_anonymous.ts index 058bc419986d4..30dbb7544a46c 100644 --- a/tests/cases/fourslash/findAllRefsForDefaultExport_anonymous.ts +++ b/tests/cases/fourslash/findAllRefsForDefaultExport_anonymous.ts @@ -1,12 +1,12 @@ /// // @Filename: /a.ts -////export [|{| "isDefinition": true, "isWriteAccess": true |}default|] 1; +////[|export [|{| "isDefinition": true, "isWriteAccess": true, "contextRangeIndex": 0 |}default|] 1;|] // @Filename: /b.ts -////import [|{| "isDefinition": true, "isWriteAccess": true |}a|] from "./a"; +////[|import [|{| "isDefinition": true, "isWriteAccess": true, "contextRangeIndex": 2 |}a|] from "./a";|] -const [r0, r1] = test.ranges(); +const [r0Def, r0, r1Def, r1] = test.ranges(); verify.referenceGroups(r0, [ { definition: "(property) default: 1", ranges: [r0] }, { definition: "import a", ranges: [r1] }, diff --git a/tests/cases/fourslash/findAllRefsForDefaultExport_reExport.ts b/tests/cases/fourslash/findAllRefsForDefaultExport_reExport.ts index 2abd33b7d6ee5..2178f71d8f989 100644 --- a/tests/cases/fourslash/findAllRefsForDefaultExport_reExport.ts +++ b/tests/cases/fourslash/findAllRefsForDefaultExport_reExport.ts @@ -1,16 +1,16 @@ /// // @Filename: /export.ts -////const [|{| "isWriteAccess": true, "isDefinition": true |}foo|] = 1; -////export default [|foo|]; +////[|const [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}foo|] = 1;|] +////[|export default [|{| "contextRangeIndex": 2 |}foo|];|] // @Filename: /re-export.ts -////export { [|{| "isWriteAccess": true, "isDefinition": true |}default|] } from "./export"; +////[|export { [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 4 |}default|] } from "./export";|] // @Filename: /re-export-dep.ts -////import [|{| "isWriteAccess": true, "isDefinition": true |}fooDefault|] from "./re-export"; +////[|import [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 6 |}fooDefault|] from "./re-export";|] -const [r0, r1, r2, r3] = test.ranges(); +const [r0Def, r0, r1Def, r1, r2Def, r2, r3Def, r3] = test.ranges(); verify.referenceGroups([r0, r1], [ { definition: "const foo: 1", ranges: [r0, r1] }, { definition: "(alias) const foo: 1\nexport default", ranges: [r2], }, diff --git a/tests/cases/fourslash/findAllRefsForDefaultExport_reExport_allowSyntheticDefaultImports.ts b/tests/cases/fourslash/findAllRefsForDefaultExport_reExport_allowSyntheticDefaultImports.ts index 386eca5eae0d8..2e45a18e396fd 100644 --- a/tests/cases/fourslash/findAllRefsForDefaultExport_reExport_allowSyntheticDefaultImports.ts +++ b/tests/cases/fourslash/findAllRefsForDefaultExport_reExport_allowSyntheticDefaultImports.ts @@ -3,18 +3,18 @@ // @allowSyntheticDefaultImports: true // @Filename: /export.ts -////const [|{| "isWriteAccess": true, "isDefinition": true |}foo|] = 1; -////export = [|foo|]; +////[|const [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}foo|] = 1;|] +////[|export = [|{| "contextRangeIndex": 2 |}foo|];|] // @Filename: /re-export.ts -////export { [|{| "isWriteAccess": true, "isDefinition": true |}default|] } from "./export"; +////[|export { [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 4 |}default|] } from "./export";|] // @Filename: /re-export-dep.ts -////import [|{| "isWriteAccess": true, "isDefinition": true |}fooDefault|] from "./re-export"; +////[|import [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 6 |}fooDefault|] from "./re-export";|] verify.noErrors(); -const [r0, r1, r2, r3] = test.ranges(); +const [r0Def, r0, r1Def, r1, r2Def, r2, r3Def, r3] = test.ranges(); verify.referenceGroups([r0, r1], [ { definition: "const foo: 1", ranges: [r0, r1] }, { definition: "(alias) const foo: 1\nexport default", ranges: [r2], }, diff --git a/tests/cases/fourslash/findAllRefsForFunctionExpression01.ts b/tests/cases/fourslash/findAllRefsForFunctionExpression01.ts index ddb98711629ea..9665c18971509 100644 --- a/tests/cases/fourslash/findAllRefsForFunctionExpression01.ts +++ b/tests/cases/fourslash/findAllRefsForFunctionExpression01.ts @@ -1,12 +1,12 @@ /// // @Filename: file1.ts -////var foo = function [|{| "isWriteAccess": true, "isDefinition": true |}foo|](a = [|foo|](), b = () => [|foo|]) { +////var foo = [|function [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}foo|](a = [|foo|](), b = () => [|foo|]) { //// [|foo|]([|foo|], [|foo|]); -////} +////}|] // @Filename: file2.ts /////// ////foo(); -verify.singleReferenceGroup("(local function) foo(a?: void, b?: () => (a?: void, b?: ...) => void): void"); +verify.singleReferenceGroup("(local function) foo(a?: void, b?: () => (a?: void, b?: ...) => void): void", "foo"); diff --git a/tests/cases/fourslash/findAllRefsForMappedType.ts b/tests/cases/fourslash/findAllRefsForMappedType.ts index 8965fa046eac3..5c6aa30b3bb29 100644 --- a/tests/cases/fourslash/findAllRefsForMappedType.ts +++ b/tests/cases/fourslash/findAllRefsForMappedType.ts @@ -1,9 +1,9 @@ /// -////interface T { [|{| "isDefinition": true |}a|]: number }; +////interface T { [|[|{| "isDefinition": true, "contextRangeIndex": 0 |}a|]: number|] }; ////type U = { [K in keyof T]: string }; ////type V = { [K in keyof U]: boolean }; -////const u: U = { [|{| "isWriteAccess": true, "isDefinition": true |}a|]: "" } -////const v: V = { [|{| "isWriteAccess": true, "isDefinition": true |}a|]: true } +////const u: U = { [|[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 2 |}a|]: ""|] } +////const v: V = { [|[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 4 |}a|]: true|] } -verify.singleReferenceGroup("(property) T.a: number"); +verify.singleReferenceGroup("(property) T.a: number", "a"); diff --git a/tests/cases/fourslash/findAllRefsForModule.ts b/tests/cases/fourslash/findAllRefsForModule.ts index a9a44d6ffaa82..0197c27210771 100644 --- a/tests/cases/fourslash/findAllRefsForModule.ts +++ b/tests/cases/fourslash/findAllRefsForModule.ts @@ -6,16 +6,16 @@ ////export const x = 0; // @Filename: /b.ts -////import { x } from "[|./a|]"; +////[|import { x } from "[|{| "contextRangeIndex": 0 |}./a|]";|] // @Filename: /c/sub.js -////const a = require("[|../a|]"); +////[|const a = require("[|{| "contextRangeIndex": 2 |}../a|]");|] // @Filename: /d.ts //// /// -const ranges = test.ranges(); -const [r0, r1, r2] = ranges; +const [r0Def, r0, r1Def, r1, r2] = test.ranges(); +const ranges = [r0, r1, r2]; verify.referenceGroups(ranges, [{ definition: 'module "/a"', ranges: [r0, r1, r2] }]); // Testing that it works with documentHighlights too -verify.rangesAreDocumentHighlights(); +verify.rangesAreDocumentHighlights(ranges); diff --git a/tests/cases/fourslash/findAllRefsForModuleGlobal.ts b/tests/cases/fourslash/findAllRefsForModuleGlobal.ts index 817064c3f1449..1ad69e018561e 100644 --- a/tests/cases/fourslash/findAllRefsForModuleGlobal.ts +++ b/tests/cases/fourslash/findAllRefsForModuleGlobal.ts @@ -5,8 +5,8 @@ // @Filename: /b.ts /////// -////import { x } from "[|foo|]"; -////declare module "[|{| "isWriteAccess": true, "isDefinition": true |}foo|]" {} +////[|import { x } from "[|{| "contextRangeIndex": 1 |}foo|]";|] +////[|declare module "[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 3 |}foo|]" {}|] verify.noErrors(); -verify.singleReferenceGroup('module "/node_modules/foo/index"'); +verify.singleReferenceGroup('module "/node_modules/foo/index"', "foo"); diff --git a/tests/cases/fourslash/findAllRefsForObjectLiteralProperties.ts b/tests/cases/fourslash/findAllRefsForObjectLiteralProperties.ts index 2d9d9e267c5b0..a9de9bb632cf2 100644 --- a/tests/cases/fourslash/findAllRefsForObjectLiteralProperties.ts +++ b/tests/cases/fourslash/findAllRefsForObjectLiteralProperties.ts @@ -1,11 +1,11 @@ /// ////var x = { -//// [|{| "isWriteAccess": true, "isDefinition": true |}property|]: {} +//// [|[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}property|]: {}|] ////}; //// ////x.[|property|]; //// -////let {[|property|]: pVar} = x; +////[|let {[|{| "contextRangeIndex": 3 |}property|]: pVar} = x;|] -verify.singleReferenceGroup("(property) property: {}"); +verify.singleReferenceGroup("(property) property: {}", "property"); diff --git a/tests/cases/fourslash/findAllRefsForObjectSpread.ts b/tests/cases/fourslash/findAllRefsForObjectSpread.ts index 12c338ca52914..c4226a5310c49 100644 --- a/tests/cases/fourslash/findAllRefsForObjectSpread.ts +++ b/tests/cases/fourslash/findAllRefsForObjectSpread.ts @@ -1,14 +1,14 @@ /// -////interface A1 { readonly [|{| "isDefinition": true |}a|]: string }; -////interface A2 { [|{| "isDefinition": true |}a|]?: number }; +////interface A1 { [|readonly [|{| "isDefinition": true, "contextRangeIndex": 0 |}a|]: string|] }; +////interface A2 { [|[|{| "isDefinition": true, "contextRangeIndex": 2 |}a|]?: number|] }; ////let a1: A1; ////let a2: A2; ////let a12 = { ...a1, ...a2 }; ////a12.[|a|]; ////a1.[|a|]; -const ranges = test.ranges(); -const [r0, r1, r2, r3] = ranges; + +const [r0Def, r0, r1Def, r1, r2, r3] = test.ranges(); // members of spread types only refer to themselves and the resulting property verify.referenceGroups(r0, [{ definition: "(property) A1.a: string", ranges: [r0, r2, r3] }]); diff --git a/tests/cases/fourslash/findAllRefsForRest.ts b/tests/cases/fourslash/findAllRefsForRest.ts index 3dac71374f065..81aadfe69c91b 100644 --- a/tests/cases/fourslash/findAllRefsForRest.ts +++ b/tests/cases/fourslash/findAllRefsForRest.ts @@ -1,11 +1,11 @@ /// ////interface Gen { //// x: number -//// [|{| "isDefinition": true |}parent|]: Gen; +//// [|[|{| "isDefinition": true, "contextRangeIndex": 0 |}parent|]: Gen;|] //// millenial: string; ////} ////let t: Gen; ////var { x, ...rest } = t; ////rest.[|parent|]; -verify.singleReferenceGroup("(property) Gen.parent: Gen"); +verify.singleReferenceGroup("(property) Gen.parent: Gen", "parent"); diff --git a/tests/cases/fourslash/findAllRefsForUMDModuleAlias1.ts b/tests/cases/fourslash/findAllRefsForUMDModuleAlias1.ts index 99ca347eac4bb..10776d35617f8 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 [|{| "isWriteAccess": true, "isDefinition": true |}myLib|]; +//// [|export as namespace [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}myLib|];|] // @Filename: 1.ts //// /// //// [|myLib|].doThing(); -verify.singleReferenceGroup("export namespace myLib"); +verify.singleReferenceGroup("export namespace myLib", "myLib"); diff --git a/tests/cases/fourslash/findAllRefsForVariableInExtendsClause01.ts b/tests/cases/fourslash/findAllRefsForVariableInExtendsClause01.ts index a61f925c97ecc..20037640a8c6d 100644 --- a/tests/cases/fourslash/findAllRefsForVariableInExtendsClause01.ts +++ b/tests/cases/fourslash/findAllRefsForVariableInExtendsClause01.ts @@ -1,6 +1,6 @@ /// -////var [|{| "isWriteAccess": true, "isDefinition": true |}Base|] = class { }; +////[|var [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}Base|] = class { };|] ////class C extends [|Base|] { } -verify.singleReferenceGroup("var Base: typeof Base"); +verify.singleReferenceGroup("var Base: typeof Base", "Base"); diff --git a/tests/cases/fourslash/findAllRefsForVariableInExtendsClause02.ts b/tests/cases/fourslash/findAllRefsForVariableInExtendsClause02.ts index 5685df0c4e1dc..da9faa17ef4e6 100644 --- a/tests/cases/fourslash/findAllRefsForVariableInExtendsClause02.ts +++ b/tests/cases/fourslash/findAllRefsForVariableInExtendsClause02.ts @@ -1,9 +1,9 @@ /// -////interface [|{| "isWriteAccess": true, "isDefinition": true |}Base|] { } +////[|interface [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}Base|] { }|] ////namespace n { //// var Base = class { }; //// interface I extends [|Base|] { } ////} -verify.singleReferenceGroup("interface Base"); +verify.singleReferenceGroup("interface Base", "Base"); diff --git a/tests/cases/fourslash/findAllRefsGlobalModuleAugmentation.ts b/tests/cases/fourslash/findAllRefsGlobalModuleAugmentation.ts index c2f4982b65353..68f691e27f57f 100644 --- a/tests/cases/fourslash/findAllRefsGlobalModuleAugmentation.ts +++ b/tests/cases/fourslash/findAllRefsGlobalModuleAugmentation.ts @@ -3,11 +3,11 @@ // @Filename: /a.ts ////export {}; ////declare global { -//// function [|{| "isWriteAccess": true, "isDefinition": true |}f|](): void; +//// [|function [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}f|](): void;|] ////} // @Filename: /b.ts ////[|f|](); verify.noErrors(); -verify.singleReferenceGroup("function f(): void"); +verify.singleReferenceGroup("function f(): void", "f"); diff --git a/tests/cases/fourslash/findAllRefsImportDefault.ts b/tests/cases/fourslash/findAllRefsImportDefault.ts index 15b3bda8ddf1a..5c491fc29f677 100644 --- a/tests/cases/fourslash/findAllRefsImportDefault.ts +++ b/tests/cases/fourslash/findAllRefsImportDefault.ts @@ -1,17 +1,17 @@ /// // @Filename: f.ts -////export { [|foo|] as [|{| "isWriteAccess": true, "isDefinition": true |}default|] }; -////function /*start*/[|{| "isWriteAccess": true, "isDefinition": true |}foo|](a: number, b: number) { +////[|export { [|{| "contextRangeIndex": 0 |}foo|] as [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}default|] };|] +////[|function /*start*/[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 3 |}foo|](a: number, b: number) { //// return a + b; -////} +////}|] // @Filename: b.ts -////import [|{| "isWriteAccess": true, "isDefinition": true |}bar|] from "./f"; +////[|import [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 5 |}bar|] from "./f";|] ////[|bar|](1, 2); verify.noErrors(); -const [ foo0, foo1, foo2, bar0, bar1 ] = test.ranges(); +const [ foo0Def, foo0, foo1, foo2Def, foo2, bar0Def, bar0, bar1 ] = test.ranges(); const fooGroup = { definition: "function foo(a: number, b: number): number", ranges: [foo0, foo2] }; const exportDefaultGroup = { definition: "(alias) function foo(a: number, b: number): number\nexport default", ranges: [foo1] }; const barGroup = { definition: "(alias) function bar(a: number, b: number): number\nimport bar", ranges: [bar0, bar1]}; diff --git a/tests/cases/fourslash/findAllRefsImportEquals.ts b/tests/cases/fourslash/findAllRefsImportEquals.ts index c6884c78b8c62..7a35f4a9fdb5e 100644 --- a/tests/cases/fourslash/findAllRefsImportEquals.ts +++ b/tests/cases/fourslash/findAllRefsImportEquals.ts @@ -1,7 +1,7 @@ /// ////import j = N./**/ [|q|]; -////namespace N { export const [|{| "isWriteAccess": true, "isDefinition": true |}q|] = 0; } +////namespace N { [|export const [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 1 |}q|] = 0;|] } goTo.marker(); -verify.referenceGroups("", [{ definition: "const N.q: 0", ranges: test.ranges() }]); +verify.referenceGroups("", [{ definition: "const N.q: 0", ranges: test.rangesByText().get("q") }]); diff --git a/tests/cases/fourslash/findAllRefsImportEqualsJsonFile.ts b/tests/cases/fourslash/findAllRefsImportEqualsJsonFile.ts index 3c3c0dbb2e47a..f8b40c908f376 100644 --- a/tests/cases/fourslash/findAllRefsImportEqualsJsonFile.ts +++ b/tests/cases/fourslash/findAllRefsImportEqualsJsonFile.ts @@ -5,11 +5,11 @@ // @resolveJsonModule: true // @Filename: /a.ts -////import [|{| "isWriteAccess": true, "isDefinition": true |}j|] = require("[|./j.json|]"); +////[|import [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}j|] = require("[|{| "contextRangeIndex": 0 |}./j.json|]");|] ////[|j|]; // @Filename: /b.js -////const [|{| "isWriteAccess": true, "isDefinition": true |}j|] = require("[|./j.json|]"); +////[|const [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 4 |}j|] = require("[|{| "contextRangeIndex": 4 |}./j.json|]");|] ////[|j|]; // @Filename: /j.json @@ -17,7 +17,7 @@ verify.noErrors(); -const [r0, r1, r2, r3, r4, r5, r6] = test.ranges(); +const [r0Def, r0, r1, r2, r3Def, r3, r4, r5, r6] = test.ranges(); verify.singleReferenceGroup('import j = require("./j.json")', [r0, r2]); verify.referenceGroups([r1, r4], [{ definition: 'module "/j"', ranges: [r1, r4, r6] }]); verify.singleReferenceGroup('const j: {\n "x": number;\n}', [r3, r5]); diff --git a/tests/cases/fourslash/findAllRefsImportNamed.ts b/tests/cases/fourslash/findAllRefsImportNamed.ts index 5d18a8de1640d..dab150508a3b9 100644 --- a/tests/cases/fourslash/findAllRefsImportNamed.ts +++ b/tests/cases/fourslash/findAllRefsImportNamed.ts @@ -1,15 +1,15 @@ /// // @Filename: f.ts -////export { [|foo|] as [|{| "isWriteAccess": true, "isDefinition": true |}foo|] } -////function /*start*/[|{| "isWriteAccess": true, "isDefinition": true |}foo|](a: number, b: number) { } +////[|export { [|{| "contextRangeIndex": 0 |}foo|] as [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}foo|] }|] +////[|function /*start*/[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 3 |}foo|](a: number, b: number) { }|] // @Filename: b.ts ////import x = require("./f"); ////x.[|foo|](1, 2); verify.noErrors(); -const [ foo0, foo1, foo2, foo3 ] = test.ranges(); +const [ foo0Def, foo0, foo1, foo2Def, foo2, foo3 ] = test.ranges(); const fooGroup = { definition: "function foo(a: number, b: number): void", ranges: [foo0, foo2] }; const exportFooGroup = { definition: "(alias) function foo(a: number, b: number): void\nexport foo", ranges: [foo1, foo3] }; verify.referenceGroups("start", [fooGroup, exportFooGroup]); diff --git a/tests/cases/fourslash/findAllRefsImportStarOfExportEquals.ts b/tests/cases/fourslash/findAllRefsImportStarOfExportEquals.ts index 7cab65bc38835..017ea4b520d68 100644 --- a/tests/cases/fourslash/findAllRefsImportStarOfExportEquals.ts +++ b/tests/cases/fourslash/findAllRefsImportStarOfExportEquals.ts @@ -2,27 +2,26 @@ // @allowSyntheticDefaultimports: true // @Filename: /node_modules/a/index.d.ts -////declare function [|{| "isWriteAccess": true, "isDefinition": true |}a|](): void; -////declare namespace [|{| "isWriteAccess": true, "isDefinition": true |}a|] { +////[|declare function [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}a|](): void;|] +////[|declare namespace [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 2 |}a|] { //// export const x: number; -////} -////export = [|a|]; +////}|] +////[|export = [|{| "contextRangeIndex": 4 |}a|];|] // Import with different name and we find local refs // @Filename: /b.ts -////import [|{| "isWriteAccess": true, "isDefinition": true |}b|] from "a"; +////[|import [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 6 |}b|] from "a";|] ////[|b|](); ////[|b|].x; // Import with same name and we find all refs // @Filename: /c.ts -////import [|{| "isWriteAccess": true, "isDefinition": true |}a|] from "a"; +////[|import [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 10 |}a|] from "a";|] ////[|a|](); ////[|a|].x; verify.noErrors(); -const ranges = test.ranges(); -const [a0, a1, a2, b0, b1, b2, c0, c1, c2] = ranges; +const [a0Def, a0, a1Def, a1, a2Def, a2, b0Def, b0, b1, b2, c0Def, c0, c1, c2] = test.ranges(); const aRanges = [a0, a1, a2]; const bRanges = [b0, b1, b2]; const cRanges = [c0, c1, c2]; diff --git a/tests/cases/fourslash/findAllRefsImportType.ts b/tests/cases/fourslash/findAllRefsImportType.ts index 9f1fa09436e4e..5ae1495ca557e 100644 --- a/tests/cases/fourslash/findAllRefsImportType.ts +++ b/tests/cases/fourslash/findAllRefsImportType.ts @@ -4,9 +4,9 @@ // @Filename: /a.js ////module.exports = 0; -////export type [|{| "isWriteAccess": true, "isDefinition": true |}N|] = number; +////[|export type [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}N|] = number;|] // @Filename: /b.js ////type T = import("./a").[|N|]; -verify.singleReferenceGroup("type N = number"); +verify.singleReferenceGroup("type N = number", "N"); diff --git a/tests/cases/fourslash/findAllRefsInClassExpression.ts b/tests/cases/fourslash/findAllRefsInClassExpression.ts index 8adc64e8e6d49..b2c18543c4196 100644 --- a/tests/cases/fourslash/findAllRefsInClassExpression.ts +++ b/tests/cases/fourslash/findAllRefsInClassExpression.ts @@ -1,11 +1,11 @@ /// -////interface I { [|{| "isDefinition": true |}boom|](): void; } +////interface I { [|[|{| "isDefinition": true, "contextRangeIndex": 0 |}boom|](): void;|] } ////new class C implements I { -//// [|{| "isWriteAccess": true, "isDefinition": true |}boom|](){} +//// [|[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 2 |}boom|](){}|] ////} -const [r0, r1] = test.ranges(); +const [r0Def, r0, r1Def, r1] = test.ranges(); verify.referenceGroups([r0, r1], [ { definition: "(method) I.boom(): void", ranges: [r0] }, { definition: "(method) C.boom(): void", ranges: [r1] } diff --git a/tests/cases/fourslash/findAllRefsIndexedAccessTypes.ts b/tests/cases/fourslash/findAllRefsIndexedAccessTypes.ts index 49dac24729442..aa80c6c3c1f1d 100644 --- a/tests/cases/fourslash/findAllRefsIndexedAccessTypes.ts +++ b/tests/cases/fourslash/findAllRefsIndexedAccessTypes.ts @@ -1,14 +1,13 @@ /// ////interface I { -//// [|{| "isDefinition": true |}0|]: number; -//// [|{| "isDefinition": true |}s|]: string; +//// [|[|{| "isDefinition": true, "contextRangeIndex": 0 |}0|]: number;|] +//// [|[|{| "isDefinition": true, "contextRangeIndex": 2 |}s|]: string;|] ////} ////interface J { //// a: I[[|0|]], //// b: I["[|s|]"], ////} -const [n0, s0, n1, s1] = test.ranges(); -verify.singleReferenceGroup("(property) I[0]: number", [n0, n1]); -verify.singleReferenceGroup("(property) I.s: string", [s0, s1]); +verify.singleReferenceGroup("(property) I[0]: number", "0"); +verify.singleReferenceGroup("(property) I.s: string", "s"); diff --git a/tests/cases/fourslash/findAllRefsInheritedProperties1.ts b/tests/cases/fourslash/findAllRefsInheritedProperties1.ts index 9e58a37c589bb..f2eef8e3a99bb 100644 --- a/tests/cases/fourslash/findAllRefsInheritedProperties1.ts +++ b/tests/cases/fourslash/findAllRefsInheritedProperties1.ts @@ -1,14 +1,14 @@ /// //// class class1 extends class1 { -//// [|{| "isWriteAccess": true, "isDefinition": true |}doStuff|]() { } -//// [|{| "isDefinition": true |}propName|]: string; +//// [|[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}doStuff|]() { }|] +//// [|[|{| "isDefinition": true, "contextRangeIndex": 2 |}propName|]: string;|] //// } //// //// var v: class1; //// v.[|doStuff|](); //// v.[|propName|]; -const [r0, r1, r2, r3] = test.ranges(); +const [r0Def, r0, r1Def, r1, r2, r3] = test.ranges(); verify.singleReferenceGroup("(method) class1.doStuff(): void", [r0, r2]); verify.singleReferenceGroup("(property) class1.propName: string", [r1, r3]); diff --git a/tests/cases/fourslash/findAllRefsInheritedProperties2.ts b/tests/cases/fourslash/findAllRefsInheritedProperties2.ts index 2e776e48acd79..1179527379957 100644 --- a/tests/cases/fourslash/findAllRefsInheritedProperties2.ts +++ b/tests/cases/fourslash/findAllRefsInheritedProperties2.ts @@ -1,14 +1,14 @@ /// //// interface interface1 extends interface1 { -//// [|{| "isDefinition": true |}doStuff|](): void; // r0 -//// [|{| "isDefinition": true |}propName|]: string; // r1 +//// [|[|{| "isDefinition": true, "contextRangeIndex": 0 |}doStuff|](): void;|] // r0 +//// [|[|{| "isDefinition": true, "contextRangeIndex": 2 |}propName|]: string;|] // r1 //// } //// //// var v: interface1; //// v.[|doStuff|](); // r2 //// v.[|propName|]; // r3 -const [r0, r1, r2, r3] = test.ranges(); +const [r0Def, r0, r1Def, r1, r2, r3] = test.ranges(); 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 ea5b1ce7bf46e..22f03d909829b 100644 --- a/tests/cases/fourslash/findAllRefsInheritedProperties3.ts +++ b/tests/cases/fourslash/findAllRefsInheritedProperties3.ts @@ -1,23 +1,23 @@ /// //// class class1 extends class1 { -//// [|{| "isWriteAccess": true, "isDefinition": true |}doStuff|]() { } // r0 -//// [|{| "isDefinition": true |}propName|]: string; // r1 +//// [|[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}doStuff|]() { }|] // r0 +//// [|[|{| "isDefinition": true, "contextRangeIndex": 2 |}propName|]: string;|] // r1 //// } //// interface interface1 extends interface1 { -//// [|{| "isDefinition": true |}doStuff|](): void; // r2 -//// [|{| "isDefinition": true |}propName|]: string; // r3 +//// [|[|{| "isDefinition": true, "contextRangeIndex": 4 |}doStuff|](): void;|] // r2 +//// [|[|{| "isDefinition": true, "contextRangeIndex": 6 |}propName|]: string;|] // r3 //// } //// class class2 extends class1 implements interface1 { -//// [|{| "isWriteAccess": true, "isDefinition": true |}doStuff|]() { } // r4 -//// [|{| "isDefinition": true |}propName|]: string; // r5 +//// [|[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 8 |}doStuff|]() { }|] // r4 +//// [|[|{| "isDefinition": true, "contextRangeIndex": 10 |}propName|]: string;|] // r5 //// } //// //// var v: class2; //// v.[|doStuff|](); // r6 //// v.[|propName|]; // r7 -const [r0, r1, r2, r3, r4, r5, r6, r7] = test.ranges(); +const [r0Def, r0, r1Def, r1, r2Def, r2, r3Def, r3, r4Def, r4, r5Def, r5, r6, r7] = test.ranges(); verify.referenceGroups(r0, [ { definition: "(method) class1.doStuff(): void", ranges: [r0] }, { definition: "(method) class2.doStuff(): void", ranges: [r4, r6] }, diff --git a/tests/cases/fourslash/findAllRefsInheritedProperties4.ts b/tests/cases/fourslash/findAllRefsInheritedProperties4.ts index 2528fef193984..8fb97268d9515 100644 --- a/tests/cases/fourslash/findAllRefsInheritedProperties4.ts +++ b/tests/cases/fourslash/findAllRefsInheritedProperties4.ts @@ -1,19 +1,19 @@ /// //// interface C extends D { -//// [|{| "isDefinition": true |}prop0|]: string; // r0 -//// [|{| "isDefinition": true |}prop1|]: number; // r1 +//// [|[|{| "isDefinition": true, "contextRangeIndex": 0 |}prop0|]: string;|] // r0 +//// [|[|{| "isDefinition": true, "contextRangeIndex": 2 |}prop1|]: number;|] // r1 //// } //// //// interface D extends C { -//// [|{| "isDefinition": true |}prop0|]: string; // r2 +//// [|[|{| "isDefinition": true, "contextRangeIndex": 4 |}prop0|]: string;|] // r2 //// } //// //// var d: D; //// d.[|prop0|]; // r3 //// d.[|prop1|]; // r4 -const [r0, r1, r2, r3, r4] = test.ranges(); +const [r0Def, r0, r1Def, r1, r2Def, r2, r3, r4] = test.ranges(); verify.referenceGroups([r0, r2, r3], [ { definition: "(property) C.prop0: string", ranges: [r0] }, { definition: "(property) D.prop0: string", ranges: [r2, r3] } diff --git a/tests/cases/fourslash/findAllRefsInheritedProperties5.ts b/tests/cases/fourslash/findAllRefsInheritedProperties5.ts index 343328405d5ae..a8b37a254ab01 100644 --- a/tests/cases/fourslash/findAllRefsInheritedProperties5.ts +++ b/tests/cases/fourslash/findAllRefsInheritedProperties5.ts @@ -1,19 +1,19 @@ /// //// class C extends D { -//// [|{| "isDefinition": true |}prop0|]: string; // r0 -//// [|{| "isDefinition": true |}prop1|]: number; // r1 +//// [|[|{| "isDefinition": true, "contextRangeIndex": 0 |}prop0|]: string;|] // r0 +//// [|[|{| "isDefinition": true, "contextRangeIndex": 2 |}prop1|]: number;|] // r1 //// } //// //// class D extends C { -//// [|{| "isDefinition": true |}prop0|]: string; // r2 +//// [|[|{| "isDefinition": true, "contextRangeIndex": 4 |}prop0|]: string;|] // r2 //// } //// //// var d: D; //// d.[|prop0|]; // r3 //// d.[|prop1|]; // r4 -const [r0, r1, r2, r3, r4] = test.ranges(); +const [r0Def, r0, r1Def, r1, r2Def, r2, r3, r4] = test.ranges(); verify.singleReferenceGroup("(property) C.prop0: string", [r0]); verify.singleReferenceGroup("(property) C.prop1: number", [r1]); verify.singleReferenceGroup("(property) D.prop0: string", [r2, r3]); diff --git a/tests/cases/fourslash/findAllRefsInsideTemplates1.ts b/tests/cases/fourslash/findAllRefsInsideTemplates1.ts index 8d41961c6fda1..14e7d33999114 100644 --- a/tests/cases/fourslash/findAllRefsInsideTemplates1.ts +++ b/tests/cases/fourslash/findAllRefsInsideTemplates1.ts @@ -1,6 +1,6 @@ /// -////var [|{| "isWriteAccess": true, "isDefinition": true |}x|] = 10; +////[|var [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}x|] = 10;|] ////var y = `${ [|x|] } ${ [|x|] }` -verify.singleReferenceGroup("var x: number"); +verify.singleReferenceGroup("var x: number", "x"); diff --git a/tests/cases/fourslash/findAllRefsInsideTemplates2.ts b/tests/cases/fourslash/findAllRefsInsideTemplates2.ts index 24a4a7c131b42..8096081e363c9 100644 --- a/tests/cases/fourslash/findAllRefsInsideTemplates2.ts +++ b/tests/cases/fourslash/findAllRefsInsideTemplates2.ts @@ -1,6 +1,6 @@ /// -////function [|{| "isWriteAccess": true, "isDefinition": true |}f|](...rest: any[]) { } +////[|function [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}f|](...rest: any[]) { }|] ////[|f|] `${ [|f|] } ${ [|f|] }` -verify.singleReferenceGroup("function f(...rest: any[]): void"); +verify.singleReferenceGroup("function f(...rest: any[]): void", "f"); diff --git a/tests/cases/fourslash/findAllRefsInsideWithBlock.ts b/tests/cases/fourslash/findAllRefsInsideWithBlock.ts index 5293624809588..991bf25753831 100644 --- a/tests/cases/fourslash/findAllRefsInsideWithBlock.ts +++ b/tests/cases/fourslash/findAllRefsInsideWithBlock.ts @@ -1,6 +1,6 @@ /// -////var [|{| "isWriteAccess": true, "isDefinition": true |}x|] = 0; +////[|var [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}x|] = 0;|] //// ////with ({}) { //// var y = x; // Reference of x here should not be picked @@ -9,4 +9,4 @@ //// ////[|{| "isWriteAccess": true |}x|] = [|x|] + 1; -verify.singleReferenceGroup("var x: number"); +verify.singleReferenceGroup("var x: number", "x"); diff --git a/tests/cases/fourslash/findAllRefsJsDocTypeDef_js.ts b/tests/cases/fourslash/findAllRefsJsDocTypeDef_js.ts index a2d0cad3886ea..fb3cdf5bc33a3 100644 --- a/tests/cases/fourslash/findAllRefsJsDocTypeDef_js.ts +++ b/tests/cases/fourslash/findAllRefsJsDocTypeDef_js.ts @@ -5,7 +5,7 @@ // @allowJs: true // @Filename: /a.js -/////** @typedef {number} [|{| "isWriteAccess": true, "isDefinition": true |}T|] */ +/////** [|@typedef {number} [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}T|]|] */ //// /////** //// * @return {[|T|]} @@ -17,4 +17,4 @@ //// */ ////function f2(obj) { return 0; } -verify.singleReferenceGroup("type T = number"); +verify.singleReferenceGroup("type T = number", "T"); diff --git a/tests/cases/fourslash/findAllRefsMappedType.ts b/tests/cases/fourslash/findAllRefsMappedType.ts index 8c6c59150afc1..a505f41a1510f 100644 --- a/tests/cases/fourslash/findAllRefsMappedType.ts +++ b/tests/cases/fourslash/findAllRefsMappedType.ts @@ -1,10 +1,10 @@ /// -////interface T { [|{| "isDefinition": true |}a|]: number; } +////interface T { [|[|{| "isDefinition": true, "contextRangeIndex": 0 |}a|]: number;|] } ////type U = { readonly [K in keyof T]?: string }; ////declare const t: T; ////t.[|a|]; ////declare const u: U; ////u.[|a|]; -verify.singleReferenceGroup("(property) T.a: number"); +verify.singleReferenceGroup("(property) T.a: number", "a"); diff --git a/tests/cases/fourslash/findAllRefsModuleAugmentation.ts b/tests/cases/fourslash/findAllRefsModuleAugmentation.ts index c5adab35669e2..35e42f7088de3 100644 --- a/tests/cases/fourslash/findAllRefsModuleAugmentation.ts +++ b/tests/cases/fourslash/findAllRefsModuleAugmentation.ts @@ -1,7 +1,7 @@ /// // @Filename: /node_modules/foo/index.d.ts -////export type [|{| "isWriteAccess": true, "isDefinition": true |}T|] = number; +////[|export type [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}T|] = number;|] // @Filename: /a.ts ////import * as foo from "foo"; @@ -10,4 +10,4 @@ ////} verify.noErrors(); -verify.singleReferenceGroup("type T = number"); +verify.singleReferenceGroup("type T = number", "T"); diff --git a/tests/cases/fourslash/findAllRefsModuleDotExports.ts b/tests/cases/fourslash/findAllRefsModuleDotExports.ts index bc1bd705c2f8e..2d9a67a2155d3 100644 --- a/tests/cases/fourslash/findAllRefsModuleDotExports.ts +++ b/tests/cases/fourslash/findAllRefsModuleDotExports.ts @@ -3,9 +3,10 @@ // @allowJs: true // @Filename: /a.js -////const b = require("[|./b|]"); +////[|const b = require("[|{| "contextRangeIndex": 0 |}./b|]");|] // @Filename: /b.js -////[|module|].exports = 0; +////[|[|{| "contextRangeIndex": 2 |}module|].exports = 0;|] -verify.singleReferenceGroup('module "/b"') +const [r0Def, r0, rDef, r1] = test.ranges(); +verify.singleReferenceGroup('module "/b"', [r0, r1]); diff --git a/tests/cases/fourslash/findAllRefsNoImportClause.ts b/tests/cases/fourslash/findAllRefsNoImportClause.ts index b98f5d02d01bf..4226af2b4cf56 100644 --- a/tests/cases/fourslash/findAllRefsNoImportClause.ts +++ b/tests/cases/fourslash/findAllRefsNoImportClause.ts @@ -3,9 +3,9 @@ // https://github.com/Microsoft/TypeScript/issues/15452 // @Filename: /a.ts -////export const [|{| "isWriteAccess": true, "isDefinition": true |}x|] = 0; +////[|export const [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}x|] = 0;|] // @Filename: /b.ts ////import "./a"; -verify.singleReferenceGroup("const x: 0"); +verify.singleReferenceGroup("const x: 0", "x"); diff --git a/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName01.ts b/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName01.ts index 5a72ca1c1ec8d..ca1a23740ba82 100644 --- a/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName01.ts +++ b/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName01.ts @@ -1,11 +1,11 @@ /// ////interface I { -//// [|{| "isDefinition": true |}property1|]: number; +//// [|[|{| "isDefinition": true, "contextRangeIndex": 0 |}property1|]: number;|] //// property2: string; ////} //// ////var foo: I; -////var { [|property1|]: prop1 } = foo; +////[|var { [|{| "contextRangeIndex": 2 |}property1|]: prop1 } = foo;|] -verify.singleReferenceGroup("(property) I.property1: number"); +verify.singleReferenceGroup("(property) I.property1: number", "property1"); diff --git a/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName02.ts b/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName02.ts index 76b6d046b8e21..fba2676f6dd38 100644 --- a/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName02.ts +++ b/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName02.ts @@ -1,11 +1,11 @@ /// ////interface I { -//// [|{| "isDefinition": true |}property1|]: number; +//// [|[|{| "isDefinition": true, "contextRangeIndex": 0 |}property1|]: number;|] //// property2: string; ////} //// ////var foo: I; -////var { [|property1|]: {} } = foo; +////[|var { [|{| "contextRangeIndex": 2 |}property1|]: {} } = foo;|] -verify.singleReferenceGroup("(property) I.property1: number"); +verify.singleReferenceGroup("(property) I.property1: number", "property1"); diff --git a/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName03.ts b/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName03.ts index f82eca087bb7a..db7c9d6f71f63 100644 --- a/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName03.ts +++ b/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName03.ts @@ -1,16 +1,18 @@ /// ////interface I { -//// [|{| "isDefinition": true |}property1|]: number; +//// [|[|{| "isDefinition": true, "contextRangeIndex": 0 |}property1|]: number;|] //// property2: string; ////} //// ////var foo: I; -////var [{ [|property1|]: prop1 }, { [|{| "isWriteAccess": true, "isDefinition": true |}property1|], property2 } ] = [foo, foo]; +////[|var [{ [|{| "contextRangeIndex": 2 |}property1|]: prop1 }, { [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 2 |}property1|], property2 } ] = [foo, foo];|] -const ranges = test.ranges(); -const [r0, r1, r2] = ranges; -verify.referenceGroups([r0, r1], [{ definition: "(property) I.property1: number", ranges }]); +const [r0Def, r0, r1Def, r1, r2] = test.ranges(); +verify.referenceGroups([r0, r1], [{ + definition: "(property) I.property1: number", + ranges: [r0, r1, r2] +}]); 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 c3bebdb262314..19bbf7d6cd88b 100644 --- a/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName04.ts +++ b/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName04.ts @@ -1,19 +1,18 @@ /// ////interface I { -//// [|{| "isDefinition": true |}property1|]: number; +//// [|[|{| "isDefinition": true, "contextRangeIndex": 0 |}property1|]: number;|] //// property2: string; ////} //// -////function f({ [|property1|]: p1 }: I, -//// { [|{| "isWriteAccess": true, "isDefinition": true |}property1|] }: I, +////function f([|{ [|{| "contextRangeIndex": 2 |}property1|]: p1 }: I|], +//// [|{ [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 4 |}property1|] }: I|], //// { property1: p2 }) { //// //// return [|property1|] + 1; ////} -const ranges = test.ranges(); -const [r0, r1, r2, r3] = ranges; +const [r0Def, r0, r1Def, r1, r2Def, r2, r3] = test.ranges(); verify.referenceGroups([r0, r1], [{ definition: "(property) I.property1: number", ranges: [r0, r1, r2] }]); verify.referenceGroups(r2, [ { definition: "(property) I.property1: number", ranges: [r0, r1] }, diff --git a/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName06.ts b/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName06.ts index 62d1637f3b31e..3405d1db44b64 100644 --- a/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName06.ts +++ b/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName06.ts @@ -1,24 +1,26 @@ /// ////interface I { -//// [|{| "isDefinition": true |}property1|]: number; +//// [|[|{| "isDefinition": true, "contextRangeIndex": 0 |}property1|]: number;|] //// property2: string; ////} //// ////var elems: I[]; -////for (let { [|property1|]: p } of elems) { +////for ([|let { [|{| "contextRangeIndex": 2 |}property1|]: p } of elems|]) { ////} -////for (let { [|{| "isWriteAccess": true, "isDefinition": true |}property1|] } of elems) { +////for ([|let { [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 4 |}property1|] } of elems|]) { ////} -////for (var { [|property1|]: p1 } of elems) { +////for ([|var { [|{| "contextRangeIndex": 6 |}property1|]: p1 } of elems|]) { ////} ////var p2; -////for ({ [|{| "isWriteAccess": true, "isDefinition": true |}property1|] : p2 } of elems) { +////for ([|{ [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 8 |}property1|] : p2 } of elems|]) { ////} -const ranges = test.ranges(); -const [r0, r1, r2, r3, r4] = ranges; -verify.referenceGroups([r0, r1, r3, r4], [{ definition: "(property) I.property1: number", ranges }]); +const [r0Def, r0, r1Def, r1, r2Def, r2, r3Def, r3, r4Def, r4] = test.ranges(); +verify.referenceGroups([r0, r1, r3, r4], [{ + definition: "(property) I.property1: number", + ranges: [r0, r1, r2, r3, r4] +}]); verify.referenceGroups(r2, [ { definition: "(property) I.property1: number", ranges: [r0, r1, r3, r4] }, { definition: "let property1: number", ranges: [r2] } diff --git a/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName07.ts b/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName07.ts index 18fa4e4327377..6fa268a2b7bed 100644 --- a/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName07.ts +++ b/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName07.ts @@ -2,6 +2,6 @@ ////let p, b; //// -////p, [{ [|{| "isDefinition": true |}a|]: p, b }] = [{ [|{| "isWriteAccess": true, "isDefinition": true |}a|]: 10, b: true }]; +////p, [|[{ [|{| "isDefinition": true, "contextRangeIndex": 0 |}a|]: p, b }] = [{ [|[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 2 |}a|]: 10|], b: true }]|]; -verify.singleReferenceGroup("(property) a: any"); +verify.singleReferenceGroup("(property) a: any", "a"); diff --git a/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName10.ts b/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName10.ts index 7d31cfd43452a..64413cc8cba2b 100644 --- a/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName10.ts +++ b/tests/cases/fourslash/findAllRefsObjectBindingElementPropertyName10.ts @@ -1,11 +1,11 @@ /// ////interface Recursive { -//// [|{| "isDefinition": true |}next|]?: Recursive; +//// [|[|{| "isDefinition": true, "contextRangeIndex": 0 |}next|]?: Recursive;|] //// value: any; ////} //// -////function f ({ [|next|]: { [|next|]: x} }: Recursive) { +////function f ([|{ [|{| "contextRangeIndex": 2 |}next|]: { [|{| "contextRangeIndex": 2 |}next|]: x} }: Recursive|]) { ////} -verify.singleReferenceGroup("(property) Recursive.next?: Recursive"); +verify.singleReferenceGroup("(property) Recursive.next?: Recursive", "next"); diff --git a/tests/cases/fourslash/findAllRefsOfConstructor.ts b/tests/cases/fourslash/findAllRefsOfConstructor.ts index 08846380749f0..b5c02e09c03f0 100644 --- a/tests/cases/fourslash/findAllRefsOfConstructor.ts +++ b/tests/cases/fourslash/findAllRefsOfConstructor.ts @@ -2,13 +2,13 @@ ////class A { -//// [|constructor|](s: string) {} +//// [|[|{| "contextRangeIndex": 0 |}constructor|](s: string) {}|] ////} ////class B extends A { } ////class C extends B { -//// [|constructor|]() { +//// [|[|{| "contextRangeIndex": 2 |}constructor|]() { //// [|super|](""); -//// } +//// }|] ////} ////class D extends B { } ////class E implements A { } @@ -19,7 +19,7 @@ ////const e = new E(); verify.noErrors(); -const [aCtr, cCtr, cSuper, aNew, bNew, cNew, dNew] = test.ranges(); +const [aCtrDef, aCtr, cCtrDef, cCtr, cSuper, aNew, bNew, cNew, dNew] = test.ranges(); verify.referenceGroups(aCtr, [ { definition: "class A", ranges: [aCtr, aNew] }, { definition: "class B", ranges: [cSuper, bNew]}, diff --git a/tests/cases/fourslash/findAllRefsOfConstructor2.ts b/tests/cases/fourslash/findAllRefsOfConstructor2.ts index 17991cb555c81..5c65a098f4fa7 100644 --- a/tests/cases/fourslash/findAllRefsOfConstructor2.ts +++ b/tests/cases/fourslash/findAllRefsOfConstructor2.ts @@ -2,15 +2,15 @@ ////class A { -//// [|constructor|](s: string) {} +//// [|[|{| "contextRangeIndex": 0 |}constructor|](s: string) {}|] ////} ////class B extends A { -//// [|constructor|]() { [|super|](""); } +//// [|[|{| "contextRangeIndex": 2 |}constructor|]() { [|super|](""); }|] ////} ////class C extends B { -//// [|constructor|]() { +//// [|[|{| "contextRangeIndex": 5 |}constructor|]() { //// [|super|](); -//// } +//// }|] ////} ////class D extends B { } ////const a = new [|A|]("a"); @@ -19,7 +19,7 @@ ////const d = new [|D|](); verify.noErrors(); -const [aCtr, bCtr, bSuper, cCtr, cSuper, aNew, bNew, cNew, dNew] = test.ranges(); +const [aCtrDef, aCtr, bCtrDef, bCtr, bSuper, cCtrDef, cCtr, cSuper, aNew, bNew, cNew, dNew] = test.ranges(); verify.referenceGroups(aCtr, [{ definition: "class A", ranges: [aCtr, bSuper, aNew] }]); verify.referenceGroups(bCtr, [{ definition: "class B", ranges: [bCtr, cSuper, bNew]}, { definition: "class D", ranges: [dNew]}]); verify.referenceGroups(cCtr, [{ definition: "class C", ranges: [cCtr, cNew]}]); \ No newline at end of file diff --git a/tests/cases/fourslash/findAllRefsOfConstructor_multipleFiles.ts b/tests/cases/fourslash/findAllRefsOfConstructor_multipleFiles.ts index a20d9fc1f29ec..f768cb1df2655 100644 --- a/tests/cases/fourslash/findAllRefsOfConstructor_multipleFiles.ts +++ b/tests/cases/fourslash/findAllRefsOfConstructor_multipleFiles.ts @@ -3,26 +3,26 @@ // @Filename: f.ts ////class A { -//// [|constructor|](s: string) {} +//// [|[|{| "contextRangeIndex": 0 |}constructor|](s: string) {}|] ////} ////class B extends A { } -////export { [|{| "isWriteAccess": true, "isDefinition": true |}A|], [|{| "isWriteAccess": true, "isDefinition": true |}B|] }; +////[|export { [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 2 |}A|], [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 2 |}B|] };|] // @Filename: a.ts -////import { [|A|] as A1 } from "./f"; +////[|import { [|{| "contextRangeIndex": 5 |}A|] as A1 } from "./f";|] ////const a1 = new [|A1|]("a1"); ////export default class extends A1 { } -////export { [|B|] as [|{| "isWriteAccess": true, "isDefinition": true |}B1|] } from "./f"; +////[|export { [|{| "contextRangeIndex": 8 |}B|] as [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 8 |}B1|] } from "./f";|] // @Filename: b.ts -////import [|B|], { B1 } from "./a"; +////[|import [|{| "contextRangeIndex": 11 |}B|], { B1 } from "./a";|] ////const d = new [|B|]("b"); ////const d1 = new [|B1|]("b1"); verify.noErrors(); -const [aCtr, aExport, bExport, aImport, a1New, bReExport, b1Export, bDefault, bNew, b1New ] = test.ranges(); +const [aCtrDef, aCtr, exportDef, aExport, bExport, aImportDef, aImport, a1New, reExportDef, bReExport, b1Export, bDefaultDef, bDefault, bNew, b1New ] = test.ranges(); verify.referenceGroups(aCtr, [ { definition: "class A", ranges: [aCtr, aExport] }, { definition: "class B", ranges: [bExport]}, diff --git a/tests/cases/fourslash/findAllRefsOfConstructor_withModifier.ts b/tests/cases/fourslash/findAllRefsOfConstructor_withModifier.ts index c425029490fa9..f89bd730a772a 100644 --- a/tests/cases/fourslash/findAllRefsOfConstructor_withModifier.ts +++ b/tests/cases/fourslash/findAllRefsOfConstructor_withModifier.ts @@ -1,9 +1,9 @@ /// ////class X { -//// public [|constructor|]() {} +//// [|public [|{| "contextRangeIndex": 0 |}constructor|]() {}|] ////} ////var x = new [|X|](); -const ranges = test.ranges(); +const [rDef, ...ranges] = test.ranges(); verify.referenceGroups(ranges[0], [{ definition: "class X", ranges }]); diff --git a/tests/cases/fourslash/findAllRefsOnDecorators.ts b/tests/cases/fourslash/findAllRefsOnDecorators.ts index 95bf1072014d1..0c261c9dd5b67 100644 --- a/tests/cases/fourslash/findAllRefsOnDecorators.ts +++ b/tests/cases/fourslash/findAllRefsOnDecorators.ts @@ -1,9 +1,9 @@ /// // @Filename: a.ts -////function [|{| "isWriteAccess": true, "isDefinition": true |}decorator|](target) { +////[|function [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}decorator|](target) { //// return target; -////} +////}|] ////[|decorator|](); // @Filename: b.ts @@ -13,4 +13,4 @@ //// method() {} ////} -verify.singleReferenceGroup("function decorator(target: any): any"); +verify.singleReferenceGroup("function decorator(target: any): any", "decorator"); diff --git a/tests/cases/fourslash/findAllRefsOnDefinition.ts b/tests/cases/fourslash/findAllRefsOnDefinition.ts index 91582b928840f..f70d8a396c51c 100644 --- a/tests/cases/fourslash/findAllRefsOnDefinition.ts +++ b/tests/cases/fourslash/findAllRefsOnDefinition.ts @@ -7,9 +7,9 @@ //// //// } //// -//// public [|{| "isWriteAccess": true, "isDefinition": true |}start|](){ +//// [|public [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}start|](){ //// return this; -//// } +//// }|] //// //// public stop(){ //// return this; @@ -23,4 +23,4 @@ ////second.[|start|](); ////second.stop(); -verify.singleReferenceGroup("(method) Test.start(): this"); +verify.singleReferenceGroup("(method) Test.start(): this", "start"); diff --git a/tests/cases/fourslash/findAllRefsOnDefinition2.ts b/tests/cases/fourslash/findAllRefsOnDefinition2.ts index 9a0fd390c1e9f..7041dc22282b5 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 [|{| "isWriteAccess": true, "isDefinition": true |}start|] { } +//// [|export interface [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}start|] { }|] //// //// export interface stop { } ////} @@ -14,4 +14,4 @@ ////var start: Second.Test.[|start|]; ////var stop: Second.Test.stop; -verify.singleReferenceGroup("interface Test.start"); +verify.singleReferenceGroup("interface Test.start", "start"); diff --git a/tests/cases/fourslash/findAllRefsOnImportAliases.ts b/tests/cases/fourslash/findAllRefsOnImportAliases.ts index 17f947ffdc3b7..52d9bd9c518ec 100644 --- a/tests/cases/fourslash/findAllRefsOnImportAliases.ts +++ b/tests/cases/fourslash/findAllRefsOnImportAliases.ts @@ -1,19 +1,19 @@ /// //@Filename: a.ts -////export class [|{| "isWriteAccess": true, "isDefinition": true |}Class|] { -////} +////[|export class [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}Class|] { +////}|] //@Filename: b.ts -////import { [|{| "isWriteAccess": true, "isDefinition": true |}Class|] } from "./a"; +////[|import { [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 2 |}Class|] } from "./a";|] //// ////var c = new [|Class|](); //@Filename: c.ts -////export { [|{| "isWriteAccess": true, "isDefinition": true |}Class|] } from "./a"; +////[|export { [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 5 |}Class|] } from "./a";|] const ranges = test.ranges(); -const [r0, r1, r2, r3] = ranges; +const [r0Def, r0, r1Def, r1, r2, r3Def, r3] = ranges; const classes = { definition: "class Class", ranges: [r0] }; const imports = { definition: "(alias) class Class\nimport Class", ranges: [r1, r2] }; const reExports = { definition: "(alias) class Class\nexport Class", ranges: [r3] }; diff --git a/tests/cases/fourslash/findAllRefsOnImportAliases2.ts b/tests/cases/fourslash/findAllRefsOnImportAliases2.ts index 7be887c6af2e4..d29be30ee85b6 100644 --- a/tests/cases/fourslash/findAllRefsOnImportAliases2.ts +++ b/tests/cases/fourslash/findAllRefsOnImportAliases2.ts @@ -1,14 +1,14 @@ /// //@Filename: a.ts -////export class [|{| "isWriteAccess": true, "isDefinition": true |}Class|] {} +////[|export class [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}Class|] {}|] //@Filename: b.ts -////import { [|Class|] as [|{| "isWriteAccess": true, "isDefinition": true |}C2|] } from "./a"; +////[|import { [|{| "contextRangeIndex": 2 |}Class|] as [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 2 |}C2|] } from "./a";|] ////var c = new [|C2|](); //@Filename: c.ts -////export { [|Class|] as [|{| "isWriteAccess": true, "isDefinition": true |}C3|] } from "./a"; +////[|export { [|{| "contextRangeIndex": 6 |}Class|] as [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 6 |}C3|] } from "./a";|] const ranges = test.rangesByText(); const classRanges = ranges.get("Class"); @@ -26,4 +26,4 @@ verify.referenceGroups(c2Ranges, [c2s]) verify.referenceGroups(c3Ranges, [c3s]); -verify.rangesWithSameTextAreRenameLocations(); +verify.rangesWithSameTextAreRenameLocations("Class", "C2", "C3"); diff --git a/tests/cases/fourslash/findAllRefsOnPrivateParameterProperty1.ts b/tests/cases/fourslash/findAllRefsOnPrivateParameterProperty1.ts index df33f2888e6c1..e0a0169305914 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 [|{| "isWriteAccess": true, "isDefinition": true |}z|]: number) { +//// constructor(private x: number, public y: number, [|private [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}z|]: number|]) { //// } //// //// func() { @@ -9,4 +9,4 @@ //// } ////} -verify.singleReferenceGroup("(property) ABCD.z: number"); +verify.singleReferenceGroup("(property) ABCD.z: number", "z"); diff --git a/tests/cases/fourslash/findAllRefsParameterPropertyDeclaration1.ts b/tests/cases/fourslash/findAllRefsParameterPropertyDeclaration1.ts index 89bb40b6830ad..1abd696775ad2 100644 --- a/tests/cases/fourslash/findAllRefsParameterPropertyDeclaration1.ts +++ b/tests/cases/fourslash/findAllRefsParameterPropertyDeclaration1.ts @@ -1,13 +1,13 @@ /// //// class Foo { -//// constructor(private [|{| "isWriteAccess": true, "isDefinition": true |}privateParam|]: number) { +//// constructor([|private [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}privateParam|]: number|]) { //// let localPrivate = [|privateParam|]; //// this.[|{| "isWriteAccess": true |}privateParam|] += 10; //// } //// } -const ranges = test.ranges(); +const [rDef, ...ranges] = test.ranges(); const [r0, r1, r2] = ranges; verify.referenceGroups(ranges, [ { definition: "(property) Foo.privateParam: number", ranges: [r0, r2] }, diff --git a/tests/cases/fourslash/findAllRefsParameterPropertyDeclaration2.ts b/tests/cases/fourslash/findAllRefsParameterPropertyDeclaration2.ts index 519ca74c5c4a6..96070a24c40e7 100644 --- a/tests/cases/fourslash/findAllRefsParameterPropertyDeclaration2.ts +++ b/tests/cases/fourslash/findAllRefsParameterPropertyDeclaration2.ts @@ -1,13 +1,13 @@ /// //// class Foo { -//// constructor(public [|{| "isWriteAccess": true, "isDefinition": true |}publicParam|]: number) { +//// constructor([|public [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}publicParam|]: number|]) { //// let localPublic = [|publicParam|]; //// this.[|{| "isWriteAccess": true |}publicParam|] += 10; //// } //// } -const ranges = test.ranges(); +const [rDef, ...ranges] = test.ranges(); const [r0, r1, r2] = ranges; verify.referenceGroups(ranges, [ { definition: "(property) Foo.publicParam: number", ranges: [r0, r2] }, diff --git a/tests/cases/fourslash/findAllRefsParameterPropertyDeclaration3.ts b/tests/cases/fourslash/findAllRefsParameterPropertyDeclaration3.ts index 7addc2ba7a076..d261e995a2e97 100644 --- a/tests/cases/fourslash/findAllRefsParameterPropertyDeclaration3.ts +++ b/tests/cases/fourslash/findAllRefsParameterPropertyDeclaration3.ts @@ -1,13 +1,13 @@ /// //// class Foo { -//// constructor(protected [|{| "isWriteAccess": true, "isDefinition": true |}protectedParam|]: number) { +//// constructor([|protected [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}protectedParam|]: number|]) { //// let localProtected = [|protectedParam|]; //// this.[|{| "isWriteAccess": true |}protectedParam|] += 10; //// } //// } -const ranges = test.ranges(); +const [rDef, ...ranges] = test.ranges(); const [r0, r1, r2] = ranges; verify.referenceGroups(ranges, [ { definition: "(property) Foo.protectedParam: number", ranges: [r0, r2] }, diff --git a/tests/cases/fourslash/findAllRefsParameterPropertyDeclaration_inheritance.ts b/tests/cases/fourslash/findAllRefsParameterPropertyDeclaration_inheritance.ts index 9d7cfd51185b4..1741fdfbe4881 100644 --- a/tests/cases/fourslash/findAllRefsParameterPropertyDeclaration_inheritance.ts +++ b/tests/cases/fourslash/findAllRefsParameterPropertyDeclaration_inheritance.ts @@ -1,17 +1,17 @@ /// ////class C { -//// constructor(public [|{| "isWriteAccess": true, "isDefinition": true |}x|]: string) { +//// constructor([|public [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}x|]: string|]) { //// [|x|]; //// } ////} ////class D extends C { -//// constructor(public [|{| "isWriteAccess": true, "isDefinition": true |}x|]: string) { +//// constructor([|public [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 3 |}x|]: string|]) { //// super([|x|]); //// } ////} -const [r0, r1, r2, r3] = test.ranges(); +const [r0Def, r0, r1, r2Def, r2, r3] = test.ranges(); verify.referenceGroups(r0, [ { definition: "(property) C.x: string", ranges: [r0] }, { definition: "(parameter) x: string", ranges: [r1] }, diff --git a/tests/cases/fourslash/findAllRefsPrefixSuffixPreference.ts b/tests/cases/fourslash/findAllRefsPrefixSuffixPreference.ts index 3745eff4e5d84..3fe2a874760e8 100644 --- a/tests/cases/fourslash/findAllRefsPrefixSuffixPreference.ts +++ b/tests/cases/fourslash/findAllRefsPrefixSuffixPreference.ts @@ -2,22 +2,22 @@ // @Filename: /file1.ts ////declare function log(s: string | number): void; -////const [|{| "isWriteAccess": true, "isDefinition": true |}q|] = 1; -////export { [|{| "isWriteAccess": true, "isDefinition": true |}q|] }; +////[|const [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}q|] = 1;|] +////[|export { [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 2 |}q|] };|] ////const x = { -//// [|{| "isWriteAccess": true, "isDefinition": true |}z|]: 'value' +//// [|[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 4 |}z|]: 'value'|] ////} -////const { [|{| "isWriteAccess": true, "isDefinition": true |}z|] } = x; +////[|const { [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 6 |}z|] } = x;|] ////log([|z|]); // @Filename: /file2.ts ////declare function log(s: string | number): void; -////import { [|{| "isWriteAccess": true, "isDefinition": true |}q|] } from "./file1"; +////[|import { [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 9 |}q|] } from "./file1";|] ////log([|q|] + 1); verify.noErrors(); -const [q0, q1, z0, z1, z2, q2, q3] = test.ranges(); +const [q0Def, q0, q1Def, q1, z0Def, z0, z1Def, z1, z2, q2Def, q2, q3] = test.ranges(); const qFile1Ranges = [q0, q1]; const qFile2Ranges = [q2, q3]; const qFile1ReferenceGroup: FourSlashInterface.ReferenceGroup = { diff --git a/tests/cases/fourslash/findAllRefsPropertyContextuallyTypedByTypeParam01.ts b/tests/cases/fourslash/findAllRefsPropertyContextuallyTypedByTypeParam01.ts index d4aefb58ac394..22c69a1616f23 100644 --- a/tests/cases/fourslash/findAllRefsPropertyContextuallyTypedByTypeParam01.ts +++ b/tests/cases/fourslash/findAllRefsPropertyContextuallyTypedByTypeParam01.ts @@ -1,12 +1,12 @@ /// ////interface IFoo { -//// [|{| "isDefinition": true |}a|]: string; +//// [|[|{| "isDefinition": true, "contextRangeIndex": 0 |}a|]: string;|] ////} ////class C { //// method() { //// var x: T = { -//// [|{| "isWriteAccess": true, "isDefinition": true |}a|]: "" +//// [|[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 2 |}a|]: ""|] //// }; //// x.[|a|]; //// } @@ -14,7 +14,7 @@ //// //// ////var x: IFoo = { -//// [|{| "isWriteAccess": true, "isDefinition": true |}a|]: "ss" +//// [|[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 5 |}a|]: "ss"|] ////}; -verify.singleReferenceGroup("(property) IFoo.a: string"); +verify.singleReferenceGroup("(property) IFoo.a: string", "a"); diff --git a/tests/cases/fourslash/findAllRefsReExportLocal.ts b/tests/cases/fourslash/findAllRefsReExportLocal.ts index 502c7fdde464b..ddc236d3e60a2 100644 --- a/tests/cases/fourslash/findAllRefsReExportLocal.ts +++ b/tests/cases/fourslash/findAllRefsReExportLocal.ts @@ -3,17 +3,17 @@ // @noLib: true // @Filename: /a.ts -////var [|{| "isDefinition": true |}x|]; -////export { [|{| "isWriteAccess": true, "isDefinition": true |}x|] }; -////export { [|x|] as [|{| "isWriteAccess": true, "isDefinition": true |}y|] }; +////[|var [|{| "isDefinition": true, "contextRangeIndex": 0 |}x|];|] +////[|export { [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 2 |}x|] };|] +////[|export { [|{| "contextRangeIndex": 4 |}x|] as [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 4 |}y|] };|] // @Filename: /b.ts -////import { [|{| "isWriteAccess": true, "isDefinition": true |}x|], [|{| "isWriteAccess": true, "isDefinition": true |}y|] } from "./a"; +////[|import { [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 7 |}x|], [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 7 |}y|] } from "./a";|] ////[|x|]; [|y|]; verify.noErrors(); -const [ax0, ax1, ax2, ay, bx0, by0, bx1, by1] = test.ranges(); +const [ax0Def, ax0, ax1Def, ax1, ax2Def, ax2, ay, bx0Def, bx0, by0, bx1, by1] = test.ranges(); const axRanges = [ax0, ax1, ax2]; const bxRanges = [bx0, bx1]; const byRanges = [by0, by1]; diff --git a/tests/cases/fourslash/findAllRefsReExportRightNameWrongSymbol.ts b/tests/cases/fourslash/findAllRefsReExportRightNameWrongSymbol.ts index c44bdd2fffcbe..5d7bd485d051f 100644 --- a/tests/cases/fourslash/findAllRefsReExportRightNameWrongSymbol.ts +++ b/tests/cases/fourslash/findAllRefsReExportRightNameWrongSymbol.ts @@ -1,21 +1,21 @@ /// // @Filename: /a.ts -////export const [|{| "isWriteAccess": true, "isDefinition": true |}x|] = 0; +////[|export const [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}x|] = 0;|] // @Filename: /b.ts -////export const [|{| "isWriteAccess": true, "isDefinition": true |}x|] = 0; +////[|export const [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 2 |}x|] = 0;|] //@Filename: /c.ts -////export { [|{| "isWriteAccess": true, "isDefinition": true |}x|] } from "./b"; -////import { [|{| "isWriteAccess": true, "isDefinition": true |}x|] } from "./a"; +////[|export { [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 4 |}x|] } from "./b";|] +////[|import { [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 6 |}x|] } from "./a";|] ////[|x|]; // @Filename: /d.ts -////import { [|{| "isWriteAccess": true, "isDefinition": true |}x|] } from "./c"; +////[|import { [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 9 |}x|] } from "./c";|] verify.noErrors(); -const [a, b, cFromB, cFromA, cUse, d] = test.ranges(); +const [aDef, a, bDef, b, cFromBDef, cFromB, cFromADef, cFromA, cUse, dDef, d] = test.ranges(); const cFromARanges = [cFromA, cUse]; const aGroup = { definition: "const x: 0", ranges: [a] }; diff --git a/tests/cases/fourslash/findAllRefsReExportStar.ts b/tests/cases/fourslash/findAllRefsReExportStar.ts index a82f91cc5b0a3..f8103f70a9b43 100644 --- a/tests/cases/fourslash/findAllRefsReExportStar.ts +++ b/tests/cases/fourslash/findAllRefsReExportStar.ts @@ -1,17 +1,17 @@ /// // @Filename: /a.ts -////export function [|{| "isWriteAccess": true, "isDefinition": true |}foo|](): void {} +////[|export function [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}foo|](): void {}|] // @Filename: /b.ts ////export * from "./a"; // @Filename: /c.ts -////import { [|{| "isWriteAccess": true, "isDefinition": true |}foo|] } from "./b"; +////[|import { [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 2 |}foo|] } from "./b";|] verify.noErrors(); const ranges = test.ranges(); -const [r0, r1] = ranges; +const [r0Def, r0, r1Def, r1] = ranges; const a = { definition: "function foo(): void", ranges: [r0] }; const c = { definition: "(alias) function foo(): void\nimport foo", ranges: [r1] }; verify.referenceGroups(r0, [a, c]); diff --git a/tests/cases/fourslash/findAllRefsReExport_broken.ts b/tests/cases/fourslash/findAllRefsReExport_broken.ts index 92e4fcaa57c84..4e17e26224e3c 100644 --- a/tests/cases/fourslash/findAllRefsReExport_broken.ts +++ b/tests/cases/fourslash/findAllRefsReExport_broken.ts @@ -1,6 +1,6 @@ /// // @Filename: /a.ts -////export { [|{| "isWriteAccess": true, "isDefinition": true |}x|] }; +////[|export { [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}x|] };|] -verify.singleReferenceGroup("export x"); +verify.singleReferenceGroup("export x", "x"); diff --git a/tests/cases/fourslash/findAllRefsReExport_broken2.ts b/tests/cases/fourslash/findAllRefsReExport_broken2.ts index 1a6649465fbe9..a9d7373067993 100644 --- a/tests/cases/fourslash/findAllRefsReExport_broken2.ts +++ b/tests/cases/fourslash/findAllRefsReExport_broken2.ts @@ -1,6 +1,6 @@ /// // @Filename: /a.ts -////export { [|{| "isWriteAccess": true, "isDefinition": true |}x|] } from "nonsense"; +////[|export { [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}x|] } from "nonsense";|] -verify.singleReferenceGroup("export x"); +verify.singleReferenceGroup("export x", "x"); diff --git a/tests/cases/fourslash/findAllRefsReExports.ts b/tests/cases/fourslash/findAllRefsReExports.ts index 89e65d5bb373e..76af87ed12505 100644 --- a/tests/cases/fourslash/findAllRefsReExports.ts +++ b/tests/cases/fourslash/findAllRefsReExports.ts @@ -1,26 +1,36 @@ /// // @Filename: /a.ts -////export function [|{| "isWriteAccess": true, "isDefinition": true |}foo|](): void {} +////[|export function [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}foo|](): void {}|] // @Filename: /b.ts -////export { [|foo|] as [|{| "isWriteAccess": true, "isDefinition": true |}bar|] } from "./a"; +////[|export { [|{| "contextRangeIndex": 2 |}foo|] as [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 2 |}bar|] } from "./a";|] // @Filename: /c.ts -////export { [|foo|] as [|{| "isWriteAccess": true, "isDefinition": true |}default|] } from "./a"; +////[|export { [|{| "contextRangeIndex": 5 |}foo|] as [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 5 |}default|] } from "./a";|] // @Filename: /d.ts -////export { [|{| "isWriteAccess": true, "isDefinition": true |}default|] } from "./c"; +////[|export { [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 8 |}default|] } from "./c";|] // @Filename: /e.ts -////import { [|{| "isWriteAccess": true, "isDefinition": true |}bar|] } from "./b"; -////import [|{| "isWriteAccess": true, "isDefinition": true |}baz|] from "./c"; -////import { [|default|] as [|{| "isWriteAccess": true, "isDefinition": true |}bang|] } from "./c"; -////import [|{| "isWriteAccess": true, "isDefinition": true |}boom|] from "./d"; +////[|import { [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 10 |}bar|] } from "./b";|] +////[|import [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 12 |}baz|] from "./c";|] +////[|import { [|{| "contextRangeIndex": 14 |}default|] as [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 14 |}bang|] } from "./c";|] +////[|import [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 17 |}boom|] from "./d";|] ////[|bar|](); [|baz|](); [|bang|](); [|boom|](); verify.noErrors(); -const [foo0, foo1, bar0, foo2, defaultC, defaultD, bar1, baz0, defaultE, bang0, boom0, bar2, baz1, bang1, boom1] = test.ranges(); +const [ + foo0Def, foo0, + foo1Def, foo1, bar0, + foo2Def, foo2, defaultC, + defaultDDef, defaultD, + bar1Def, bar1, + baz0Def, baz0, + defaultEDef, defaultE, bang0, + boom0Def, boom0, + bar2, baz1, bang1, boom1 +] = test.ranges(); const a = { definition: "function foo(): void", ranges: [foo0, foo1, foo2] }; const b = { definition: "(alias) function bar(): void\nexport bar", ranges: [bar0] }; const c = { definition: "(alias) function foo(): void\nexport default", ranges: [defaultC, defaultE] }; @@ -43,6 +53,7 @@ verify.referenceGroups([bang0, bang1], [eBang]); verify.referenceGroups([boom0, boom1], [eBoom, d, a, b, eBar, c, eBaz, eBang]); test.rangesByText().forEach((ranges, text) => { + if (text.indexOf("export") === 0 || text.indexOf("import") === 0) return; switch (text) { case "default": for (const range of ranges) { diff --git a/tests/cases/fourslash/findAllRefsReExports2.ts b/tests/cases/fourslash/findAllRefsReExports2.ts index 31aa07fa29ef2..b3eee515639e1 100644 --- a/tests/cases/fourslash/findAllRefsReExports2.ts +++ b/tests/cases/fourslash/findAllRefsReExports2.ts @@ -1,13 +1,13 @@ /// // @Filename: /a.ts -////export function [|{| "isWriteAccess": true, "isDefinition": true |}foo|](): void {} +////[|export function [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}foo|](): void {}|] // @Filename: /b.ts -////import { [|foo|] as [|{| "isWriteAccess": true, "isDefinition": true |}oof|] } from "./a"; +////[|import { [|{| "contextRangeIndex": 2 |}foo|] as [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 2 |}oof|] } from "./a";|] verify.noErrors(); -const [r0, r1, r2] = test.ranges(); +const [r0Def, r0, r1Def, r1, r2] = test.ranges(); verify.referenceGroups(r0, [ { definition: "function foo(): void", ranges: [r0, r1] }, { definition: "(alias) function oof(): void\nimport oof", ranges: [r2] } diff --git a/tests/cases/fourslash/findAllRefsRedeclaredPropertyInDerivedInterface.ts b/tests/cases/fourslash/findAllRefsRedeclaredPropertyInDerivedInterface.ts index dff05b219be67..1886bd34d1033 100644 --- a/tests/cases/fourslash/findAllRefsRedeclaredPropertyInDerivedInterface.ts +++ b/tests/cases/fourslash/findAllRefsRedeclaredPropertyInDerivedInterface.ts @@ -3,17 +3,16 @@ // @noLib: true ////interface A { -//// readonly [|{| "isDefinition": true |}x|]: number | string; +//// [|readonly [|{| "isDefinition": true, "contextRangeIndex": 0 |}x|]: number | string;|] ////} ////interface B extends A { -//// readonly [|{| "isDefinition": true |}x|]: number; +//// [|readonly [|{| "isDefinition": true, "contextRangeIndex": 2 |}x|]: number;|] ////} -////const a: A = { [|{| "isWriteAccess": true, "isDefinition": true |}x|]: 0 }; -////const b: B = { [|{| "isWriteAccess": true, "isDefinition": true |}x|]: 0 }; +////const a: A = { [|[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 4 |}x|]: 0|] }; +////const b: B = { [|[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 6 |}x|]: 0|] }; -const ranges = test.ranges(); -const [r0, r1, r2, r3] = ranges; -verify.referenceGroups(ranges, [ +const [r0Def, r0, r1Def, r1, r2Def, r2, r3Def, r3] = test.ranges(); +verify.referenceGroups([r0, r1, r2, r3], [ { definition: "(property) A.x: string | number", ranges: [r0, r2] }, { definition: "(property) B.x: number", ranges: [r1, r3] }, ]); diff --git a/tests/cases/fourslash/findAllRefsRenameImportWithSameName.ts b/tests/cases/fourslash/findAllRefsRenameImportWithSameName.ts index 38c3aaf939831..6ccede2db1ee6 100644 --- a/tests/cases/fourslash/findAllRefsRenameImportWithSameName.ts +++ b/tests/cases/fourslash/findAllRefsRenameImportWithSameName.ts @@ -1,14 +1,14 @@ /// // @Filename: /a.ts -////export const [|{| "isWriteAccess": true, "isDefinition": true |}x|] = 0; +////[|export const [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}x|] = 0;|] //@Filename: /b.ts -////import { [|x|] as [|{| "isWriteAccess": true, "isDefinition": true |}x|] } from "./a"; +////[|import { [|{| "contextRangeIndex": 2 |}x|] as [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 2 |}x|] } from "./a";|] ////[|x|]; verify.noErrors(); -const [r0, r1, r2, r3] = test.ranges(); +const [r0Def, r0, r1Def, r1, r2, r3] = test.ranges(); const aRanges = [r0, r1]; const bRanges = [r2, r3]; const aGroup = { definition: "const x: 0", ranges: aRanges }; diff --git a/tests/cases/fourslash/findAllRefsRootSymbols.ts b/tests/cases/fourslash/findAllRefsRootSymbols.ts index 18fbb8e212c76..0928c53fdcb55 100644 --- a/tests/cases/fourslash/findAllRefsRootSymbols.ts +++ b/tests/cases/fourslash/findAllRefsRootSymbols.ts @@ -1,11 +1,11 @@ /// -////interface I { [|{| "isDefinition": true |}x|]: {}; } -////interface J { [|{| "isDefinition": true |}x|]: {}; } -////declare const o: (I | J) & { [|{| "isWriteAccess": true, "isDefinition": true |}x|]: string }; +////interface I { [|[|{| "isDefinition": true, "contextRangeIndex": 0 |}x|]: {};|] } +////interface J { [|[|{| "isDefinition": true, "contextRangeIndex": 2 |}x|]: {};|] } +////declare const o: (I | J) & { [|[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 4 |}x|]: string|] }; ////o.[|x|]; -const [r0, r1, r2, r3] = test.ranges(); +const [r0Def, r0, r1Def, r1, r2Def, r2, r3] = test.ranges(); const i = { definition: "(property) I.x: {}", ranges: [r0] }; const j = { definition: "(property) J.x: {}", ranges: [r1] }; const anon = { definition: "(property) x: string", ranges: [r2] }; diff --git a/tests/cases/fourslash/findAllRefsThisKeyword.ts b/tests/cases/fourslash/findAllRefsThisKeyword.ts index b0045e91bc195..9779169bdd0d2 100644 --- a/tests/cases/fourslash/findAllRefsThisKeyword.ts +++ b/tests/cases/fourslash/findAllRefsThisKeyword.ts @@ -21,10 +21,10 @@ //// } ////} ////// These are *not* real uses of the 'this' keyword, they are identifiers. -////const x = { [|{| "isWriteAccess": true, "isDefinition": true |}this|]: 0 } +////const x = { [|[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 9 |}this|]: 0|] } ////x.[|this|]; -const [glob, f0, f1, g0, g1, x, y, constructor, method, propDef, propUse] = test.ranges(); +const [glob, f0, f1, g0, g1, x, y, constructor, method, propDefDef, propDef, propUse] = test.ranges(); verify.singleReferenceGroup("this: typeof globalThis", [glob]); verify.singleReferenceGroup("(parameter) this: any", [f0, f1]); verify.singleReferenceGroup("(parameter) this: any", [g0, g1]); diff --git a/tests/cases/fourslash/findAllRefsTypedef.ts b/tests/cases/fourslash/findAllRefsTypedef.ts index 2e7d8601656e8..c17f568946db3 100644 --- a/tests/cases/fourslash/findAllRefsTypedef.ts +++ b/tests/cases/fourslash/findAllRefsTypedef.ts @@ -5,11 +5,11 @@ // @Filename: /a.js /////** //// * @typedef I {Object} -//// * @prop [|{| "isDefinition": true |}p|] {number} -//// */ +//// * [|@prop [|{| "isDefinition": true, "contextRangeIndex": 0 |}p|] {number} +//// |]*/ //// /////** @type {I} */ ////let x; ////x.[|p|]; -verify.singleReferenceGroup("(property) p: number"); +verify.singleReferenceGroup("(property) p: number", "p"); diff --git a/tests/cases/fourslash/findAllRefsTypedef_importType.ts b/tests/cases/fourslash/findAllRefsTypedef_importType.ts index ddd0cb7c966d4..4816406d518f3 100644 --- a/tests/cases/fourslash/findAllRefsTypedef_importType.ts +++ b/tests/cases/fourslash/findAllRefsTypedef_importType.ts @@ -4,11 +4,11 @@ // @Filename: /a.js ////module.exports = 0; -/////** @typedef {number} [|{| "isWriteAccess": true, "isDefinition": true |}Foo|] */ +/////** [|@typedef {number} [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}Foo|]|] */ ////const dummy = 0; // @Filename: /b.js /////** @type {import('./a').[|Foo|]} */ ////const x = 0; -verify.singleReferenceGroup("type Foo = number"); +verify.singleReferenceGroup("type Foo = number", "Foo"); diff --git a/tests/cases/fourslash/findAllRefsTypeofImport.ts b/tests/cases/fourslash/findAllRefsTypeofImport.ts index 77bd2d51a8c13..c89c0037b59ac 100644 --- a/tests/cases/fourslash/findAllRefsTypeofImport.ts +++ b/tests/cases/fourslash/findAllRefsTypeofImport.ts @@ -1,8 +1,8 @@ /// // @Filename: /a.ts -////export const [|{| "isWriteAccess": true, "isDefinition": true |}x|] = 0; +////[|export const [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}x|] = 0;|] ////declare const a: typeof import("./a"); ////a.[|x|]; -verify.singleReferenceGroup("const x: 0"); +verify.singleReferenceGroup("const x: 0", "x"); diff --git a/tests/cases/fourslash/findAllRefsUnionProperty.ts b/tests/cases/fourslash/findAllRefsUnionProperty.ts index 3b7813f638bc5..cb83398c19184 100644 --- a/tests/cases/fourslash/findAllRefsUnionProperty.ts +++ b/tests/cases/fourslash/findAllRefsUnionProperty.ts @@ -1,11 +1,11 @@ /// ////type T = -//// | { [|{| "isDefinition": true |}type|]: "a", [|{| "isDefinition": true |}prop|]: number } -//// | { [|{| "isDefinition": true |}type|]: "b", [|{| "isDefinition": true |}prop|]: string }; +//// | { [|[|{| "isDefinition": true, "contextRangeIndex": 0 |}type|]: "a",|] [|[|{| "isDefinition": true, "contextRangeIndex": 2 |}prop|]: number|] } +//// | { [|[|{| "isDefinition": true, "contextRangeIndex": 4 |}type|]: "b",|] [|[|{| "isDefinition": true, "contextRangeIndex": 6 |}prop|]: string|] }; ////const tt: T = { -//// [|{| "isWriteAccess": true, "isDefinition": true |}type|]: "a", -//// [|{| "isWriteAccess": true, "isDefinition": true |}prop|]: 0, +//// [|[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 8 |}type|]: "a"|], +//// [|[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 10 |}prop|]: 0|], ////}; ////declare const t: T; ////if (t.[|type|] === "a") { @@ -14,7 +14,7 @@ //// t.[|type|]; ////} -const [t0, p0, t1, p1, t2, p2, t3, t4, t5] = test.ranges(); +const [t0Def, t0, p0Def, p0, t1Def, t1, p1Def, p1, t2Def, t2, p2Def, p2, t3, t4, t5] = test.ranges(); const a = { definition: { text: '(property) type: "a"', range: t0 }, ranges: [t0, t2, t4] }; const b = { definition: { text: '(property) type: "b"', range: t1 }, ranges: [t1, t5] }; diff --git a/tests/cases/fourslash/findAllRefsWithLeadingUnderscoreNames1.ts b/tests/cases/fourslash/findAllRefsWithLeadingUnderscoreNames1.ts index 4a1bf374c0585..a63d511ef09bc 100644 --- a/tests/cases/fourslash/findAllRefsWithLeadingUnderscoreNames1.ts +++ b/tests/cases/fourslash/findAllRefsWithLeadingUnderscoreNames1.ts @@ -1,10 +1,10 @@ /// ////class Foo { -//// public [|{| "isWriteAccess": true, "isDefinition": true |}_bar|]() { return 0; } +//// [|public [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}_bar|]() { return 0; }|] ////} //// ////var x: Foo; ////x.[|_bar|]; -verify.singleReferenceGroup("(method) Foo._bar(): number"); +verify.singleReferenceGroup("(method) Foo._bar(): number", "_bar"); diff --git a/tests/cases/fourslash/findAllRefsWithLeadingUnderscoreNames2.ts b/tests/cases/fourslash/findAllRefsWithLeadingUnderscoreNames2.ts index ec120254fde36..bc449992fc0f7 100644 --- a/tests/cases/fourslash/findAllRefsWithLeadingUnderscoreNames2.ts +++ b/tests/cases/fourslash/findAllRefsWithLeadingUnderscoreNames2.ts @@ -1,10 +1,10 @@ /// ////class Foo { -//// public [|{| "isWriteAccess": true, "isDefinition": true |}__bar|]() { return 0; } +//// [|public [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}__bar|]() { return 0; }|] ////} //// ////var x: Foo; ////x.[|__bar|]; -verify.singleReferenceGroup("(method) Foo.__bar(): number"); +verify.singleReferenceGroup("(method) Foo.__bar(): number", "__bar"); diff --git a/tests/cases/fourslash/findAllRefsWithLeadingUnderscoreNames3.ts b/tests/cases/fourslash/findAllRefsWithLeadingUnderscoreNames3.ts index e6f46b128e7b9..8af1468e8b8ba 100644 --- a/tests/cases/fourslash/findAllRefsWithLeadingUnderscoreNames3.ts +++ b/tests/cases/fourslash/findAllRefsWithLeadingUnderscoreNames3.ts @@ -1,10 +1,10 @@ /// ////class Foo { -//// public [|{| "isWriteAccess": true, "isDefinition": true |}___bar|]() { return 0; } +//// [|public [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}___bar|]() { return 0; }|] ////} //// ////var x: Foo; ////x.[|___bar|]; -verify.singleReferenceGroup("(method) Foo.___bar(): number"); +verify.singleReferenceGroup("(method) Foo.___bar(): number", "___bar"); diff --git a/tests/cases/fourslash/findAllRefsWithLeadingUnderscoreNames4.ts b/tests/cases/fourslash/findAllRefsWithLeadingUnderscoreNames4.ts index 593d61f3fbe80..dcc15f35382b4 100644 --- a/tests/cases/fourslash/findAllRefsWithLeadingUnderscoreNames4.ts +++ b/tests/cases/fourslash/findAllRefsWithLeadingUnderscoreNames4.ts @@ -1,10 +1,10 @@ /// ////class Foo { -//// public [|{| "isWriteAccess": true, "isDefinition": true |}____bar|]() { return 0; } +//// [|public [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}____bar|]() { return 0; }|] ////} //// ////var x: Foo; ////x.[|____bar|]; -verify.singleReferenceGroup("(method) Foo.____bar(): number"); +verify.singleReferenceGroup("(method) Foo.____bar(): number", "____bar"); diff --git a/tests/cases/fourslash/findAllRefsWithLeadingUnderscoreNames5.ts b/tests/cases/fourslash/findAllRefsWithLeadingUnderscoreNames5.ts index cf1716625965e..26e7ed094ff7f 100644 --- a/tests/cases/fourslash/findAllRefsWithLeadingUnderscoreNames5.ts +++ b/tests/cases/fourslash/findAllRefsWithLeadingUnderscoreNames5.ts @@ -3,7 +3,7 @@ ////class Foo { //// public _bar; //// public __bar; -//// public [|{| "isDefinition": true |}___bar|]; +//// [|public [|{| "isDefinition": true, "contextRangeIndex": 0 |}___bar|];|] //// public ____bar; ////} //// @@ -13,4 +13,4 @@ ////x.[|___bar|]; ////x.____bar; -verify.singleReferenceGroup("(property) Foo.___bar: any"); +verify.singleReferenceGroup("(property) Foo.___bar: any", "___bar"); diff --git a/tests/cases/fourslash/findAllRefsWithLeadingUnderscoreNames6.ts b/tests/cases/fourslash/findAllRefsWithLeadingUnderscoreNames6.ts index 77197480eb1c0..7b1a4066adf4c 100644 --- a/tests/cases/fourslash/findAllRefsWithLeadingUnderscoreNames6.ts +++ b/tests/cases/fourslash/findAllRefsWithLeadingUnderscoreNames6.ts @@ -2,7 +2,7 @@ ////class Foo { //// public _bar; -//// public [|{| "isDefinition": true |}__bar|]; +//// [|public [|{| "isDefinition": true, "contextRangeIndex": 0 |}__bar|];|] //// public ___bar; //// public ____bar; ////} @@ -13,4 +13,4 @@ ////x.___bar; ////x.____bar; -verify.singleReferenceGroup("(property) Foo.__bar: any"); +verify.singleReferenceGroup("(property) Foo.__bar: any", "__bar"); diff --git a/tests/cases/fourslash/findAllRefsWithLeadingUnderscoreNames7.ts b/tests/cases/fourslash/findAllRefsWithLeadingUnderscoreNames7.ts index dac42f4fc7c1a..1876e71d3aeb0 100644 --- a/tests/cases/fourslash/findAllRefsWithLeadingUnderscoreNames7.ts +++ b/tests/cases/fourslash/findAllRefsWithLeadingUnderscoreNames7.ts @@ -1,7 +1,7 @@ /// -////function [|{| "isWriteAccess": true, "isDefinition": true |}__foo|]() { +////[|function [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}__foo|]() { //// [|__foo|](); -////} +////}|] -verify.singleReferenceGroup("function __foo(): void"); +verify.singleReferenceGroup("function __foo(): void", "__foo"); diff --git a/tests/cases/fourslash/findAllRefsWithLeadingUnderscoreNames8.ts b/tests/cases/fourslash/findAllRefsWithLeadingUnderscoreNames8.ts index 8c92275e27fc7..1c8b80dde95d7 100644 --- a/tests/cases/fourslash/findAllRefsWithLeadingUnderscoreNames8.ts +++ b/tests/cases/fourslash/findAllRefsWithLeadingUnderscoreNames8.ts @@ -1,7 +1,7 @@ /// -////(function [|{| "isWriteAccess": true, "isDefinition": true |}__foo|]() { +////([|function [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}__foo|]() { //// [|__foo|](); -////}) +////}|]) -verify.singleReferenceGroup("(local function) __foo(): void"); +verify.singleReferenceGroup("(local function) __foo(): void", "__foo"); diff --git a/tests/cases/fourslash/findAllRefsWithLeadingUnderscoreNames9.ts b/tests/cases/fourslash/findAllRefsWithLeadingUnderscoreNames9.ts index bc5799e61cff0..5fd2097788ef0 100644 --- a/tests/cases/fourslash/findAllRefsWithLeadingUnderscoreNames9.ts +++ b/tests/cases/fourslash/findAllRefsWithLeadingUnderscoreNames9.ts @@ -1,7 +1,7 @@ /// -////(function [|{| "isWriteAccess": true, "isDefinition": true |}___foo|]() { +////([|function [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}___foo|]() { //// [|___foo|](); -////}) +////}|]) -verify.singleReferenceGroup("(local function) ___foo(): void"); +verify.singleReferenceGroup("(local function) ___foo(): void", "___foo"); diff --git a/tests/cases/fourslash/findAllRefsWithShorthandPropertyAssignment.ts b/tests/cases/fourslash/findAllRefsWithShorthandPropertyAssignment.ts index b25c08cd6927a..3dc322c842c3e 100644 --- a/tests/cases/fourslash/findAllRefsWithShorthandPropertyAssignment.ts +++ b/tests/cases/fourslash/findAllRefsWithShorthandPropertyAssignment.ts @@ -1,12 +1,12 @@ /// -//// var [|{| "isWriteAccess": true, "isDefinition": true |}name|] = "Foo"; +//// [|var [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}name|] = "Foo";|] //// //// var obj = { [|{| "isWriteAccess": true, "isDefinition": true |}name|] }; -//// var obj1 = { [|{| "isWriteAccess": true, "isDefinition": true |}name|]:[|name|] }; +//// var obj1 = { [|[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 3 |}name|]:[|name|]|] }; //// obj.[|name|]; -const [r0, r1, r2, r3, r4] = test.ranges(); +const [r0Def, r0, r1, r2Def, r2, r3, r4] = test.ranges(); verify.referenceGroups([r0, r3], [{ definition: "var name: string", ranges: [r0, r1, r3] }]); verify.referenceGroups(r1, [ { definition: "var name: string", ranges: [r0, r1, r3] }, diff --git a/tests/cases/fourslash/findAllRefsWithShorthandPropertyAssignment2.ts b/tests/cases/fourslash/findAllRefsWithShorthandPropertyAssignment2.ts index f19640698cdf7..52aaf8d2f1fa8 100644 --- a/tests/cases/fourslash/findAllRefsWithShorthandPropertyAssignment2.ts +++ b/tests/cases/fourslash/findAllRefsWithShorthandPropertyAssignment2.ts @@ -1,15 +1,15 @@ /// -//// var [|{| "isWriteAccess": true, "isDefinition": true |}dx|] = "Foo"; +//// [|var [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}dx|] = "Foo";|] //// -//// module M { export var [|{| "isDefinition": true |}dx|]; } +//// module M { [|export var [|{| "isDefinition": true, "contextRangeIndex": 2 |}dx|];|] } //// module M { //// var z = 100; //// export var y = { [|{| "isWriteAccess": true, "isDefinition": true |}dx|], z }; //// } //// M.y.[|dx|]; -const [r0, r1, r2, r3] = test.ranges(); +const [r0Def, r0, r1Def, r1, r2, r3] = test.ranges(); verify.singleReferenceGroup("var dx: string", [r0]); verify.referenceGroups(r1, [{ definition: "var M.dx: any", ranges: [r1, r2] }]); verify.referenceGroups(r2, [ diff --git a/tests/cases/fourslash/findAllRefs_importType_exportEquals.ts b/tests/cases/fourslash/findAllRefs_importType_exportEquals.ts index 3734b7a2e880f..61e66de94cac5 100644 --- a/tests/cases/fourslash/findAllRefs_importType_exportEquals.ts +++ b/tests/cases/fourslash/findAllRefs_importType_exportEquals.ts @@ -1,19 +1,19 @@ /// // @Filename: /a.ts -////type [|{| "isWriteAccess": true, "isDefinition": true |}T|] = number; -////namespace [|{| "isWriteAccess": true, "isDefinition": true |}T|] { +////[|type [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}T|] = number;|] +////[|namespace [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 2 |}T|] { //// export type U = string; -////} -////[|export|] = [|T|]; +////}|] +////[|[|{| "contextRangeIndex": 4 |}export|] = [|{| "contextRangeIndex": 4 |}T|];|] // @Filename: /b.ts -////const x: import("[|./[|a|]|]") = 0; -////const y: import("[|./[|a|]|]").U = ""; +////[|const x: import("[|{| "contextRangeIndex": 7 |}./[|a|]|]") = 0;|] +////[|const y: import("[|{| "contextRangeIndex": 10 |}./[|a|]|]").U = "";|] verify.noErrors(); -const [r0, r1, rExport, r2, r3, r3b, r4, r4b] = test.ranges(); +const [r0Def, r0, r1Def, r1, r2Def, rExport, r2, r3Def, r3, r3b, r4Def, r4, r4b] = test.ranges(); verify.referenceGroups(r0, [{ definition: "type T = number\nnamespace T", ranges: [r0, r2, r3] }]); verify.referenceGroups(r1, [{ definition: "namespace T", ranges: [r1, r2] }]); const t: FourSlashInterface.ReferenceGroup = { definition: "type T = number\nnamespace T", ranges: [r0, r1, r2, r3] }; diff --git a/tests/cases/fourslash/findAllRefs_importType_js.ts b/tests/cases/fourslash/findAllRefs_importType_js.ts index b1f612c8e4571..0f952ae28e3ca 100644 --- a/tests/cases/fourslash/findAllRefs_importType_js.ts +++ b/tests/cases/fourslash/findAllRefs_importType_js.ts @@ -4,20 +4,20 @@ // @checkJs: true // @Filename: /a.js -////[|module|].exports = class [|{| "isWriteAccess": true, "isDefinition": true |}C|] {}; -////module.exports.[|{| "isWriteAccess": true, "isDefinition": true |}D|] = class [|{| "isWriteAccess": true, "isDefinition": true |}D|] {}; +////[|[|{| "contextRangeIndex": 0 |}module|].exports = [|class [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 2 |}C|] {}|];|] +////[|module.exports.[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 4 |}D|] = [|class [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 6 |}D|] {}|];|] // @Filename: /b.js -/////** @type {import("[|./a|]")} */ +/////** [|@type {import("[|{| "contextRangeIndex": 8 |}./a|]")}|] */ ////const x = 0; -/////** @type {import("[|./a|]").[|D|]} */ +/////** [|@type {import("[|{| "contextRangeIndex": 10 |}./a|]").[|D|]}|] */ ////const y = 0; verify.noErrors(); // TODO: GH#24025 -const [rModule, r0, r1, r2, r3, r4, r5] = test.ranges(); +const [rModuleDef, rModule, r0Def, r0, r1Def, r1, r2Def, r2, r3Def, r3, r4Def, r4, r5] = test.ranges(); verify.referenceGroups(rModule, [{ definition: 'module "/a"', ranges: [r3, r4, rModule] }]); verify.referenceGroups(r0, [ { definition: "(local class) C", ranges: [r0] }, diff --git a/tests/cases/fourslash/findAllRefs_importType_meaningAtLocation.ts b/tests/cases/fourslash/findAllRefs_importType_meaningAtLocation.ts index 4c79999a86681..2671cd0c00a53 100644 --- a/tests/cases/fourslash/findAllRefs_importType_meaningAtLocation.ts +++ b/tests/cases/fourslash/findAllRefs_importType_meaningAtLocation.ts @@ -1,13 +1,13 @@ /// // @Filename: /a.ts -////export type [|{| "isWriteAccess": true, "isDefinition": true |}T|] = 0; -////export const [|{| "isWriteAccess": true, "isDefinition": true |}T|] = 0; +////[|export type [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}T|] = 0;|] +////[|export const [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 2 |}T|] = 0;|] // @Filename: /b.ts ////const x: import("./a").[|T|] = 0; ////const x: typeof import("./a").[|T|] = 0; -const [r0, r1, r2, r3] = test.ranges(); +const [r0Def, r0, r1Def, r1, r2, r3] = test.ranges(); verify.singleReferenceGroup("type T = 0", [r0, r2]); verify.singleReferenceGroup("const T: 0", [r1, r3]); diff --git a/tests/cases/fourslash/findAllRefs_importType_named.ts b/tests/cases/fourslash/findAllRefs_importType_named.ts index ed4d4a1427bb4..921464e9b83b5 100644 --- a/tests/cases/fourslash/findAllRefs_importType_named.ts +++ b/tests/cases/fourslash/findAllRefs_importType_named.ts @@ -1,13 +1,13 @@ /// // @Filename: /a.ts -////export type [|{| "isWriteAccess": true, "isDefinition": true |}T|] = number; -////export type [|{| "isWriteAccess": true, "isDefinition": true |}U|] = string; +////[|export type [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}T|] = number;|] +////[|export type [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 2 |}U|] = string;|] // @Filename: /b.ts ////const x: import("./a").[|T|] = 0; ////const x: import("./a").[|U|] = 0; -const [r0, r1, r2, r3] = test.ranges(); +const [r0Def, r0, r1Def, r1, r2, r3] = test.ranges(); verify.singleReferenceGroup("type T = number", [r0, r2]); verify.singleReferenceGroup("type U = string", [r1, r3]); diff --git a/tests/cases/fourslash/findAllRefs_importType_typeofImport.ts b/tests/cases/fourslash/findAllRefs_importType_typeofImport.ts index beab9c7cfc41f..89741206c7491 100644 --- a/tests/cases/fourslash/findAllRefs_importType_typeofImport.ts +++ b/tests/cases/fourslash/findAllRefs_importType_typeofImport.ts @@ -4,7 +4,7 @@ ////export const x = 0; // @Filename: /b.ts -////const x: typeof import("[|./a|]") = { x: 0 }; -////const y: typeof import("[|./a|]") = { x: 0 }; +////[|const x: typeof import("[|{| "contextRangeIndex": 0 |}./a|]") = { x: 0 };|] +////[|const y: typeof import("[|{| "contextRangeIndex": 2 |}./a|]") = { x: 0 };|] -verify.singleReferenceGroup('module "/a"'); +verify.singleReferenceGroup('module "/a"', "./a"); diff --git a/tests/cases/fourslash/findAllRefs_jsEnum.ts b/tests/cases/fourslash/findAllRefs_jsEnum.ts index c77b24256bfea..f9033d6c588b9 100644 --- a/tests/cases/fourslash/findAllRefs_jsEnum.ts +++ b/tests/cases/fourslash/findAllRefs_jsEnum.ts @@ -4,7 +4,7 @@ // @Filename: /a.js /////** @enum {string} */ -////const [|{| "isWriteAccess": true, "isDefinition": true |}E|] = { A: "" }; +////[|const [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}E|] = { A: "" };|] ////[|E|]["A"]; /////** @type {[|E|]} */ ////const e = [|E|].A; @@ -13,4 +13,4 @@ verify.singleReferenceGroup( `enum E const E: { A: string; -}`); +}`, "E"); diff --git a/tests/cases/fourslash/findReferencesAcrossMultipleProjects.ts b/tests/cases/fourslash/findReferencesAcrossMultipleProjects.ts index 2141399705fd8..bfa20f5195986 100644 --- a/tests/cases/fourslash/findReferencesAcrossMultipleProjects.ts +++ b/tests/cases/fourslash/findReferencesAcrossMultipleProjects.ts @@ -1,7 +1,7 @@ /// //@Filename: a.ts -////var [|{| "isDefinition": true |}x|]: number; +////[|var [|{| "isDefinition": true, "contextRangeIndex": 0 |}x|]: number;|] //@Filename: b.ts /////// @@ -11,4 +11,4 @@ /////// ////[|{| "isWriteAccess": true |}x|]++; -verify.singleReferenceGroup("var x: number"); +verify.singleReferenceGroup("var x: number", "x"); diff --git a/tests/cases/fourslash/findReferencesAfterEdit.ts b/tests/cases/fourslash/findReferencesAfterEdit.ts index 3787617692ac5..4974132dd12e2 100644 --- a/tests/cases/fourslash/findReferencesAfterEdit.ts +++ b/tests/cases/fourslash/findReferencesAfterEdit.ts @@ -2,7 +2,7 @@ // @Filename: a.ts ////interface A { -//// [|{| "isDefinition": true |}foo|]: string; +//// [|[|{| "isDefinition": true, "contextRangeIndex": 0 |}foo|]: string;|] ////} // @Filename: b.ts @@ -12,9 +12,9 @@ //// x.[|foo|] ////} -verify.singleReferenceGroup("(property) A.foo: string"); +verify.singleReferenceGroup("(property) A.foo: string", "foo"); goTo.marker(""); edit.insert("\n"); -verify.singleReferenceGroup("(property) A.foo: string"); +verify.singleReferenceGroup("(property) A.foo: string", "foo"); diff --git a/tests/cases/fourslash/findReferencesJSXTagName.ts b/tests/cases/fourslash/findReferencesJSXTagName.ts index 8547ad8b3309a..3fb221822b3b2 100644 --- a/tests/cases/fourslash/findReferencesJSXTagName.ts +++ b/tests/cases/fourslash/findReferencesJSXTagName.ts @@ -1,17 +1,17 @@ /// // @Filename: index.tsx -////import { [|{| "isWriteAccess": true, "isDefinition": true |}SubmissionComp|] } from "./RedditSubmission" +////[|import { [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}SubmissionComp|] } from "./RedditSubmission"|] ////function displaySubreddit(subreddit: string) { //// let components = submissions -//// .map((value, index) => <[|SubmissionComp|] key={ index } elementPosition= { index } {...value.data} />); +//// .map((value, index) => [|<[|{| "contextRangeIndex": 2 |}SubmissionComp|] key={ index } elementPosition= { index } {...value.data} />|]); ////} // @Filename: RedditSubmission.ts -////export const [|{| "isWriteAccess": true, "isDefinition": true |}SubmissionComp|] = (submission: SubmissionProps) => -////
; +////export const [|[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 4 |}SubmissionComp|] = (submission: SubmissionProps) => +////
; -const [r0, r1, r2] = test.ranges(); +const [r0Def, r0, r1Def, r1, r2Def, r2] = test.ranges(); const imports = { definition: "(alias) const SubmissionComp: (submission: any) => any\nimport SubmissionComp", ranges: [r0, r1] }; const def = { definition: "const SubmissionComp: (submission: any) => any", ranges: [r2] }; verify.referenceGroups([r0, r1], [imports, def]); diff --git a/tests/cases/fourslash/findReferencesJSXTagName2.ts b/tests/cases/fourslash/findReferencesJSXTagName2.ts index a8882b600886a..dc942720a0e97 100644 --- a/tests/cases/fourslash/findReferencesJSXTagName2.ts +++ b/tests/cases/fourslash/findReferencesJSXTagName2.ts @@ -1,9 +1,9 @@ /// // @Filename: index.tsx -////const [|{| "isWriteAccess": true, "isDefinition": true |}obj|] = {Component: () =>
}; +////[|const [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}obj|] = {Component: () =>
};|] ////const element = <[|obj|].Component/>; verify.singleReferenceGroup(`const obj: { Component: () => any; -}`); +}`, "obj"); diff --git a/tests/cases/fourslash/findReferencesJSXTagName3.ts b/tests/cases/fourslash/findReferencesJSXTagName3.ts index 58715ade2fa1c..2613f86473044 100644 --- a/tests/cases/fourslash/findReferencesJSXTagName3.ts +++ b/tests/cases/fourslash/findReferencesJSXTagName3.ts @@ -6,22 +6,21 @@ ////namespace JSX { //// export interface Element { } //// export interface IntrinsicElements { -//// [|{| "isDefinition": true |}div|]: any; +//// [|[|{| "isDefinition": true, "contextRangeIndex": 0 |}div|]: any;|] //// } ////} //// -////const [|{| "isWriteAccess": true, "isDefinition": true |}Comp|] = () => -//// <[|div|]> +////[|const [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 2 |}Comp|] = () => +//// [|<[|{| "contextRangeIndex": 4 |}div|]> //// Some content -//// <[|div|]>More content -//// ; +//// [|<[|{| "contextRangeIndex": 6 |}div|]>More content|] +//// |];|] //// -////const x = <[|Comp|]> +////const x = [|<[|{| "contextRangeIndex": 10 |}Comp|]> //// Content -////; +////|]; -const ranges = test.ranges(); -const [d0, c0, d1, d2, d3, d4, c1, c2] = test.ranges(); +const [d0Def, d0, c0Def, c0, d1Def, d1, d2Def, d2, d3, d4, c1Def, c1, c2] = test.ranges(); const allD = [d0, d1, d2, d3, d4]; const allC = [c0, c1, c2]; diff --git a/tests/cases/fourslash/fourslash.ts b/tests/cases/fourslash/fourslash.ts index b471817b4044f..07a07995bd8e4 100644 --- a/tests/cases/fourslash/fourslash.ts +++ b/tests/cases/fourslash/fourslash.ts @@ -227,9 +227,9 @@ declare namespace FourSlashInterface { * This uses the 'findReferences' command instead of 'getReferencesAtPosition', so references are grouped by their definition. */ referenceGroups(starts: ArrayOrSingle | ArrayOrSingle, parts: ReadonlyArray): void; - singleReferenceGroup(definition: ReferencesDefinition, ranges?: Range[]): void; - rangesAreOccurrences(isWriteAccess?: boolean): void; - rangesWithSameTextAreRenameLocations(): void; + singleReferenceGroup(definition: ReferencesDefinition, ranges?: Range[] | string): void; + rangesAreOccurrences(isWriteAccess?: boolean, ranges?: Range[]): void; + rangesWithSameTextAreRenameLocations(...texts: string[]): void; rangesAreRenameLocations(options?: Range[] | { findInStrings?: boolean, findInComments?: boolean, ranges?: Range[] }); findReferencesDefinitionDisplayPartsAtCaretAre(expected: ts.SymbolDisplayPart[]): void; noSignatureHelp(...markers: (string | Marker)[]): void; diff --git a/tests/cases/fourslash/getOccurrencesIsDefinitionOfArrowFunction.ts b/tests/cases/fourslash/getOccurrencesIsDefinitionOfArrowFunction.ts index b1acb76ad2c80..839a270e611ff 100644 --- a/tests/cases/fourslash/getOccurrencesIsDefinitionOfArrowFunction.ts +++ b/tests/cases/fourslash/getOccurrencesIsDefinitionOfArrowFunction.ts @@ -1,5 +1,5 @@ /// -////var [|{| "isWriteAccess": true, "isDefinition": true |}f|] = x => x + 1; +////[|var [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}f|] = x => x + 1;|] ////[|f|](12); -verify.singleReferenceGroup("var f: (x: any) => any"); +verify.singleReferenceGroup("var f: (x: any) => any", "f"); diff --git a/tests/cases/fourslash/getOccurrencesIsDefinitionOfBindingPattern.ts b/tests/cases/fourslash/getOccurrencesIsDefinitionOfBindingPattern.ts index 32fec74d162b1..e5df8984ad3fe 100644 --- a/tests/cases/fourslash/getOccurrencesIsDefinitionOfBindingPattern.ts +++ b/tests/cases/fourslash/getOccurrencesIsDefinitionOfBindingPattern.ts @@ -1,8 +1,8 @@ /// -////const { [|{| "isWriteAccess": true, "isDefinition": true |}x|], y } = { [|{| "isWriteAccess": true, "isDefinition": true |}x|]: 1, y: 2 }; +////[|const { [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}x|], y } = { [|[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 2 |}x|]: 1|], y: 2 };|] ////const z = [|x|]; -const [r0, r1, r2] = test.ranges(); +const [r0Def, r0, r1Def, r1, r2] = test.ranges(); const local = { definition: "const x: number", ranges: [r0, r2] }; const prop = { definition: "(property) x: number", ranges: [r1] }; verify.referenceGroups(r0, [local, prop]); diff --git a/tests/cases/fourslash/getOccurrencesIsDefinitionOfClass.ts b/tests/cases/fourslash/getOccurrencesIsDefinitionOfClass.ts index 302ed5ce6f543..c6ab29fd884be 100644 --- a/tests/cases/fourslash/getOccurrencesIsDefinitionOfClass.ts +++ b/tests/cases/fourslash/getOccurrencesIsDefinitionOfClass.ts @@ -1,10 +1,10 @@ /// -////class [|{| "isWriteAccess": true, "isDefinition": true |}C|] { +////[|class [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}C|] { //// n: number; //// constructor() { //// this.n = 12; //// } -////} +////}|] ////let c = new [|C|](); -verify.singleReferenceGroup("class C"); +verify.singleReferenceGroup("class C", "C"); diff --git a/tests/cases/fourslash/getOccurrencesIsDefinitionOfComputedProperty.ts b/tests/cases/fourslash/getOccurrencesIsDefinitionOfComputedProperty.ts index 88ab38e5428c1..16c29b8800621 100644 --- a/tests/cases/fourslash/getOccurrencesIsDefinitionOfComputedProperty.ts +++ b/tests/cases/fourslash/getOccurrencesIsDefinitionOfComputedProperty.ts @@ -1,6 +1,6 @@ /// -////let o = { ["[|{| "isWriteAccess": true, "isDefinition": true |}foo|]"]: 12 }; +////let o = { [|["[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}foo|]"]: 12|] }; ////let y = o.[|foo|]; ////let z = o['[|foo|]']; -verify.singleReferenceGroup('(property) ["foo"]: number'); +verify.singleReferenceGroup('(property) ["foo"]: number', "foo"); diff --git a/tests/cases/fourslash/getOccurrencesIsDefinitionOfEnum.ts b/tests/cases/fourslash/getOccurrencesIsDefinitionOfEnum.ts index 325674d8ee721..26010967b2590 100644 --- a/tests/cases/fourslash/getOccurrencesIsDefinitionOfEnum.ts +++ b/tests/cases/fourslash/getOccurrencesIsDefinitionOfEnum.ts @@ -1,8 +1,8 @@ /// -////enum [|{| "isWriteAccess": true, "isDefinition": true |}E|] { +////[|enum [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}E|] { //// First, //// Second -////} +////}|] ////let first = [|E|].First; -verify.singleReferenceGroup("enum E"); +verify.singleReferenceGroup("enum E", "E"); diff --git a/tests/cases/fourslash/getOccurrencesIsDefinitionOfExport.ts b/tests/cases/fourslash/getOccurrencesIsDefinitionOfExport.ts index e31bc46eae644..61c25e0de2ef5 100644 --- a/tests/cases/fourslash/getOccurrencesIsDefinitionOfExport.ts +++ b/tests/cases/fourslash/getOccurrencesIsDefinitionOfExport.ts @@ -1,12 +1,12 @@ /// // @Filename: m.ts -////export var [|{| "isWriteAccess": true, "isDefinition": true |}x|] = 12; +////[|export var [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}x|] = 12;|] // @Filename: main.ts -////import { [|{| "isWriteAccess": true, "isDefinition": true |}x|] } from "./m"; +////[|import { [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 2 |}x|] } from "./m";|] ////const y = [|x|]; const ranges = test.ranges(); -const [r0, r1, r2] = ranges; +const [r0Def, r0, r1Def, r1, r2] = ranges; const defs = { definition: "var x: number", ranges: [r0] }; const imports = { definition: "(alias) var x: number\nimport x", ranges: [r1, r2] }; verify.referenceGroups(r0, [defs, imports]); diff --git a/tests/cases/fourslash/getOccurrencesIsDefinitionOfFunction.ts b/tests/cases/fourslash/getOccurrencesIsDefinitionOfFunction.ts index 4c91bc08ef851..1275671d4335a 100644 --- a/tests/cases/fourslash/getOccurrencesIsDefinitionOfFunction.ts +++ b/tests/cases/fourslash/getOccurrencesIsDefinitionOfFunction.ts @@ -1,6 +1,6 @@ /// -////function [|{| "isWriteAccess": true, "isDefinition": true |}func|](x: number) { -////} +////[|function [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}func|](x: number) { +////}|] ////[|func|](x) -verify.singleReferenceGroup("function func(x: number): void"); +verify.singleReferenceGroup("function func(x: number): void", "func"); diff --git a/tests/cases/fourslash/getOccurrencesIsDefinitionOfInterface.ts b/tests/cases/fourslash/getOccurrencesIsDefinitionOfInterface.ts index 826890c4da93e..3fe4753feefed 100644 --- a/tests/cases/fourslash/getOccurrencesIsDefinitionOfInterface.ts +++ b/tests/cases/fourslash/getOccurrencesIsDefinitionOfInterface.ts @@ -1,7 +1,7 @@ /// -////interface [|{| "isWriteAccess": true, "isDefinition": true |}I|] { +////[|interface [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}I|] { //// p: number; -////} +////}|] ////let i: [|I|] = { p: 12 }; -verify.singleReferenceGroup("interface I"); +verify.singleReferenceGroup("interface I", "I"); diff --git a/tests/cases/fourslash/getOccurrencesIsDefinitionOfInterfaceClassMerge.ts b/tests/cases/fourslash/getOccurrencesIsDefinitionOfInterfaceClassMerge.ts index 0e363a216eb4d..a454f212531f4 100644 --- a/tests/cases/fourslash/getOccurrencesIsDefinitionOfInterfaceClassMerge.ts +++ b/tests/cases/fourslash/getOccurrencesIsDefinitionOfInterfaceClassMerge.ts @@ -1,16 +1,16 @@ /// -////interface [|{| "isWriteAccess": true, "isDefinition": true |}Numbers|] { +////[|interface [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}Numbers|] { //// p: number; -////} -////interface [|{| "isWriteAccess": true, "isDefinition": true |}Numbers|] { +////}|] +////[|interface [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 2 |}Numbers|] { //// m: number; -////} -////class [|{| "isWriteAccess": true, "isDefinition": true |}Numbers|] { +////}|] +////[|class [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 4 |}Numbers|] { //// f(n: number) { //// return this.p + this.m + n; //// } -////} +////}|] ////let i: [|Numbers|] = new [|Numbers|](); ////let x = i.f(i.p + i.m); -verify.singleReferenceGroup("class Numbers\ninterface Numbers"); +verify.singleReferenceGroup("class Numbers\ninterface Numbers", "Numbers"); diff --git a/tests/cases/fourslash/getOccurrencesIsDefinitionOfNamespace.ts b/tests/cases/fourslash/getOccurrencesIsDefinitionOfNamespace.ts index 04d00e6c19f74..48ec42cdac0db 100644 --- a/tests/cases/fourslash/getOccurrencesIsDefinitionOfNamespace.ts +++ b/tests/cases/fourslash/getOccurrencesIsDefinitionOfNamespace.ts @@ -1,7 +1,7 @@ /// -////namespace [|{| "isWriteAccess": true, "isDefinition": true |}Numbers|] { +////[|namespace [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}Numbers|] { //// export var n = 12; -////} +////}|] ////let x = [|Numbers|].n + 1; -verify.singleReferenceGroup("namespace Numbers"); +verify.singleReferenceGroup("namespace Numbers", "Numbers"); diff --git a/tests/cases/fourslash/getOccurrencesIsDefinitionOfNumberNamedProperty.ts b/tests/cases/fourslash/getOccurrencesIsDefinitionOfNumberNamedProperty.ts index 33bdad09e1aea..02bdbb14f517b 100644 --- a/tests/cases/fourslash/getOccurrencesIsDefinitionOfNumberNamedProperty.ts +++ b/tests/cases/fourslash/getOccurrencesIsDefinitionOfNumberNamedProperty.ts @@ -1,5 +1,5 @@ /// -////let o = { [|{| "isWriteAccess": true, "isDefinition": true |}1|]: 12 }; +////let o = { [|[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}1|]: 12|] }; ////let y = o[[|1|]]; -verify.singleReferenceGroup("(property) 1: number"); +verify.singleReferenceGroup("(property) 1: number", "1"); diff --git a/tests/cases/fourslash/getOccurrencesIsDefinitionOfParameter.ts b/tests/cases/fourslash/getOccurrencesIsDefinitionOfParameter.ts index 8afa67bfe641c..1a09882464a28 100644 --- a/tests/cases/fourslash/getOccurrencesIsDefinitionOfParameter.ts +++ b/tests/cases/fourslash/getOccurrencesIsDefinitionOfParameter.ts @@ -1,6 +1,6 @@ /// -////function f([|{| "isWriteAccess": true, "isDefinition": true |}x|]: number) { +////function f([|[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}x|]: number|]) { //// return [|x|] + 1 ////} -verify.singleReferenceGroup("(parameter) x: number"); +verify.singleReferenceGroup("(parameter) x: number", "x"); diff --git a/tests/cases/fourslash/getOccurrencesIsDefinitionOfStringNamedProperty.ts b/tests/cases/fourslash/getOccurrencesIsDefinitionOfStringNamedProperty.ts index cf88d476fef2c..1e806fc496836 100644 --- a/tests/cases/fourslash/getOccurrencesIsDefinitionOfStringNamedProperty.ts +++ b/tests/cases/fourslash/getOccurrencesIsDefinitionOfStringNamedProperty.ts @@ -1,5 +1,5 @@ /// -////let o = { "[|{| "isWriteAccess": true, "isDefinition": true |}x|]": 12 }; +////let o = { [|"[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}x|]": 12|] }; ////let y = o.[|x|]; -verify.singleReferenceGroup('(property) "x": number'); +verify.singleReferenceGroup('(property) "x": number', "x"); diff --git a/tests/cases/fourslash/getOccurrencesIsDefinitionOfTypeAlias.ts b/tests/cases/fourslash/getOccurrencesIsDefinitionOfTypeAlias.ts index 18a4ec0396c46..dae8c5e384021 100644 --- a/tests/cases/fourslash/getOccurrencesIsDefinitionOfTypeAlias.ts +++ b/tests/cases/fourslash/getOccurrencesIsDefinitionOfTypeAlias.ts @@ -1,5 +1,5 @@ /// -////type [|{| "isWriteAccess": true, "isDefinition": true |}Alias|]= number; +////[|type [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}Alias|]= number;|] ////let n: [|Alias|] = 12; -verify.singleReferenceGroup("type Alias = number"); +verify.singleReferenceGroup("type Alias = number", "Alias"); diff --git a/tests/cases/fourslash/getOccurrencesIsDefinitionOfVariable.ts b/tests/cases/fourslash/getOccurrencesIsDefinitionOfVariable.ts index 2faf5b53e1b7b..b90641779f6fa 100644 --- a/tests/cases/fourslash/getOccurrencesIsDefinitionOfVariable.ts +++ b/tests/cases/fourslash/getOccurrencesIsDefinitionOfVariable.ts @@ -1,5 +1,5 @@ /// -////var [|{| "isWriteAccess": true, "isDefinition": true |}x|] = 0; +////[|var [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}x|] = 0;|] ////var assignmentRightHandSide = [|x|]; ////var assignmentRightHandSide2 = 1 + [|x|]; //// @@ -17,4 +17,4 @@ ////[|{| "isWriteAccess": true |}x|] += 1; ////[|{| "isWriteAccess": true |}x|] <<= 1; -verify.singleReferenceGroup("var x: number"); +verify.singleReferenceGroup("var x: number", "x"); diff --git a/tests/cases/fourslash/javaScriptClass2.ts b/tests/cases/fourslash/javaScriptClass2.ts index dcdac24c7b853..e8edf33bc4221 100644 --- a/tests/cases/fourslash/javaScriptClass2.ts +++ b/tests/cases/fourslash/javaScriptClass2.ts @@ -6,12 +6,12 @@ // @Filename: Foo.js //// class Foo { //// constructor() { -//// this.[|union|] = 'foo'; -//// this.[|union|] = 100; +//// [|this.[|{| "contextRangeIndex": 0 |}union|] = 'foo';|] +//// [|this.[|{| "contextRangeIndex": 2 |}union|] = 100;|] //// } //// method() { return this.[|union|]; } //// } //// var x = new Foo(); //// x.[|union|]; -verify.rangesAreRenameLocations(); +verify.rangesWithSameTextAreRenameLocations("union"); diff --git a/tests/cases/fourslash/jsDocServices.ts b/tests/cases/fourslash/jsDocServices.ts index df1e985f8761f..01619abe44df0 100644 --- a/tests/cases/fourslash/jsDocServices.ts +++ b/tests/cases/fourslash/jsDocServices.ts @@ -7,11 +7,12 @@ /////** //// * @param /*use*/[|foo|] I pity the foo //// */ -////function f([|/*def*/{| "isWriteAccess": true, "isDefinition": true |}foo|]: I) { +////function f([|[|/*def*/{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 1 |}foo|]: I|]) { //// return [|foo|]; ////} -const ranges = test.ranges(); +const [r0, r1Def, r1, r2] = test.ranges(); +const ranges = [r0, r1, r2]; goTo.marker("use"); verify.goToDefinitionIs("def"); verify.goToType("use", "I"); @@ -19,6 +20,6 @@ verify.goToType("use", "I"); goTo.marker("use"); verify.quickInfoIs("(parameter) foo: I", "I pity the foo"); -verify.singleReferenceGroup("(parameter) foo: I"); -verify.rangesAreDocumentHighlights(); -verify.rangesAreRenameLocations(); +verify.singleReferenceGroup("(parameter) foo: I", ranges); +verify.rangesAreDocumentHighlights(ranges); +verify.rangesAreRenameLocations(ranges); diff --git a/tests/cases/fourslash/jsdocTypedefTagSemanticMeaning0.ts b/tests/cases/fourslash/jsdocTypedefTagSemanticMeaning0.ts index c45f4aadc809a..44156116d2f83 100644 --- a/tests/cases/fourslash/jsdocTypedefTagSemanticMeaning0.ts +++ b/tests/cases/fourslash/jsdocTypedefTagSemanticMeaning0.ts @@ -3,14 +3,14 @@ // @allowJs: true // @Filename: a.js -/////** @typedef {number} [|{| "isWriteAccess": true, "isDefinition": true |}T|] */ +/////** [|@typedef {number} [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}T|]|] */ -////const [|{| "isWriteAccess": true, "isDefinition": true |}T|] = 1; +////[|const [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 2 |}T|] = 1;|] /////** @type {[|T|]} */ ////const n = [|T|]; -const [t0, v0, t1, v1] = test.ranges(); +const [t0Def, t0, v0Def, v0, t1, v1] = test.ranges(); verify.singleReferenceGroup("type T = number", [t0, t1]); verify.singleReferenceGroup("const T: 1", [v0, v1]); diff --git a/tests/cases/fourslash/jsdocTypedefTagSemanticMeaning1.ts b/tests/cases/fourslash/jsdocTypedefTagSemanticMeaning1.ts index f052d4bd8705d..10b076c55f819 100644 --- a/tests/cases/fourslash/jsdocTypedefTagSemanticMeaning1.ts +++ b/tests/cases/fourslash/jsdocTypedefTagSemanticMeaning1.ts @@ -4,9 +4,9 @@ // @Filename: a.js /////** @typedef {number} */ -////const [|{| "isWriteAccess": true, "isDefinition": true |}T|] = 1; +////[|const [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}T|] = 1;|] /////** @type {[|T|]} */ ////const n = [|T|]; -verify.singleReferenceGroup("type T = number\nconst T: 1"); +verify.singleReferenceGroup("type T = number\nconst T: 1", "T"); diff --git a/tests/cases/fourslash/jsdocTypedefTagServices.ts b/tests/cases/fourslash/jsdocTypedefTagServices.ts index e4b262c3ee43e..7d9e4154c6c79 100644 --- a/tests/cases/fourslash/jsdocTypedefTagServices.ts +++ b/tests/cases/fourslash/jsdocTypedefTagServices.ts @@ -5,9 +5,9 @@ /////** //// * Doc comment -//// * @typedef /*def*/[|{| "isWriteAccess": true, "isDefinition": true |}Product|] +//// * [|@typedef /*def*/[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}Product|] //// * @property {string} title -//// */ +//// |]*/ /////** //// * @type {[|/*use*/Product|]} @@ -18,11 +18,12 @@ const desc = `type Product = { title: string; }`; +const [r0Def, ...ranges] = test.ranges(); verify.quickInfoAt("use", desc, "Doc comment"); verify.goToDefinition("use", "def"); -verify.rangesAreOccurrences(); -verify.rangesAreDocumentHighlights(); -verify.singleReferenceGroup(desc); -verify.rangesAreRenameLocations(); +verify.rangesAreOccurrences(/*isWriteAccesss*/ undefined, ranges); +verify.rangesAreDocumentHighlights(ranges); +verify.singleReferenceGroup(desc, ranges); +verify.rangesAreRenameLocations(ranges); diff --git a/tests/cases/fourslash/jsxSpreadReference.ts b/tests/cases/fourslash/jsxSpreadReference.ts index 915dbdcecdf59..62e6328aa0785 100644 --- a/tests/cases/fourslash/jsxSpreadReference.ts +++ b/tests/cases/fourslash/jsxSpreadReference.ts @@ -14,8 +14,8 @@ //// } //// } //// -//// var [|/*dst*/nn|]: {name?: string; size?: number}; +//// [|var [|/*dst*/{| "contextRangeIndex": 0 |}nn|]: {name?: string; size?: number};|] //// var x = ; verify.goToDefinition("src", "dst"); -verify.rangesAreRenameLocations(); +verify.rangesWithSameTextAreRenameLocations("nn"); diff --git a/tests/cases/fourslash/localGetReferences.ts b/tests/cases/fourslash/localGetReferences.ts index a434a6b082041..c3253ea960ca3 100644 --- a/tests/cases/fourslash/localGetReferences.ts +++ b/tests/cases/fourslash/localGetReferences.ts @@ -3,15 +3,15 @@ // @Filename: localGetReferences_1.ts ////// Comment Refence Test: g/*1*/lobalVar ////// References to a variable declared in global. -////var [|{| "isWriteAccess": true, "isDefinition": true |}globalVar|]: number = 2; +////[|var [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}globalVar|]: number = 2;|] //// ////class fooCls { //// // References to static variable declared in a class. -//// static [|{| "isWriteAccess": true, "isDefinition": true |}clsSVar|] = 1; +//// [|static [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 2 |}clsSVar|] = 1;|] //// // References to a variable declared in a class. -//// [|{| "isWriteAccess": true, "isDefinition": true |}clsVar|] = 1; +//// [|[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 4 |}clsVar|] = 1;|] //// -//// constructor (public [|{| "isWriteAccess": true, "isDefinition": true |}clsParam|]: number) { +//// constructor ([|public [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 6 |}clsParam|]: number|]) { //// //Increments //// [|{| "isWriteAccess": true |}globalVar|]++; //// this.[|{| "isWriteAccess": true |}clsVar|]++; @@ -23,9 +23,9 @@ ////} //// ////// References to a function parameter. -////function [|{| "isWriteAccess": true, "isDefinition": true |}foo|]([|{| "isWriteAccess": true, "isDefinition": true |}x|]: number) { +////[|function [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 12 |}foo|]([|[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 14 |}x|]: number|]) { //// // References to a variable declared in a function. -//// var [|{| "isWriteAccess": true, "isDefinition": true |}fnVar|] = 1; +//// [|var [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 16 |}fnVar|] = 1;|] //// //// //Increments //// fooCls.[|{| "isWriteAccess": true |}clsSVar|]++; @@ -35,7 +35,7 @@ //// //// //Return //// return [|{| "isWriteAccess": true |}x|]++; -////} +////}|] //// ////module modTest { //// //Declare @@ -85,7 +85,7 @@ /////*3*/err = err++; /////*4*/ //////Shadowed fn Parameter -////function shdw([|{| "isWriteAccess": true, "isDefinition": true, "shadow": true |}globalVar|]: number) { +////function shdw([|[|{| "isWriteAccess": true, "isDefinition": true, "shadow": true, "contextRangeIndex": 39 |}globalVar|]: number|]) { //// //Increments //// [|{| "isWriteAccess": true, "shadow": true |}globalVar|]++; //// return [|{| "shadow": true |}globalVar|]; @@ -198,6 +198,30 @@ goTo.marker("4"); verify.noReferences(); test.rangesByText().forEach((ranges, text) => { + switch (text) { + case "var globalVar: number = 2;": + case "static clsSVar = 1;": + case "clsVar = 1;": + case "public clsParam: number": + case `function foo(x: number) { + // References to a variable declared in a function. + var fnVar = 1; + + //Increments + fooCls.clsSVar++; + globalVar++; + modTest.modVar++; + fnVar++; + + //Return + return x++; +}`: + case "x: number": + case "var fnVar = 1;": + case "globalVar: number": + return; + } + if (text === "globalVar") { verify.singleReferenceGroup("(parameter) globalVar: number", ranges.filter(isShadow)); verify.singleReferenceGroup("var globalVar: number", ranges.filter(r => !isShadow(r))); diff --git a/tests/cases/fourslash/referenceInParameterPropertyDeclaration.ts b/tests/cases/fourslash/referenceInParameterPropertyDeclaration.ts index 63494352ff496..bd087bd155ebb 100644 --- a/tests/cases/fourslash/referenceInParameterPropertyDeclaration.ts +++ b/tests/cases/fourslash/referenceInParameterPropertyDeclaration.ts @@ -2,9 +2,9 @@ // @Filename: file1.ts //// class Foo { -//// 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) { +//// constructor([|private [|{| "isWriteAccess": true, "isDefinition": true, "type": "number", "contextRangeIndex": 0 |}privateParam|]: number|], +//// [|public [|{| "isWriteAccess": true, "isDefinition": true, "type": "string", "contextRangeIndex": 2 |}publicParam|]: string|], +//// [|protected [|{| "isWriteAccess": true, "isDefinition": true, "type": "boolean", "contextRangeIndex": 4 |}protectedParam|]: boolean|]) { //// //// let localPrivate = [|privateParam|]; //// this.[|{| "isWriteAccess": true |}privateParam|] += 10; @@ -18,6 +18,8 @@ //// } test.rangesByText().forEach((ranges, text) => { + if (text !== "privateParam" && text !== "publicParam" && text !== "protectedParam") return; + const [r0, r1, r2] = ranges; const type = r0.marker.data.type; verify.referenceGroups(ranges, [ diff --git a/tests/cases/fourslash/referenceToClass.ts b/tests/cases/fourslash/referenceToClass.ts index d74f24703d23a..37e5322165e6d 100644 --- a/tests/cases/fourslash/referenceToClass.ts +++ b/tests/cases/fourslash/referenceToClass.ts @@ -3,10 +3,10 @@ // Class references should work across file and not find local variables. // @Filename: referenceToClass_1.ts -////class [|{| "isWriteAccess": true, "isDefinition": true |}foo|] { +////[|class [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}foo|] { //// public n: [|foo|]; //// public foo: number; -////} +////}|] //// ////class bar { //// public n: [|foo|]; @@ -20,4 +20,4 @@ // @Filename: referenceToClass_2.ts ////var k: [|foo|]; -verify.singleReferenceGroup("class foo"); +verify.singleReferenceGroup("class foo", "foo"); diff --git a/tests/cases/fourslash/referencesBloomFilters.ts b/tests/cases/fourslash/referencesBloomFilters.ts index 1b96ef6f1c9b1..c71ec7533c6ab 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 = { [|{| "isWriteAccess": true, "isDefinition": true |}searchProp|] : 1 }; +////var container = { [|[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}searchProp|] : 1|] }; // @Filename: expression.ts ////function blah() { return (1 + 2 + container.[|searchProp|]()) === 2; }; @@ -12,6 +12,6 @@ ////function blah2() { container["[|searchProp|]"] }; // @Filename: redeclaration.ts -////container = { "[|{| "isWriteAccess": true, "isDefinition": true |}searchProp|]" : 18 }; +////container = { [|"[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 4 |}searchProp|]" : 18|] }; -verify.singleReferenceGroup("(property) searchProp: number"); +verify.singleReferenceGroup("(property) searchProp: number", "searchProp"); diff --git a/tests/cases/fourslash/referencesBloomFilters2.ts b/tests/cases/fourslash/referencesBloomFilters2.ts index 6f1dfa16e80fe..ee74343c462c6 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 = { [|{| "isWriteAccess": true, "isDefinition": true |}42|]: 1 }; +////var container = { [|[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}42|]: 1|] }; // @Filename: expression.ts ////function blah() { return (container[[|42|]]) === 2; }; @@ -12,6 +12,6 @@ ////function blah2() { container["[|42|]"] }; // @Filename: redeclaration.ts -////container = { "[|{| "isWriteAccess": true, "isDefinition": true |}42|]" : 18 }; +////container = { [|"[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 4 |}42|]" : 18|] }; -verify.singleReferenceGroup("(property) 42: number"); +verify.singleReferenceGroup("(property) 42: number", "42"); diff --git a/tests/cases/fourslash/referencesBloomFilters3.ts b/tests/cases/fourslash/referencesBloomFilters3.ts index d7d335cde02cb..5d6d68c9dd512 100644 --- a/tests/cases/fourslash/referencesBloomFilters3.ts +++ b/tests/cases/fourslash/referencesBloomFilters3.ts @@ -4,9 +4,9 @@ // @Filename: declaration.ts -////enum Test { "[|{| "isWriteAccess": true, "isDefinition": true |}42|]" = 1 }; +////enum Test { [|"[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}42|]" = 1|] }; // @Filename: expression.ts ////(Test[[|42|]]); -verify.singleReferenceGroup('(enum member) Test["42"] = 1'); +verify.singleReferenceGroup('(enum member) Test["42"] = 1', "42"); diff --git a/tests/cases/fourslash/referencesForAmbients.ts b/tests/cases/fourslash/referencesForAmbients.ts index 89036befce3d1..6852ad8f2cb3a 100644 --- a/tests/cases/fourslash/referencesForAmbients.ts +++ b/tests/cases/fourslash/referencesForAmbients.ts @@ -1,20 +1,20 @@ /// -////declare module "[|{| "isWriteAccess": true, "isDefinition": true |}foo|]" { -//// var [|{| "isWriteAccess": true, "isDefinition": true |}f|]: number; -////} +////[|declare module "[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}foo|]" { +//// [|var [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 2 |}f|]: number;|] +////}|] //// -////declare module "[|{| "isWriteAccess": true, "isDefinition": true |}bar|]" { -//// export import [|{| "isWriteAccess": true, "isDefinition": true |}foo|] = require("[|foo|]"); +////[|declare module "[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 4 |}bar|]" { +//// [|export import [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 6 |}foo|] = require("[|{| "contextRangeIndex": 6 |}foo|]");|] //// var f2: typeof [|foo|].[|f|]; -////} +////}|] //// ////declare module "baz" { -//// import bar = require("[|bar|]"); +//// [|import bar = require("[|{| "contextRangeIndex": 11 |}bar|]");|] //// var f2: typeof bar.[|foo|]; ////} -const [moduleFoo0, f0, moduleBar0, foo0, moduleFoo1, foo1, f1, moduleBar1, foo2] = test.ranges(); +const [moduleFoo0Def, moduleFoo0, f0Def, f0, moduleBar0Def, moduleBar0, foo0Def, foo0, moduleFoo1, foo1, f1, moduleBar1Def, moduleBar1, foo2] = test.ranges(); verify.singleReferenceGroup('module "foo"', [moduleFoo0, moduleFoo1]); verify.singleReferenceGroup('module "bar"', [moduleBar0, moduleBar1]); verify.singleReferenceGroup('(alias) module "foo"\nimport foo = require("foo")', [foo0, foo1, foo2]); diff --git a/tests/cases/fourslash/referencesForAmbients2.ts b/tests/cases/fourslash/referencesForAmbients2.ts index 8654d90f8546e..2ec60cf3731d4 100644 --- a/tests/cases/fourslash/referencesForAmbients2.ts +++ b/tests/cases/fourslash/referencesForAmbients2.ts @@ -2,7 +2,7 @@ // @Filename: /defA.ts ////declare module "a" { -//// export type [|{| "isWriteAccess": true, "isDefinition": true |}T|] = number; +//// [|export type [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}T|] = number;|] ////} // @Filename: /defB.ts @@ -18,4 +18,4 @@ ////} verify.noErrors(); -verify.singleReferenceGroup("type T = number"); +verify.singleReferenceGroup("type T = number", "T"); diff --git a/tests/cases/fourslash/referencesForClassLocal.ts b/tests/cases/fourslash/referencesForClassLocal.ts index 9e2576413f2a4..406b512d62b16 100644 --- a/tests/cases/fourslash/referencesForClassLocal.ts +++ b/tests/cases/fourslash/referencesForClassLocal.ts @@ -5,7 +5,7 @@ ////var n = 14; //// ////class foo { -//// private [|{| "isWriteAccess": true, "isDefinition": true |}n|] = 0; +//// [|private [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}n|] = 0;|] //// //// public bar() { //// this.[|{| "isWriteAccess": true |}n|] = 9; @@ -20,4 +20,4 @@ //// } ////} -verify.singleReferenceGroup("(property) foo.n: number"); +verify.singleReferenceGroup("(property) foo.n: number", "n"); diff --git a/tests/cases/fourslash/referencesForClassMembers.ts b/tests/cases/fourslash/referencesForClassMembers.ts index e60c03524a162..ff9b5098aa29b 100644 --- a/tests/cases/fourslash/referencesForClassMembers.ts +++ b/tests/cases/fourslash/referencesForClassMembers.ts @@ -1,12 +1,12 @@ /// ////class Base { -//// [|{| "isDefinition": true |}a|]: number; -//// [|{| "isWriteAccess": true, "isDefinition": true |}method|](): void { } +//// [|[|{| "isDefinition": true, "contextRangeIndex": 0 |}a|]: number;|] +//// [|[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 2 |}method|](): void { }|] ////} ////class MyClass extends Base { -//// [|{| "isDefinition": true |}a|]; -//// [|{| "isWriteAccess": true, "isDefinition": true |}method|]() { } +//// [|[|{| "isDefinition": true, "contextRangeIndex": 4 |}a|];|] +//// [|[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 6 |}method|]() { }|] ////} //// ////var c: MyClass; diff --git a/tests/cases/fourslash/referencesForClassMembersExtendingAbstractClass.ts b/tests/cases/fourslash/referencesForClassMembersExtendingAbstractClass.ts index 12df996629d2a..ed2276023558f 100644 --- a/tests/cases/fourslash/referencesForClassMembersExtendingAbstractClass.ts +++ b/tests/cases/fourslash/referencesForClassMembersExtendingAbstractClass.ts @@ -1,12 +1,12 @@ /// ////abstract class Base { -//// abstract [|{| "isDefinition": true |}a|]: number; -//// abstract [|{| "isDefinition": true |}method|](): void; +//// [|abstract [|{| "isDefinition": true, "contextRangeIndex": 0 |}a|]: number;|] +//// [|abstract [|{| "isDefinition": true, "contextRangeIndex": 2 |}method|](): void;|] ////} ////class MyClass extends Base { -//// [|{| "isDefinition": true |}a|]; -//// [|{| "isWriteAccess": true, "isDefinition": true |}method|]() { } +//// [|[|{| "isDefinition": true, "contextRangeIndex": 4 |}a|];|] +//// [|[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 6 |}method|]() { }|] ////} //// ////var c: MyClass; diff --git a/tests/cases/fourslash/referencesForClassMembersExtendingGenericClass.ts b/tests/cases/fourslash/referencesForClassMembersExtendingGenericClass.ts index 103b66ff74b77..a05007b638b97 100644 --- a/tests/cases/fourslash/referencesForClassMembersExtendingGenericClass.ts +++ b/tests/cases/fourslash/referencesForClassMembersExtendingGenericClass.ts @@ -1,12 +1,12 @@ /// ////class Base { -//// [|{| "isDefinition": true |}a|]: this; -//// [|{| "isWriteAccess": true, "isDefinition": true |}method|](a?:T, b?:U): this { } +//// [|[|{| "isDefinition": true, "contextRangeIndex": 0 |}a|]: this;|] +//// [|[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 2 |}method|](a?:T, b?:U): this { }|] ////} ////class MyClass extends Base { -//// [|{| "isDefinition": true |}a|]; -//// [|{| "isWriteAccess": true, "isDefinition": true |}method|]() { } +//// [|[|{| "isDefinition": true, "contextRangeIndex": 4 |}a|];|] +//// [|[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 6 |}method|]() { }|] ////} //// ////var c: MyClass; diff --git a/tests/cases/fourslash/referencesForClassParameter.ts b/tests/cases/fourslash/referencesForClassParameter.ts index ec1e1bb2f0e2a..011be7e85bbd8 100644 --- a/tests/cases/fourslash/referencesForClassParameter.ts +++ b/tests/cases/fourslash/referencesForClassParameter.ts @@ -7,7 +7,7 @@ ////class p { } //// ////class foo { -//// constructor (public [|{| "isWriteAccess": true, "isDefinition": true |}p|]: any) { +//// constructor ([|public [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}p|]: any|]) { //// } //// //// public f(p) { @@ -19,4 +19,4 @@ ////var n = new foo(undefined); ////n.[|{| "isWriteAccess": true |}p|] = null; -verify.singleReferenceGroup("(property) foo.p: any"); +verify.singleReferenceGroup("(property) foo.p: any", "p"); diff --git a/tests/cases/fourslash/referencesForContextuallyTypedObjectLiteralProperties.ts b/tests/cases/fourslash/referencesForContextuallyTypedObjectLiteralProperties.ts index 67f09a9dcd18d..4cd843926902d 100644 --- a/tests/cases/fourslash/referencesForContextuallyTypedObjectLiteralProperties.ts +++ b/tests/cases/fourslash/referencesForContextuallyTypedObjectLiteralProperties.ts @@ -1,28 +1,28 @@ /// -////interface IFoo { [|{| "isDefinition": true |}xy|]: number; } +////interface IFoo { [|[|{| "isDefinition": true, "contextRangeIndex": 0 |}xy|]: number;|] } //// ////// Assignment -////var a1: IFoo = { [|{| "isWriteAccess": true, "isDefinition": true |}xy|]: 0 }; -////var a2: IFoo = { [|{| "isWriteAccess": true, "isDefinition": true |}xy|]: 0 }; +////var a1: IFoo = { [|[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 2 |}xy|]: 0|] }; +////var a2: IFoo = { [|[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 4 |}xy|]: 0|] }; //// ////// Function call ////function consumer(f: IFoo) { } -////consumer({ [|{| "isWriteAccess": true, "isDefinition": true |}xy|]: 1 }); +////consumer({ [|[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 6 |}xy|]: 1|] }); //// ////// Type cast -////var c = { [|{| "isWriteAccess": true, "isDefinition": true |}xy|]: 0 }; +////var c = { [|[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 8 |}xy|]: 0|] }; //// ////// Array literal -////var ar: IFoo[] = [{ [|{| "isWriteAccess": true, "isDefinition": true |}xy|]: 1 }, { [|{| "isWriteAccess": true, "isDefinition": true |}xy|]: 2 }]; +////var ar: IFoo[] = [{ [|[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 10 |}xy|]: 1|] }, { [|[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 12 |}xy|]: 2|] }]; //// ////// Nested object literal -////var ob: { ifoo: IFoo } = { ifoo: { [|{| "isWriteAccess": true, "isDefinition": true |}xy|]: 0 } }; +////var ob: { ifoo: IFoo } = { ifoo: { [|[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 14 |}xy|]: 0|] } }; //// ////// Widened type -////var w: IFoo = { [|{| "isWriteAccess": true, "isDefinition": true, "type": "undefined" |}xy|]: undefined }; +////var w: IFoo = { [|[|{| "isWriteAccess": true, "isDefinition": true, "type": "undefined", "contextRangeIndex": 16 |}xy|]: undefined|] }; //// ////// Untped -- should not be included ////var u = { xy: 0 }; -verify.singleReferenceGroup("(property) IFoo.xy: number"); +verify.singleReferenceGroup("(property) IFoo.xy: number", "xy"); diff --git a/tests/cases/fourslash/referencesForContextuallyTypedUnionProperties.ts b/tests/cases/fourslash/referencesForContextuallyTypedUnionProperties.ts index b0bb5d62b4d32..fecef82615284 100644 --- a/tests/cases/fourslash/referencesForContextuallyTypedUnionProperties.ts +++ b/tests/cases/fourslash/referencesForContextuallyTypedUnionProperties.ts @@ -2,39 +2,39 @@ ////interface A { //// a: number; -//// [|{| "isDefinition": true |}common|]: string; +//// [|[|{| "isDefinition": true, "contextRangeIndex": 0 |}common|]: string;|] ////} //// ////interface B { //// b: number; -//// [|{| "isDefinition": true |}common|]: number; +//// [|[|{| "isDefinition": true, "contextRangeIndex": 2 |}common|]: number;|] ////} //// ////// Assignment -////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 }; +////var v1: A | B = { a: 0, [|[|{| "isWriteAccess": true, "isDefinition": true, "type": "string", "contextRangeIndex": 4 |}common|]: ""|] }; +////var v2: A | B = { b: 0, [|[|{| "isWriteAccess": true, "isDefinition": true, "type": "number", "contextRangeIndex": 6 |}common|]: 3|] }; //// ////// Function call ////function consumer(f: A | B) { } -////consumer({ a: 0, b: 0, [|{| "isWriteAccess": true, "isDefinition": true, "type": "number" |}common|]: 1 }); +////consumer({ a: 0, b: 0, [|[|{| "isWriteAccess": true, "isDefinition": true, "type": "number", "contextRangeIndex": 8 |}common|]: 1|] }); //// ////// Type cast -////var c = { [|{| "isWriteAccess": true, "isDefinition": true, "type": "number" |}common|]: 0, b: 0 }; +////var c = { [|[|{| "isWriteAccess": true, "isDefinition": true, "type": "number", "contextRangeIndex": 10 |}common|]: 0|], b: 0 }; //// ////// Array literal -////var ar: Array = [{ a: 0, [|{| "isWriteAccess": true, "isDefinition": true, "type": "string" |}common|]: "" }, { b: 0, [|{| "isWriteAccess": true, "isDefinition": true, "type": "number" |}common|]: 0 }]; +////var ar: Array = [{ a: 0, [|[|{| "isWriteAccess": true, "isDefinition": true, "type": "string", "contextRangeIndex": 12 |}common|]: ""|] }, { b: 0, [|[|{| "isWriteAccess": true, "isDefinition": true, "type": "number", "contextRangeIndex": 14 |}common|]: 0|] }]; //// ////// Nested object literal -////var ob: { aorb: A|B } = { aorb: { b: 0, [|{| "isWriteAccess": true, "isDefinition": true, "type": "number" |}common|]: 0 } }; +////var ob: { aorb: A|B } = { aorb: { b: 0, [|[|{| "isWriteAccess": true, "isDefinition": true, "type": "number", "contextRangeIndex": 16 |}common|]: 0|] } }; //// ////// Widened type -////var w: A|B = { a:0, [|{| "isWriteAccess": true, "isDefinition": true, "type": "undefined" |}common|]: undefined }; +////var w: A|B = { a:0, [|[|{| "isWriteAccess": true, "isDefinition": true, "type": "undefined", "contextRangeIndex": 18 |}common|]: undefined|] }; //// ////// Untped -- should not be included ////var u1 = { a: 0, b: 0, common: "" }; ////var u2 = { b: 0, common: 0 }; -const [aCommon, bCommon, ...unionRefs] = test.ranges(); +const [aCommon, bCommon, ...unionRefs] = test.rangesByText().get("common"); verify.referenceGroups(aCommon, [ { definition: "(property) A.common: string", ranges: [aCommon] }, { definition: "(property) common: string | number", ranges: unionRefs }, diff --git a/tests/cases/fourslash/referencesForContextuallyTypedUnionProperties2.ts b/tests/cases/fourslash/referencesForContextuallyTypedUnionProperties2.ts index a9741d3e39d00..22e5da052b0d5 100644 --- a/tests/cases/fourslash/referencesForContextuallyTypedUnionProperties2.ts +++ b/tests/cases/fourslash/referencesForContextuallyTypedUnionProperties2.ts @@ -6,32 +6,32 @@ ////} //// ////interface B { -//// [|{| "isDefinition": true |}b|]: number; +//// [|[|{| "isDefinition": true, "contextRangeIndex": 0 |}b|]: number;|] //// common: number; ////} //// ////// Assignment ////var v1: A | B = { a: 0, common: "" }; -////var v2: A | B = { [|{| "isWriteAccess": true, "isDefinition": true, "type": "number" |}b|]: 0, common: 3 }; +////var v2: A | B = { [|[|{| "isWriteAccess": true, "isDefinition": true, "type": "number", "contextRangeIndex": 2 |}b|]: 0|], common: 3 }; //// ////// Function call ////function consumer(f: A | B) { } -////consumer({ a: 0, [|{| "isWriteAccess": true, "isDefinition": true, "type": "number" |}b|]: 0, common: 1 }); +////consumer({ a: 0, [|[|{| "isWriteAccess": true, "isDefinition": true, "type": "number", "contextRangeIndex": 4 |}b|]: 0|], common: 1 }); //// ////// Type cast -////var c = { common: 0, [|{| "isWriteAccess": true, "isDefinition": true, "type": "number" |}b|]: 0 }; +////var c = { common: 0, [|[|{| "isWriteAccess": true, "isDefinition": true, "type": "number", "contextRangeIndex": 6 |}b|]: 0|] }; //// ////// Array literal -////var ar: Array = [{ a: 0, common: "" }, { [|{| "isWriteAccess": true, "isDefinition": true, "type": "number" |}b|]: 0, common: 0 }]; +////var ar: Array = [{ a: 0, common: "" }, { [|[|{| "isWriteAccess": true, "isDefinition": true, "type": "number", "contextRangeIndex": 8 |}b|]: 0|], common: 0 }]; //// ////// Nested object literal -////var ob: { aorb: A|B } = { aorb: { [|{| "isWriteAccess": true, "isDefinition": true, "type": "number" |}b|]: 0, common: 0 } }; +////var ob: { aorb: A|B } = { aorb: { [|[|{| "isWriteAccess": true, "isDefinition": true, "type": "number", "contextRangeIndex": 10 |}b|]: 0|], common: 0 } }; //// ////// Widened type -////var w: A|B = { [|{| "isWriteAccess": true, "isDefinition": true, "type": "undefined" |}b|]:undefined, common: undefined }; +////var w: A|B = { [|[|{| "isWriteAccess": true, "isDefinition": true, "type": "undefined", "contextRangeIndex": 12 |}b|]:undefined|], common: undefined }; //// ////// Untped -- should not be included ////var u1 = { a: 0, b: 0, common: "" }; ////var u2 = { b: 0, common: 0 }; -verify.singleReferenceGroup("(property) B.b: number"); +verify.singleReferenceGroup("(property) B.b: number", "b"); diff --git a/tests/cases/fourslash/referencesForEnums.ts b/tests/cases/fourslash/referencesForEnums.ts index af4fec8aae869..395dee4a3a7fc 100644 --- a/tests/cases/fourslash/referencesForEnums.ts +++ b/tests/cases/fourslash/referencesForEnums.ts @@ -1,9 +1,9 @@ /// ////enum E { -//// [|{| "isWriteAccess": true, "isDefinition": true |}value1|] = 1, -//// "[|{| "isWriteAccess": true, "isDefinition": true |}value2|]" = [|value1|], -//// [|{| "isWriteAccess": true, "isDefinition": true |}111|] = 11 +//// [|[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}value1|] = 1|], +//// [|"[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 2 |}value2|]" = [|value1|]|], +//// [|[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 5 |}111|] = 11|] ////} //// ////E.[|value1|]; @@ -11,7 +11,6 @@ ////E.[|value2|]; ////E[[|111|]]; -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")); +verify.singleReferenceGroup("(enum member) E.value1 = 1", "value1"); +verify.singleReferenceGroup("(enum member) E[\"value2\"] = 1", "value2"); +verify.singleReferenceGroup("(enum member) E[111] = 11", "111"); diff --git a/tests/cases/fourslash/referencesForExportedValues.ts b/tests/cases/fourslash/referencesForExportedValues.ts index ff00f844260f3..c623e270bed4a 100644 --- a/tests/cases/fourslash/referencesForExportedValues.ts +++ b/tests/cases/fourslash/referencesForExportedValues.ts @@ -1,7 +1,7 @@ /// ////module M { -//// export var [|{| "isWriteAccess": true, "isDefinition": true |}variable|] = 0; +//// [|export var [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}variable|] = 0;|] //// //// // local use //// var x = [|variable|]; @@ -10,4 +10,4 @@ ////// external use ////M.[|variable|] -verify.singleReferenceGroup("var M.variable: number"); +verify.singleReferenceGroup("var M.variable: number", "variable"); diff --git a/tests/cases/fourslash/referencesForExternalModuleNames.ts b/tests/cases/fourslash/referencesForExternalModuleNames.ts index 90db189e04a16..699e04a518a45 100644 --- a/tests/cases/fourslash/referencesForExternalModuleNames.ts +++ b/tests/cases/fourslash/referencesForExternalModuleNames.ts @@ -1,11 +1,11 @@ /// // @Filename: referencesForGlobals_1.ts -////declare module "[|{| "isWriteAccess": true, "isDefinition": true |}foo|]" { +////[|declare module "[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}foo|]" { //// var f: number; -////} +////}|] // @Filename: referencesForGlobals_2.ts -////import f = require("[|foo|]"); +////[|import f = require("[|{| "contextRangeIndex": 2 |}foo|]");|] -verify.singleReferenceGroup('module "foo"'); +verify.singleReferenceGroup('module "foo"', "foo"); diff --git a/tests/cases/fourslash/referencesForFunctionOverloads.ts b/tests/cases/fourslash/referencesForFunctionOverloads.ts index 2a1ea032e2009..a124321f464b7 100644 --- a/tests/cases/fourslash/referencesForFunctionOverloads.ts +++ b/tests/cases/fourslash/referencesForFunctionOverloads.ts @@ -2,9 +2,9 @@ // Function overloads should be highlighted together. -////function [|{| "isDefinition": true |}foo|](x: string); -////function [|{| "isWriteAccess": true, "isDefinition": true |}foo|](x: string, y: number) { +////[|function [|{| "isDefinition": true, "contextRangeIndex": 0 |}foo|](x: string);|] +////[|function [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 2 |}foo|](x: string, y: number) { //// [|foo|]('', 43); -////} +////}|] -verify.singleReferenceGroup("function foo(x: string): any"); +verify.singleReferenceGroup("function foo(x: string): any", "foo"); diff --git a/tests/cases/fourslash/referencesForFunctionParameter.ts b/tests/cases/fourslash/referencesForFunctionParameter.ts index 24582a68e08a2..83baed3b83498 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, [|{| "isWriteAccess": true, "isDefinition": true |}n|]: number) { +////function n(x: number, [|[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}n|]: number|]) { //// [|{| "isWriteAccess": true |}n|] = 32; //// x = [|n|]; ////} -verify.singleReferenceGroup("(parameter) n: number"); +verify.singleReferenceGroup("(parameter) n: number", "n"); diff --git a/tests/cases/fourslash/referencesForGlobals.ts b/tests/cases/fourslash/referencesForGlobals.ts index dc5bc4deb6f83..0cbe1aae9faf4 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 [|{| "isWriteAccess": true, "isDefinition": true |}global|] = 2; +////[|var [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}global|] = 2;|] //// ////class foo { //// constructor (public global) { } @@ -25,4 +25,4 @@ // @Filename: referencesForGlobals_2.ts ////var m = [|global|]; -verify.singleReferenceGroup("var global: number"); +verify.singleReferenceGroup("var global: number", "global"); diff --git a/tests/cases/fourslash/referencesForGlobals2.ts b/tests/cases/fourslash/referencesForGlobals2.ts index e08be585c7ac9..3539944745597 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 [|{| "isWriteAccess": true, "isDefinition": true |}globalClass|] { +////[|class [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}globalClass|] { //// public f() { } -////} +////}|] // @Filename: referencesForGlobals_2.ts ////var c = [|globalClass|](); -verify.singleReferenceGroup("class globalClass"); +verify.singleReferenceGroup("class globalClass", "globalClass"); diff --git a/tests/cases/fourslash/referencesForGlobals3.ts b/tests/cases/fourslash/referencesForGlobals3.ts index 38edddc82557f..76c7f4d54e319 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 [|{| "isWriteAccess": true, "isDefinition": true |}globalInterface|] { +////[|interface [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}globalInterface|] { //// f(); -////} +////}|] // @Filename: referencesForGlobals_2.ts ////var i: [|globalInterface|]; -verify.singleReferenceGroup("interface globalInterface"); +verify.singleReferenceGroup("interface globalInterface", "globalInterface"); diff --git a/tests/cases/fourslash/referencesForGlobals4.ts b/tests/cases/fourslash/referencesForGlobals4.ts index b8356461699be..3ce0bf541a9aa 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 [|{| "isWriteAccess": true, "isDefinition": true |}globalModule|] { +////[|module [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}globalModule|] { //// export f() { }; -////} +////}|] // @Filename: referencesForGlobals_2.ts ////var m = [|globalModule|]; -verify.singleReferenceGroup("namespace globalModule"); +verify.singleReferenceGroup("namespace globalModule", "globalModule"); diff --git a/tests/cases/fourslash/referencesForGlobals5.ts b/tests/cases/fourslash/referencesForGlobals5.ts index 0d205b4b9b2b9..b0be1609cf829 100644 --- a/tests/cases/fourslash/referencesForGlobals5.ts +++ b/tests/cases/fourslash/referencesForGlobals5.ts @@ -7,9 +7,9 @@ //// export var x; ////} //// -////import [|{| "isWriteAccess": true, "isDefinition": true |}globalAlias|] = globalModule; +////[|import [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}globalAlias|] = globalModule;|] // @Filename: referencesForGlobals_2.ts ////var m = [|globalAlias|]; -verify.singleReferenceGroup("(alias) namespace globalAlias\nimport globalAlias = globalModule"); +verify.singleReferenceGroup("(alias) namespace globalAlias\nimport globalAlias = globalModule", "globalAlias"); diff --git a/tests/cases/fourslash/referencesForGlobalsInExternalModule.ts b/tests/cases/fourslash/referencesForGlobalsInExternalModule.ts index 7bfbb0ff8810b..3c3af49a38230 100644 --- a/tests/cases/fourslash/referencesForGlobalsInExternalModule.ts +++ b/tests/cases/fourslash/referencesForGlobalsInExternalModule.ts @@ -2,27 +2,23 @@ // Global variable reference. -////var [|{| "isWriteAccess": true, "isDefinition": true |}topLevelVar|] = 2; +////[|var [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}topLevelVar|] = 2;|] ////var topLevelVar2 = [|topLevelVar|]; //// -////class [|{| "isWriteAccess": true, "isDefinition": true |}topLevelClass|] { } +////[|class [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 3 |}topLevelClass|] { }|] ////var c = new [|topLevelClass|](); //// -////interface [|{| "isWriteAccess": true, "isDefinition": true |}topLevelInterface|] { } +////[|interface [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 6 |}topLevelInterface|] { }|] ////var i: [|topLevelInterface|]; //// -////module [|{| "isWriteAccess": true, "isDefinition": true |}topLevelModule|] { +////[|module [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 9 |}topLevelModule|] { //// export var x; -////} +////}|] ////var x = [|topLevelModule|].x; //// ////export = x; -const ranges = test.rangesByText(); -verify.singleReferenceGroup("var topLevelVar: number", ranges.get("topLevelVar")); - -const topLevelClass = ranges.get("topLevelClass"); -verify.singleReferenceGroup("class topLevelClass", topLevelClass); - -verify.singleReferenceGroup("interface topLevelInterface", ranges.get("topLevelInterface")); -verify.singleReferenceGroup("namespace topLevelModule", ranges.get("topLevelModule")); +verify.singleReferenceGroup("var topLevelVar: number", "topLevelVar"); +verify.singleReferenceGroup("class topLevelClass", "topLevelClass"); +verify.singleReferenceGroup("interface topLevelInterface", "topLevelInterface"); +verify.singleReferenceGroup("namespace topLevelModule", "topLevelModule"); diff --git a/tests/cases/fourslash/referencesForIllegalAssignment.ts b/tests/cases/fourslash/referencesForIllegalAssignment.ts index f65cd5bf1a6f8..e96b969de30c8 100644 --- a/tests/cases/fourslash/referencesForIllegalAssignment.ts +++ b/tests/cases/fourslash/referencesForIllegalAssignment.ts @@ -2,7 +2,7 @@ ////f/*1*/oo = fo/*2*/o; -////var [|{| "isWriteAccess": true, "isDefinition": true |}bar|] = function () { }; +////[|var [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}bar|] = function () { };|] ////[|{| "isWriteAccess": true |}bar|] = [|bar|] + 1; goTo.marker("1"); @@ -11,4 +11,4 @@ verify.noReferences(); goTo.marker("2"); verify.noReferences(); -verify.singleReferenceGroup("var bar: () => void"); +verify.singleReferenceGroup("var bar: () => void", "bar"); diff --git a/tests/cases/fourslash/referencesForImports.ts b/tests/cases/fourslash/referencesForImports.ts index 54cbb0f115582..ed9ec91b6f8a0 100644 --- a/tests/cases/fourslash/referencesForImports.ts +++ b/tests/cases/fourslash/referencesForImports.ts @@ -5,11 +5,11 @@ //// export = $; ////} -////import [|{| "isWriteAccess": true, "isDefinition": true |}$|] = require("jquery"); +////[|import [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}$|] = require("jquery");|] ////[|$|]("a"); -////import [|{| "isWriteAccess": true, "isDefinition": true |}$|] = require("jquery"); +////[|import [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 3 |}$|] = require("jquery");|] -const [r0, r1, r2] = test.ranges(); +const [r0Def, r0, r1, r2Def, r2] = test.ranges(); 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 4bc0b3620ea67..6c5abf442002a 100644 --- a/tests/cases/fourslash/referencesForIndexProperty.ts +++ b/tests/cases/fourslash/referencesForIndexProperty.ts @@ -3,14 +3,13 @@ // References a class property using string index access ////class Foo { -//// [|{| "isDefinition": true |}property|]: number; -//// [|{| "isWriteAccess": true, "isDefinition": true |}method|](): void { } +//// [|[|{| "isDefinition": true, "contextRangeIndex": 0 |}property|]: number;|] +//// [|[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 2 |}method|](): void { }|] ////} //// ////var f: Foo; ////f["[|property|]"]; ////f["[|method|]"]; -const ranges = test.rangesByText(); -verify.singleReferenceGroup("(property) Foo.property: number", ranges.get("property")); -verify.singleReferenceGroup("(method) Foo.method(): void", ranges.get("method")); +verify.singleReferenceGroup("(property) Foo.property: number", "property"); +verify.singleReferenceGroup("(method) Foo.method(): void", "method"); diff --git a/tests/cases/fourslash/referencesForIndexProperty3.ts b/tests/cases/fourslash/referencesForIndexProperty3.ts index 69417700ed07c..4cb763baec140 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 { -//// [|{| "isDefinition": true |}toMyString|](); +//// [|[|{| "isDefinition": true, "contextRangeIndex": 0 |}toMyString|]();|] ////} //// ////var y: Object; @@ -12,4 +12,4 @@ ////var x = {}; ////x["[|toMyString|]"](); -verify.singleReferenceGroup("(method) Object.toMyString(): any"); +verify.singleReferenceGroup("(method) Object.toMyString(): any", "toMyString"); diff --git a/tests/cases/fourslash/referencesForInheritedProperties.ts b/tests/cases/fourslash/referencesForInheritedProperties.ts index 88d7ea7537db3..10b24aeef392a 100644 --- a/tests/cases/fourslash/referencesForInheritedProperties.ts +++ b/tests/cases/fourslash/referencesForInheritedProperties.ts @@ -1,17 +1,17 @@ /// ////interface interface1 { -//// [|{| "isDefinition": true |}doStuff|](): void; +//// [|[|{| "isDefinition": true, "contextRangeIndex": 0 |}doStuff|](): void;|] ////} //// ////interface interface2 extends interface1{ -//// [|{| "isDefinition": true |}doStuff|](): void; +//// [|[|{| "isDefinition": true, "contextRangeIndex": 2 |}doStuff|](): void;|] ////} //// ////class class1 implements interface2 { -//// [|{| "isWriteAccess": true, "isDefinition": true |}doStuff|]() { +//// [|[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 4 |}doStuff|]() { //// -//// } +//// }|] ////} //// ////class class2 extends class1 { @@ -21,9 +21,8 @@ ////var v: class2; ////v.[|doStuff|](); -const ranges = test.ranges(); -const [r0, r1, r2, r3] = ranges; -verify.referenceGroups(ranges, [ +const [r0Def, r0, r1Def, r1, r2Def, r2, r3] = test.ranges(); +verify.referenceGroups([r0, r1, r2, r3], [ { definition: "(method) interface1.doStuff(): void", ranges: [r0] }, { definition: "(method) interface2.doStuff(): void", ranges: [r1] }, { definition: "(method) class1.doStuff(): void", ranges: [r2, r3] } diff --git a/tests/cases/fourslash/referencesForInheritedProperties2.ts b/tests/cases/fourslash/referencesForInheritedProperties2.ts index 712c7f2ecf255..d6b5d25af1484 100644 --- a/tests/cases/fourslash/referencesForInheritedProperties2.ts +++ b/tests/cases/fourslash/referencesForInheritedProperties2.ts @@ -3,20 +3,20 @@ // extends statement in a diffrent declaration ////interface interface1 { -//// [|{| "isDefinition": true |}doStuff|](): void; +//// [|[|{| "isDefinition": true, "contextRangeIndex": 0 |}doStuff|](): void;|] ////} //// ////interface interface2 { -//// [|{| "isDefinition": true |}doStuff|](): void; +//// [|[|{| "isDefinition": true, "contextRangeIndex": 2 |}doStuff|](): void;|] ////} //// ////interface interface2 extends interface1 { ////} //// ////class class1 implements interface2 { -//// [|{| "isWriteAccess": true, "isDefinition": true |}doStuff|]() { +//// [|[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 4 |}doStuff|]() { //// -//// } +//// }|] ////} //// ////class class2 extends class1 { @@ -26,9 +26,8 @@ ////var v: class2; ////v.[|doStuff|](); -const ranges = test.ranges(); -const [r0, r1, r2, r3] = ranges; -verify.referenceGroups(ranges, [ +const [r0Def, r0, r1Def, r1, r2Def, r2, r3] = test.ranges(); +verify.referenceGroups([r0, r1, r2, r3], [ { definition: "(method) interface1.doStuff(): void", ranges: [r0] }, { definition: "(method) interface2.doStuff(): void", ranges: [r1] }, { definition: "(method) class1.doStuff(): void", ranges: [r2, r3] } diff --git a/tests/cases/fourslash/referencesForInheritedProperties3.ts b/tests/cases/fourslash/referencesForInheritedProperties3.ts index 0eabc6cda9e59..3cff5ac7e9902 100644 --- a/tests/cases/fourslash/referencesForInheritedProperties3.ts +++ b/tests/cases/fourslash/referencesForInheritedProperties3.ts @@ -1,14 +1,13 @@ /// //// interface interface1 extends interface1 { -//// [|{| "isDefinition": true |}doStuff|](): void; -//// [|{| "isDefinition": true |}propName|]: string; +//// [|[|{| "isDefinition": true, "contextRangeIndex": 0 |}doStuff|](): void;|] +//// [|[|{| "isDefinition": true, "contextRangeIndex": 2 |}propName|]: string;|] //// } //// //// var v: interface1; //// v.[|propName|]; //// v.[|doStuff|](); -const ranges = test.rangesByText(); -verify.singleReferenceGroup("(method) interface1.doStuff(): void", ranges.get("doStuff")); -verify.singleReferenceGroup("(property) interface1.propName: string", ranges.get("propName")); +verify.singleReferenceGroup("(method) interface1.doStuff(): void", "doStuff"); +verify.singleReferenceGroup("(property) interface1.propName: string", "propName"); diff --git a/tests/cases/fourslash/referencesForInheritedProperties4.ts b/tests/cases/fourslash/referencesForInheritedProperties4.ts index f6a7d48f9d1bf..7e2ec51421317 100644 --- a/tests/cases/fourslash/referencesForInheritedProperties4.ts +++ b/tests/cases/fourslash/referencesForInheritedProperties4.ts @@ -1,15 +1,13 @@ /// //// class class1 extends class1 { -//// [|{| "isWriteAccess": true, "isDefinition": true |}doStuff|]() { } -//// [|{| "isDefinition": true |}propName|]: string; +//// [|[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}doStuff|]() { }|] +//// [|[|{| "isDefinition": true, "contextRangeIndex": 2 |}propName|]: string;|] //// } //// //// var c: class1; //// c.[|doStuff|](); //// c.[|propName|]; -const ranges = test.rangesByText(); -const [r0, r1] = ranges.get("doStuff"); -verify.singleReferenceGroup("(method) class1.doStuff(): void", ranges.get("doStuff")); -verify.singleReferenceGroup("(property) class1.propName: string", ranges.get("propName")); +verify.singleReferenceGroup("(method) class1.doStuff(): void", "doStuff"); +verify.singleReferenceGroup("(property) class1.propName: string", "propName"); diff --git a/tests/cases/fourslash/referencesForInheritedProperties5.ts b/tests/cases/fourslash/referencesForInheritedProperties5.ts index 232b654c63f20..d1d5019af806f 100644 --- a/tests/cases/fourslash/referencesForInheritedProperties5.ts +++ b/tests/cases/fourslash/referencesForInheritedProperties5.ts @@ -1,12 +1,12 @@ /// //// interface interface1 extends interface1 { -//// [|{| "isDefinition": true |}doStuff|](): void; -//// [|{| "isDefinition": true |}propName|]: string; +//// [|[|{| "isDefinition": true, "contextRangeIndex": 0 |}doStuff|](): void;|] +//// [|[|{| "isDefinition": true, "contextRangeIndex": 2 |}propName|]: string;|] //// } //// interface interface2 extends interface1 { -//// [|{| "isDefinition": true |}doStuff|](): void; -//// [|{| "isDefinition": true |}propName|]: string; +//// [|[|{| "isDefinition": true, "contextRangeIndex": 4 |}doStuff|](): void;|] +//// [|[|{| "isDefinition": true, "contextRangeIndex": 6 |}propName|]: string;|] //// } //// //// var v: interface1; diff --git a/tests/cases/fourslash/referencesForInheritedProperties6.ts b/tests/cases/fourslash/referencesForInheritedProperties6.ts index a84a6a0b2961a..40e17136a1d1a 100644 --- a/tests/cases/fourslash/referencesForInheritedProperties6.ts +++ b/tests/cases/fourslash/referencesForInheritedProperties6.ts @@ -1,18 +1,17 @@ /// ////class class1 extends class1 { -//// [|{| "isWriteAccess": true, "isDefinition": true |}doStuff|]() { } +//// [|[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}doStuff|]() { }|] ////} ////class class2 extends class1 { -//// [|{| "isWriteAccess": true, "isDefinition": true |}doStuff|]() { } +//// [|[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 2 |}doStuff|]() { }|] ////} //// ////var v: class2; ////v.[|doStuff|](); -const ranges = test.ranges(); -const [m0, m1, m2] = ranges; -verify.referenceGroups(ranges, [ +const [m0Def, m0, m1Def, m1, m2] = test.ranges(); +verify.referenceGroups([m0, m1, m2], [ { definition: "(method) class1.doStuff(): void", ranges: [m0] }, { definition: "(method) class2.doStuff(): void", ranges: [m1, m2] } ]); diff --git a/tests/cases/fourslash/referencesForInheritedProperties7.ts b/tests/cases/fourslash/referencesForInheritedProperties7.ts index 25402d36b6e0a..c10548c9a8a7b 100644 --- a/tests/cases/fourslash/referencesForInheritedProperties7.ts +++ b/tests/cases/fourslash/referencesForInheritedProperties7.ts @@ -1,23 +1,23 @@ /// //// class class1 extends class1 { -//// [|{| "isWriteAccess": true, "isDefinition": true |}doStuff|]() { } -//// [|{| "isDefinition": true |}propName|]: string; +//// [|[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}doStuff|]() { }|] +//// [|[|{| "isDefinition": true, "contextRangeIndex": 2 |}propName|]: string;|] //// } //// interface interface1 extends interface1 { -//// [|{| "isDefinition": true |}doStuff|](): void; -//// [|{| "isDefinition": true |}propName|]: string; +//// [|[|{| "isDefinition": true, "contextRangeIndex": 4 |}doStuff|](): void;|] +//// [|[|{| "isDefinition": true, "contextRangeIndex": 6 |}propName|]: string;|] //// } //// class class2 extends class1 implements interface1 { -//// [|{| "isWriteAccess": true, "isDefinition": true |}doStuff|]() { } -//// [|{| "isDefinition": true |}propName|]: string; +//// [|[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 8 |}doStuff|]() { }|] +//// [|[|{| "isDefinition": true, "contextRangeIndex": 10 |}propName|]: string;|] //// } //// //// var v: class2; //// v.[|doStuff|](); //// v.[|propName|]; -const [r0, r1, r2, r3, r4, r5, r6, r7] = test.ranges(); +const [r0Def, r0, r1Def, r1, r2Def, r2, r3Def, r3, r4Def, r4, r5Def, r5, r6, r7] = test.ranges(); const c1DoStuff = { definition: "(method) class1.doStuff(): void", ranges: [r0] }; const c2DoStuff = { definition: "(method) class2.doStuff(): void", ranges: [r4, r6] }; const c1PropName = { definition: "(property) class1.propName: string", ranges: [r1] }; diff --git a/tests/cases/fourslash/referencesForInheritedProperties8.ts b/tests/cases/fourslash/referencesForInheritedProperties8.ts index 331a90f91818c..fef6e41e0a497 100644 --- a/tests/cases/fourslash/referencesForInheritedProperties8.ts +++ b/tests/cases/fourslash/referencesForInheritedProperties8.ts @@ -1,17 +1,17 @@ /// //// interface C extends D { -//// [|{| "isDefinition": true |}propD|]: number; +//// [|[|{| "isDefinition": true, "contextRangeIndex": 0 |}propD|]: number;|] //// } //// interface D extends C { -//// [|{| "isDefinition": true |}propD|]: string; -//// [|{| "isDefinition": true |}propC|]: number; +//// [|[|{| "isDefinition": true, "contextRangeIndex": 2 |}propD|]: string;|] +//// [|[|{| "isDefinition": true, "contextRangeIndex": 4 |}propC|]: number;|] //// } //// var d: D; //// d.[|propD|]; //// d.[|propC|]; -const [d0, d1, c0, d2, c1] = test.ranges(); +const [d0Def, d0, d1Def, d1, c0Def, c0, d2, c1] = test.ranges(); verify.referenceGroups([d0, d1, d2], [ { definition: "(property) C.propD: number", ranges: [d0] }, { definition: "(property) D.propD: string", ranges: [d1, d2] }, diff --git a/tests/cases/fourslash/referencesForInheritedProperties9.ts b/tests/cases/fourslash/referencesForInheritedProperties9.ts index 3648be2f98949..941d286f86d56 100644 --- a/tests/cases/fourslash/referencesForInheritedProperties9.ts +++ b/tests/cases/fourslash/referencesForInheritedProperties9.ts @@ -1,16 +1,16 @@ /// //// class D extends C { -//// [|{| "isDefinition": true |}prop1|]: string; +//// [|[|{| "isDefinition": true, "contextRangeIndex": 0 |}prop1|]: string;|] //// } //// //// class C extends D { -//// [|{| "isDefinition": true |}prop1|]: string; +//// [|[|{| "isDefinition": true, "contextRangeIndex": 2 |}prop1|]: string;|] //// } //// //// var c: C; //// c.[|prop1|]; -const [r0, r1, r2] = test.ranges(); +const [r0Def, r0, r1Def, r1, r2] = test.ranges(); 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 1abcafda0f264..c7ee984b6a719 100644 --- a/tests/cases/fourslash/referencesForLabel.ts +++ b/tests/cases/fourslash/referencesForLabel.ts @@ -2,14 +2,14 @@ // Valid References for a label -////[|label|]: while (true) { -//// if (false) break [|label|]; -//// if (true) continue [|label|]; -////} +////[|[|{| "contextRangeIndex": 0 |}label|]: while (true) { +//// if (false) [|break [|{| "contextRangeIndex": 2 |}label|];|] +//// if (true) [|continue [|{| "contextRangeIndex": 4 |}label|];|] +////}|] //// -////[|label|]: while (false) { } +////[|[|{| "contextRangeIndex": 6 |}label|]: while (false) { }|] ////var label = "label"; -const [r0, r1, r2, r3] = test.ranges(); +const [r0Def, r0, r1Def, r1, r2Def, r2, r3Def, r3] = test.ranges(); verify.singleReferenceGroup("label", [r0, r1, r2]); verify.singleReferenceGroup("label", [r3]); diff --git a/tests/cases/fourslash/referencesForLabel3.ts b/tests/cases/fourslash/referencesForLabel3.ts index 13622eb90c3b9..4d666aff632e4 100644 --- a/tests/cases/fourslash/referencesForLabel3.ts +++ b/tests/cases/fourslash/referencesForLabel3.ts @@ -2,8 +2,8 @@ // References to unused label -////[|label|]: while (true) { +////[|[|{| "contextRangeIndex": 0 |}label|]: while (true) { //// var label = "label"; -////} +////}|] -verify.singleReferenceGroup("label"); +verify.singleReferenceGroup("label", "label"); diff --git a/tests/cases/fourslash/referencesForLabel4.ts b/tests/cases/fourslash/referencesForLabel4.ts index 2ff159bc755c2..4cf8bf2baf75f 100644 --- a/tests/cases/fourslash/referencesForLabel4.ts +++ b/tests/cases/fourslash/referencesForLabel4.ts @@ -2,10 +2,10 @@ // References to a label outside function bounderies -////[|label|]: function foo(label) { +////[|[|{| "contextRangeIndex": 0 |}label|]: function foo(label) { //// while (true) { -//// break [|label|]; +//// [|break [|{| "contextRangeIndex": 2 |}label|];|] //// } -////} +////}|] -verify.singleReferenceGroup("label"); +verify.singleReferenceGroup("label", "label"); diff --git a/tests/cases/fourslash/referencesForLabel5.ts b/tests/cases/fourslash/referencesForLabel5.ts index bc986e3350ddf..923c0be9c724b 100644 --- a/tests/cases/fourslash/referencesForLabel5.ts +++ b/tests/cases/fourslash/referencesForLabel5.ts @@ -2,16 +2,16 @@ // References to shadowed label -////[|label|]: while (true) { -//// if (false) break [|label|]; +////[|[|{| "contextRangeIndex": 0 |}label|]: while (true) { +//// if (false) [|break [|{| "contextRangeIndex": 2 |}label|];|] //// function blah() { -////[|label|]: while (true) { -//// if (false) break [|label|]; -//// } +////[|[|{| "contextRangeIndex": 4 |}label|]: while (true) { +//// if (false) [|break [|{| "contextRangeIndex": 6 |}label|];|] +//// }|] //// } -//// if (false) break [|label|]; -//// } +//// if (false) [|break [|{| "contextRangeIndex": 8 |}label|];|] +//// }|] -const [outer1, outer2, inner1, inner2, outer3] = test.ranges(); +const [ourter1Def, outer1, outer2Def, outer2, inner1Def, inner1, inner2Def, inner2, outer3Def, outer3] = test.ranges(); 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 0255c07943c1c..0fbc468fc92a7 100644 --- a/tests/cases/fourslash/referencesForLabel6.ts +++ b/tests/cases/fourslash/referencesForLabel6.ts @@ -2,11 +2,10 @@ // References to labels with close names -////[|labela|]: while (true) { -////[|labelb|]: while (false) { break [|labelb|]; } +////[|[|{| "contextRangeIndex": 0 |}labela|]: while (true) { +////[|[|{| "contextRangeIndex": 2 |}labelb|]: while (false) { [|break [|{| "contextRangeIndex": 4 |}labelb|];|] }|] //// break labelc; -////} +////}|] -const ranges = test.rangesByText(); -verify.singleReferenceGroup("labela", ranges.get("labela")); -verify.singleReferenceGroup("labelb", ranges.get("labelb")); +verify.singleReferenceGroup("labela", "labela"); +verify.singleReferenceGroup("labelb", "labelb"); diff --git a/tests/cases/fourslash/referencesForMergedDeclarations.ts b/tests/cases/fourslash/referencesForMergedDeclarations.ts index 5346a85f24f82..22d17342afd41 100644 --- a/tests/cases/fourslash/referencesForMergedDeclarations.ts +++ b/tests/cases/fourslash/referencesForMergedDeclarations.ts @@ -1,20 +1,20 @@ /// -////interface [|{| "isWriteAccess": true, "isDefinition": true |}Foo|] { -////} +////[|interface [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}Foo|] { +////}|] //// -////module [|{| "isWriteAccess": true, "isDefinition": true |}Foo|] { +////[|module [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 2 |}Foo|] { //// export interface Bar { } -////} +////}|] //// -////function [|{| "isWriteAccess": true, "isDefinition": true |}Foo|](): void { -////} +////[|function [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 4 |}Foo|](): void { +////}|] //// ////var f1: [|Foo|].Bar; ////var f2: [|Foo|]; ////[|Foo|].bind(this); -const [type1, namespace1, value1, namespace2, type2, value2] = test.ranges(); +const [type1Def, type1, namespace1Def, namespace1, value1Def, value1, namespace2, type2, value2] = test.ranges(); verify.singleReferenceGroup("interface Foo\nnamespace Foo", [type1, type2]); verify.singleReferenceGroup("namespace Foo", [namespace1, namespace2]); verify.singleReferenceGroup("namespace Foo\nfunction Foo(): void", [value1, value2]); diff --git a/tests/cases/fourslash/referencesForMergedDeclarations2.ts b/tests/cases/fourslash/referencesForMergedDeclarations2.ts index 1a4bc59c9b2e0..f590c321385d1 100644 --- a/tests/cases/fourslash/referencesForMergedDeclarations2.ts +++ b/tests/cases/fourslash/referencesForMergedDeclarations2.ts @@ -6,7 +6,7 @@ //// ////function ATest() { } //// -////import [|{| "isWriteAccess": true, "isDefinition": true |}alias|] = ATest; // definition +////[|import [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}alias|] = ATest;|] // definition //// ////var a: [|alias|].Bar; // namespace ////[|alias|].call(this); // value @@ -15,4 +15,4 @@ verify.singleReferenceGroup([ "(alias) function alias(): void", "(alias) namespace alias", "import alias = ATest" -].join("\n")); +].join("\n"), "alias"); diff --git a/tests/cases/fourslash/referencesForMergedDeclarations3.ts b/tests/cases/fourslash/referencesForMergedDeclarations3.ts index 27c442b5bccf8..8f14222394915 100644 --- a/tests/cases/fourslash/referencesForMergedDeclarations3.ts +++ b/tests/cases/fourslash/referencesForMergedDeclarations3.ts @@ -2,16 +2,16 @@ // class and uninstantiated module -////class [|{| "isWriteAccess": true, "isDefinition": true |}testClass|] { +////[|class [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}testClass|] { //// static staticMethod() { } //// method() { } -////} +////}|] //// -////module [|{| "isWriteAccess": true, "isDefinition": true |}testClass|] { +////[|module [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 2 |}testClass|] { //// export interface Bar { //// //// } -////} +////}|] //// ////var c1: [|testClass|]; ////var c2: [|testClass|].Bar; @@ -20,7 +20,7 @@ ////[|testClass|].bind(this); ////new [|testClass|](); -const [class0, module0, class1, module1, class2, class3, class4, class5] = test.ranges(); +const [class0Def, class0, module0Def, module0, class1, module1, class2, class3, class4, class5] = test.ranges(); verify.singleReferenceGroup("class testClass\nnamespace testClass", [module0, module1]); const classes = [class0, class1, class2, class3, class4, class5]; verify.referenceGroups(classes, [{ definition: "class testClass\nnamespace testClass", ranges: classes }]); diff --git a/tests/cases/fourslash/referencesForMergedDeclarations4.ts b/tests/cases/fourslash/referencesForMergedDeclarations4.ts index 1418912019717..63dc543b9d2f4 100644 --- a/tests/cases/fourslash/referencesForMergedDeclarations4.ts +++ b/tests/cases/fourslash/referencesForMergedDeclarations4.ts @@ -2,17 +2,17 @@ // class and instantiated module -////class [|{| "isWriteAccess": true, "isDefinition": true |}testClass|] { +////[|class [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}testClass|] { //// static staticMethod() { } //// method() { } -////} +////}|] //// -////module [|{| "isWriteAccess": true, "isDefinition": true |}testClass|] { +////[|module [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 2 |}testClass|] { //// export interface Bar { //// //// } //// export var s = 0; -////} +////}|] //// ////var c1: [|testClass|]; ////var c2: [|testClass|].Bar; @@ -22,4 +22,4 @@ ////[|testClass|].s; ////new [|testClass|](); -verify.singleReferenceGroup("class testClass\nnamespace testClass"); +verify.singleReferenceGroup("class testClass\nnamespace testClass", "testClass"); diff --git a/tests/cases/fourslash/referencesForMergedDeclarations5.ts b/tests/cases/fourslash/referencesForMergedDeclarations5.ts index 40b43eb68195f..241a097d6a2c1 100644 --- a/tests/cases/fourslash/referencesForMergedDeclarations5.ts +++ b/tests/cases/fourslash/referencesForMergedDeclarations5.ts @@ -1,14 +1,14 @@ /// -////interface [|{| "isWriteAccess": true, "isDefinition": true |}Foo|] { } -////module [|{| "isWriteAccess": true, "isDefinition": true |}Foo|] { export interface Bar { } } -////function [|{| "isWriteAccess": true, "isDefinition": true |}Foo|]() { } +////[|interface [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}Foo|] { }|] +////[|module [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 2 |}Foo|] { export interface Bar { } }|] +////[|function [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 4 |}Foo|]() { }|] //// -////export = [|Foo|]; +////[|export = [|{| "contextRangeIndex": 6 |}Foo|];|] const ranges = test.ranges(); -const [r0, r1, r2, r3] = ranges; +const [r0Def, r0, r1Def, r1, r2Def, r2, r3Def, r3] = ranges; verify.referenceGroups(r0, [{ definition: "interface Foo\nnamespace Foo", ranges: [r0, r3] }]); verify.referenceGroups(r1, [{ definition: "namespace Foo", ranges: [r1, r3] }]); verify.referenceGroups(r2, [{ definition: "namespace Foo\nfunction Foo(): void", ranges: [r2, r3] }]); -verify.referenceGroups(r3, [{ definition: "interface Foo\nnamespace Foo\nfunction Foo(): void", ranges }]); +verify.referenceGroups(r3, [{ definition: "interface Foo\nnamespace Foo\nfunction Foo(): void", ranges: [r0, r1, r2, r3] }]); diff --git a/tests/cases/fourslash/referencesForMergedDeclarations6.ts b/tests/cases/fourslash/referencesForMergedDeclarations6.ts index 79ee0128ab602..1557fdb7201c5 100644 --- a/tests/cases/fourslash/referencesForMergedDeclarations6.ts +++ b/tests/cases/fourslash/referencesForMergedDeclarations6.ts @@ -1,13 +1,13 @@ /// ////interface Foo { } -////module [|{| "isWriteAccess": true, "isDefinition": true |}Foo|] { +////[|module [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}Foo|] { //// export interface Bar { } //// export module Bar { export interface Baz { } } //// export function Bar() { } -////} +////}|] //// ////// module ////import a1 = [|Foo|]; -verify.singleReferenceGroup("namespace Foo"); +verify.singleReferenceGroup("namespace Foo", "Foo"); diff --git a/tests/cases/fourslash/referencesForMergedDeclarations7.ts b/tests/cases/fourslash/referencesForMergedDeclarations7.ts index c119992c8bc4c..695e7bef05049 100644 --- a/tests/cases/fourslash/referencesForMergedDeclarations7.ts +++ b/tests/cases/fourslash/referencesForMergedDeclarations7.ts @@ -2,17 +2,17 @@ ////interface Foo { } ////module Foo { -//// export interface [|{| "isWriteAccess": true, "isDefinition": true |}Bar|] { } -//// export module [|{| "isWriteAccess": true, "isDefinition": true |}Bar|] { export interface Baz { } } -//// export function [|{| "isWriteAccess": true, "isDefinition": true |}Bar|]() { } +//// [|export interface [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}Bar|] { }|] +//// [|export module [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 2 |}Bar|] { export interface Baz { } }|] +//// [|export function [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 4 |}Bar|]() { }|] ////} //// ////// module, value and type ////import a2 = Foo.[|Bar|]; const ranges = test.ranges(); -const [r0, r1, r2, r3] = ranges; +const [r0Def, r0, r1Def, r1, r2Def, r2, r3] = ranges; verify.referenceGroups(r0, [{ definition: "interface Foo.Bar\nnamespace Foo.Bar", ranges: [r0, r3] }]); verify.referenceGroups(r1, [{ definition: "namespace Foo.Bar", ranges: [r1, r3] }]); verify.referenceGroups(r2, [{ definition: "namespace Foo.Bar\nfunction Foo.Bar(): void", ranges: [r2, r3] }]); -verify.referenceGroups(r3, [{ definition: "interface Foo.Bar\nnamespace Foo.Bar\nfunction Foo.Bar(): void", ranges }]); +verify.referenceGroups(r3, [{ definition: "interface Foo.Bar\nnamespace Foo.Bar\nfunction Foo.Bar(): void", ranges: [r0, r1, r2, r3] }]); diff --git a/tests/cases/fourslash/referencesForMergedDeclarations8.ts b/tests/cases/fourslash/referencesForMergedDeclarations8.ts index 4b4716c08a50d..7434fda95b4ef 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 [|{| "isWriteAccess": true, "isDefinition": true |}Bar|] { export interface Baz { } } +//// [|export module [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}Bar|] { export interface Baz { } }|] //// export function Bar() { } ////} //// ////// module ////import a3 = Foo.[|Bar|].Baz; -verify.singleReferenceGroup("namespace Foo.Bar"); +verify.singleReferenceGroup("namespace Foo.Bar", "Bar"); diff --git a/tests/cases/fourslash/referencesForNumericLiteralPropertyNames.ts b/tests/cases/fourslash/referencesForNumericLiteralPropertyNames.ts index 1f28714daa13e..153460912b58d 100644 --- a/tests/cases/fourslash/referencesForNumericLiteralPropertyNames.ts +++ b/tests/cases/fourslash/referencesForNumericLiteralPropertyNames.ts @@ -1,12 +1,12 @@ /// ////class Foo { -//// public [|{| "isDefinition": true |}12|]: any; +//// [|public [|{| "isDefinition": true, "contextRangeIndex": 0 |}12|]: any;|] ////} //// ////var x: Foo; ////x[[|12|]]; -////x = { "[|{| "isWriteAccess": true, "isDefinition": true |}12|]": 0 }; -////x = { [|{| "isWriteAccess": true, "isDefinition": true |}12|]: 0 }; +////x = { [|"[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 3 |}12|]": 0|] }; +////x = { [|[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 5 |}12|]: 0|] }; -verify.singleReferenceGroup("(property) Foo[12]: any"); +verify.singleReferenceGroup("(property) Foo[12]: any", "12"); diff --git a/tests/cases/fourslash/referencesForObjectLiteralProperties.ts b/tests/cases/fourslash/referencesForObjectLiteralProperties.ts index 804faaebe6e24..86e8cea583de7 100644 --- a/tests/cases/fourslash/referencesForObjectLiteralProperties.ts +++ b/tests/cases/fourslash/referencesForObjectLiteralProperties.ts @@ -2,10 +2,10 @@ // References to an object literal property -////var x = { [|{| "isWriteAccess": true, "isDefinition": true |}add|]: 0, b: "string" }; +////var x = { [|[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}add|]: 0|], b: "string" }; ////x["[|add|]"]; ////x.[|add|]; ////var y = x; ////y.[|add|]; -verify.singleReferenceGroup("(property) add: number"); +verify.singleReferenceGroup("(property) add: number", "add"); diff --git a/tests/cases/fourslash/referencesForOverrides.ts b/tests/cases/fourslash/referencesForOverrides.ts index d5d9ea0a6b653..e639ba0928114 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 [|{| "isWriteAccess": true, "isDefinition": true |}foo|](): void { -//// } +//// [|public [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}foo|](): void { +//// }|] //// } //// export class Bar extends Foo { -//// public [|{| "isWriteAccess": true, "isDefinition": true |}foo|](): void { -//// } +//// [|public [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 2 |}foo|](): void { +//// }|] //// } //// } //// //// module SimpleInterfaceTest { //// export interface IFoo { -//// [|{| "isDefinition": true |}ifoo|](): void; +//// [|[|{| "isDefinition": true, "contextRangeIndex": 4 |}ifoo|](): void;|] //// } //// export interface IBar extends IFoo { -//// [|{| "isDefinition": true |}ifoo|](): void; +//// [|[|{| "isDefinition": true, "contextRangeIndex": 6 |}ifoo|](): void;|] //// } //// } //// //// module SimpleClassInterfaceTest { //// export interface IFoo { -//// [|{| "isDefinition": true |}icfoo|](): void; +//// [|[|{| "isDefinition": true, "contextRangeIndex": 8 |}icfoo|](): void;|] //// } //// export class Bar implements IFoo { -//// public [|{| "isWriteAccess": true, "isDefinition": true |}icfoo|](): void { -//// } +//// [|public [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 10 |}icfoo|](): void { +//// }|] //// } //// } //// //// module Test { //// export interface IBase { -//// [|{| "isDefinition": true |}field|]: string; -//// [|{| "isDefinition": true |}method|](): void; +//// [|[|{| "isDefinition": true, "contextRangeIndex": 12 |}field|]: string;|] +//// [|[|{| "isDefinition": true, "contextRangeIndex": 14 |}method|](): void;|] //// } //// //// export interface IBlah extends IBase { -//// [|{| "isDefinition": true |}field|]: string; +//// [|[|{| "isDefinition": true, "contextRangeIndex": 16 |}field|]: string;|] //// } //// //// export interface IBlah2 extends IBlah { -//// [|{| "isDefinition": true |}field|]: string; +//// [|[|{| "isDefinition": true, "contextRangeIndex": 18 |}field|]: string;|] //// } //// //// export interface IDerived extends IBlah2 { -//// [|{| "isDefinition": true |}method|](): void; +//// [|[|{| "isDefinition": true, "contextRangeIndex": 20 |}method|](): void;|] //// } //// //// export class Bar implements IDerived { -//// public [|{| "isDefinition": true |}field|]: string; -//// public [|{| "isWriteAccess": true, "isDefinition": true |}method|](): void { } +//// [|public [|{| "isDefinition": true, "contextRangeIndex": 22 |}field|]: string;|] +//// [|public [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 24 |}method|](): void { }|] //// } //// //// export class BarBlah extends Bar { -//// public [|{| "isDefinition": true |}field|]: string; +//// [|public [|{| "isDefinition": true, "contextRangeIndex": 26 |}field|]: string;|] //// } //// } //// diff --git a/tests/cases/fourslash/referencesForPropertiesOfGenericType.ts b/tests/cases/fourslash/referencesForPropertiesOfGenericType.ts index be00bb7593f61..c7cc345970a1f 100644 --- a/tests/cases/fourslash/referencesForPropertiesOfGenericType.ts +++ b/tests/cases/fourslash/referencesForPropertiesOfGenericType.ts @@ -1,7 +1,7 @@ /// ////interface IFoo { -//// [|{| "isDefinition": true |}doSomething|](v: T): T; +//// [|[|{| "isDefinition": true, "contextRangeIndex": 0 |}doSomething|](v: T): T;|] ////} //// ////var x: IFoo; @@ -10,4 +10,4 @@ ////var y: IFoo; ////y.[|doSomething|](12); -verify.singleReferenceGroup("(method) IFoo.doSomething(v: T): T"); +verify.singleReferenceGroup("(method) IFoo.doSomething(v: T): T", "doSomething"); diff --git a/tests/cases/fourslash/referencesForStatic.ts b/tests/cases/fourslash/referencesForStatic.ts index 1c82d2fde6cfe..2571e37952825 100644 --- a/tests/cases/fourslash/referencesForStatic.ts +++ b/tests/cases/fourslash/referencesForStatic.ts @@ -6,7 +6,7 @@ ////var n = 43; //// ////class foo { -//// static [|{| "isWriteAccess": true, "isDefinition": true |}n|] = ''; +//// [|static [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}n|] = '';|] //// //// public bar() { //// foo.[|{| "isWriteAccess": true |}n|] = "'"; @@ -30,4 +30,4 @@ // @Filename: referencesOnStatic_2.ts ////var q = foo.[|n|]; -verify.singleReferenceGroup("(property) foo.n: string"); +verify.singleReferenceGroup("(property) foo.n: string", "n"); diff --git a/tests/cases/fourslash/referencesForStaticsAndMembersWithSameNames.ts b/tests/cases/fourslash/referencesForStaticsAndMembersWithSameNames.ts index 816b866421a67..655b4b9a30813 100644 --- a/tests/cases/fourslash/referencesForStaticsAndMembersWithSameNames.ts +++ b/tests/cases/fourslash/referencesForStaticsAndMembersWithSameNames.ts @@ -3,13 +3,13 @@ ////module FindRef4 { //// module MixedStaticsClassTest { //// export class Foo { -//// [|{| "isDefinition": true |}bar|]: Foo; -//// static [|{| "isDefinition": true |}bar|]: Foo; +//// [|[|{| "isDefinition": true, "contextRangeIndex": 0 |}bar|]: Foo;|] +//// [|static [|{| "isDefinition": true, "contextRangeIndex": 2 |}bar|]: Foo;|] //// -//// public [|{| "isWriteAccess": true, "isDefinition": true |}foo|](): void { -//// } -//// public static [|{| "isWriteAccess": true, "isDefinition": true |}foo|](): void { -//// } +//// [|public [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 4 |}foo|](): void { +//// }|] +//// [|public static [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 6 |}foo|](): void { +//// }|] //// } //// } //// @@ -25,7 +25,7 @@ //// } ////} -const [fooBar, fooStaticBar, fooFoo, fooStaticFoo, xFoo, xBar, staticFoo, staticBar] = test.ranges(); +const [fooBarDef, fooBar, fooStaticBarDef, fooStaticBar, fooFooDef, fooFoo, fooStaticFooDef, fooStaticFoo, xFoo, xBar, staticFoo, staticBar] = test.ranges(); // References to a member method with the same name as a static. verify.singleReferenceGroup("(method) MixedStaticsClassTest.Foo.foo(): void", [fooFoo, xFoo]); diff --git a/tests/cases/fourslash/referencesForStringLiteralPropertyNames.ts b/tests/cases/fourslash/referencesForStringLiteralPropertyNames.ts index 88c9a74bc6efb..b0497753f90dd 100644 --- a/tests/cases/fourslash/referencesForStringLiteralPropertyNames.ts +++ b/tests/cases/fourslash/referencesForStringLiteralPropertyNames.ts @@ -1,13 +1,13 @@ /// ////class Foo { -//// public "[|{| "isDefinition": true |}ss|]": any; +//// [|public "[|{| "isDefinition": true, "contextRangeIndex": 0 |}ss|]": any;|] ////} //// ////var x: Foo; ////x.[|ss|]; ////x["[|ss|]"]; -////x = { "[|{| "isWriteAccess": true, "isDefinition": true |}ss|]": 0 }; -////x = { [|{| "isWriteAccess": true, "isDefinition": true |}ss|]: 0 }; +////x = { [|"[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 4 |}ss|]": 0|] }; +////x = { [|[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 6 |}ss|]: 0|] }; -verify.singleReferenceGroup('(property) Foo["ss"]: any'); +verify.singleReferenceGroup('(property) Foo["ss"]: any', "ss"); diff --git a/tests/cases/fourslash/referencesForStringLiteralPropertyNames2.ts b/tests/cases/fourslash/referencesForStringLiteralPropertyNames2.ts index ce5d474b9dcbf..4402316c5a369 100644 --- a/tests/cases/fourslash/referencesForStringLiteralPropertyNames2.ts +++ b/tests/cases/fourslash/referencesForStringLiteralPropertyNames2.ts @@ -1,10 +1,10 @@ /// ////class Foo { -//// "[|{| "isWriteAccess": true, "isDefinition": true |}blah|]"() { return 0; } +//// [|"[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}blah|]"() { return 0; }|] ////} //// ////var x: Foo; ////x.[|blah|]; -verify.singleReferenceGroup('(method) Foo["blah"](): number'); +verify.singleReferenceGroup('(method) Foo["blah"](): number', "blah"); diff --git a/tests/cases/fourslash/referencesForStringLiteralPropertyNames3.ts b/tests/cases/fourslash/referencesForStringLiteralPropertyNames3.ts index 22fa6b30cbcc2..2ef57d19b5c82 100644 --- a/tests/cases/fourslash/referencesForStringLiteralPropertyNames3.ts +++ b/tests/cases/fourslash/referencesForStringLiteralPropertyNames3.ts @@ -1,11 +1,11 @@ /// ////class Foo2 { -//// get "[|{| "isWriteAccess": true, "isDefinition": true |}42|]"() { return 0; } -//// set [|{| "isWriteAccess": true, "isDefinition": true |}42|](n) { } +//// [|get "[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}42|]"() { return 0; }|] +//// [|set [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 2 |}42|](n) { }|] ////} //// ////var y: Foo2; ////y[[|42|]]; -verify.singleReferenceGroup('(property) Foo2["42"]: number'); +verify.singleReferenceGroup('(property) Foo2["42"]: number', "42"); \ No newline at end of file diff --git a/tests/cases/fourslash/referencesForStringLiteralPropertyNames4.ts b/tests/cases/fourslash/referencesForStringLiteralPropertyNames4.ts index a7589ba29a033..39fa5c7ec7d0c 100644 --- a/tests/cases/fourslash/referencesForStringLiteralPropertyNames4.ts +++ b/tests/cases/fourslash/referencesForStringLiteralPropertyNames4.ts @@ -1,10 +1,10 @@ /// -////var x = { "[|{| "isWriteAccess": true, "isDefinition": true |}someProperty|]": 0 } +////var x = { [|"[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}someProperty|]": 0|] } ////x["[|someProperty|]"] = 3; ////x.[|{| "isWriteAccess": true |}someProperty|] = 5; -const ranges = test.ranges(); +const [rDef, ...ranges] = test.ranges(); const [r0, r1, r2] = ranges; verify.referenceGroups(r0, [{ definition: '(property) "someProperty": number', ranges }]); verify.referenceGroups([r1, r2], [ diff --git a/tests/cases/fourslash/referencesForStringLiteralPropertyNames5.ts b/tests/cases/fourslash/referencesForStringLiteralPropertyNames5.ts index 22d35006c2583..a3fc6f7405c19 100644 --- a/tests/cases/fourslash/referencesForStringLiteralPropertyNames5.ts +++ b/tests/cases/fourslash/referencesForStringLiteralPropertyNames5.ts @@ -1,10 +1,10 @@ /// -////var x = { "[|{| "isWriteAccess": true, "isDefinition": true |}someProperty|]": 0 } +////var x = { [|"[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}someProperty|]": 0|] } ////x["[|someProperty|]"] = 3; ////x.[|{| "isWriteAccess": true, "isDefinition": false |}someProperty|] = 5; -const ranges = test.ranges(); +const [r0Def, ...ranges] = test.ranges(); const [r0, r1, r2] = ranges; verify.referenceGroups(r0, [{ definition: '(property) "someProperty": number', ranges }]); verify.referenceGroups([r1, r2], [ diff --git a/tests/cases/fourslash/referencesForStringLiteralPropertyNames7.ts b/tests/cases/fourslash/referencesForStringLiteralPropertyNames7.ts index 98a6dc2ac47f6..eac206f90de05 100644 --- a/tests/cases/fourslash/referencesForStringLiteralPropertyNames7.ts +++ b/tests/cases/fourslash/referencesForStringLiteralPropertyNames7.ts @@ -4,13 +4,13 @@ // @allowJs: true // @checkJs: true -////var x = { "[|{| "isWriteAccess": true, "isDefinition": true |}someProperty|]": 0 } +////var x = { [|"[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}someProperty|]": 0|] } ////x["[|someProperty|]"] = 3; -////x.[|{| "isWriteAccess": true, "isDefinition": true |}someProperty|] = 5; +////[|x.[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 3 |}someProperty|] = 5;|] -const ranges = test.ranges(); -const [r0, r1, r2] = ranges; +const [r0Def, r0, r1, r2Def, r2] = test.ranges(); +const ranges = [r0, r1, r2]; verify.referenceGroups(r0, [{ definition: '(property) "someProperty": number', ranges }]); verify.referenceGroups([r1, r2], [ - { definition: '(property) "someProperty": number', ranges: [r0, r1, r2] }, + { definition: '(property) "someProperty": number', ranges }, ]); diff --git a/tests/cases/fourslash/referencesForUnionProperties.ts b/tests/cases/fourslash/referencesForUnionProperties.ts index 7efff1aabd050..eaeccce41a197 100644 --- a/tests/cases/fourslash/referencesForUnionProperties.ts +++ b/tests/cases/fourslash/referencesForUnionProperties.ts @@ -1,16 +1,16 @@ /// ////interface One { -//// common: { [|{| "isDefinition": true |}a|]: number; }; +//// common: { [|[|{| "isDefinition": true, "contextRangeIndex": 0 |}a|]: number;|] }; ////} //// ////interface Base { -//// [|{| "isDefinition": true |}a|]: string; +//// [|[|{| "isDefinition": true, "contextRangeIndex": 2 |}a|]: string;|] //// b: string; ////} //// ////interface HasAOrB extends Base { -//// [|{| "isDefinition": true |}a|]: string; +//// [|[|{| "isDefinition": true, "contextRangeIndex": 4 |}a|]: string;|] //// b: string; ////} //// @@ -22,7 +22,7 @@ //// ////x.common.[|a|]; -const [one, base, hasAOrB, x] = test.ranges(); +const [oneDef, one, baseDef, base, hasAOrBDef, hasAOrB, x] = test.ranges(); verify.referenceGroups(one, [ { definition: "(property) a: number", ranges: [one] }, { definition: "(property) a: string | number", ranges: [x] }, diff --git a/tests/cases/fourslash/remoteGetReferences.ts b/tests/cases/fourslash/remoteGetReferences.ts index c9b8c3b4e2f7e..5636be5d242cf 100644 --- a/tests/cases/fourslash/remoteGetReferences.ts +++ b/tests/cases/fourslash/remoteGetReferences.ts @@ -119,12 +119,12 @@ ////}); // @Filename: remoteGetReferences_2.ts -////var [|{| "isWriteAccess": true, "isDefinition": true |}remoteglobalVar|]: number = 2; +////[|var [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 10 |}remoteglobalVar|]: number = 2;|] //// -////class [|{| "isWriteAccess": true, "isDefinition": true |}remotefooCls|] { +////[|class [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 12 |}remotefooCls|] { //// //Declare -//// [|{| "isWriteAccess": true, "isDefinition": true |}remoteclsVar|] = 1; -//// static [|{| "isWriteAccess": true, "isDefinition": true |}remoteclsSVar|] = 1; +//// [|[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 14 |}remoteclsVar|] = 1;|] +//// [|static [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 16 |}remoteclsSVar|] = 1;|] //// //// constructor(public remoteclsParam: number) { //// //Increments @@ -134,7 +134,7 @@ //// this.remoteclsParam++; //// remotemodTest.remotemodVar++; //// } -////} +////}|] //// ////function remotefoo(remotex: number) { //// //Declare @@ -178,6 +178,26 @@ ////} test.rangesByText().forEach((ranges, text) => { + // Definitions + if (text === "var remoteglobalVar: number = 2;" || + text === `class remotefooCls { + //Declare + remoteclsVar = 1; + static remoteclsSVar = 1; + + constructor(public remoteclsParam: number) { + //Increments + remoteglobalVar++; + this.remoteclsVar++; + remotefooCls.remoteclsSVar++; + this.remoteclsParam++; + remotemodTest.remotemodVar++; + } +}` || + text == "remoteclsVar = 1;" || + text === "static remoteclsSVar = 1;" + ) return; + const definition = (() => { switch (text) { case "remotefooCls": return "class remotefooCls"; diff --git a/tests/cases/fourslash/renameAcrossMultipleProjects.ts b/tests/cases/fourslash/renameAcrossMultipleProjects.ts index 2cc5824a8434b..dc497e8ee3a5f 100644 --- a/tests/cases/fourslash/renameAcrossMultipleProjects.ts +++ b/tests/cases/fourslash/renameAcrossMultipleProjects.ts @@ -1,7 +1,7 @@ /// //@Filename: a.ts -////var [|x|]: number; +////[|var [|{| "contextRangeIndex": 0 |}x|]: number;|] //@Filename: b.ts /////// @@ -11,4 +11,4 @@ /////// ////[|x|]++; -verify.rangesAreRenameLocations(); +verify.rangesWithSameTextAreRenameLocations("x"); diff --git a/tests/cases/fourslash/renameAlias.ts b/tests/cases/fourslash/renameAlias.ts index 3869b1522b5af..6ff2b87816fa2 100644 --- a/tests/cases/fourslash/renameAlias.ts +++ b/tests/cases/fourslash/renameAlias.ts @@ -1,7 +1,7 @@ /// ////module SomeModule { export class SomeClass { } } -////import [|M|] = SomeModule; +////[|import [|{| "contextRangeIndex": 0 |}M|] = SomeModule;|] ////import C = [|M|].SomeClass; -verify.rangesAreRenameLocations(); +verify.rangesWithSameTextAreRenameLocations("M"); diff --git a/tests/cases/fourslash/renameAlias2.ts b/tests/cases/fourslash/renameAlias2.ts index f97121f5f7dbc..60fb0eab3f475 100644 --- a/tests/cases/fourslash/renameAlias2.ts +++ b/tests/cases/fourslash/renameAlias2.ts @@ -1,7 +1,7 @@ /// -////module [|SomeModule|] { export class SomeClass { } } +////[|module [|{| "contextRangeIndex": 0 |}SomeModule|] { export class SomeClass { } }|] ////import M = [|SomeModule|]; ////import C = M.SomeClass; -verify.rangesAreRenameLocations(); \ No newline at end of file +verify.rangesWithSameTextAreRenameLocations("SomeModule"); \ No newline at end of file diff --git a/tests/cases/fourslash/renameAlias3.ts b/tests/cases/fourslash/renameAlias3.ts index af3bafef115b8..78e01f6b13b87 100644 --- a/tests/cases/fourslash/renameAlias3.ts +++ b/tests/cases/fourslash/renameAlias3.ts @@ -1,7 +1,7 @@ /// -////module SomeModule { export class [|SomeClass|] { } } +////module SomeModule { [|export class [|{| "contextRangeIndex": 0 |}SomeClass|] { }|] } ////import M = SomeModule; ////import C = M.[|SomeClass|]; -verify.rangesAreRenameLocations(); +verify.rangesWithSameTextAreRenameLocations("SomeClass"); diff --git a/tests/cases/fourslash/renameAliasExternalModule.ts b/tests/cases/fourslash/renameAliasExternalModule.ts index 49cc6396717a7..dc259a2ef5af8 100644 --- a/tests/cases/fourslash/renameAliasExternalModule.ts +++ b/tests/cases/fourslash/renameAliasExternalModule.ts @@ -5,7 +5,7 @@ ////export = SomeModule; // @Filename: b.ts -////import [|M|] = require("./a"); +////[|import [|{| "contextRangeIndex": 0 |}M|] = require("./a");|] ////import C = [|M|].SomeClass; -verify.rangesAreRenameLocations(); +verify.rangesWithSameTextAreRenameLocations("M"); diff --git a/tests/cases/fourslash/renameAliasExternalModule2.ts b/tests/cases/fourslash/renameAliasExternalModule2.ts index 8416d12f4b261..a78a616d6ef10 100644 --- a/tests/cases/fourslash/renameAliasExternalModule2.ts +++ b/tests/cases/fourslash/renameAliasExternalModule2.ts @@ -1,13 +1,13 @@ /// // @Filename: a.ts -////module [|SomeModule|] { export class SomeClass { } } -////export = [|SomeModule|]; +////[|module [|{| "contextRangeIndex": 0 |}SomeModule|] { export class SomeClass { } }|] +////[|export = [|{| "contextRangeIndex": 2 |}SomeModule|];|] // @Filename: b.ts -////import [|M|] = require("./a"); +////[|import [|{| "contextRangeIndex": 4 |}M|] = require("./a");|] ////import C = [|M|].SomeClass; -const [r0, r1, r2, r3] = test.ranges(); +const [r0Def, r0, r1Def, r1, r2Def, r2, r3] = test.ranges(); verify.rangesAreRenameLocations([r0, r1]); verify.rangesAreRenameLocations([r2, r3]); diff --git a/tests/cases/fourslash/renameAliasExternalModule3.ts b/tests/cases/fourslash/renameAliasExternalModule3.ts index 53b28e7983e9b..0aee598124c8c 100644 --- a/tests/cases/fourslash/renameAliasExternalModule3.ts +++ b/tests/cases/fourslash/renameAliasExternalModule3.ts @@ -1,11 +1,11 @@ /// // @Filename: a.ts -////module SomeModule { export class [|SomeClass|] { } } +////module SomeModule { [|export class [|{| "contextRangeIndex": 0 |}SomeClass|] { }|] } ////export = SomeModule; // @Filename: b.ts ////import M = require("./a"); ////import C = M.[|SomeClass|]; -verify.rangesAreRenameLocations(); +verify.rangesWithSameTextAreRenameLocations("SomeClass"); diff --git a/tests/cases/fourslash/renameCommentsAndStrings1.ts b/tests/cases/fourslash/renameCommentsAndStrings1.ts index cd350e3046cee..53cae40e72f15 100644 --- a/tests/cases/fourslash/renameCommentsAndStrings1.ts +++ b/tests/cases/fourslash/renameCommentsAndStrings1.ts @@ -2,9 +2,9 @@ /////// -////function [|Bar|]() { +////[|function [|{| "contextRangeIndex": 0 |}Bar|]() { //// // This is a reference to Bar in a comment. //// "this is a reference to Bar in a string" -////} +////}|] -verify.rangesAreRenameLocations(); +verify.rangesWithSameTextAreRenameLocations("Bar"); diff --git a/tests/cases/fourslash/renameCommentsAndStrings2.ts b/tests/cases/fourslash/renameCommentsAndStrings2.ts index e31c3b7690003..8d088759b0756 100644 --- a/tests/cases/fourslash/renameCommentsAndStrings2.ts +++ b/tests/cases/fourslash/renameCommentsAndStrings2.ts @@ -2,10 +2,10 @@ /////// -////function [|Bar|]() { +////[|function [|{| "contextRangeIndex": 0 |}Bar|]() { //// // This is a reference to Bar in a comment. //// "this is a reference to [|Bar|] in a string" -////} +////}|] -const ranges = test.ranges(); +const [rDef, ...ranges] = test.ranges(); verify.renameLocations(ranges[0], { findInStrings: true, ranges }) diff --git a/tests/cases/fourslash/renameCommentsAndStrings3.ts b/tests/cases/fourslash/renameCommentsAndStrings3.ts index 7d88ddf2438c6..08672716a6110 100644 --- a/tests/cases/fourslash/renameCommentsAndStrings3.ts +++ b/tests/cases/fourslash/renameCommentsAndStrings3.ts @@ -2,10 +2,10 @@ /////// -////function [|Bar|]() { +////[|function [|{| "contextRangeIndex": 0 |}Bar|]() { //// // This is a reference to [|Bar|] in a comment. //// "this is a reference to Bar in a string" -////} +////}|] -const ranges = test.ranges(); +const [rDef, ...ranges] = test.ranges(); verify.renameLocations(ranges[0], { findInComments: true, ranges }); diff --git a/tests/cases/fourslash/renameCommentsAndStrings4.ts b/tests/cases/fourslash/renameCommentsAndStrings4.ts index eab53149d6d40..a5e0e24b3ef31 100644 --- a/tests/cases/fourslash/renameCommentsAndStrings4.ts +++ b/tests/cases/fourslash/renameCommentsAndStrings4.ts @@ -2,7 +2,7 @@ /////// -////function [|Bar|]() { +////[|function [|{| "contextRangeIndex": 0 |}Bar|]() { //// // This is a reference to [|Bar|] in a comment. //// "this is a reference to [|Bar|] in a string"; //// `Foo [|Bar|] Baz.`; @@ -10,7 +10,7 @@ //// const Bar = 0; //// `[|Bar|] ba ${Bar} bara [|Bar|] berbobo ${Bar} araura [|Bar|] ara!`; //// } -////} +////}|] -const ranges = test.ranges(); +const [rDef, ...ranges] = test.ranges(); verify.renameLocations(ranges[0], { findInStrings: true, findInComments: true, ranges }); diff --git a/tests/cases/fourslash/renameContextuallyTypedProperties.ts b/tests/cases/fourslash/renameContextuallyTypedProperties.ts index 4ce3c2b073818..da5286a714c64 100644 --- a/tests/cases/fourslash/renameContextuallyTypedProperties.ts +++ b/tests/cases/fourslash/renameContextuallyTypedProperties.ts @@ -1,58 +1,58 @@ /// ////interface I { -//// [|prop1|]: () => void; +//// [|[|{| "contextRangeIndex": 0 |}prop1|]: () => void;|] //// prop2(): void; ////} //// ////var o1: I = { -//// [|prop1|]() { }, +//// [|[|{| "contextRangeIndex": 2 |}prop1|]() { }|], //// prop2() { } ////}; //// ////var o2: I = { -//// [|prop1|]: () => { }, +//// [|[|{| "contextRangeIndex": 4 |}prop1|]: () => { }|], //// prop2: () => { } ////}; //// ////var o3: I = { -//// get [|prop1|]() { return () => { }; }, +//// [|get [|{| "contextRangeIndex": 6 |}prop1|]() { return () => { }; }|], //// get prop2() { return () => { }; } ////}; //// ////var o4: I = { -//// set [|prop1|](v) { }, +//// [|set [|{| "contextRangeIndex": 8 |}prop1|](v) { }|], //// set prop2(v) { } ////}; //// ////var o5: I = { -//// "[|prop1|]"() { }, +//// [|"[|{| "contextRangeIndex": 10 |}prop1|]"() { }|], //// "prop2"() { } ////}; //// ////var o6: I = { -//// "[|prop1|]": function () { }, +//// [|"[|{| "contextRangeIndex": 12 |}prop1|]": function () { }|], //// "prop2": function () { } ////}; //// ////var o7: I = { -//// ["[|prop1|]"]: function () { }, +//// [|["[|{| "contextRangeIndex": 14 |}prop1|]"]: function () { }|], //// ["prop2"]: function () { } ////}; //// ////var o8: I = { -//// ["[|prop1|]"]() { }, +//// [|["[|{| "contextRangeIndex": 16 |}prop1|]"]() { }|], //// ["prop2"]() { } ////}; //// ////var o9: I = { -//// get ["[|prop1|]"]() { return () => { }; }, +//// [|get ["[|{| "contextRangeIndex": 18 |}prop1|]"]() { return () => { }; }|], //// get ["prop2"]() { return () => { }; } ////}; //// ////var o10: I = { -//// set ["[|prop1|]"](v) { }, +//// [|set ["[|{| "contextRangeIndex": 20 |}prop1|]"](v) { }|], //// set ["prop2"](v) { } ////}; -verify.rangesAreRenameLocations(); +verify.rangesWithSameTextAreRenameLocations("prop1"); diff --git a/tests/cases/fourslash/renameContextuallyTypedProperties2.ts b/tests/cases/fourslash/renameContextuallyTypedProperties2.ts index 01e638395a077..fc3980404c983 100644 --- a/tests/cases/fourslash/renameContextuallyTypedProperties2.ts +++ b/tests/cases/fourslash/renameContextuallyTypedProperties2.ts @@ -2,57 +2,57 @@ ////interface I { //// prop1: () => void; -//// [|prop2|](): void; +//// [|[|{| "contextRangeIndex": 0 |}prop2|](): void;|] ////} //// ////var o1: I = { //// prop1() { }, -//// [|prop2|]() { } +//// [|[|{| "contextRangeIndex": 2 |}prop2|]() { }|] ////}; //// ////var o2: I = { //// prop1: () => { }, -//// [|prop2|]: () => { } +//// [|[|{| "contextRangeIndex": 4 |}prop2|]: () => { }|] ////}; //// ////var o3: I = { //// get prop1() { return () => { }; }, -//// get [|prop2|]() { return () => { }; } +//// [|get [|{| "contextRangeIndex": 6 |}prop2|]() { return () => { }; }|] ////}; //// ////var o4: I = { //// set prop1(v) { }, -//// set [|prop2|](v) { } +//// [|set [|{| "contextRangeIndex": 8 |}prop2|](v) { }|] ////}; //// ////var o5: I = { //// "prop1"() { }, -//// "[|prop2|]"() { } +//// [|"[|{| "contextRangeIndex": 10 |}prop2|]"() { }|] ////}; //// ////var o6: I = { //// "prop1": function () { }, -//// "[|prop2|]": function () { } +//// [|"[|{| "contextRangeIndex": 12 |}prop2|]": function () { }|] ////}; //// ////var o7: I = { //// ["prop1"]: function () { }, -//// ["[|prop2|]"]: function () { } +//// [|["[|{| "contextRangeIndex": 14 |}prop2|]"]: function () { }|] ////}; //// ////var o8: I = { //// ["prop1"]() { }, -//// ["[|prop2|]"]() { } +//// [|["[|{| "contextRangeIndex": 16 |}prop2|]"]() { }|] ////}; //// ////var o9: I = { //// get ["prop1"]() { return () => { }; }, -//// get ["[|prop2|]"]() { return () => { }; } +//// [|get ["[|{| "contextRangeIndex": 18 |}prop2|]"]() { return () => { }; }|] ////}; //// ////var o10: I = { //// set ["prop1"](v) { }, -//// set ["[|prop2|]"](v) { } +//// [|set ["[|{| "contextRangeIndex": 20 |}prop2|]"](v) { }|] ////}; -verify.rangesAreRenameLocations(); +verify.rangesWithSameTextAreRenameLocations("prop2"); diff --git a/tests/cases/fourslash/renameCrossJsTs01.ts b/tests/cases/fourslash/renameCrossJsTs01.ts index fbe0d4395cd13..2ebdaf80d0435 100644 --- a/tests/cases/fourslash/renameCrossJsTs01.ts +++ b/tests/cases/fourslash/renameCrossJsTs01.ts @@ -2,12 +2,12 @@ // @allowJs: true // @Filename: a.js -////exports.[|area|] = function (r) { return r * r; } +////[|exports.[|{| "contextRangeIndex": 0 |}area|] = function (r) { return r * r; }|] // @Filename: b.ts -////import { [|area|] } from './a'; +////[|import { [|{| "contextRangeIndex": 2 |}area|] } from './a';|] ////var t = [|area|](10); -const [r0, r1, r2] = test.ranges(); +const [r0Def, r0, r1Def, r1, r2] = test.ranges(); verify.renameLocations(r0, [r0, r1, r2]); verify.renameLocations([r1, r2], [{ range: r1, prefixText: "area as " }, r2]); diff --git a/tests/cases/fourslash/renameDefaultImport.ts b/tests/cases/fourslash/renameDefaultImport.ts index a3a698ec4c404..e8599bf7cb6d4 100644 --- a/tests/cases/fourslash/renameDefaultImport.ts +++ b/tests/cases/fourslash/renameDefaultImport.ts @@ -1,26 +1,25 @@ /// // @Filename: B.ts -////export default class /*1*/[|{| "isWriteAccess": true, "isDefinition": true |}B|] { +////[|export default class /*1*/[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}B|] { //// test() { //// } -////} +////}|] // @Filename: A.ts -////import [|{| "isWriteAccess": true, "isDefinition": true |}B|] from "./B"; +////[|import [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 2 |}B|] from "./B";|] ////let b = new [|B|](); ////b.test(); goTo.marker("1"); verify.occurrencesAtPositionCount(1); -const ranges = test.ranges(); -const [C, B0, B1] = ranges; +const [CDef, C, B0Def, B0, B1] = test.ranges();; const classes = { definition: "class B", ranges: [C] }; const imports = { definition: "(alias) class B\nimport B", ranges: [B0, B1] }; verify.referenceGroups(C, [classes, imports]); verify.referenceGroups([B0, B1], [imports, classes]); -verify.renameLocations(C, ranges); +verify.renameLocations(C, [C, B0, B1]); verify.rangesAreRenameLocations([B0, B1]); diff --git a/tests/cases/fourslash/renameDefaultImportDifferentName.ts b/tests/cases/fourslash/renameDefaultImportDifferentName.ts index 11473ade501c4..c0d58e3a76b32 100644 --- a/tests/cases/fourslash/renameDefaultImportDifferentName.ts +++ b/tests/cases/fourslash/renameDefaultImportDifferentName.ts @@ -1,21 +1,20 @@ /// // @Filename: B.ts -////export default class /*1*/[|{| "isWriteAccess": true, "isDefinition": true |}C|] { +////[|export default class /*1*/[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}C|] { //// test() { //// } -////} +////}|] // @Filename: A.ts -////import [|{| "isWriteAccess": true, "isDefinition": true |}B|] from "./B"; +////[|import [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 2 |}B|] from "./B";|] ////let b = new [|B|](); ////b.test(); goTo.marker("1"); verify.occurrencesAtPositionCount(1); -const ranges = test.ranges(); -const [C, B0, B1] = ranges; +const [CDef, C, B0Def, B0, B1] = test.ranges(); const bRanges = [B0, B1]; const classes = { definition: "class C", ranges: [C] }; const imports = { definition: "(alias) class B\nimport B", ranges: [B0, B1] }; diff --git a/tests/cases/fourslash/renameDefaultLibDontWork.ts b/tests/cases/fourslash/renameDefaultLibDontWork.ts index 5d2cfb43eb4b2..87b17f6f08435 100644 --- a/tests/cases/fourslash/renameDefaultLibDontWork.ts +++ b/tests/cases/fourslash/renameDefaultLibDontWork.ts @@ -4,8 +4,8 @@ // "test" is a comment on the default library. // @Filename: file1.ts -//// var [|test|] = "foo"; +//// [|var [|{| "contextRangeIndex": 0 |}test|] = "foo";|] //// console.log([|test|]); -const ranges = test.ranges(); +const [r0Def, ...ranges] = test.ranges(); verify.renameLocations(ranges[0], { findInComments: true, ranges }); \ No newline at end of file diff --git a/tests/cases/fourslash/renameDestructuringAssignment.ts b/tests/cases/fourslash/renameDestructuringAssignment.ts index 89a44a3a9d912..5fc19730691e7 100644 --- a/tests/cases/fourslash/renameDestructuringAssignment.ts +++ b/tests/cases/fourslash/renameDestructuringAssignment.ts @@ -1,10 +1,10 @@ /// ////interface I { -//// [|x|]: number; +//// [|[|{| "contextRangeIndex": 0 |}x|]: number;|] ////} ////var a: I; ////var x; -////({ [|x|]: x } = a); +////([|{ [|{| "contextRangeIndex": 2 |}x|]: x } = a|]); -verify.rangesAreRenameLocations(); +verify.rangesWithSameTextAreRenameLocations("x"); diff --git a/tests/cases/fourslash/renameDestructuringAssignmentInFor.ts b/tests/cases/fourslash/renameDestructuringAssignmentInFor.ts index 2c8ad51f48697..1444d597ba5e5 100644 --- a/tests/cases/fourslash/renameDestructuringAssignmentInFor.ts +++ b/tests/cases/fourslash/renameDestructuringAssignmentInFor.ts @@ -1,20 +1,20 @@ /// ////interface I { -//// [|property1|]: number; +//// [|[|{| "contextRangeIndex": 0 |}property1|]: number;|] //// property2: string; ////} ////var elems: I[]; //// -////var p2: number, [|property1|]: number; -////for ({ [|property1|] } = elems[0]; p2 < 100; p2++) { +////var p2: number, [|[|{| "contextRangeIndex": 2 |}property1|]: number|]; +////for ([|{ [|{| "contextRangeIndex": 4 |}property1|] } = elems[0]|]; p2 < 100; p2++) { //// p2 = [|property1|]++; ////} -////for ({ [|property1|]: p2 } = elems[0]; p2 < 100; p2++) { +////for ([|{ [|{| "contextRangeIndex": 7 |}property1|]: p2 } = elems[0]|]; p2 < 100; p2++) { ////} verify.noErrors(); const ranges = test.ranges(); -const [r0, r1, r2, r3, r4] = ranges; +const [r0Def, r0, r1Def, r1, r2Def, r2, r3, r4Def, r4] = ranges; verify.renameLocations([r0, r4], [r0, { range: r2, suffixText: ": property1" }, r4]); verify.renameLocations([r1, r2, r3], [r1, { range: r2, prefixText: "property1: " }, r3]); diff --git a/tests/cases/fourslash/renameDestructuringAssignmentInForOf.ts b/tests/cases/fourslash/renameDestructuringAssignmentInForOf.ts index 38703a68b99b0..53bd7786adb48 100644 --- a/tests/cases/fourslash/renameDestructuringAssignmentInForOf.ts +++ b/tests/cases/fourslash/renameDestructuringAssignmentInForOf.ts @@ -1,20 +1,20 @@ /// ////interface I { -//// [|property1|]: number; +//// [|[|{| "contextRangeIndex": 0 |}property1|]: number;|] //// property2: string; ////} ////var elems: I[]; //// -////var [|property1|]: number, p2: number; -////for ({ [|property1|] } of elems) { +////var [|[|{| "contextRangeIndex": 2 |}property1|]: number|], p2: number; +////for ([|{ [|{| "contextRangeIndex": 4 |}property1|] } of elems|]) { //// [|property1|]++; ////} -////for ({ [|property1|]: p2 } of elems) { +////for ([|{ [|{| "contextRangeIndex": 7 |}property1|]: p2 } of elems|]) { ////} verify.noErrors(); const ranges = test.ranges(); -const [r0, r1, r2, r3, r4] = ranges; +const [r0Def, r0, r1Def, r1, r2Def, r2, r3, r4Def, r4] = ranges; verify.renameLocations([r0, r4], [r0, { range: r2, suffixText: ": property1" }, r4]); verify.renameLocations([r1, r2, r3], [r1, { range: r2, prefixText: "property1: " }, r3]); diff --git a/tests/cases/fourslash/renameDestructuringAssignmentNestedInArrayLiteral.ts b/tests/cases/fourslash/renameDestructuringAssignmentNestedInArrayLiteral.ts index 292aaf1bf6d69..260e80ed4d0ca 100644 --- a/tests/cases/fourslash/renameDestructuringAssignmentNestedInArrayLiteral.ts +++ b/tests/cases/fourslash/renameDestructuringAssignmentNestedInArrayLiteral.ts @@ -1,15 +1,15 @@ /// ////interface I { -//// [|property1|]: number; +//// [|[|{| "contextRangeIndex": 0 |}property1|]: number;|] //// property2: string; ////} -////var elems: I[], p1: number, [|property1|]: number; -////[{ [|property1|]: p1 }] = elems; -////[{ [|property1|] }] = elems; +////var elems: I[], p1: number, [|[|{| "contextRangeIndex": 2 |}property1|]: number|]; +////[|[{ [|{| "contextRangeIndex": 4 |}property1|]: p1 }] = elems;|] +////[|[{ [|{| "contextRangeIndex": 6 |}property1|] }] = elems;|] const ranges = test.ranges(); -const [r0, r1, r2, r3] = ranges; +const [r0Def, r0, r1Def, r1, r2Def, r2, r3Def, r3] = ranges; verify.renameLocations([r0, r2], [r0, r2, { range: r3, suffixText: ": property1" }]); verify.renameLocations([r1, r3], [r1, { range: r3, prefixText: "property1: " }]); diff --git a/tests/cases/fourslash/renameDestructuringAssignmentNestedInFor.ts b/tests/cases/fourslash/renameDestructuringAssignmentNestedInFor.ts index e83487d15d250..a275f63d0b333 100644 --- a/tests/cases/fourslash/renameDestructuringAssignmentNestedInFor.ts +++ b/tests/cases/fourslash/renameDestructuringAssignmentNestedInFor.ts @@ -3,20 +3,20 @@ ////interface MultiRobot { //// name: string; //// skills: { -//// [|primary|]: string; +//// [|[|{| "contextRangeIndex": 0 |}primary|]: string;|] //// secondary: string; //// }; ////} -////let multiRobot: MultiRobot, [|primary|]: string, secondary: string, primaryA: string, secondaryA: string, i: number; -////for ({ skills: { [|primary|]: primaryA, secondary: secondaryA } } = multiRobot, i = 0; i < 1; i++) { +////let multiRobot: MultiRobot, [|[|{| "contextRangeIndex": 2 |}primary|]: string|], secondary: string, primaryA: string, secondaryA: string, i: number; +////for ([|{ skills: { [|{| "contextRangeIndex": 4 |}primary|]: primaryA, secondary: secondaryA } } = multiRobot|], i = 0; i < 1; i++) { //// primaryA; ////} -////for ({ skills: { [|primary|], secondary } } = multiRobot, i = 0; i < 1; i++) { +////for ([|{ skills: { [|{| "contextRangeIndex": 6 |}primary|], secondary } } = multiRobot|], i = 0; i < 1; i++) { //// [|primary|]; ////} verify.noErrors(); const ranges = test.ranges(); -const [r0, r1, r2, r3, r4] = ranges; +const [r0Def, r0, r1Def, r1, r2Def, r2, r3Def, r3, r4] = ranges; verify.renameLocations([r0, r2], [r0, r2, { range: r3, suffixText: ": primary" }]); verify.renameLocations([r1, r3, r4], [r1, { range: r3, prefixText: "primary: " }, r4]); diff --git a/tests/cases/fourslash/renameDestructuringAssignmentNestedInFor2.ts b/tests/cases/fourslash/renameDestructuringAssignmentNestedInFor2.ts index e83487d15d250..a275f63d0b333 100644 --- a/tests/cases/fourslash/renameDestructuringAssignmentNestedInFor2.ts +++ b/tests/cases/fourslash/renameDestructuringAssignmentNestedInFor2.ts @@ -3,20 +3,20 @@ ////interface MultiRobot { //// name: string; //// skills: { -//// [|primary|]: string; +//// [|[|{| "contextRangeIndex": 0 |}primary|]: string;|] //// secondary: string; //// }; ////} -////let multiRobot: MultiRobot, [|primary|]: string, secondary: string, primaryA: string, secondaryA: string, i: number; -////for ({ skills: { [|primary|]: primaryA, secondary: secondaryA } } = multiRobot, i = 0; i < 1; i++) { +////let multiRobot: MultiRobot, [|[|{| "contextRangeIndex": 2 |}primary|]: string|], secondary: string, primaryA: string, secondaryA: string, i: number; +////for ([|{ skills: { [|{| "contextRangeIndex": 4 |}primary|]: primaryA, secondary: secondaryA } } = multiRobot|], i = 0; i < 1; i++) { //// primaryA; ////} -////for ({ skills: { [|primary|], secondary } } = multiRobot, i = 0; i < 1; i++) { +////for ([|{ skills: { [|{| "contextRangeIndex": 6 |}primary|], secondary } } = multiRobot|], i = 0; i < 1; i++) { //// [|primary|]; ////} verify.noErrors(); const ranges = test.ranges(); -const [r0, r1, r2, r3, r4] = ranges; +const [r0Def, r0, r1Def, r1, r2Def, r2, r3Def, r3, r4] = ranges; verify.renameLocations([r0, r2], [r0, r2, { range: r3, suffixText: ": primary" }]); verify.renameLocations([r1, r3, r4], [r1, { range: r3, prefixText: "primary: " }, r4]); diff --git a/tests/cases/fourslash/renameDestructuringAssignmentNestedInForOf.ts b/tests/cases/fourslash/renameDestructuringAssignmentNestedInForOf.ts index 6a9eb6235b7ba..18161d538a095 100644 --- a/tests/cases/fourslash/renameDestructuringAssignmentNestedInForOf.ts +++ b/tests/cases/fourslash/renameDestructuringAssignmentNestedInForOf.ts @@ -3,20 +3,20 @@ ////interface MultiRobot { //// name: string; //// skills: { -//// [|primary|]: string; +//// [|[|{| "contextRangeIndex": 0 |}primary|]: string;|] //// secondary: string; //// }; ////} ////let multiRobots: MultiRobot[]; -////let [|primary|]: string, secondary: string, primaryA: string, secondaryA: string; -////for ({ skills: { [|primary|]: primaryA, secondary: secondaryA } } of multiRobots) { +////let [|[|{| "contextRangeIndex": 2 |}primary|]: string|], secondary: string, primaryA: string, secondaryA: string; +////for ([|{ skills: { [|{| "contextRangeIndex": 4 |}primary|]: primaryA, secondary: secondaryA } } of multiRobots|]) { //// primaryA; ////} -////for ({ skills: { [|primary|], secondary } } of multiRobots) { +////for ([|{ skills: { [|{| "contextRangeIndex": 6 |}primary|], secondary } } of multiRobots|]) { //// [|primary|]; ////} verify.noErrors(); -const [r0, r1, r2, r3, r4] = test.ranges(); +const [r0Def, r0, r1Def, r1, r2Def, r2, r3Def, r3, r4] = test.ranges(); verify.renameLocations([r0, r2], [r0, r2, { range: r3, suffixText: ": primary" }]); verify.renameLocations([r1, r3, r4], [r1, { range: r3, prefixText: "primary: " }, r4]) diff --git a/tests/cases/fourslash/renameDestructuringAssignmentNestedInForOf2.ts b/tests/cases/fourslash/renameDestructuringAssignmentNestedInForOf2.ts index 7c5c288ea78fe..90835e75b5a27 100644 --- a/tests/cases/fourslash/renameDestructuringAssignmentNestedInForOf2.ts +++ b/tests/cases/fourslash/renameDestructuringAssignmentNestedInForOf2.ts @@ -3,19 +3,19 @@ ////interface MultiRobot { //// name: string; //// skills: { -//// [|primary|]: string; +//// [|[|{| "contextRangeIndex": 0 |}primary|]: string;|] //// secondary: string; //// }; ////} -////let multiRobots: MultiRobot[], [|primary|]: string; -////for ({ skills: { [|primary|]: primaryA, secondary: secondaryA } } of multiRobots) { +////let multiRobots: MultiRobot[], [|[|{| "contextRangeIndex": 2 |}primary|]: string|]; +////for ([|{ skills: { [|{| "contextRangeIndex": 4 |}primary|]: primaryA, secondary: secondaryA } } of multiRobots|]) { //// console.log(primaryA); ////} -////for ({ skills: { [|primary|], secondary } } of multiRobots) { +////for ([|{ skills: { [|{| "contextRangeIndex": 6 |}primary|], secondary } } of multiRobots|]) { //// console.log([|primary|]); ////} const ranges = test.ranges(); -const [r0, r1, r2, r3, r4] = ranges; +const [r0Def, r0, r1Def, r1,r2Def, r2, r3Def, r3, r4] = ranges; verify.renameLocations([r0, r2], [r0, r2, { range: r3, suffixText: ": primary" }]); verify.renameLocations([r1, r3, r4], [r1, { range: r3, prefixText: "primary: " }, r4]); diff --git a/tests/cases/fourslash/renameDestructuringClassProperty.ts b/tests/cases/fourslash/renameDestructuringClassProperty.ts index ac708e554717e..365d7fb6b25b7 100644 --- a/tests/cases/fourslash/renameDestructuringClassProperty.ts +++ b/tests/cases/fourslash/renameDestructuringClassProperty.ts @@ -1,22 +1,22 @@ /// ////class A { -//// [|foo|]: string; +//// [|[|{| "contextRangeIndex": 0 |}foo|]: string;|] ////} ////class B { //// syntax1(a: A): void { -//// let { [|foo|] } = a; +//// [|let { [|{| "contextRangeIndex": 2 |}foo|] } = a;|] //// } //// syntax2(a: A): void { -//// let { [|foo|]: foo } = a; +//// [|let { [|{| "contextRangeIndex": 4 |}foo|]: foo } = a;|] //// } //// syntax11(a: A): void { -//// let { [|foo|] } = a; +//// [|let { [|{| "contextRangeIndex": 6 |}foo|] } = a;|] //// [|foo|] = "newString"; //// } ////} -const [r0, r1, r2, r3, r4] = test.ranges(); +const [r0Def, r0, r1Def, r1, r2Def, r2, r3Def, r3, r4] = test.ranges(); verify.renameLocations([r0, r2], [r0, { range: r1, suffixText: ": foo" }, r2, { range: r3, suffixText: ": foo" }]); verify.renameLocations(r1, [{ range: r1, prefixText: "foo: " }]); verify.renameLocations([r3, r4], [{ range: r3, prefixText: "foo: " }, r4]); diff --git a/tests/cases/fourslash/renameDestructuringDeclarationInFor.ts b/tests/cases/fourslash/renameDestructuringDeclarationInFor.ts index 02bc0f508269c..b1a653775ec78 100644 --- a/tests/cases/fourslash/renameDestructuringDeclarationInFor.ts +++ b/tests/cases/fourslash/renameDestructuringDeclarationInFor.ts @@ -1,18 +1,18 @@ /// ////interface I { -//// [|property1|]: number; +//// [|[|{| "contextRangeIndex": 0 |}property1|]: number;|] //// property2: string; ////} ////var elems: I[]; //// ////var p2: number, property1: number; -////for (let { [|property1|]: p2 } = elems[0]; p2 < 100; p2++) { +////for ([|let { [|{| "contextRangeIndex": 2 |}property1|]: p2 } = elems[0]|]; p2 < 100; p2++) { ////} -////for (let { [|property1|] } = elems[0]; p2 < 100; p2++) { +////for ([|let { [|{| "contextRangeIndex": 4 |}property1|] } = elems[0]|]; p2 < 100; p2++) { //// [|property1|] = p2; ////} -const [r0, r1, r2, r3] = test.ranges(); +const [r0Def, r0, r1Def, r1, r2Def, r2, r3] = test.ranges(); verify.renameLocations([r0, r1], [r0, r1, { range: r2, suffixText: ": property1" }]); verify.renameLocations([r2, r3], [{ range: r2, prefixText: "property1: " }, r3]); diff --git a/tests/cases/fourslash/renameDestructuringDeclarationInForOf.ts b/tests/cases/fourslash/renameDestructuringDeclarationInForOf.ts index a8e21c83cf35a..f0c35ce8125bf 100644 --- a/tests/cases/fourslash/renameDestructuringDeclarationInForOf.ts +++ b/tests/cases/fourslash/renameDestructuringDeclarationInForOf.ts @@ -1,17 +1,17 @@ /// ////interface I { -//// [|property1|]: number; +//// [|[|{| "contextRangeIndex": 0 |}property1|]: number;|] //// property2: string; ////} ////var elems: I[]; //// -////for (let { [|property1|] } of elems) { +////for ([|let { [|{| "contextRangeIndex": 2 |}property1|] } of elems|]) { //// [|property1|]++; ////} -////for (let { [|property1|]: p2 } of elems) { +////for ([|let { [|{| "contextRangeIndex": 5 |}property1|]: p2 } of elems|]) { ////} -const [r0, r1, r2, r3] = test.ranges(); +const [r0Def, r0, r1Def, r1, r2, r3Def, r3] = test.ranges(); verify.renameLocations([r0, r3], [r0, { range: r1, suffixText: ": property1" }, r3]); verify.renameLocations([r1, r2], [{ range: r1, prefixText: "property1: " }, r2]); diff --git a/tests/cases/fourslash/renameDestructuringFunctionParameter.ts b/tests/cases/fourslash/renameDestructuringFunctionParameter.ts index d6a732176d204..faa423dac4964 100644 --- a/tests/cases/fourslash/renameDestructuringFunctionParameter.ts +++ b/tests/cases/fourslash/renameDestructuringFunctionParameter.ts @@ -1,10 +1,10 @@ /// -////function f({[|a|]}: {[|a|]}) { +////function f([|{[|{| "contextRangeIndex": 0 |}a|]}: {[|a|]}|]) { //// f({[|a|]}); ////} -const [r0, r1, r2] = test.ranges(); +const [r0Def, r0, r1, r2] = test.ranges(); // renames the local verify.renameLocations([r0, r2], [{ range: r0, prefixText: "a: " }, { range: r2, prefixText: "a: " }]); // renames the property diff --git a/tests/cases/fourslash/renameDestructuringNestedBindingElement.ts b/tests/cases/fourslash/renameDestructuringNestedBindingElement.ts index 6643382f6c91e..040106a0c90a3 100644 --- a/tests/cases/fourslash/renameDestructuringNestedBindingElement.ts +++ b/tests/cases/fourslash/renameDestructuringNestedBindingElement.ts @@ -3,18 +3,18 @@ ////interface MultiRobot { //// name: string; //// skills: { -//// [|primary|]: string; +//// [|[|{| "contextRangeIndex": 0|}primary|]: string;|] //// secondary: string; //// }; ////} ////let multiRobots: MultiRobot[]; -////for (let { skills: {[|primary|]: primaryA, secondary: secondaryA } } of multiRobots) { +////for ([|let { skills: {[|{| "contextRangeIndex": 2|}primary|]: primaryA, secondary: secondaryA } } of multiRobots|]) { //// console.log(primaryA); ////} -////for (let { skills: {[|primary|], secondary } } of multiRobots) { +////for ([|let { skills: {[|{| "contextRangeIndex": 4|}primary|], secondary } } of multiRobots|]) { //// console.log([|primary|]); ////} -const [r0, r1, r2, r3] = test.ranges(); +const [r0Def, r0, r1Def, r1, r2Def, r2, r3] = test.ranges(); verify.renameLocations([r0, r1], [r0, r1, { range: r2, suffixText: ": primary" }]); verify.renameLocations([r2, r3], [{ range: r2, prefixText: "primary: " }, r3]); diff --git a/tests/cases/fourslash/renameForDefaultExport01.ts b/tests/cases/fourslash/renameForDefaultExport01.ts index 1256a9698fa86..26697d1df1e48 100644 --- a/tests/cases/fourslash/renameForDefaultExport01.ts +++ b/tests/cases/fourslash/renameForDefaultExport01.ts @@ -1,7 +1,7 @@ /// -////export default class [|DefaultExportedClass|] { -////} +////[|export default class [|{| "contextRangeIndex": 0 |}DefaultExportedClass|] { +////}|] /////* //// * Commenting [|{| "inComment": true |}DefaultExportedClass|] //// */ @@ -10,5 +10,5 @@ //// ////var y = new [|DefaultExportedClass|]; -const ranges = test.ranges(); +const ranges = test.rangesByText().get("DefaultExportedClass"); verify.renameLocations(ranges.filter(r => !(r.marker && r.marker.data.inComment)), { findInComments: true, ranges }); diff --git a/tests/cases/fourslash/renameForDefaultExport02.ts b/tests/cases/fourslash/renameForDefaultExport02.ts index a6f6116ec1a2a..d9b172f2d2e10 100644 --- a/tests/cases/fourslash/renameForDefaultExport02.ts +++ b/tests/cases/fourslash/renameForDefaultExport02.ts @@ -1,8 +1,8 @@ /// -////export default function /*1*/[|DefaultExportedFunction|]() { +////[|export default function /*1*/[|{| "contextRangeIndex": 0 |}DefaultExportedFunction|]() { //// return /*2*/[|DefaultExportedFunction|] -////} +////}|] /////** //// * Commenting [|{| "inComment": true |}DefaultExportedFunction|] //// */ @@ -11,5 +11,5 @@ //// ////var y = /*4*/[|DefaultExportedFunction|](); -const ranges = test.ranges(); +const ranges = test.rangesByText().get("DefaultExportedFunction"); verify.renameLocations(ranges.filter(r => !(r.marker && r.marker.data.inComment)), { findInComments: true, ranges }); diff --git a/tests/cases/fourslash/renameForDefaultExport03.ts b/tests/cases/fourslash/renameForDefaultExport03.ts index edc22bb0db09c..7b67d2e450919 100644 --- a/tests/cases/fourslash/renameForDefaultExport03.ts +++ b/tests/cases/fourslash/renameForDefaultExport03.ts @@ -1,10 +1,10 @@ /// -////function /*1*/[|f|]() { +////[|function /*1*/[|{| "contextRangeIndex": 0 |}f|]() { //// return 100; -////} +////}|] //// -////export default /*2*/[|f|]; +////[|export default /*2*/[|{| "contextRangeIndex": 2 |}f|];|] //// ////var x: typeof /*3*/[|f|]; //// @@ -13,9 +13,9 @@ /////** //// * Commenting [|{| "inComment": true |}f|] //// */ -////namespace /*5*/[|f|] { +////[|namespace /*5*/[|{| "contextRangeIndex": 7 |}f|] { //// var local = 100; -////} +////}|] -const ranges = test.ranges(); +const ranges = test.rangesByText().get("f"); verify.renameLocations(ranges.filter(r => !(r.marker && r.marker.data.inComment)), { findInComments: true, ranges }); diff --git a/tests/cases/fourslash/renameImportAndExport.ts b/tests/cases/fourslash/renameImportAndExport.ts index 6a9cac061a4ef..9b94d6fedda4f 100644 --- a/tests/cases/fourslash/renameImportAndExport.ts +++ b/tests/cases/fourslash/renameImportAndExport.ts @@ -1,8 +1,8 @@ /// -////import [|a|] from "module"; -////export { [|a|] }; +////[|import [|{| "contextRangeIndex": 0 |}a|] from "module";|] +////[|export { [|{| "contextRangeIndex": 2 |}a|] };|] -const [r0, r1] = test.ranges(); +const [r0Def, r0, r1Def, r1] = test.ranges(); verify.renameLocations(r0, [r0, { range: r1, suffixText: " as a" }]); verify.renameLocations(r1, [{ range: r1, prefixText: "a as " }]); diff --git a/tests/cases/fourslash/renameImportAndExportInDiffFiles.ts b/tests/cases/fourslash/renameImportAndExportInDiffFiles.ts index 28297fc725596..1e459e6ec072a 100644 --- a/tests/cases/fourslash/renameImportAndExportInDiffFiles.ts +++ b/tests/cases/fourslash/renameImportAndExportInDiffFiles.ts @@ -1,13 +1,13 @@ /// // @Filename: a.ts -////export var [|{| "isDefinition": true |}a|]; +////[|export var [|{| "isDefinition": true, "contextRangeIndex": 0 |}a|];|] // @Filename: b.ts -////import { [|{| "isWriteAccess": true, "isDefinition": true |}a|] } from './a'; -////export { [|{| "isWriteAccess": true, "isDefinition": true |}a|] }; +////[|import { [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 2 |}a|] } from './a';|] +////[|export { [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 4 |}a|] };|] -const [r0, r1, r2] = test.ranges(); +const [r0Def, r0, r1Def, r1, r2Def, r2] = test.ranges(); const vars = { definition: "var a: any", ranges: [r0] }; const imports = { definition: "(alias) var a: any\nimport a", ranges: [r1, r2] }; verify.referenceGroups(r0, [vars, imports]); diff --git a/tests/cases/fourslash/renameImportAndShorthand.ts b/tests/cases/fourslash/renameImportAndShorthand.ts index 01be6650b3b1e..376f16c9c5be0 100644 --- a/tests/cases/fourslash/renameImportAndShorthand.ts +++ b/tests/cases/fourslash/renameImportAndShorthand.ts @@ -1,7 +1,7 @@ /// -////import [|foo|] from 'bar'; +////[|import [|{| "contextRangeIndex": 0 |}foo|] from 'bar';|] ////const bar = { [|foo|] }; -const [r0, r1] = test.ranges(); +const [r0Def, r0, r1] = test.ranges(); verify.renameLocations([r0, r1], [r0, { range: r1, prefixText: "foo: " }]); diff --git a/tests/cases/fourslash/renameImportNamespaceAndShorthand.ts b/tests/cases/fourslash/renameImportNamespaceAndShorthand.ts index e577d82d3ae60..5a3ed66e976eb 100644 --- a/tests/cases/fourslash/renameImportNamespaceAndShorthand.ts +++ b/tests/cases/fourslash/renameImportNamespaceAndShorthand.ts @@ -1,7 +1,7 @@ /// -////import * as [|foo|] from 'bar'; +////[|import * as [|{| "contextRangeIndex": 0 |}foo|] from 'bar';|] ////const bar = { [|foo|] }; -const [r0, r1] = test.ranges(); +const [r0Def, r0, r1] = test.ranges(); verify.renameLocations([r0, r1], [r0, { range: r1, prefixText: "foo: " }]); diff --git a/tests/cases/fourslash/renameImportOfExportEquals.ts b/tests/cases/fourslash/renameImportOfExportEquals.ts index 6dfe8270c6b64..25e58947d30a6 100644 --- a/tests/cases/fourslash/renameImportOfExportEquals.ts +++ b/tests/cases/fourslash/renameImportOfExportEquals.ts @@ -1,21 +1,21 @@ /// -////declare namespace [|{| "isWriteAccess": true, "isDefinition": true |}N|] { -//// export var [|{| "isWriteAccess": true, "isDefinition": true |}x|]: number; -////} +////[|declare namespace [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}N|] { +//// [|export var [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 2 |}x|]: number;|] +////}|] ////declare module "mod" { -//// export = [|N|]; +//// [|export = [|{| "contextRangeIndex": 4 |}N|];|] ////} ////declare module "a" { -//// import * as [|{| "isWriteAccess": true, "isDefinition": true |}N|] from "mod"; -//// export { [|{| "isWriteAccess": true, "isDefinition": true |}N|] }; // Renaming N here would rename +//// [|import * as [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 6 |}N|] from "mod";|] +//// [|export { [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 8 |}N|] };|] // Renaming N here would rename ////} ////declare module "b" { -//// import { [|{| "isWriteAccess": true, "isDefinition": true |}N|] } from "a"; +//// [|import { [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 10 |}N|] } from "a";|] //// export const y: typeof [|N|].[|x|]; ////} -const [N0, x0, N1, a0, a1, b0, b1, x1] = test.ranges(); +const [N0Def, N0, x0Def, x0, N1Def, N1, a0Def, a0, a1Def, a1, b0Def, b0, b1, x1] = test.ranges(); const nRanges = [N0, N1]; const aRanges = [a0, a1]; const bRanges = [b0, b1]; diff --git a/tests/cases/fourslash/renameImportOfExportEquals2.ts b/tests/cases/fourslash/renameImportOfExportEquals2.ts index dfb472caab8fd..4f1e6c39f22dd 100644 --- a/tests/cases/fourslash/renameImportOfExportEquals2.ts +++ b/tests/cases/fourslash/renameImportOfExportEquals2.ts @@ -1,27 +1,27 @@ /// -////declare namespace [|{| "isWriteAccess": true, "isDefinition": true |}N|] { +////[|declare namespace [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}N|] { //// export var x: number; -////} +////}|] ////declare module "mod" { -//// export = [|N|]; +//// [|export = [|{| "contextRangeIndex": 2 |}N|];|] ////} ////declare module "a" { -//// import * as [|{| "isWriteAccess": true, "isDefinition": true |}O|] from "mod"; -//// export { [|O|] as [|{| "isWriteAccess": true, "isDefinition": true |}P|] }; // Renaming N here would rename +//// [|import * as [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 4 |}O|] from "mod";|] +//// [|export { [|{| "contextRangeIndex": 6 |}O|] as [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 6 |}P|] };|] // Renaming N here would rename ////} ////declare module "b" { -//// import { [|P|] as [|{| "isWriteAccess": true, "isDefinition": true |}Q|] } from "a"; +//// [|import { [|{| "contextRangeIndex": 9 |}P|] as [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 9 |}Q|] } from "a";|] //// export const y: typeof [|Q|].x; ////} verify.noErrors(); -const [N0, N1, O0, O1, P0, P1, Q0, Q1] = test.ranges(); -const nRanges = [N0, N1]; -const oRanges = [O0, O1]; -const pRanges = [P0, P1]; -const qRanges = [Q0, Q1]; +const ranges = test.rangesByText(); +const nRanges = ranges.get("N");// [N0, N1]; +const oRanges = ranges.get("O");// [O0, O1]; +const pRanges = ranges.get("P");//[P0, P1]; +const qRanges = ranges.get("Q");//[Q0, Q1]; const ns = { definition: "namespace N", ranges: nRanges }; const os = { definition: "(alias) namespace O\nimport O", ranges: oRanges }; @@ -33,4 +33,4 @@ verify.referenceGroups(oRanges, [os, ps, qs]); verify.referenceGroups(pRanges, [ps, qs]); verify.referenceGroups(qRanges, [qs]); -verify.rangesWithSameTextAreRenameLocations(); +verify.rangesWithSameTextAreRenameLocations("N", "O", "P", "Q"); \ No newline at end of file diff --git a/tests/cases/fourslash/renameImportOfReExport.ts b/tests/cases/fourslash/renameImportOfReExport.ts index ced67d43b9c7e..c80da246699f7 100644 --- a/tests/cases/fourslash/renameImportOfReExport.ts +++ b/tests/cases/fourslash/renameImportOfReExport.ts @@ -2,20 +2,20 @@ // @noLib: true ////declare module "a" { -//// export class [|{| "isWriteAccess": true, "isDefinition": true |}C|] {} +//// [|export class [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}C|] {}|] ////} ////declare module "b" { -//// export { [|{| "isWriteAccess": true, "isDefinition": true |}C|] } from "a"; +//// [|export { [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 2 |}C|] } from "a";|] ////} ////declare module "c" { -//// import { [|{| "isWriteAccess": true, "isDefinition": true |}C|] } from "b"; +//// [|import { [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 4 |}C|] } from "b";|] //// export function f(c: [|C|]): void; ////} verify.noErrors(); const ranges = test.ranges(); -const [r0, r1, r2, r3] = ranges; +const [r0Def, r0, r1Def, r1, r2Def, r2, r3] = ranges; const importRanges = [r2, r3]; verify.renameLocations(r0, [r0, { range: r1, suffixText: " as C" }]); //, r1 verify.renameLocations(r1, [{ range: r1, prefixText: "C as " }, r2, r3]); diff --git a/tests/cases/fourslash/renameImportOfReExport2.ts b/tests/cases/fourslash/renameImportOfReExport2.ts index a6389d4aeb822..f8589dbb41d6b 100644 --- a/tests/cases/fourslash/renameImportOfReExport2.ts +++ b/tests/cases/fourslash/renameImportOfReExport2.ts @@ -1,13 +1,13 @@ /// ////declare module "a" { -//// export class [|{| "isWriteAccess": true, "isDefinition": true |}C|] {} +//// [|export class [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}C|] {}|] ////} ////declare module "b" { -//// export { [|C|] as [|{| "isWriteAccess": true, "isDefinition": true |}D|] } from "a"; +//// [|export { [|{| "contextRangeIndex": 2 |}C|] as [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 2 |}D|] } from "a";|] ////} ////declare module "c" { -//// import { [|{| "isWriteAccess": true, "isDefinition": true |}D|] } from "b"; +//// [|import { [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 5 |}D|] } from "b";|] //// export function f(c: [|D|]): void; ////} diff --git a/tests/cases/fourslash/renameImportRequire.ts b/tests/cases/fourslash/renameImportRequire.ts index 915143263dd8a..fc41d5a95ac9d 100644 --- a/tests/cases/fourslash/renameImportRequire.ts +++ b/tests/cases/fourslash/renameImportRequire.ts @@ -1,16 +1,16 @@ /// // @Filename: /a.ts -////import [|e|] = require("mod4"); +////[|import [|{| "contextRangeIndex": 0 |}e|] = require("mod4");|] ////[|e|]; ////a = { [|e|] }; -////export { [|e|] }; +////[|export { [|{| "contextRangeIndex": 4 |}e|] };|] // @Filename: /b.ts -////import { [|e|] } from "./a"; -////export { [|e|] }; +////[|import { [|{| "contextRangeIndex": 6 |}e|] } from "./a";|] +////[|export { [|{| "contextRangeIndex": 8 |}e|] };|] -const [r0, r1, r2, r3, r4, r5] = test.ranges(); +const [r0Def, r0, r1, r2, r3Def, r3, r4Def, r4, r5Def, r5] = test.ranges(); verify.renameLocations([r0, r1, r2], [r0, r1, { range: r2, prefixText: "e: " }, { range: r3, suffixText: " as e" }]); verify.renameLocations(r3, [{ range: r3, prefixText: "e as " }, r4, { range: r5, suffixText: " as e" }]); verify.renameLocations(r4, [{ range: r4, prefixText: "e as " }, { range: r5, suffixText: " as e" }]); diff --git a/tests/cases/fourslash/renameInheritedProperties1.ts b/tests/cases/fourslash/renameInheritedProperties1.ts index b42335277a920..5f52732d65f97 100644 --- a/tests/cases/fourslash/renameInheritedProperties1.ts +++ b/tests/cases/fourslash/renameInheritedProperties1.ts @@ -1,10 +1,10 @@ /// //// class class1 extends class1 { -//// [|propName|]: string; +//// [|[|{| "contextRangeIndex": 0 |}propName|]: string;|] //// } //// //// var v: class1; //// v.[|propName|]; -verify.rangesAreRenameLocations(); +verify.rangesWithSameTextAreRenameLocations("propName"); diff --git a/tests/cases/fourslash/renameInheritedProperties2.ts b/tests/cases/fourslash/renameInheritedProperties2.ts index bcc4c5fc323d6..0dd3435a807fe 100644 --- a/tests/cases/fourslash/renameInheritedProperties2.ts +++ b/tests/cases/fourslash/renameInheritedProperties2.ts @@ -1,10 +1,10 @@ /// //// class class1 extends class1 { -//// [|doStuff|]() { } +//// [|[|{| "contextRangeIndex": 0 |}doStuff|]() { }|] //// } //// //// var v: class1; //// v.[|doStuff|](); -verify.rangesAreRenameLocations(); +verify.rangesWithSameTextAreRenameLocations("doStuff"); diff --git a/tests/cases/fourslash/renameInheritedProperties3.ts b/tests/cases/fourslash/renameInheritedProperties3.ts index f1ec547d6ed71..ecdab6c39016b 100644 --- a/tests/cases/fourslash/renameInheritedProperties3.ts +++ b/tests/cases/fourslash/renameInheritedProperties3.ts @@ -1,10 +1,10 @@ /// //// interface interface1 extends interface1 { -//// [|propName|]: string; +//// [|[|{| "contextRangeIndex": 0 |}propName|]: string;|] //// } //// //// var v: interface1; //// v.[|propName|]; -verify.rangesAreRenameLocations(); +verify.rangesWithSameTextAreRenameLocations("propName"); diff --git a/tests/cases/fourslash/renameInheritedProperties4.ts b/tests/cases/fourslash/renameInheritedProperties4.ts index 42d9acfdb5349..b16eaa55d1b23 100644 --- a/tests/cases/fourslash/renameInheritedProperties4.ts +++ b/tests/cases/fourslash/renameInheritedProperties4.ts @@ -1,10 +1,10 @@ /// //// interface interface1 extends interface1 { -//// [|doStuff|](): string; +//// [|[|{| "contextRangeIndex": 0 |}doStuff|](): string;|] //// } //// //// var v: interface1; //// v.[|doStuff|](); -verify.rangesAreRenameLocations(); +verify.rangesWithSameTextAreRenameLocations("doStuff"); diff --git a/tests/cases/fourslash/renameInheritedProperties5.ts b/tests/cases/fourslash/renameInheritedProperties5.ts index e153742d4ede2..430744110f77e 100644 --- a/tests/cases/fourslash/renameInheritedProperties5.ts +++ b/tests/cases/fourslash/renameInheritedProperties5.ts @@ -4,10 +4,10 @@ //// propC: number; //// } //// interface D extends C { -//// [|propD|]: string; +//// [|[|{| "contextRangeIndex": 0 |}propD|]: string;|] //// } //// var d: D; //// d.[|propD|]; -verify.rangesAreRenameLocations(); +verify.rangesWithSameTextAreRenameLocations("propD"); diff --git a/tests/cases/fourslash/renameInheritedProperties6.ts b/tests/cases/fourslash/renameInheritedProperties6.ts index 59318334cb0a9..31f28fbbd336d 100644 --- a/tests/cases/fourslash/renameInheritedProperties6.ts +++ b/tests/cases/fourslash/renameInheritedProperties6.ts @@ -4,9 +4,9 @@ //// propD: number; //// } //// interface D extends C { -//// [|propC|]: number; +//// [|[|{| "contextRangeIndex": 0 |}propC|]: number;|] //// } //// var d: D; //// d.[|propC|]; -verify.rangesAreRenameLocations(); +verify.rangesWithSameTextAreRenameLocations("propC"); diff --git a/tests/cases/fourslash/renameInheritedProperties7.ts b/tests/cases/fourslash/renameInheritedProperties7.ts index bc0521458f89d..02bdae3132989 100644 --- a/tests/cases/fourslash/renameInheritedProperties7.ts +++ b/tests/cases/fourslash/renameInheritedProperties7.ts @@ -1,7 +1,7 @@ /// //// class C extends D { -//// [|prop1|]: string; +//// [|[|{| "contextRangeIndex": 0 |}prop1|]: string;|] //// } //// //// class D extends C { @@ -11,4 +11,4 @@ //// var c: C; //// c.[|prop1|]; -verify.rangesAreRenameLocations(); +verify.rangesWithSameTextAreRenameLocations("prop1"); diff --git a/tests/cases/fourslash/renameInheritedProperties8.ts b/tests/cases/fourslash/renameInheritedProperties8.ts index 7cde300bf0ba2..2113ec92db558 100644 --- a/tests/cases/fourslash/renameInheritedProperties8.ts +++ b/tests/cases/fourslash/renameInheritedProperties8.ts @@ -1,14 +1,14 @@ /// //// class C implements D { -//// [|prop1|]: string; +//// [|[|{| "contextRangeIndex": 0 |}prop1|]: string;|] //// } //// //// interface D extends C { -//// [|prop1|]: string; +//// [|[|{| "contextRangeIndex": 2 |}prop1|]: string;|] //// } //// //// var c: C; //// c.[|prop1|]; -verify.rangesAreRenameLocations(); +verify.rangesWithSameTextAreRenameLocations("prop1"); diff --git a/tests/cases/fourslash/renameJsExports01.ts b/tests/cases/fourslash/renameJsExports01.ts index e1b71d232a65a..bcb9b3b78e5c5 100644 --- a/tests/cases/fourslash/renameJsExports01.ts +++ b/tests/cases/fourslash/renameJsExports01.ts @@ -2,11 +2,11 @@ // @allowJs: true // @Filename: a.js -////exports.[|{| "isWriteAccess": true, "isDefinition": true |}area|] = function (r) { return r * r; } +////[|exports.[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}area|] = function (r) { return r * r; }|] // @Filename: b.js ////var mod = require('./a'); ////var t = mod./**/[|area|](10); -verify.singleReferenceGroup("(property) area: (r: any) => number"); -verify.rangesAreRenameLocations(); +verify.singleReferenceGroup("(property) area: (r: any) => number", "area"); +verify.rangesWithSameTextAreRenameLocations("area"); diff --git a/tests/cases/fourslash/renameJsExports02.ts b/tests/cases/fourslash/renameJsExports02.ts index 94c84980784f4..17f69760931c9 100644 --- a/tests/cases/fourslash/renameJsExports02.ts +++ b/tests/cases/fourslash/renameJsExports02.ts @@ -2,12 +2,12 @@ // @allowJs: true // @Filename: a.js -////module.exports = class [|{| "isWriteAccess": true, "isDefinition": true |}A|] {} +////module.exports = [|class [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}A|] {}|] // @Filename: b.js -////const [|{| "isWriteAccess": true, "isDefinition": true |}A|] = require("./a"); +////[|const [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 2 |}A|] = require("./a");|] -const [r0, r1] = test.ranges(); +const [rDef, r0, r1Def, r1] = test.ranges(); verify.referenceGroups(r0, [ { definition: "(local class) A", ranges: [r0] }, { definition: "const A: typeof A", ranges: [r1] } diff --git a/tests/cases/fourslash/renameJsExports03.ts b/tests/cases/fourslash/renameJsExports03.ts index c4378cfaa1ae6..d1fafa70c8089 100644 --- a/tests/cases/fourslash/renameJsExports03.ts +++ b/tests/cases/fourslash/renameJsExports03.ts @@ -2,16 +2,16 @@ // @allowJs: true // @Filename: a.js -////class [|{| "isWriteAccess": true, "isDefinition": true |}A|] { -//// [|constructor|]() { } -////} -////module.exports = [|A|]; +////[|class [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}A|] { +//// [|[|{| "contextRangeIndex": 2 |}constructor|]() { }|] +////}|] +////[|module.exports = [|{| "contextRangeIndex": 4 |}A|];|] // @Filename: b.js -////const [|{| "isWriteAccess": true, "isDefinition": true |}A|] = require("./a"); +////[|const [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 6 |}A|] = require("./a");|] ////new [|A|]; -const [r0, r1, r2, r3, r4] = test.ranges(); +const [r0Def, r0, r1Def, r1, r2Def, r2, r3Def, r3, r4] = test.ranges(); verify.referenceGroups([r0, r2], [ { definition: "class A", ranges: [r0, r2] }, { definition: "const A: typeof A", ranges: [r3, r4] } diff --git a/tests/cases/fourslash/renameJsPropertyAssignment.ts b/tests/cases/fourslash/renameJsPropertyAssignment.ts index 87daae544e1e8..5db313ad5ab1c 100644 --- a/tests/cases/fourslash/renameJsPropertyAssignment.ts +++ b/tests/cases/fourslash/renameJsPropertyAssignment.ts @@ -4,7 +4,7 @@ // @Filename: a.js ////function bar() { ////} -////bar.[|foo|] = "foo"; +////[|bar.[|{| "contextRangeIndex": 0 |}foo|] = "foo";|] ////console.log(bar.[|foo|]); -verify.rangesAreRenameLocations(); +verify.rangesWithSameTextAreRenameLocations("foo"); diff --git a/tests/cases/fourslash/renameJsPropertyAssignment2.ts b/tests/cases/fourslash/renameJsPropertyAssignment2.ts index eaea2b9aa276b..9bdc71f4713d0 100644 --- a/tests/cases/fourslash/renameJsPropertyAssignment2.ts +++ b/tests/cases/fourslash/renameJsPropertyAssignment2.ts @@ -4,7 +4,7 @@ // @Filename: a.js ////class Minimatch { ////} -////Minimatch.[|staticProperty|] = "string"; +////[|Minimatch.[|{| "contextRangeIndex": 0 |}staticProperty|] = "string";|] ////console.log(Minimatch.[|staticProperty|]); -verify.rangesAreRenameLocations(); +verify.rangesWithSameTextAreRenameLocations("staticProperty"); diff --git a/tests/cases/fourslash/renameJsPropertyAssignment3.ts b/tests/cases/fourslash/renameJsPropertyAssignment3.ts index cedf69c7eeea8..0d32cf5575233 100644 --- a/tests/cases/fourslash/renameJsPropertyAssignment3.ts +++ b/tests/cases/fourslash/renameJsPropertyAssignment3.ts @@ -4,7 +4,7 @@ // @Filename: a.js ////var C = class { ////} -////C.[|staticProperty|] = "string"; +////[|C.[|{| "contextRangeIndex": 0 |}staticProperty|] = "string";|] ////console.log(C.[|staticProperty|]); -verify.rangesAreRenameLocations(); +verify.rangesWithSameTextAreRenameLocations("staticProperty"); diff --git a/tests/cases/fourslash/renameJsPrototypeProperty01.ts b/tests/cases/fourslash/renameJsPrototypeProperty01.ts index 1700f15619d50..8e37e6b88bea8 100644 --- a/tests/cases/fourslash/renameJsPrototypeProperty01.ts +++ b/tests/cases/fourslash/renameJsPrototypeProperty01.ts @@ -4,8 +4,8 @@ // @Filename: a.js ////function bar() { ////} -////bar.prototype.[|x|] = 10; +////[|bar.prototype.[|{| "contextRangeIndex": 0 |}x|] = 10;|] ////var t = new bar(); -////t.[|x|] = 11; +////[|t.[|{| "contextRangeIndex": 2 |}x|] = 11;|] -verify.rangesAreRenameLocations(); +verify.rangesWithSameTextAreRenameLocations("x"); diff --git a/tests/cases/fourslash/renameJsPrototypeProperty02.ts b/tests/cases/fourslash/renameJsPrototypeProperty02.ts index 1700f15619d50..8e37e6b88bea8 100644 --- a/tests/cases/fourslash/renameJsPrototypeProperty02.ts +++ b/tests/cases/fourslash/renameJsPrototypeProperty02.ts @@ -4,8 +4,8 @@ // @Filename: a.js ////function bar() { ////} -////bar.prototype.[|x|] = 10; +////[|bar.prototype.[|{| "contextRangeIndex": 0 |}x|] = 10;|] ////var t = new bar(); -////t.[|x|] = 11; +////[|t.[|{| "contextRangeIndex": 2 |}x|] = 11;|] -verify.rangesAreRenameLocations(); +verify.rangesWithSameTextAreRenameLocations("x"); diff --git a/tests/cases/fourslash/renameJsThisProperty01.ts b/tests/cases/fourslash/renameJsThisProperty01.ts index 5680dbf08fd1a..de42aa6be0380 100644 --- a/tests/cases/fourslash/renameJsThisProperty01.ts +++ b/tests/cases/fourslash/renameJsThisProperty01.ts @@ -3,9 +3,9 @@ // @allowJs: true // @Filename: a.js ////function bar() { -//// this.[|x|] = 10; +//// [|this.[|{| "contextRangeIndex": 0 |}x|] = 10;|] ////} ////var t = new bar(); -////t.[|x|] = 11; +////[|t.[|{| "contextRangeIndex": 2 |}x|] = 11;|] -verify.rangesAreRenameLocations(); +verify.rangesWithSameTextAreRenameLocations("x"); diff --git a/tests/cases/fourslash/renameJsThisProperty03.ts b/tests/cases/fourslash/renameJsThisProperty03.ts index 8633c61132c8b..c9891aef81ff9 100644 --- a/tests/cases/fourslash/renameJsThisProperty03.ts +++ b/tests/cases/fourslash/renameJsThisProperty03.ts @@ -4,10 +4,10 @@ // @Filename: a.js ////class C { //// constructor(y) { -//// this.[|x|] = y; +//// [|this.[|{| "contextRangeIndex": 0 |}x|] = y;|] //// } ////} ////var t = new C(12); -////t.[|x|] = 11; +////[|t.[|{| "contextRangeIndex": 2 |}x|] = 11;|] -verify.rangesAreRenameLocations(); +verify.rangesWithSameTextAreRenameLocations("x"); diff --git a/tests/cases/fourslash/renameJsThisProperty05.ts b/tests/cases/fourslash/renameJsThisProperty05.ts index 861919ec777e2..b9d36f164a84f 100644 --- a/tests/cases/fourslash/renameJsThisProperty05.ts +++ b/tests/cases/fourslash/renameJsThisProperty05.ts @@ -7,8 +7,8 @@ //// this.x = y; //// } ////} -////C.prototype.[|z|] = 1; +////[|C.prototype.[|{| "contextRangeIndex": 0 |}z|] = 1;|] ////var t = new C(12); -////t.[|z|] = 11; +////[|t.[|{| "contextRangeIndex": 2 |}z|] = 11;|] -verify.rangesAreRenameLocations(); +verify.rangesWithSameTextAreRenameLocations("z"); diff --git a/tests/cases/fourslash/renameJsThisProperty06.ts b/tests/cases/fourslash/renameJsThisProperty06.ts index 7269a50f4f0b5..de73d27180d5d 100644 --- a/tests/cases/fourslash/renameJsThisProperty06.ts +++ b/tests/cases/fourslash/renameJsThisProperty06.ts @@ -7,8 +7,8 @@ //// this.x = y; //// } ////} -////C.prototype.[|z|] = 1; +////[|C.prototype.[|{| "contextRangeIndex": 0 |}z|] = 1;|] ////var t = new C(12); -////t.[|z|] = 11; +////[|t.[|{| "contextRangeIndex": 2 |}z|] = 11;|] -verify.rangesAreRenameLocations(); +verify.rangesWithSameTextAreRenameLocations("z"); diff --git a/tests/cases/fourslash/renameLocationsForClassExpression01.ts b/tests/cases/fourslash/renameLocationsForClassExpression01.ts index b0f2f5095007a..b7d8258b3870d 100644 --- a/tests/cases/fourslash/renameLocationsForClassExpression01.ts +++ b/tests/cases/fourslash/renameLocationsForClassExpression01.ts @@ -3,7 +3,7 @@ ////class Foo { ////} //// -////var x = class [|Foo|] { +////var x = [|class [|{| "contextRangeIndex": 0 |}Foo|] { //// doIt() { //// return [|Foo|]; //// } @@ -11,7 +11,7 @@ //// static doItStatically() { //// return [|Foo|].y; //// } -////} +////}|] //// ////var y = class { //// getSomeName() { @@ -20,4 +20,4 @@ ////} ////var z = class Foo {} -verify.rangesAreRenameLocations(); +verify.rangesWithSameTextAreRenameLocations("Foo"); diff --git a/tests/cases/fourslash/renameLocationsForFunctionExpression01.ts b/tests/cases/fourslash/renameLocationsForFunctionExpression01.ts index 1e02e3f52849d..976637271ae5b 100644 --- a/tests/cases/fourslash/renameLocationsForFunctionExpression01.ts +++ b/tests/cases/fourslash/renameLocationsForFunctionExpression01.ts @@ -1,7 +1,7 @@ /// -////var x = function [|f|](g: any, h: any) { +////var x = [|function [|{| "contextRangeIndex": 0 |}f|](g: any, h: any) { //// [|f|]([|f|], g); -////} +////}|] -verify.rangesAreRenameLocations(); +verify.rangesWithSameTextAreRenameLocations("f"); diff --git a/tests/cases/fourslash/renameLocationsForFunctionExpression02.ts b/tests/cases/fourslash/renameLocationsForFunctionExpression02.ts index a258bcd803d2d..e2eb6c02a3d51 100644 --- a/tests/cases/fourslash/renameLocationsForFunctionExpression02.ts +++ b/tests/cases/fourslash/renameLocationsForFunctionExpression02.ts @@ -3,11 +3,11 @@ ////function f() { //// ////} -////var x = function [|f|](g: any, h: any) { +////var x = [|function [|{| "contextRangeIndex": 0 |}f|](g: any, h: any) { //// //// let helper = function f(): any { f(); } //// //// let foo = () => [|f|]([|f|], g); -////} +////}|] -verify.rangesAreRenameLocations(); +verify.rangesWithSameTextAreRenameLocations("f"); diff --git a/tests/cases/fourslash/renameObjectBindingElementPropertyName01.ts b/tests/cases/fourslash/renameObjectBindingElementPropertyName01.ts index 4ae87f19db53e..079085b5875a8 100644 --- a/tests/cases/fourslash/renameObjectBindingElementPropertyName01.ts +++ b/tests/cases/fourslash/renameObjectBindingElementPropertyName01.ts @@ -1,11 +1,12 @@ /// ////interface I { -//// [|property1|]: number; +//// [|[|{| "contextRangeIndex": 0 |}property1|]: number;|] //// property2: string; ////} //// ////var foo: I; -////var { [|property1|]: prop1 } = foo; +////[|var { [|{| "contextRangeIndex": 2 |}property1|]: prop1 } = foo;|] -verify.rangesAreRenameLocations(); + +verify.rangesWithSameTextAreRenameLocations("property1"); diff --git a/tests/cases/fourslash/renameObjectSpread.ts b/tests/cases/fourslash/renameObjectSpread.ts index f3af6e0280f80..945d7613bfc39 100644 --- a/tests/cases/fourslash/renameObjectSpread.ts +++ b/tests/cases/fourslash/renameObjectSpread.ts @@ -1,13 +1,13 @@ /// -////interface A1 { [|a|]: number }; -////interface A2 { [|a|]?: number }; +////interface A1 { [|[|{| "contextRangeIndex": 0 |}a|]: number|] }; +////interface A2 { [|[|{| "contextRangeIndex": 2 |}a|]?: number|] }; ////let a1: A1; ////let a2: A2; ////let a12 = { ...a1, ...a2 }; ////a12.[|a|]; -const [r0, r1, r2] = test.ranges(); +const [r0Def, r0, r1Def, r1, r2] = test.ranges(); // A1 unions with A2, so rename A1.a and a12.a verify.renameLocations(r0, [r0, r2]); // A1 unions with A2, so rename A2.a and a12.a diff --git a/tests/cases/fourslash/renameObjectSpreadAssignment.ts b/tests/cases/fourslash/renameObjectSpreadAssignment.ts index 9d55e43afa563..4ff66fef99ec2 100644 --- a/tests/cases/fourslash/renameObjectSpreadAssignment.ts +++ b/tests/cases/fourslash/renameObjectSpreadAssignment.ts @@ -2,10 +2,10 @@ ////interface A1 { a: number }; ////interface A2 { a?: number }; -////let [|a1|]: A1; -////let [|a2|]: A2; +////[|let [|{| "contextRangeIndex": 0 |}a1|]: A1;|] +////[|let [|{| "contextRangeIndex": 2 |}a2|]: A2;|] ////let a12 = { ...[|a1|], ...[|a2|] }; -const [r0, r1, r2, r3] = test.ranges(); +const [r0Def, r0, r1Def, r1, r2, r3] = test.ranges(); verify.rangesAreRenameLocations([r0, r2]); verify.rangesAreRenameLocations([r1, r3]); diff --git a/tests/cases/fourslash/renameParameterPropertyDeclaration1.ts b/tests/cases/fourslash/renameParameterPropertyDeclaration1.ts index 14f8a240bfb66..08b9b5456d62b 100644 --- a/tests/cases/fourslash/renameParameterPropertyDeclaration1.ts +++ b/tests/cases/fourslash/renameParameterPropertyDeclaration1.ts @@ -1,10 +1,10 @@ /// //// class Foo { -//// constructor(private [|privateParam|]: number) { +//// constructor([|private [|{| "contextRangeIndex": 0 |}privateParam|]: number|]) { //// let localPrivate = [|privateParam|]; //// this.[|privateParam|] += 10; //// } //// } -verify.rangesAreRenameLocations(); +verify.rangesWithSameTextAreRenameLocations("privateParam"); diff --git a/tests/cases/fourslash/renameParameterPropertyDeclaration2.ts b/tests/cases/fourslash/renameParameterPropertyDeclaration2.ts index ce31ad6c9c5d0..0fc326cd11605 100644 --- a/tests/cases/fourslash/renameParameterPropertyDeclaration2.ts +++ b/tests/cases/fourslash/renameParameterPropertyDeclaration2.ts @@ -1,10 +1,10 @@ /// //// class Foo { -//// constructor(public [|publicParam|]: number) { +//// constructor([|public [|{| "contextRangeIndex": 0 |}publicParam|]: number|]) { //// let publicParam = [|publicParam|]; //// this.[|publicParam|] += 10; //// } //// } -verify.rangesAreRenameLocations(); +verify.rangesWithSameTextAreRenameLocations("publicParam"); diff --git a/tests/cases/fourslash/renameParameterPropertyDeclaration3.ts b/tests/cases/fourslash/renameParameterPropertyDeclaration3.ts index 6291eff2605ba..127b735048772 100644 --- a/tests/cases/fourslash/renameParameterPropertyDeclaration3.ts +++ b/tests/cases/fourslash/renameParameterPropertyDeclaration3.ts @@ -1,10 +1,10 @@ /// //// class Foo { -//// constructor(protected [|protectedParam|]: number) { +//// constructor([|protected [|{| "contextRangeIndex": 0 |}protectedParam|]: number|]) { //// let protectedParam = [|protectedParam|]; //// this.[|protectedParam|] += 10; //// } //// } -verify.rangesAreRenameLocations(); +verify.rangesWithSameTextAreRenameLocations("protectedParam"); diff --git a/tests/cases/fourslash/renameParameterPropertyDeclaration4.ts b/tests/cases/fourslash/renameParameterPropertyDeclaration4.ts index 292c82a2d523f..ce2b26a2fc8f8 100644 --- a/tests/cases/fourslash/renameParameterPropertyDeclaration4.ts +++ b/tests/cases/fourslash/renameParameterPropertyDeclaration4.ts @@ -1,10 +1,10 @@ /// //// class Foo { -//// constructor(protected { [|protectedParam|] }) { +//// constructor([|protected { [|{| "contextRangeIndex": 0 |}protectedParam|] }|]) { //// let myProtectedParam = [|protectedParam|]; //// } //// } -const [r0, r1] = test.ranges(); +const [r0Def, r0, r1] = test.ranges(); verify.renameLocations([r0, r1], [{ range: r0, prefixText: "protectedParam: " }, r1]); diff --git a/tests/cases/fourslash/renameParameterPropertyDeclaration5.ts b/tests/cases/fourslash/renameParameterPropertyDeclaration5.ts index f989e7c3fd9fc..4bd9cd137bcef 100644 --- a/tests/cases/fourslash/renameParameterPropertyDeclaration5.ts +++ b/tests/cases/fourslash/renameParameterPropertyDeclaration5.ts @@ -1,9 +1,9 @@ /// //// class Foo { -//// constructor(protected [ [|protectedParam|] ]) { +//// constructor([|protected [ [|{| "contextRangeIndex": 0 |}protectedParam|] ]|]) { //// let myProtectedParam = [|protectedParam|]; //// } //// } -verify.rangesAreRenameLocations(); +verify.rangesWithSameTextAreRenameLocations("protectedParam"); diff --git a/tests/cases/fourslash/renamePropertyAccessExpressionHeritageClause.ts b/tests/cases/fourslash/renamePropertyAccessExpressionHeritageClause.ts index 04b741a4b97d5..7967533faf009 100644 --- a/tests/cases/fourslash/renamePropertyAccessExpressionHeritageClause.ts +++ b/tests/cases/fourslash/renamePropertyAccessExpressionHeritageClause.ts @@ -2,9 +2,9 @@ //// class B {} //// function foo() { -//// return {[|B|]: B}; +//// return {[|[|{| "contextRangeIndex": 0 |}B|]: B|]}; //// } //// class C extends (foo()).[|B|] {} //// class C1 extends foo().[|B|] {} -verify.rangesAreRenameLocations(); \ No newline at end of file +verify.rangesWithSameTextAreRenameLocations("B"); \ No newline at end of file diff --git a/tests/cases/fourslash/renameReExportDefault.ts b/tests/cases/fourslash/renameReExportDefault.ts index 0eb5b81d20957..df544f6e87d53 100644 --- a/tests/cases/fourslash/renameReExportDefault.ts +++ b/tests/cases/fourslash/renameReExportDefault.ts @@ -2,17 +2,17 @@ // @Filename: /a.ts ////export { default } from "./b"; -////export { default as [|b|] } from "./b"; +////[|export { default as [|{| "contextRangeIndex": 0 |}b|] } from "./b";|] ////export { default as bee } from "./b"; -////import { default as [|b|] } from "./b"; +////[|import { default as [|{| "contextRangeIndex": 2 |}b|] } from "./b";|] ////import { default as bee } from "./b"; -////import [|b|] from "./b"; +////[|import [|{| "contextRangeIndex": 4 |}b|] from "./b";|] // @Filename: /b.ts -////const [|b|] = 0; -////export default [|b|]; +////[|const [|{| "contextRangeIndex": 6 |}b|] = 0;|] +////[|export default [|{| "contextRangeIndex": 8 |}b|];|] -const [r0, r1, r2, r3, r4] = test.ranges(); +const [r0Def, r0, r1Def, r1, r2Def, r2, r3Def, r3, r4Def, r4] = test.ranges(); verify.renameLocations(r0, [r0]); verify.renameLocations(r1, [r1]); verify.renameLocations(r2, [r2]); diff --git a/tests/cases/fourslash/renameRest.ts b/tests/cases/fourslash/renameRest.ts index 60fc1bbb22757..a1bf56c737ecf 100644 --- a/tests/cases/fourslash/renameRest.ts +++ b/tests/cases/fourslash/renameRest.ts @@ -1,11 +1,11 @@ /// ////interface Gen { //// x: number; -//// [|parent|]: Gen; +//// [|[|{| "contextRangeIndex": 0 |}parent|]: Gen;|] //// millenial: string; ////} ////let t: Gen; ////var { x, ...rest } = t; ////rest.[|parent|]; -verify.rangesAreRenameLocations(); +verify.rangesWithSameTextAreRenameLocations("parent"); diff --git a/tests/cases/fourslash/renameStringPropertyNames.ts b/tests/cases/fourslash/renameStringPropertyNames.ts index 13863b043e7d5..5c7d761422e17 100644 --- a/tests/cases/fourslash/renameStringPropertyNames.ts +++ b/tests/cases/fourslash/renameStringPropertyNames.ts @@ -1,15 +1,15 @@ /// ////var o = { -//// [|prop|]: 0 +//// [|[|{| "contextRangeIndex": 0 |}prop|]: 0|] ////}; //// ////o = { -//// "[|prop|]": 1 +//// [|"[|{| "contextRangeIndex": 2 |}prop|]": 1|] ////}; //// ////o["[|prop|]"]; ////o['[|prop|]']; ////o.[|prop|]; -verify.rangesAreRenameLocations(); +verify.rangesWithSameTextAreRenameLocations("prop"); diff --git a/tests/cases/fourslash/renameThis.ts b/tests/cases/fourslash/renameThis.ts index e626294bf46c4..b26a02553017b 100644 --- a/tests/cases/fourslash/renameThis.ts +++ b/tests/cases/fourslash/renameThis.ts @@ -4,9 +4,9 @@ //// return [|this|]; ////} ////this/**/; -////const _ = { [|this|]: 0 }.[|this|]; +////const _ = { [|[|{| "contextRangeIndex": 2 |}this|]: 0|] }.[|this|]; -const [r0, r1, r2, r3] = test.ranges() +const [r0, r1, r2Def, r2, r3] = test.ranges() verify.rangesAreRenameLocations([r0, r1]); // Trying to rename a non-parameter 'this' should fail diff --git a/tests/cases/fourslash/renameUMDModuleAlias1.ts b/tests/cases/fourslash/renameUMDModuleAlias1.ts index c44e459b0084a..04bc8a15489a1 100644 --- a/tests/cases/fourslash/renameUMDModuleAlias1.ts +++ b/tests/cases/fourslash/renameUMDModuleAlias1.ts @@ -4,10 +4,10 @@ //// export function doThing(): string; //// export function doTheOtherThing(): void; -//// export as namespace [|myLib|]; +//// [|export as namespace [|{| "contextRangeIndex": 0 |}myLib|];|] // @Filename: 1.ts //// /// //// [|myLib|].doThing(); -verify.rangesAreRenameLocations(); +verify.rangesWithSameTextAreRenameLocations("myLib"); diff --git a/tests/cases/fourslash/server/jsdocCallbackTagRename01.ts b/tests/cases/fourslash/server/jsdocCallbackTagRename01.ts index bb7dd32cfc28d..e4cd7d06feb14 100644 --- a/tests/cases/fourslash/server/jsdocCallbackTagRename01.ts +++ b/tests/cases/fourslash/server/jsdocCallbackTagRename01.ts @@ -4,12 +4,12 @@ // @Filename: jsDocCallback.js //// //// /** -//// * @callback [|FooCallback|] +//// * [|@callback [|{| "contextRangeIndex": 0 |}FooCallback|] //// * @param {string} eventName - Rename should work -//// */ +//// |]*/ //// //// /** @type {/*1*/[|FooCallback|]} */ //// var t; -const ranges = test.ranges(); +const [rDef, ...ranges] = test.ranges(); verify.renameLocations(ranges[0], { findInStrings: false, findInComments: true, ranges }); diff --git a/tests/cases/fourslash/server/jsdocTypedefTagRename01.ts b/tests/cases/fourslash/server/jsdocTypedefTagRename01.ts index 38a35b58cbfd9..14f24b4c6eabb 100644 --- a/tests/cases/fourslash/server/jsdocTypedefTagRename01.ts +++ b/tests/cases/fourslash/server/jsdocTypedefTagRename01.ts @@ -4,11 +4,12 @@ // @Filename: jsDocTypedef_form1.js //// //// /** @typedef {(string | number)} */ -//// var [|NumberLike|]; +//// [|var [|{| "contextRangeIndex": 0 |}NumberLike|];|] //// //// [|NumberLike|] = 10; //// //// /** @type {[|NumberLike|]} */ //// var numberLike; -verify.rangesAreRenameLocations({ findInComments: true }); +const [rDef, ...ranges] = test.ranges(); +verify.rangesAreRenameLocations({ findInComments: true, ranges }); diff --git a/tests/cases/fourslash/server/jsdocTypedefTagRename02.ts b/tests/cases/fourslash/server/jsdocTypedefTagRename02.ts index 38da754247fa1..30c99deb0a86c 100644 --- a/tests/cases/fourslash/server/jsdocTypedefTagRename02.ts +++ b/tests/cases/fourslash/server/jsdocTypedefTagRename02.ts @@ -3,9 +3,10 @@ // @allowNonTsExtensions: true // @Filename: jsDocTypedef_form2.js //// -//// /** @typedef {(string | number)} [|NumberLike|] */ +//// /** [|@typedef {(string | number)} [|{| "contextRangeIndex": 0 |}NumberLike|]|] */ //// //// /** @type {[|NumberLike|]} */ //// var numberLike; -verify.rangesAreRenameLocations({ findInComments: true }); +const [rDef, ...ranges] = test.ranges(); +verify.rangesAreRenameLocations({ findInComments: true, ranges }); diff --git a/tests/cases/fourslash/server/jsdocTypedefTagRename03.ts b/tests/cases/fourslash/server/jsdocTypedefTagRename03.ts index 7b61682e59496..310235bc8e901 100644 --- a/tests/cases/fourslash/server/jsdocTypedefTagRename03.ts +++ b/tests/cases/fourslash/server/jsdocTypedefTagRename03.ts @@ -4,14 +4,14 @@ // @Filename: jsDocTypedef_form3.js //// //// /** -//// * @typedef /*1*/[|Person|] +//// * [|@typedef /*1*/[|{| "contextRangeIndex": 0 |}Person|] //// * @type {Object} //// * @property {number} age //// * @property {string} name -//// */ +//// |]*/ //// //// /** @type {/*2*/[|Person|]} */ //// var person; goTo.file('jsDocTypedef_form3.js') -verify.rangesAreRenameLocations({ findInComments: true }); +verify.rangesAreRenameLocations({ findInComments: true, ranges: test.rangesByText().get("Person") }); diff --git a/tests/cases/fourslash/server/rename01.ts b/tests/cases/fourslash/server/rename01.ts index 74385c30da396..66afa70a8e882 100644 --- a/tests/cases/fourslash/server/rename01.ts +++ b/tests/cases/fourslash/server/rename01.ts @@ -2,10 +2,10 @@ /////// -////function [|Bar|]() { +////[|function [|{| "contextRangeIndex": 0 |}Bar|]() { //// // This is a reference to [|Bar|] in a comment. //// "this is a reference to [|Bar|] in a string" -////} +////}|] -const ranges = test.ranges(); +const [rDef, ...ranges] = test.ranges(); verify.renameLocations(ranges[0], { findInStrings: true, findInComments: true, ranges }); diff --git a/tests/cases/fourslash/server/renameInConfiguredProject.ts b/tests/cases/fourslash/server/renameInConfiguredProject.ts index a235f783f4c27..f9e567fef049d 100644 --- a/tests/cases/fourslash/server/renameInConfiguredProject.ts +++ b/tests/cases/fourslash/server/renameInConfiguredProject.ts @@ -1,7 +1,7 @@ /// // @Filename: referencesForGlobals_1.ts -////var [|globalName|] = 0; +////[|var [|{| "contextRangeIndex": 0 |}globalName|] = 0;|] // @Filename: referencesForGlobals_2.ts ////var y = [|globalName|]; @@ -9,4 +9,5 @@ // @Filename: tsconfig.json ////{ "files": ["referencesForGlobals_1.ts", "referencesForGlobals_2.ts"] } -verify.rangesAreRenameLocations({ findInStrings: true, findInComments: true }); +const [rDef, ...ranges] = test.ranges(); +verify.rangesAreRenameLocations({ findInStrings: true, findInComments: true, ranges }); diff --git a/tests/cases/fourslash/shims-pp/getReferencesAtPosition.ts b/tests/cases/fourslash/shims-pp/getReferencesAtPosition.ts index 7189738435fbf..c3bb5fa84284e 100644 --- a/tests/cases/fourslash/shims-pp/getReferencesAtPosition.ts +++ b/tests/cases/fourslash/shims-pp/getReferencesAtPosition.ts @@ -7,9 +7,9 @@ //// //// } //// -//// public [|{| "isWriteAccess": true, "isDefinition": true |}start|](){ +//// [|public [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}start|](){ //// return this; -//// } +//// }|] //// //// public stop(){ //// return this; @@ -23,4 +23,4 @@ ////second.[|start|](); ////second.stop(); -verify.singleReferenceGroup("(method) Test.start(): this"); +verify.singleReferenceGroup("(method) Test.start(): this", "start"); diff --git a/tests/cases/fourslash/shims-pp/getRenameInfo.ts b/tests/cases/fourslash/shims-pp/getRenameInfo.ts index aa04d69962abe..3f32093ca148b 100644 --- a/tests/cases/fourslash/shims-pp/getRenameInfo.ts +++ b/tests/cases/fourslash/shims-pp/getRenameInfo.ts @@ -2,9 +2,9 @@ /////// -////function [|Bar|]() { +////[|function [|{| "contextRangeIndex": 0 |}Bar|]() { //// // This is a reference to Bar in a comment. //// "this is a reference to Bar in a string" -////} +////}|] -verify.rangesAreRenameLocations(); +verify.rangesWithSameTextAreRenameLocations("Bar"); diff --git a/tests/cases/fourslash/shims/getReferencesAtPosition.ts b/tests/cases/fourslash/shims/getReferencesAtPosition.ts index 7189738435fbf..c3bb5fa84284e 100644 --- a/tests/cases/fourslash/shims/getReferencesAtPosition.ts +++ b/tests/cases/fourslash/shims/getReferencesAtPosition.ts @@ -7,9 +7,9 @@ //// //// } //// -//// public [|{| "isWriteAccess": true, "isDefinition": true |}start|](){ +//// [|public [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}start|](){ //// return this; -//// } +//// }|] //// //// public stop(){ //// return this; @@ -23,4 +23,4 @@ ////second.[|start|](); ////second.stop(); -verify.singleReferenceGroup("(method) Test.start(): this"); +verify.singleReferenceGroup("(method) Test.start(): this", "start"); diff --git a/tests/cases/fourslash/shims/getRenameInfo.ts b/tests/cases/fourslash/shims/getRenameInfo.ts index aa04d69962abe..3f32093ca148b 100644 --- a/tests/cases/fourslash/shims/getRenameInfo.ts +++ b/tests/cases/fourslash/shims/getRenameInfo.ts @@ -2,9 +2,9 @@ /////// -////function [|Bar|]() { +////[|function [|{| "contextRangeIndex": 0 |}Bar|]() { //// // This is a reference to Bar in a comment. //// "this is a reference to Bar in a string" -////} +////}|] -verify.rangesAreRenameLocations(); +verify.rangesWithSameTextAreRenameLocations("Bar"); diff --git a/tests/cases/fourslash/transitiveExportImports.ts b/tests/cases/fourslash/transitiveExportImports.ts index 9cdfb2e3a1296..4fe92f5a528da 100644 --- a/tests/cases/fourslash/transitiveExportImports.ts +++ b/tests/cases/fourslash/transitiveExportImports.ts @@ -1,22 +1,22 @@ /// // @Filename: a.ts -////class [|{| "isWriteAccess": true, "isDefinition": true |}A|] { -////} -////export = [|A|]; +////[|class [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}A|] { +////}|] +////[|export = [|{| "contextRangeIndex": 2 |}A|];|] // @Filename: b.ts -////export import [|{| "isWriteAccess": true, "isDefinition": true |}b|] = require('./a'); +////[|export import [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 4 |}b|] = require('./a');|] // @Filename: c.ts -////import [|{| "isWriteAccess": true, "isDefinition": true |}b|] = require('./b'); +////[|import [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 6 |}b|] = require('./b');|] ////var a = new [|b|]./**/[|b|](); goTo.marker(); verify.quickInfoExists(); verify.noErrors(); -const [a0, a1, b0, c0, c1, c2] = test.ranges(); +const [a0Def, a0, a1Def, a1, b0Def, b0, c0Def, c0, c1, c2] = test.ranges(); const aRanges = [a0, a1]; const bRanges = [b0, c2]; const cRanges = [c0, c1]; diff --git a/tests/cases/fourslash/transitiveExportImports2.ts b/tests/cases/fourslash/transitiveExportImports2.ts index 7ec1e61c02b22..387b2e5be1954 100644 --- a/tests/cases/fourslash/transitiveExportImports2.ts +++ b/tests/cases/fourslash/transitiveExportImports2.ts @@ -1,20 +1,20 @@ /// // @Filename: a.ts -////namespace [|{| "isWriteAccess": true, "isDefinition": true |}A|] { +////[|namespace [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}A|] { //// export const x = 0; -////} +////}|] // @Filename: b.ts -////export import [|{| "isWriteAccess": true, "isDefinition": true |}B|] = [|A|]; +////[|export import [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 2 |}B|] = [|A|];|] ////[|B|].x; // @Filename: c.ts -////import { [|{| "isWriteAccess": true, "isDefinition": true |}B|] } from "./b"; +////[|import { [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 6 |}B|] } from "./b";|] verify.noErrors(); -const [A0, B0, A1, B1, B2] = test.ranges(); +const [A0Def, A0, B0Def, B0, A1, B1, B2Def, B2] = test.ranges(); const aRanges = [A0, A1]; const bRanges = [B0, B1]; const cRanges = [B2]; diff --git a/tests/cases/fourslash/transitiveExportImports3.ts b/tests/cases/fourslash/transitiveExportImports3.ts index c5d6dfe9afcf2..341e57003dadd 100644 --- a/tests/cases/fourslash/transitiveExportImports3.ts +++ b/tests/cases/fourslash/transitiveExportImports3.ts @@ -1,16 +1,16 @@ /// // @Filename: a.ts -////export function [|{| "isWriteAccess": true, "isDefinition": true |}f|]() {} +////[|export function [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}f|]() {}|] // @Filename: b.ts -////export { [|f|] as [|{| "isWriteAccess": true, "isDefinition": true |}g|] } from "./a"; -////import { [|{| "isWriteAccess": true, "isDefinition": true |}f|] } from "./a"; -////import { [|{| "isWriteAccess": true, "isDefinition": true |}g|] } from "./b"; +////[|export { [|{| "contextRangeIndex": 2 |}f|] as [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 2 |}g|] } from "./a";|] +////[|import { [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 5 |}f|] } from "./a";|] +////[|import { [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 7 |}g|] } from "./b";|] verify.noErrors(); -const [f0, f1, g0, f2, g1] = test.ranges(); +const [f0Def, f0, f1Def, f1, g0, f2Def, f2, g1Def, g1] = test.ranges(); const af = { definition: "function f(): void", ranges: [f0, f1] }; const g0Group = { definition: "(alias) function g(): void\nexport g", ranges: [g0] }; diff --git a/tests/cases/fourslash/tsxFindAllReferences1.ts b/tests/cases/fourslash/tsxFindAllReferences1.ts index 550dd05606cc0..8e48057e4b6cc 100644 --- a/tests/cases/fourslash/tsxFindAllReferences1.ts +++ b/tests/cases/fourslash/tsxFindAllReferences1.ts @@ -4,16 +4,17 @@ //// declare module JSX { //// interface Element { } //// interface IntrinsicElements { -//// [|{| "isWriteAccess": true, "isDefinition": true |}div|]: { +//// [|[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}div|]: { //// name?: string; //// isOpen?: boolean; -//// }; +//// };|] //// span: { n: string; }; //// } //// } -//// var x = <[|div|] />; +//// var x = [|<[|{| "contextRangeIndex": 2 |}div|] />|]; -verify.singleReferenceGroup(`(property) JSX.IntrinsicElements.div: { +verify.singleReferenceGroup( + `(property) JSX.IntrinsicElements.div: { name?: string; isOpen?: boolean; -}`); +}`, "div"); diff --git a/tests/cases/fourslash/tsxFindAllReferences10.ts b/tests/cases/fourslash/tsxFindAllReferences10.ts index 58459c7df1fae..97f58a8dbbcf3 100644 --- a/tests/cases/fourslash/tsxFindAllReferences10.ts +++ b/tests/cases/fourslash/tsxFindAllReferences10.ts @@ -15,7 +15,7 @@ //// className?: string; //// } //// interface ButtonProps extends ClickableProps { -//// [|{| "isDefinition": true |}onClick|](event?: React.MouseEvent): void; +//// [|[|{| "isDefinition": true, "contextRangeIndex": 0 |}onClick|](event?: React.MouseEvent): void;|] //// } //// interface LinkProps extends ClickableProps { //// goTo: string; @@ -25,9 +25,9 @@ //// declare function MainButton(props: ButtonProps | LinkProps): JSX.Element; //// let opt = ; //// let opt = ; -//// let opt = {}} />; -//// let opt = {}} ignore-prop />; +//// let opt = {}}|] />; +//// let opt = {}}|] ignore-prop />; //// let opt = ; //// let opt = ; -verify.singleReferenceGroup("(method) ButtonProps.onClick(event?: any): void"); +verify.singleReferenceGroup("(method) ButtonProps.onClick(event?: any): void", "onClick"); \ No newline at end of file diff --git a/tests/cases/fourslash/tsxFindAllReferences2.ts b/tests/cases/fourslash/tsxFindAllReferences2.ts index e7fda5ab30828..62de0591ab626 100644 --- a/tests/cases/fourslash/tsxFindAllReferences2.ts +++ b/tests/cases/fourslash/tsxFindAllReferences2.ts @@ -5,12 +5,12 @@ //// interface Element { } //// interface IntrinsicElements { //// div: { -//// [|{| "isWriteAccess": true, "isDefinition": true |}name|]?: string; +//// [|[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}name|]?: string;|] //// isOpen?: boolean; //// }; //// span: { n: string; }; //// } //// } -//// var x =
; +//// var x =
; -verify.singleReferenceGroup("(property) name?: string"); +verify.singleReferenceGroup("(property) name?: string", "name"); diff --git a/tests/cases/fourslash/tsxFindAllReferences3.ts b/tests/cases/fourslash/tsxFindAllReferences3.ts index e2f9215466a95..d010c65a56698 100644 --- a/tests/cases/fourslash/tsxFindAllReferences3.ts +++ b/tests/cases/fourslash/tsxFindAllReferences3.ts @@ -9,11 +9,11 @@ //// } //// class MyClass { //// props: { -//// [|{| "isDefinition": true |}name|]?: string; +//// [|[|{| "isDefinition": true, "contextRangeIndex": 0 |}name|]?: string;|] //// size?: number; //// } //// //// -//// var x = ; +//// var x = ; -verify.singleReferenceGroup("(property) name?: string"); +verify.singleReferenceGroup("(property) name?: string", "name"); diff --git a/tests/cases/fourslash/tsxFindAllReferences4.ts b/tests/cases/fourslash/tsxFindAllReferences4.ts index c932ea57f36c1..42a5d44f45350 100644 --- a/tests/cases/fourslash/tsxFindAllReferences4.ts +++ b/tests/cases/fourslash/tsxFindAllReferences4.ts @@ -7,13 +7,13 @@ //// } //// interface ElementAttributesProperty { props } //// } -//// class [|{| "isWriteAccess": true, "isDefinition": true |}MyClass|] { +//// [|class [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}MyClass|] { //// props: { //// name?: string; //// size?: number; -//// } +//// }|] //// //// -//// var x = <[|MyClass|] name='hello'>; +//// var x = [|<[|{| "contextRangeIndex" : 2 |}MyClass|] name='hello'>|]; -verify.singleReferenceGroup("class MyClass"); +verify.singleReferenceGroup("class MyClass", "MyClass"); diff --git a/tests/cases/fourslash/tsxFindAllReferences5.ts b/tests/cases/fourslash/tsxFindAllReferences5.ts index 9358dd73dc5eb..7921e503dbc0c 100644 --- a/tests/cases/fourslash/tsxFindAllReferences5.ts +++ b/tests/cases/fourslash/tsxFindAllReferences5.ts @@ -15,11 +15,14 @@ //// propString: string //// optional?: boolean //// } -//// declare function [|{| "isWriteAccess": true, "isDefinition": true |}Opt|](attributes: OptionPropBag): JSX.Element; -//// let opt = <[|Opt|] />; -//// let opt1 = <[|Opt|] propx={100} propString />; -//// let opt2 = <[|Opt|] propx={100} optional/>; -//// let opt3 = <[|Opt|] wrong />; -//// let opt4 = <[|Opt|] propx={100} propString="hi" />; +//// [|declare function [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}Opt|](attributes: OptionPropBag): JSX.Element;|] +//// let opt = [|<[|{| "contextRangeIndex": 2 |}Opt|] />|]; +//// let opt1 = [|<[|{| "contextRangeIndex": 4 |}Opt|] propx={100} propString />|]; +//// let opt2 = [|<[|{| "contextRangeIndex": 6 |}Opt|] propx={100} optional/>|]; +//// let opt3 = [|<[|{| "contextRangeIndex": 8 |}Opt|] wrong />|]; +//// let opt4 = [|<[|{| "contextRangeIndex": 10 |}Opt|] propx={100} propString="hi" />|]; -verify.singleReferenceGroup("function Opt(attributes: OptionPropBag): JSX.Element"); +verify.singleReferenceGroup( + "function Opt(attributes: OptionPropBag): JSX.Element", + "Opt" +); diff --git a/tests/cases/fourslash/tsxFindAllReferences7.ts b/tests/cases/fourslash/tsxFindAllReferences7.ts index 471cf747258de..3b82946fd1732 100644 --- a/tests/cases/fourslash/tsxFindAllReferences7.ts +++ b/tests/cases/fourslash/tsxFindAllReferences7.ts @@ -11,14 +11,14 @@ //// interface ElementAttributesProperty { props; } //// } //// interface OptionPropBag { -//// [|{| "isDefinition": true |}propx|]: number +//// [|[|{| "isDefinition": true, "contextRangeIndex": 0 |}propx|]: number|] //// propString: string //// optional?: boolean //// } //// declare function Opt(attributes: OptionPropBag): JSX.Element; //// let opt = ; -//// let opt1 = ; -//// let opt2 = ; +//// let opt1 = ; +//// let opt2 = ; //// let opt3 = ; -verify.singleReferenceGroup("(property) OptionPropBag.propx: number"); +verify.singleReferenceGroup("(property) OptionPropBag.propx: number", "propx"); diff --git a/tests/cases/fourslash/tsxFindAllReferences8.ts b/tests/cases/fourslash/tsxFindAllReferences8.ts index 0c2164888920a..efed4141230c1 100644 --- a/tests/cases/fourslash/tsxFindAllReferences8.ts +++ b/tests/cases/fourslash/tsxFindAllReferences8.ts @@ -20,14 +20,17 @@ //// interface LinkProps extends ClickableProps { //// goTo: string; //// } -//// declare function [|{| "isWriteAccess": true, "isDefinition": true |}MainButton|](buttonProps: ButtonProps): JSX.Element; -//// declare function [|{| "isWriteAccess": true, "isDefinition": true |}MainButton|](linkProps: LinkProps): JSX.Element; -//// declare function [|{| "isWriteAccess": true, "isDefinition": true |}MainButton|](props: ButtonProps | LinkProps): JSX.Element; -//// let opt = <[|MainButton|] />; -//// let opt = <[|MainButton|] children="chidlren" />; -//// let opt = <[|MainButton|] onClick={()=>{}} />; -//// let opt = <[|MainButton|] onClick={()=>{}} ignore-prop />; -//// let opt = <[|MainButton|] goTo="goTo" />; -//// let opt = <[|MainButton|] wrong />; +//// [|declare function [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}MainButton|](buttonProps: ButtonProps): JSX.Element;|] +//// [|declare function [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 2 |}MainButton|](linkProps: LinkProps): JSX.Element;|] +//// [|declare function [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 4 |}MainButton|](props: ButtonProps | LinkProps): JSX.Element;|] +//// let opt = [|<[|{| "contextRangeIndex": 6 |}MainButton|] />|]; +//// let opt = [|<[|{| "contextRangeIndex": 8 |}MainButton|] children="chidlren" />|]; +//// let opt = [|<[|{| "contextRangeIndex": 10 |}MainButton|] onClick={()=>{}} />|]; +//// let opt = [|<[|{| "contextRangeIndex": 12 |}MainButton|] onClick={()=>{}} ignore-prop />|]; +//// let opt = [|<[|{| "contextRangeIndex": 14 |}MainButton|] goTo="goTo" />|]; +//// let opt = [|<[|{| "contextRangeIndex": 16 |}MainButton|] wrong />|]; -verify.singleReferenceGroup("function MainButton(buttonProps: ButtonProps): JSX.Element (+2 overloads)"); +verify.singleReferenceGroup( + "function MainButton(buttonProps: ButtonProps): JSX.Element (+2 overloads)", + "MainButton" +); diff --git a/tests/cases/fourslash/tsxFindAllReferences9.ts b/tests/cases/fourslash/tsxFindAllReferences9.ts index bb45ce590cf2f..99f40cb33250f 100644 --- a/tests/cases/fourslash/tsxFindAllReferences9.ts +++ b/tests/cases/fourslash/tsxFindAllReferences9.ts @@ -18,7 +18,7 @@ //// onClick(event?: React.MouseEvent): void; //// } //// interface LinkProps extends ClickableProps { -//// [|{| "isDefinition": true |}goTo|]: string; +//// [|[|{| "isDefinition": true, "contextRangeIndex": 0 |}goTo|]: string;|] //// } //// declare function MainButton(buttonProps: ButtonProps): JSX.Element; //// declare function MainButton(linkProps: LinkProps): JSX.Element; @@ -27,8 +27,8 @@ //// let opt = ; //// let opt = {}} />; //// let opt = {}} ignore-prop />; -//// let opt = ; +//// let opt = ; //// let opt = ; //// let opt = ; -verify.singleReferenceGroup("(property) LinkProps.goTo: string"); +verify.singleReferenceGroup("(property) LinkProps.goTo: string", "goTo"); diff --git a/tests/cases/fourslash/tsxFindAllReferencesUnionElementType1.ts b/tests/cases/fourslash/tsxFindAllReferencesUnionElementType1.ts index 87adbc11873eb..2a1301a64f52d 100644 --- a/tests/cases/fourslash/tsxFindAllReferencesUnionElementType1.ts +++ b/tests/cases/fourslash/tsxFindAllReferencesUnionElementType1.ts @@ -18,11 +18,11 @@ //// return

World

; //// } -//// var [|{| "isWriteAccess": true, "isDefinition": true |}SFCComp|] = SFC1 || SFC2; -//// <[|SFCComp|] x={ "hi" } /> +//// [|var [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}SFCComp|] = SFC1 || SFC2;|] +//// [|<[|{| "contextRangeIndex": 2 |}SFCComp|] x={ "hi" } />|] verify.singleReferenceGroup(`var SFCComp: ((prop: { x: number; }) => JSX.Element) | ((prop: { x: boolean; -}) => JSX.Element)`); +}) => JSX.Element)`, "SFCComp"); diff --git a/tests/cases/fourslash/tsxFindAllReferencesUnionElementType2.ts b/tests/cases/fourslash/tsxFindAllReferencesUnionElementType2.ts index 2498c8bf99678..684be59907260 100644 --- a/tests/cases/fourslash/tsxFindAllReferencesUnionElementType2.ts +++ b/tests/cases/fourslash/tsxFindAllReferencesUnionElementType2.ts @@ -17,7 +17,7 @@ //// private method() { } //// } -//// var [|{| "isWriteAccess": true, "isDefinition": true |}RCComp|] = RC1 || RC2; -//// <[|RCComp|] /> +//// [|var [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}RCComp|] = RC1 || RC2;|] +//// [|<[|{| "contextRangeIndex": 2 |}RCComp|] />|] -verify.singleReferenceGroup("var RCComp: typeof RC1"); +verify.singleReferenceGroup("var RCComp: typeof RC1", "RCComp"); diff --git a/tests/cases/fourslash/tsxRename1.ts b/tests/cases/fourslash/tsxRename1.ts index 4323e99df59fa..23deda61fff6b 100644 --- a/tests/cases/fourslash/tsxRename1.ts +++ b/tests/cases/fourslash/tsxRename1.ts @@ -4,13 +4,12 @@ //// declare module JSX { //// interface Element { } //// interface IntrinsicElements { -//// [|div|]: { +//// [|[|{| "contextRangeIndex": 0 |}div|]: { //// name?: string; //// isOpen?: boolean; -//// }; +//// };|] //// span: { n: string; }; //// } //// } -//// var x = <[|div|] />; - -verify.rangesAreRenameLocations(); +//// var x = [|<[|{| "contextRangeIndex": 2 |}div|] />|]; +verify.rangesWithSameTextAreRenameLocations("div"); diff --git a/tests/cases/fourslash/tsxRename2.ts b/tests/cases/fourslash/tsxRename2.ts index e5e0688150c09..8cbb2b473ee56 100644 --- a/tests/cases/fourslash/tsxRename2.ts +++ b/tests/cases/fourslash/tsxRename2.ts @@ -5,12 +5,12 @@ //// interface Element { } //// interface IntrinsicElements { //// div: { -//// [|name|]?: string; +//// [|[|{| "contextRangeIndex": 0 |}name|]?: string;|] //// isOpen?: boolean; //// }; //// span: { n: string; }; //// } //// } -//// var x =
; +//// var x =
; -verify.rangesAreRenameLocations(); +verify.rangesWithSameTextAreRenameLocations("name"); diff --git a/tests/cases/fourslash/tsxRename3.ts b/tests/cases/fourslash/tsxRename3.ts index b997ea2fdca1a..cb190f7d59989 100644 --- a/tests/cases/fourslash/tsxRename3.ts +++ b/tests/cases/fourslash/tsxRename3.ts @@ -9,11 +9,11 @@ //// } //// class MyClass { //// props: { -//// [|name|]?: string; +//// [|[|{| "contextRangeIndex": 0 |}name|]?: string;|] //// size?: number; //// } //// //// -//// var x = ; +//// var x = ; -verify.rangesAreRenameLocations(); +verify.rangesWithSameTextAreRenameLocations("name"); diff --git a/tests/cases/fourslash/tsxRename4.ts b/tests/cases/fourslash/tsxRename4.ts index e46c2b7ebcbfa..cb561019c5914 100644 --- a/tests/cases/fourslash/tsxRename4.ts +++ b/tests/cases/fourslash/tsxRename4.ts @@ -9,15 +9,12 @@ //// div: {}; //// } ////} -////class [|MyClass|] {} +////[|class [|{| "contextRangeIndex": 0 |}MyClass|] {}|] //// -////<[|MyClass|]>; -////<[|MyClass|]/>; +////[|<[|{| "contextRangeIndex": 2 |}MyClass|]>|]; +////[|<[|{| "contextRangeIndex": 5 |}MyClass|]/>|]; //// -////<[|div|]> +////[|<[|{| "contextRangeIndex": 7 |}div|]> |] verify.noErrors(); - -const [r0, r1, r2, r3, d0, d1] = test.ranges(); -verify.rangesAreRenameLocations([r0, r1, r2, r3]); -verify.rangesAreRenameLocations([d0, d1]); +verify.rangesWithSameTextAreRenameLocations("MyClass", "div"); \ No newline at end of file diff --git a/tests/cases/fourslash/tsxRename5.ts b/tests/cases/fourslash/tsxRename5.ts index a4c70b4b1c3c6..0edc6f4f0db86 100644 --- a/tests/cases/fourslash/tsxRename5.ts +++ b/tests/cases/fourslash/tsxRename5.ts @@ -13,7 +13,7 @@ //// size?: number; //// } //// -//// var [|nn|]: string; +//// [|var [|{| "contextRangeIndex": 0 |}nn|]: string;|] //// var x = ; -verify.rangesAreRenameLocations(); +verify.rangesWithSameTextAreRenameLocations("nn"); diff --git a/tests/cases/fourslash/tsxRename6.ts b/tests/cases/fourslash/tsxRename6.ts index 6f999c127603e..8c8d252bb0099 100644 --- a/tests/cases/fourslash/tsxRename6.ts +++ b/tests/cases/fourslash/tsxRename6.ts @@ -15,11 +15,11 @@ //// propString: string //// optional?: boolean //// } -//// declare function [|Opt|](attributes: OptionPropBag): JSX.Element; -//// let opt = <[|Opt|] />; -//// let opt1 = <[|Opt|] propx={100} propString />; -//// let opt2 = <[|Opt|] propx={100} optional/>; -//// let opt3 = <[|Opt|] wrong />; -//// let opt4 = <[|Opt|] propx={100} propString="hi" />; +//// [|declare function [|{| "contextRangeIndex": 0 |}Opt|](attributes: OptionPropBag): JSX.Element;|] +//// let opt = [|<[|{| "contextRangeIndex": 2 |}Opt|] />|]; +//// let opt1 = [|<[|{| "contextRangeIndex": 4 |}Opt|] propx={100} propString />|]; +//// let opt2 = [|<[|{| "contextRangeIndex": 6 |}Opt|] propx={100} optional/>|]; +//// let opt3 = [|<[|{| "contextRangeIndex": 8 |}Opt|] wrong />|]; +//// let opt4 = [|<[|{| "contextRangeIndex": 10 |}Opt|] propx={100} propString="hi" />|]; -verify.rangesAreRenameLocations(); +verify.rangesWithSameTextAreRenameLocations("Opt"); diff --git a/tests/cases/fourslash/tsxRename7.ts b/tests/cases/fourslash/tsxRename7.ts index 5533db1b4db1d..8e23a7edef418 100644 --- a/tests/cases/fourslash/tsxRename7.ts +++ b/tests/cases/fourslash/tsxRename7.ts @@ -11,14 +11,14 @@ //// interface ElementAttributesProperty { props; } //// } //// interface OptionPropBag { -//// [|propx|]: number +//// [|[|{| "contextRangeIndex": 0 |}propx|]: number|] //// propString: string //// optional?: boolean //// } //// declare function Opt(attributes: OptionPropBag): JSX.Element; //// let opt = ; -//// let opt1 = ; -//// let opt2 = ; +//// let opt1 = ; +//// let opt2 = ; //// let opt3 = ; -verify.rangesAreRenameLocations(); +verify.rangesWithSameTextAreRenameLocations("propx"); diff --git a/tests/cases/fourslash/tsxRename9.ts b/tests/cases/fourslash/tsxRename9.ts index b39b009634d98..0818c61cd734c 100644 --- a/tests/cases/fourslash/tsxRename9.ts +++ b/tests/cases/fourslash/tsxRename9.ts @@ -15,19 +15,25 @@ //// className?: string; //// } //// interface ButtonProps extends ClickableProps { -//// [|onClick|](event?: React.MouseEvent): void; +//// [|[|{| "contextRangeIndex": 0 |}onClick|](event?: React.MouseEvent): void;|] //// } //// interface LinkProps extends ClickableProps { -//// [|goTo|]: string; +//// [|[|{| "contextRangeIndex": 2 |}goTo|]: string;|] //// } -//// declare function [|MainButton|](buttonProps: ButtonProps): JSX.Element; -//// declare function [|MainButton|](linkProps: LinkProps): JSX.Element; -//// declare function [|MainButton|](props: ButtonProps | LinkProps): JSX.Element; -//// let opt = <[|MainButton|] />; -//// let opt = <[|MainButton|] children="chidlren" />; -//// let opt = <[|MainButton|] [|onClick|]={()=>{}} />; -//// let opt = <[|MainButton|] [|onClick|]={()=>{}} [|ignore-prop|] />; -//// let opt = <[|MainButton|] [|goTo|]="goTo" />; -//// let opt = <[|MainButton|] [|wrong|] />; +//// [|declare function [|{| "contextRangeIndex": 4 |}MainButton|](buttonProps: ButtonProps): JSX.Element;|] +//// [|declare function [|{| "contextRangeIndex": 6 |}MainButton|](linkProps: LinkProps): JSX.Element;|] +//// [|declare function [|{| "contextRangeIndex": 8 |}MainButton|](props: ButtonProps | LinkProps): JSX.Element;|] +//// let opt = [|<[|{| "contextRangeIndex": 10 |}MainButton|] />|]; +//// let opt = [|<[|{| "contextRangeIndex": 12 |}MainButton|] children="chidlren" />|]; +//// let opt = [|<[|{| "contextRangeIndex": 14 |}MainButton|] [|[|{| "contextRangeIndex": 16 |}onClick|]={()=>{}}|] />|]; +//// let opt = [|<[|{| "contextRangeIndex": 18 |}MainButton|] [|[|{| "contextRangeIndex": 20 |}onClick|]={()=>{}}|] [|ignore-prop|] />|]; +//// let opt = [|<[|{| "contextRangeIndex": 23 |}MainButton|] [|[|{| "contextRangeIndex": 25 |}goTo|]="goTo"|] />|]; +//// let opt = [|<[|{| "contextRangeIndex": 27 |}MainButton|] [|wrong|] />|]; -verify.rangesWithSameTextAreRenameLocations(); +verify.rangesWithSameTextAreRenameLocations( + "onClick", + "goTo", + "MainButton", + "ignore-prop", + "wrong" +); \ No newline at end of file diff --git a/tests/cases/fourslash/untypedModuleImport.ts b/tests/cases/fourslash/untypedModuleImport.ts index 5501cec47922c..2e06c45107e71 100644 --- a/tests/cases/fourslash/untypedModuleImport.ts +++ b/tests/cases/fourslash/untypedModuleImport.ts @@ -4,7 +4,7 @@ ////{} // @Filename: a.ts -////import /*foo*/[|{| "isWriteAccess": true, "isDefinition": true |}foo|] from /*fooModule*/"[|{| "isInString": true |}foo|]"; +////[|import /*foo*/[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}foo|] from /*fooModule*/"[|{| "isInString": true, "contextRangeIndex": 0 |}foo|]";|] ////[|foo|](); goTo.file("a.ts"); @@ -13,7 +13,7 @@ verify.numberOfErrorsInCurrentFile(0); goTo.marker("fooModule"); verify.goToDefinitionIs([]); verify.quickInfoIs(""); -const [r0, r1, r2] = test.ranges(); +const [r00, r0, r1, r2] = test.ranges(); verify.singleReferenceGroup('"foo"', [r1]); goTo.marker("foo");