mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-10 06:41:59 -06:00
Rename to use contextSpan
This commit is contained in:
parent
da2aa9781e
commit
73bf2684ac
@ -395,12 +395,12 @@ namespace ts.server {
|
||||
const locations: RenameLocation[] = [];
|
||||
for (const entry of body.locs) {
|
||||
const fileName = entry.file;
|
||||
for (const { start, end, declarationStart, declarationEnd, ...prefixSuffixText } of entry.locs) {
|
||||
for (const { start, end, contextStart, contextEnd, ...prefixSuffixText } of entry.locs) {
|
||||
locations.push({
|
||||
textSpan: this.decodeSpan({ start, end }, fileName),
|
||||
fileName,
|
||||
...(declarationStart !== undefined ?
|
||||
{ declarationSpan: this.decodeSpan({ start: declarationStart, end: declarationEnd! }, fileName) } :
|
||||
...(contextStart !== undefined ?
|
||||
{ contextSpan: this.decodeSpan({ start: contextStart, end: contextEnd! }, fileName) } :
|
||||
undefined),
|
||||
...prefixSuffixText
|
||||
});
|
||||
|
||||
@ -956,14 +956,14 @@ namespace FourSlash {
|
||||
const fullExpected = ts.map<FourSlashInterface.ReferenceGroup, ReferenceGroupJson>(parts, ({ definition, ranges }) => ({
|
||||
definition: typeof definition === "string" ? definition : { ...definition, range: ts.createTextSpanFromRange(definition.range) },
|
||||
references: ranges.map<ts.ReferenceEntry>(r => {
|
||||
const { isWriteAccess = false, isDefinition = false, isInString, declarationRangeIndex } = (r.marker && r.marker.data || {}) as { isWriteAccess?: boolean, isDefinition?: boolean, isInString?: true, declarationRangeIndex?: number };
|
||||
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,
|
||||
...(declarationRangeIndex !== undefined ?
|
||||
{ declarationSpan: ts.createTextSpanFromRange(this.getRanges()[declarationRangeIndex]) } :
|
||||
...(contextRangeIndex !== undefined ?
|
||||
{ contextSpan: ts.createTextSpanFromRange(this.getRanges()[contextRangeIndex]) } :
|
||||
undefined),
|
||||
...(isInString ? { isInString: true } : undefined),
|
||||
};
|
||||
@ -1193,12 +1193,12 @@ 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 };
|
||||
const { declarationRangeIndex } = (range.marker && range.marker.data || {}) as { declarationRangeIndex?: number; };
|
||||
const { contextRangeIndex } = (range.marker && range.marker.data || {}) as { contextRangeIndex?: number; };
|
||||
return {
|
||||
fileName: range.fileName,
|
||||
textSpan: ts.createTextSpanFromRange(range),
|
||||
...(declarationRangeIndex !== undefined ?
|
||||
{ declarationSpan: ts.createTextSpanFromRange(this.getRanges()[declarationRangeIndex]) } :
|
||||
...(contextRangeIndex !== undefined ?
|
||||
{ contextSpan: ts.createTextSpanFromRange(this.getRanges()[contextRangeIndex]) } :
|
||||
undefined),
|
||||
...prefixSuffixText
|
||||
};
|
||||
|
||||
@ -872,16 +872,16 @@ namespace ts.server.protocol {
|
||||
file: string;
|
||||
}
|
||||
|
||||
export interface DeclarationTextSpan extends TextSpan {
|
||||
declarationStart?: Location;
|
||||
declarationEnd?: Location;
|
||||
export interface TextSpanWithContext extends TextSpan {
|
||||
contextStart?: Location;
|
||||
contextEnd?: Location;
|
||||
}
|
||||
|
||||
export interface DeclarationFileSpan extends FileSpan, DeclarationTextSpan {
|
||||
export interface FileSpanWithContext extends FileSpan, TextSpanWithContext {
|
||||
}
|
||||
|
||||
export interface DefinitionInfoAndBoundSpan {
|
||||
definitions: ReadonlyArray<DeclarationFileSpan>;
|
||||
definitions: ReadonlyArray<FileSpanWithContext>;
|
||||
textSpan: TextSpan;
|
||||
}
|
||||
|
||||
@ -889,7 +889,7 @@ namespace ts.server.protocol {
|
||||
* Definition response message. Gives text range for definition.
|
||||
*/
|
||||
export interface DefinitionResponse extends Response {
|
||||
body?: DeclarationFileSpan[];
|
||||
body?: FileSpanWithContext[];
|
||||
}
|
||||
|
||||
export interface DefinitionInfoAndBoundSpanReponse extends Response {
|
||||
@ -900,14 +900,14 @@ namespace ts.server.protocol {
|
||||
* Definition response message. Gives text range for definition.
|
||||
*/
|
||||
export interface TypeDefinitionResponse extends Response {
|
||||
body?: DeclarationFileSpan[];
|
||||
body?: FileSpanWithContext[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation response message. Gives text range for implementations.
|
||||
*/
|
||||
export interface ImplementationResponse extends Response {
|
||||
body?: DeclarationFileSpan[];
|
||||
body?: FileSpanWithContext[];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -950,7 +950,7 @@ namespace ts.server.protocol {
|
||||
}
|
||||
|
||||
/** @deprecated */
|
||||
export interface OccurrencesResponseItem extends DeclarationFileSpan {
|
||||
export interface OccurrencesResponseItem extends FileSpanWithContext {
|
||||
/**
|
||||
* True if the occurrence is a write location, false otherwise.
|
||||
*/
|
||||
@ -980,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 DeclarationTextSpan {
|
||||
export interface HighlightSpan extends TextSpanWithContext {
|
||||
kind: HighlightSpanKind;
|
||||
}
|
||||
|
||||
@ -1015,7 +1015,7 @@ namespace ts.server.protocol {
|
||||
command: CommandTypes.References;
|
||||
}
|
||||
|
||||
export interface ReferencesResponseItem extends DeclarationFileSpan {
|
||||
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
|
||||
@ -1158,7 +1158,7 @@ namespace ts.server.protocol {
|
||||
locs: RenameTextSpan[];
|
||||
}
|
||||
|
||||
export interface RenameTextSpan extends DeclarationTextSpan {
|
||||
export interface RenameTextSpan extends TextSpanWithContext {
|
||||
readonly prefixText?: string;
|
||||
readonly suffixText?: string;
|
||||
}
|
||||
|
||||
@ -362,7 +362,7 @@ namespace ts.server {
|
||||
...outputReferencedSymbol.definition,
|
||||
textSpan: createTextSpan(mappedDefinitionFile.pos, outputReferencedSymbol.definition.textSpan.length),
|
||||
fileName: mappedDefinitionFile.fileName,
|
||||
declarationSpan: getMappedDeclarationSpan(outputReferencedSymbol.definition, project)
|
||||
contextSpan: getMappedContextSpan(outputReferencedSymbol.definition, project)
|
||||
};
|
||||
|
||||
let symbolToAddTo = find(outputs, o => documentSpansEqual(o.definition, definition));
|
||||
@ -501,22 +501,22 @@ namespace ts.server {
|
||||
},
|
||||
originalFileName: documentSpan.fileName,
|
||||
originalTextSpan: documentSpan.textSpan,
|
||||
declarationSpan: getMappedDeclarationSpan(documentSpan, project),
|
||||
originalDeclarationSpan: documentSpan.declarationSpan
|
||||
contextSpan: getMappedContextSpan(documentSpan, project),
|
||||
originalContextSpan: documentSpan.contextSpan
|
||||
};
|
||||
}
|
||||
|
||||
function getMappedDeclarationSpan(documentSpan: DocumentSpan, project: Project): TextSpan | undefined {
|
||||
const declarationSpanStart = documentSpan.declarationSpan && getMappedLocation(
|
||||
{ fileName: documentSpan.fileName, pos: documentSpan.declarationSpan.start },
|
||||
function getMappedContextSpan(documentSpan: DocumentSpan, project: Project): TextSpan | undefined {
|
||||
const contextSpanStart = documentSpan.contextSpan && getMappedLocation(
|
||||
{ fileName: documentSpan.fileName, pos: documentSpan.contextSpan.start },
|
||||
project
|
||||
);
|
||||
const declarationSpanEnd = documentSpan.declarationSpan && getMappedLocation(
|
||||
{ fileName: documentSpan.fileName, pos: documentSpan.declarationSpan.start + documentSpan.declarationSpan.length },
|
||||
const contextSpanEnd = documentSpan.contextSpan && getMappedLocation(
|
||||
{ fileName: documentSpan.fileName, pos: documentSpan.contextSpan.start + documentSpan.contextSpan.length },
|
||||
project
|
||||
);
|
||||
return declarationSpanStart && declarationSpanEnd ?
|
||||
{ start: declarationSpanStart.pos, length: declarationSpanEnd.pos - declarationSpanStart.pos } :
|
||||
return contextSpanStart && contextSpanEnd ?
|
||||
{ start: contextSpanStart.pos, length: contextSpanEnd.pos - contextSpanStart.pos } :
|
||||
undefined;
|
||||
}
|
||||
|
||||
@ -971,7 +971,7 @@ namespace ts.server {
|
||||
: diagnostics.map(d => formatDiag(file, project, d));
|
||||
}
|
||||
|
||||
private getDefinition(args: protocol.FileLocationRequestArgs, simplifiedResult: boolean): ReadonlyArray<protocol.DeclarationFileSpan> | ReadonlyArray<DefinitionInfo> {
|
||||
private getDefinition(args: protocol.FileLocationRequestArgs, simplifiedResult: boolean): ReadonlyArray<protocol.FileSpanWithContext> | ReadonlyArray<DefinitionInfo> {
|
||||
const { file, project } = this.getFileAndProject(args);
|
||||
const position = this.getPositionInFile(args, file);
|
||||
const definitions = this.mapDefinitionInfoLocations(project.getLanguageService().getDefinitionAtPosition(file, position) || emptyArray, project);
|
||||
@ -1026,8 +1026,8 @@ namespace ts.server {
|
||||
return project.getLanguageService().getEmitOutput(file);
|
||||
}
|
||||
|
||||
private mapDefinitionInfo(definitions: ReadonlyArray<DefinitionInfo>, project: Project): ReadonlyArray<protocol.DeclarationFileSpan> {
|
||||
return definitions.map(def => this.toDeclarationFileSpan(def.fileName, def.textSpan, def.declarationSpan, project));
|
||||
private mapDefinitionInfo(definitions: ReadonlyArray<DefinitionInfo>, project: Project): ReadonlyArray<protocol.FileSpanWithContext> {
|
||||
return definitions.map(def => this.toFileSpanWithContext(def.fileName, def.textSpan, def.contextSpan, project));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1046,8 +1046,8 @@ namespace ts.server {
|
||||
textSpan: def.originalTextSpan,
|
||||
targetFileName: def.fileName,
|
||||
targetTextSpan: def.textSpan,
|
||||
declarationSpan: def.originalDeclarationSpan,
|
||||
targetDeclarationSpan: def.declarationSpan
|
||||
contextSpan: def.originalContextSpan,
|
||||
targetContextSpan: def.contextSpan
|
||||
};
|
||||
}
|
||||
return def;
|
||||
@ -1065,15 +1065,15 @@ namespace ts.server {
|
||||
};
|
||||
}
|
||||
|
||||
private toDeclarationFileSpan(fileName: string, textSpan: TextSpan, declarationSpan: TextSpan | undefined, project: Project): protocol.DeclarationFileSpan {
|
||||
private toFileSpanWithContext(fileName: string, textSpan: TextSpan, contextSpan: TextSpan | undefined, project: Project): protocol.FileSpanWithContext {
|
||||
const fileSpan = this.toFileSpan(fileName, textSpan, project);
|
||||
const declaration = declarationSpan && this.toFileSpan(fileName, declarationSpan, project);
|
||||
return declaration ?
|
||||
{ ...fileSpan, declarationStart: declaration.start, declarationEnd: declaration.end } :
|
||||
const context = contextSpan && this.toFileSpan(fileName, contextSpan, project);
|
||||
return context ?
|
||||
{ ...fileSpan, contextStart: context.start, contextEnd: context.end } :
|
||||
fileSpan;
|
||||
}
|
||||
|
||||
private getTypeDefinition(args: protocol.FileLocationRequestArgs): ReadonlyArray<protocol.DeclarationFileSpan> {
|
||||
private getTypeDefinition(args: protocol.FileLocationRequestArgs): ReadonlyArray<protocol.FileSpanWithContext> {
|
||||
const { file, project } = this.getFileAndProject(args);
|
||||
const position = this.getPositionInFile(args, file);
|
||||
|
||||
@ -1092,12 +1092,12 @@ namespace ts.server {
|
||||
});
|
||||
}
|
||||
|
||||
private getImplementation(args: protocol.FileLocationRequestArgs, simplifiedResult: boolean): ReadonlyArray<protocol.DeclarationFileSpan> | ReadonlyArray<ImplementationLocation> {
|
||||
private getImplementation(args: protocol.FileLocationRequestArgs, simplifiedResult: boolean): ReadonlyArray<protocol.FileSpanWithContext> | ReadonlyArray<ImplementationLocation> {
|
||||
const { file, project } = this.getFileAndProject(args);
|
||||
const position = this.getPositionInFile(args, file);
|
||||
const implementations = this.mapImplementationLocations(project.getLanguageService().getImplementationAtPosition(file, position) || emptyArray, project);
|
||||
return simplifiedResult ?
|
||||
implementations.map(({ fileName, textSpan, declarationSpan }) => this.toDeclarationFileSpan(fileName, textSpan, declarationSpan, project)) :
|
||||
implementations.map(({ fileName, textSpan, contextSpan }) => this.toFileSpanWithContext(fileName, textSpan, contextSpan, project)) :
|
||||
implementations.map(Session.mapToOriginalLocation);
|
||||
}
|
||||
|
||||
@ -1107,10 +1107,10 @@ namespace ts.server {
|
||||
const occurrences = project.getLanguageService().getOccurrencesAtPosition(file, position);
|
||||
return occurrences ?
|
||||
occurrences.map<protocol.OccurrencesResponseItem>(occurrence => {
|
||||
const { fileName, isWriteAccess, textSpan, isInString, declarationSpan } = occurrence;
|
||||
const { fileName, isWriteAccess, textSpan, isInString, contextSpan } = occurrence;
|
||||
const scriptInfo = project.getScriptInfo(fileName)!;
|
||||
return {
|
||||
...toProtocolDeclarationTextSpan(textSpan, declarationSpan, scriptInfo),
|
||||
...toProtocolTextSpanWithContext(textSpan, contextSpan, scriptInfo),
|
||||
file: fileName,
|
||||
isWriteAccess,
|
||||
...(isInString ? { isInString } : undefined)
|
||||
@ -1166,8 +1166,8 @@ namespace ts.server {
|
||||
const scriptInfo = project.getScriptInfo(fileName)!;
|
||||
return {
|
||||
file: fileName,
|
||||
highlightSpans: highlightSpans.map(({ textSpan, kind, declarationSpan }) => ({
|
||||
...toProtocolDeclarationTextSpan(textSpan, declarationSpan, scriptInfo),
|
||||
highlightSpans: highlightSpans.map(({ textSpan, kind, contextSpan }) => ({
|
||||
...toProtocolTextSpanWithContext(textSpan, contextSpan, scriptInfo),
|
||||
kind
|
||||
}))
|
||||
};
|
||||
@ -1273,11 +1273,11 @@ namespace ts.server {
|
||||
|
||||
private toSpanGroups(locations: ReadonlyArray<RenameLocation>): ReadonlyArray<protocol.SpanGroup> {
|
||||
const map = createMap<protocol.SpanGroup>();
|
||||
for (const { fileName, textSpan, declarationSpan, originalDeclarationSpan: _2, 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({ ...toProtocolDeclarationTextSpan(textSpan, declarationSpan, scriptInfo), ...prefixSuffixText });
|
||||
group.locs.push({ ...toProtocolTextSpanWithContext(textSpan, contextSpan, scriptInfo), ...prefixSuffixText });
|
||||
}
|
||||
return arrayFrom(map.values());
|
||||
}
|
||||
@ -1302,9 +1302,9 @@ namespace ts.server {
|
||||
const symbolStartOffset = nameSpan ? scriptInfo.positionToLineOffset(nameSpan.start).offset : 0;
|
||||
const symbolName = nameSpan ? scriptInfo.getSnapshot().getText(nameSpan.start, textSpanEnd(nameSpan)) : "";
|
||||
const refs: ReadonlyArray<protocol.ReferencesResponseItem> = flatMap(references, referencedSymbol =>
|
||||
referencedSymbol.references.map(({ fileName, textSpan, declarationSpan, isWriteAccess, isDefinition }): protocol.ReferencesResponseItem => {
|
||||
referencedSymbol.references.map(({ fileName, textSpan, contextSpan, isWriteAccess, isDefinition }): protocol.ReferencesResponseItem => {
|
||||
const scriptInfo = Debug.assertDefined(this.projectService.getScriptInfo(fileName));
|
||||
const span = toProtocolDeclarationTextSpan(textSpan, declarationSpan, scriptInfo);
|
||||
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 {
|
||||
@ -2565,11 +2565,11 @@ namespace ts.server {
|
||||
};
|
||||
}
|
||||
|
||||
function toProtocolDeclarationTextSpan(span: TextSpan, declarationSpan: TextSpan | undefined, scriptInfo: ScriptInfo): protocol.DeclarationTextSpan {
|
||||
function toProtocolTextSpanWithContext(span: TextSpan, contextSpan: TextSpan | undefined, scriptInfo: ScriptInfo): protocol.TextSpanWithContext {
|
||||
const textSpan = toProcolTextSpan(span, scriptInfo);
|
||||
const declarationTextSpan = declarationSpan && toProcolTextSpan(declarationSpan, scriptInfo);
|
||||
return declarationTextSpan ?
|
||||
{ ...textSpan, declarationStart: declarationTextSpan.start, declarationEnd: declarationTextSpan.end } :
|
||||
const contextTextSpan = contextSpan && toProcolTextSpan(contextSpan, scriptInfo);
|
||||
return contextTextSpan ?
|
||||
{ ...textSpan, contextStart: contextTextSpan.start, contextEnd: contextTextSpan.end } :
|
||||
textSpan;
|
||||
}
|
||||
|
||||
|
||||
@ -16,15 +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 DeclarationNodeWithStartAndEnd {
|
||||
export interface ContextWithStartAndEndNode {
|
||||
start: Node;
|
||||
end: Node;
|
||||
}
|
||||
export type DeclarationNode = Node | DeclarationNodeWithStartAndEnd;
|
||||
export type ContextNode = Node | ContextWithStartAndEndNode;
|
||||
export interface NodeEntry {
|
||||
readonly kind: NodeEntryKind;
|
||||
readonly node: Node;
|
||||
readonly declaration?: DeclarationNode;
|
||||
readonly context?: ContextNode;
|
||||
}
|
||||
export interface SpanEntry {
|
||||
readonly kind: EntryKind.Span;
|
||||
@ -35,17 +35,17 @@ namespace ts.FindAllReferences {
|
||||
return {
|
||||
kind,
|
||||
node: (node as NamedDeclaration).name || node,
|
||||
declaration: getDeclarationForDeclarationSpanForNode(node)
|
||||
context: getContextNodeForNodeEntry(node)
|
||||
};
|
||||
}
|
||||
|
||||
export function isDeclarationNodeWithStartAndEnd(node: DeclarationNode): node is DeclarationNodeWithStartAndEnd {
|
||||
export function isContextWithStartAndEndNode(node: ContextNode): node is ContextWithStartAndEndNode {
|
||||
return node && (node as Node).kind === undefined;
|
||||
}
|
||||
|
||||
function getDeclarationForDeclarationSpanForNode(node: Node): DeclarationNode | undefined {
|
||||
function getContextNodeForNodeEntry(node: Node): ContextNode | undefined {
|
||||
if (isDeclaration(node)) {
|
||||
return getDeclarationForDeclarationSpan(node);
|
||||
return getContextNode(node);
|
||||
}
|
||||
|
||||
if (!node.parent) return undefined;
|
||||
@ -61,7 +61,7 @@ namespace ts.FindAllReferences {
|
||||
node.parent.parent :
|
||||
undefined;
|
||||
if (binaryExpression && getAssignmentDeclarationKind(binaryExpression) !== AssignmentDeclarationKind.None) {
|
||||
return getDeclarationForDeclarationSpan(binaryExpression);
|
||||
return getContextNode(binaryExpression);
|
||||
}
|
||||
}
|
||||
|
||||
@ -83,7 +83,7 @@ namespace ts.FindAllReferences {
|
||||
isJSDocTag(node)
|
||||
)! as NamedDeclaration | Statement | JSDocTag;
|
||||
return isDeclaration(declOrStatement) ?
|
||||
getDeclarationForDeclarationSpan(declOrStatement) :
|
||||
getContextNode(declOrStatement) :
|
||||
declOrStatement;
|
||||
}
|
||||
}
|
||||
@ -91,7 +91,7 @@ namespace ts.FindAllReferences {
|
||||
// Handle computed property name
|
||||
const propertyName = findAncestor(node, isComputedPropertyName);
|
||||
return propertyName ?
|
||||
getDeclarationForDeclarationSpan(propertyName.parent) :
|
||||
getContextNode(propertyName.parent) :
|
||||
undefined;
|
||||
}
|
||||
|
||||
@ -103,13 +103,13 @@ namespace ts.FindAllReferences {
|
||||
&& node.parent.propertyName === node) ||
|
||||
// Is default export
|
||||
(node.kind === SyntaxKind.DefaultKeyword && hasModifier(node.parent, ModifierFlags.ExportDefault))) {
|
||||
return getDeclarationForDeclarationSpan(node.parent);
|
||||
return getContextNode(node.parent);
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
export function getDeclarationForDeclarationSpan(node: NamedDeclaration | BinaryExpression | ForInOrOfStatement | undefined): DeclarationNode | undefined {
|
||||
export function getContextNode(node: NamedDeclaration | BinaryExpression | ForInOrOfStatement | undefined): ContextNode | undefined {
|
||||
if (!node) return undefined;
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.VariableDeclaration:
|
||||
@ -118,11 +118,11 @@ namespace ts.FindAllReferences {
|
||||
isVariableStatement(node.parent.parent) ?
|
||||
node.parent.parent :
|
||||
isForInOrOfStatement(node.parent.parent) ?
|
||||
getDeclarationForDeclarationSpan(node.parent.parent) :
|
||||
getContextNode(node.parent.parent) :
|
||||
node.parent;
|
||||
|
||||
case SyntaxKind.BindingElement:
|
||||
return getDeclarationForDeclarationSpan(node.parent.parent as NamedDeclaration);
|
||||
return getContextNode(node.parent.parent as NamedDeclaration);
|
||||
|
||||
case SyntaxKind.ImportSpecifier:
|
||||
return node.parent.parent.parent;
|
||||
@ -149,7 +149,7 @@ namespace ts.FindAllReferences {
|
||||
case SyntaxKind.PropertyAssignment:
|
||||
case SyntaxKind.ShorthandPropertyAssignment:
|
||||
return isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent) ?
|
||||
getDeclarationForDeclarationSpan(
|
||||
getContextNode(
|
||||
findAncestor(node.parent, node =>
|
||||
isBinaryExpression(node) || isForInOrOfStatement(node)
|
||||
) as BinaryExpression | ForInOrOfStatement
|
||||
@ -161,13 +161,13 @@ namespace ts.FindAllReferences {
|
||||
}
|
||||
}
|
||||
|
||||
export function toDeclarationSpan(textSpan: TextSpan, sourceFile: SourceFile, declaration?: DeclarationNode): { declarationSpan: TextSpan } | undefined {
|
||||
if (!declaration) return undefined;
|
||||
const declarationSpan = isDeclarationNodeWithStartAndEnd(declaration) ?
|
||||
getTextSpan(declaration.start, sourceFile, declaration.end) :
|
||||
getTextSpan(declaration, sourceFile);
|
||||
return declarationSpan.start !== textSpan.start || declarationSpan.length !== textSpan.length ?
|
||||
{ declarationSpan } :
|
||||
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;
|
||||
}
|
||||
|
||||
@ -273,7 +273,7 @@ namespace ts.FindAllReferences {
|
||||
name,
|
||||
kind,
|
||||
displayParts,
|
||||
declaration: getDeclarationForDeclarationSpan(declaration)
|
||||
context: getContextNode(declaration)
|
||||
};
|
||||
}
|
||||
case DefinitionKind.Label: {
|
||||
@ -301,7 +301,7 @@ namespace ts.FindAllReferences {
|
||||
}
|
||||
})();
|
||||
|
||||
const { node, name, kind, displayParts, declaration } = info;
|
||||
const { node, name, kind, displayParts, context } = info;
|
||||
const sourceFile = node.getSourceFile();
|
||||
const textSpan = getTextSpan(isComputedPropertyName(node) ? node.expression : node, sourceFile);
|
||||
return {
|
||||
@ -312,7 +312,7 @@ namespace ts.FindAllReferences {
|
||||
name,
|
||||
textSpan,
|
||||
displayParts,
|
||||
...toDeclarationSpan(textSpan, sourceFile, declaration)
|
||||
...toContextSpan(textSpan, sourceFile, context)
|
||||
};
|
||||
}
|
||||
|
||||
@ -354,7 +354,7 @@ namespace ts.FindAllReferences {
|
||||
return {
|
||||
textSpan,
|
||||
fileName: sourceFile.fileName,
|
||||
...toDeclarationSpan(textSpan, sourceFile, entry.declaration)
|
||||
...toContextSpan(textSpan, sourceFile, entry.context)
|
||||
};
|
||||
}
|
||||
}
|
||||
@ -440,7 +440,7 @@ namespace ts.FindAllReferences {
|
||||
textSpan: documentSpan.textSpan,
|
||||
kind: writeAccess ? HighlightSpanKind.writtenReference : HighlightSpanKind.reference,
|
||||
isInString: entry.kind === EntryKind.StringLiteral ? true : undefined,
|
||||
...documentSpan.declarationSpan && { declarationSpan: documentSpan.declarationSpan }
|
||||
...documentSpan.contextSpan && { contextSpan: documentSpan.contextSpan }
|
||||
};
|
||||
return { fileName: documentSpan.fileName, span };
|
||||
}
|
||||
|
||||
@ -281,10 +281,10 @@ namespace ts.GoToDefinition {
|
||||
name: symbolName,
|
||||
containerKind: undefined!, // TODO: GH#18217
|
||||
containerName,
|
||||
...FindAllReferences.toDeclarationSpan(
|
||||
...FindAllReferences.toContextSpan(
|
||||
textSpan,
|
||||
sourceFile,
|
||||
FindAllReferences.getDeclarationForDeclarationSpan(declaration)
|
||||
FindAllReferences.getContextNode(declaration)
|
||||
)
|
||||
};
|
||||
}
|
||||
|
||||
@ -1552,7 +1552,7 @@ namespace ts {
|
||||
isWriteAccess: highlightSpan.kind === HighlightSpanKind.writtenReference,
|
||||
isDefinition: false,
|
||||
...highlightSpan.isInString && { isInString: true },
|
||||
...highlightSpan.declarationSpan && { declarationSpan: highlightSpan.declarationSpan }
|
||||
...highlightSpan.contextSpan && { contextSpan: highlightSpan.contextSpan }
|
||||
}))
|
||||
);
|
||||
}
|
||||
@ -1577,7 +1577,7 @@ namespace ts {
|
||||
return {
|
||||
fileName: sourceFile.fileName,
|
||||
textSpan,
|
||||
...FindAllReferences.toDeclarationSpan(textSpan, sourceFile, node.parent)
|
||||
...FindAllReferences.toContextSpan(textSpan, sourceFile, node.parent)
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
@ -618,8 +618,8 @@ namespace ts {
|
||||
* If DocumentSpan.textSpan is the span for name of the declaration,
|
||||
* then this is the span for relevant declaration
|
||||
*/
|
||||
declarationSpan?: TextSpan;
|
||||
originalDeclarationSpan?: TextSpan;
|
||||
contextSpan?: TextSpan;
|
||||
originalContextSpan?: TextSpan;
|
||||
}
|
||||
|
||||
export interface RenameLocation extends DocumentSpan {
|
||||
@ -654,7 +654,7 @@ namespace ts {
|
||||
fileName?: string;
|
||||
isInString?: true;
|
||||
textSpan: TextSpan;
|
||||
declarationSpan?: TextSpan;
|
||||
contextSpan?: TextSpan;
|
||||
kind: HighlightSpanKind;
|
||||
}
|
||||
|
||||
|
||||
@ -3,15 +3,15 @@ namespace ts.projectSystem {
|
||||
file: File;
|
||||
text: string;
|
||||
options?: SpanFromSubstringOptions;
|
||||
declarationText?: string;
|
||||
declarationOptions?: SpanFromSubstringOptions;
|
||||
contextText?: string;
|
||||
contextOptions?: SpanFromSubstringOptions;
|
||||
}
|
||||
function documentSpanFromSubstring({ file, text, declarationText, options, declarationOptions }: DocumentSpanFromSubstring): DocumentSpan {
|
||||
const declarationSpan = declarationText !== undefined ? documentSpanFromSubstring({ file, text: declarationText, options: declarationOptions }) : undefined;
|
||||
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),
|
||||
...declarationSpan && { declarationSpan: declarationSpan.textSpan }
|
||||
...contextSpan && { contextSpan: contextSpan.textSpan }
|
||||
};
|
||||
}
|
||||
|
||||
@ -25,7 +25,7 @@ namespace ts.projectSystem {
|
||||
}
|
||||
function makeReferenceItem({ isDefinition, lineText, ...rest }: MakeReferenceItem): protocol.ReferencesResponseItem {
|
||||
return {
|
||||
...protocolDeclarationFileSpanFromSubstring(rest),
|
||||
...protocolFileSpanWithContextFromSubstring(rest),
|
||||
isDefinition,
|
||||
isWriteAccess: isDefinition,
|
||||
lineText,
|
||||
@ -206,10 +206,10 @@ namespace ts.projectSystem {
|
||||
const session = makeSampleProjects();
|
||||
const response = executeSessionRequest<protocol.DefinitionRequest, protocol.DefinitionResponse>(session, protocol.CommandTypes.Definition, protocolFileLocationFromSubstring(userTs, "fnA()"));
|
||||
assert.deepEqual(response, [
|
||||
protocolDeclarationFileSpanFromSubstring({
|
||||
protocolFileSpanWithContextFromSubstring({
|
||||
file: aTs,
|
||||
text: "fnA",
|
||||
declarationText: "export function fnA() {}"
|
||||
contextText: "export function fnA() {}"
|
||||
})
|
||||
]);
|
||||
verifySingleInferredProject(session);
|
||||
@ -221,10 +221,10 @@ namespace ts.projectSystem {
|
||||
assert.deepEqual(response, {
|
||||
textSpan: protocolTextSpanFromSubstring(userTs.content, "fnA"),
|
||||
definitions: [
|
||||
protocolDeclarationFileSpanFromSubstring({
|
||||
protocolFileSpanWithContextFromSubstring({
|
||||
file: aTs,
|
||||
text: "fnA",
|
||||
declarationText: "export function fnA() {}"
|
||||
contextText: "export function fnA() {}"
|
||||
})
|
||||
],
|
||||
});
|
||||
@ -237,10 +237,10 @@ namespace ts.projectSystem {
|
||||
assert.deepEqual(response, {
|
||||
textSpan: protocolTextSpanFromSubstring(userTs.content, "fnA"),
|
||||
definitions: [
|
||||
protocolDeclarationFileSpanFromSubstring({
|
||||
protocolFileSpanWithContextFromSubstring({
|
||||
file: aTs,
|
||||
text: "fnA",
|
||||
declarationText: "export function fnA() {}"
|
||||
contextText: "export function fnA() {}"
|
||||
})
|
||||
],
|
||||
});
|
||||
@ -264,10 +264,10 @@ namespace ts.projectSystem {
|
||||
const session = makeSampleProjects();
|
||||
const response = executeSessionRequest<protocol.TypeDefinitionRequest, protocol.TypeDefinitionResponse>(session, protocol.CommandTypes.TypeDefinition, protocolFileLocationFromSubstring(userTs, "instanceA"));
|
||||
assert.deepEqual(response, [
|
||||
protocolDeclarationFileSpanFromSubstring({
|
||||
protocolFileSpanWithContextFromSubstring({
|
||||
file: aTs,
|
||||
text: "IfaceA",
|
||||
declarationText: "export interface IfaceA {}"
|
||||
contextText: "export interface IfaceA {}"
|
||||
})
|
||||
]);
|
||||
verifySingleInferredProject(session);
|
||||
@ -277,10 +277,10 @@ namespace ts.projectSystem {
|
||||
const session = makeSampleProjects();
|
||||
const response = executeSessionRequest<protocol.ImplementationRequest, protocol.ImplementationResponse>(session, protocol.CommandTypes.Implementation, protocolFileLocationFromSubstring(userTs, "fnA()"));
|
||||
assert.deepEqual(response, [
|
||||
protocolDeclarationFileSpanFromSubstring({
|
||||
protocolFileSpanWithContextFromSubstring({
|
||||
file: aTs,
|
||||
text: "fnA",
|
||||
declarationText: "export function fnA() {}"
|
||||
contextText: "export function fnA() {}"
|
||||
})]);
|
||||
verifySingleInferredProject(session);
|
||||
});
|
||||
@ -290,10 +290,10 @@ namespace ts.projectSystem {
|
||||
const response = executeSessionRequest<protocol.DefinitionRequest, protocol.DefinitionResponse>(session, CommandNames.Definition, protocolFileLocationFromSubstring(userTs, "fnB()"));
|
||||
// bTs does not exist, so stick with bDts
|
||||
assert.deepEqual(response, [
|
||||
protocolDeclarationFileSpanFromSubstring({
|
||||
protocolFileSpanWithContextFromSubstring({
|
||||
file: bDts,
|
||||
text: "fnB",
|
||||
declarationText: "export declare function fnB(): void;"
|
||||
contextText: "export declare function fnB(): void;"
|
||||
})
|
||||
]);
|
||||
verifySingleInferredProject(session);
|
||||
@ -345,7 +345,7 @@ namespace ts.projectSystem {
|
||||
file: aTs,
|
||||
isDefinition: true,
|
||||
text: "fnA",
|
||||
declarationText: "export function fnA() {}",
|
||||
contextText: "export function fnA() {}",
|
||||
lineText: "export function fnA() {}"
|
||||
});
|
||||
const referencesUserTs = (userTs: File): ReadonlyArray<protocol.ReferencesResponseItem> => [
|
||||
@ -398,7 +398,7 @@ namespace ts.projectSystem {
|
||||
...documentSpanFromSubstring({
|
||||
file: aTs,
|
||||
text: "fnA",
|
||||
declarationText: "export function fnA() {}"
|
||||
contextText: "export function fnA() {}"
|
||||
}),
|
||||
kind: ScriptElementKind.functionElement,
|
||||
name: "function fnA(): void",
|
||||
@ -417,7 +417,7 @@ namespace ts.projectSystem {
|
||||
},
|
||||
references: [
|
||||
makeReferenceEntry({ file: userTs, /*isDefinition*/ isDefinition: false, text: "fnA" }),
|
||||
makeReferenceEntry({ file: aTs, /*isDefinition*/ isDefinition: true, text: "fnA", declarationText: "export function fnA() {}" }),
|
||||
makeReferenceEntry({ file: aTs, /*isDefinition*/ isDefinition: true, text: "fnA", contextText: "export function fnA() {}" }),
|
||||
],
|
||||
},
|
||||
]);
|
||||
@ -452,7 +452,7 @@ namespace ts.projectSystem {
|
||||
file: aTs,
|
||||
text: "f",
|
||||
options: { index: 1 },
|
||||
declarationText: "function f() {}"
|
||||
contextText: "function f() {}"
|
||||
}),
|
||||
containerKind: ScriptElementKind.unknown,
|
||||
containerName: "",
|
||||
@ -481,7 +481,7 @@ namespace ts.projectSystem {
|
||||
file: aTs,
|
||||
text: "f",
|
||||
options: { index: 1 },
|
||||
declarationText: "function f() {}",
|
||||
contextText: "function f() {}",
|
||||
isDefinition: true
|
||||
})
|
||||
],
|
||||
@ -499,7 +499,7 @@ namespace ts.projectSystem {
|
||||
file: bDts,
|
||||
isDefinition: true,
|
||||
text: "fnB",
|
||||
declarationText: "export declare function fnB(): void;",
|
||||
contextText: "export declare function fnB(): void;",
|
||||
lineText: "export declare function fnB(): void;"
|
||||
}),
|
||||
makeReferenceItem({
|
||||
@ -522,7 +522,7 @@ namespace ts.projectSystem {
|
||||
protocolRenameSpanFromSubstring({
|
||||
fileText: aTs.content,
|
||||
text: "fnA",
|
||||
declarationText: "export function fnA() {}"
|
||||
contextText: "export function fnA() {}"
|
||||
})
|
||||
],
|
||||
});
|
||||
@ -578,7 +578,7 @@ namespace ts.projectSystem {
|
||||
const response = executeSessionRequest<protocol.RenameFullRequest, protocol.RenameFullResponse>(session, protocol.CommandTypes.RenameLocationsFull, protocolFileLocationFromSubstring(userTs, "fnA()"));
|
||||
assert.deepEqual<ReadonlyArray<RenameLocation>>(response, [
|
||||
renameLocation({ file: userTs, text: "fnA" }),
|
||||
renameLocation({ file: aTs, text: "fnA", declarationText: "export function fnA() {}" }),
|
||||
renameLocation({ file: aTs, text: "fnA", contextText: "export function fnA() {}" }),
|
||||
]);
|
||||
verifyATsConfigOriginalProject(session);
|
||||
});
|
||||
@ -603,7 +603,7 @@ namespace ts.projectSystem {
|
||||
protocolRenameSpanFromSubstring({
|
||||
fileText: bDts.content,
|
||||
text: "fnB",
|
||||
declarationText: "export declare function fnB(): void;"
|
||||
contextText: "export declare function fnB(): void;"
|
||||
})
|
||||
],
|
||||
},
|
||||
|
||||
@ -514,49 +514,49 @@ namespace ts.projectSystem {
|
||||
return { file: file.path, ...protocolTextSpanFromSubstring(file.content, text, options) };
|
||||
}
|
||||
|
||||
interface DeclarationFileSpanFromSubString {
|
||||
interface FileSpanWithContextFromSubString {
|
||||
file: File;
|
||||
text: string;
|
||||
options?: SpanFromSubstringOptions;
|
||||
declarationText?: string;
|
||||
declarationOptions?: SpanFromSubstringOptions;
|
||||
contextText?: string;
|
||||
contextOptions?: SpanFromSubstringOptions;
|
||||
}
|
||||
export function protocolDeclarationFileSpanFromSubstring({ declarationText, declarationOptions, ...rest }: DeclarationFileSpanFromSubString): protocol.DeclarationFileSpan {
|
||||
export function protocolFileSpanWithContextFromSubstring({ contextText, contextOptions, ...rest }: FileSpanWithContextFromSubString): protocol.FileSpanWithContext {
|
||||
const result = protocolFileSpanFromSubstring(rest);
|
||||
const declarationSpan = declarationText !== undefined ?
|
||||
protocolFileSpanFromSubstring({ file: rest.file, text: declarationText, options: declarationOptions }) :
|
||||
const contextSpan = contextText !== undefined ?
|
||||
protocolFileSpanFromSubstring({ file: rest.file, text: contextText, options: contextOptions }) :
|
||||
undefined;
|
||||
return declarationSpan ?
|
||||
return contextSpan ?
|
||||
{
|
||||
...result,
|
||||
declarationStart: declarationSpan.start,
|
||||
declarationEnd: declarationSpan.end
|
||||
contextStart: contextSpan.start,
|
||||
contextEnd: contextSpan.end
|
||||
} :
|
||||
result;
|
||||
}
|
||||
|
||||
export interface ProtocolDeclarationTextSpanFromString {
|
||||
export interface ProtocolTextSpanWithContextFromString {
|
||||
fileText: string;
|
||||
text: string;
|
||||
options?: SpanFromSubstringOptions;
|
||||
declarationText?: string;
|
||||
declarationOptions?: SpanFromSubstringOptions;
|
||||
contextText?: string;
|
||||
contextOptions?: SpanFromSubstringOptions;
|
||||
}
|
||||
export function protocolDeclarationTextSpanFromSubstring({ fileText, text, options, declarationText, declarationOptions }: ProtocolDeclarationTextSpanFromString): protocol.DeclarationTextSpan {
|
||||
export function protocolTextSpanWithContextFromSubstring({ fileText, text, options, contextText, contextOptions }: ProtocolTextSpanWithContextFromString): protocol.TextSpanWithContext {
|
||||
const span = textSpanFromSubstring(fileText, text, options);
|
||||
const toLocation = protocolToLocation(fileText);
|
||||
const declarationSpan = declarationText !== undefined ? textSpanFromSubstring(fileText, declarationText, declarationOptions) : undefined;
|
||||
const contextSpan = contextText !== undefined ? textSpanFromSubstring(fileText, contextText, contextOptions) : undefined;
|
||||
return {
|
||||
start: toLocation(span.start),
|
||||
end: toLocation(textSpanEnd(span)),
|
||||
...declarationSpan && {
|
||||
declarationStart: toLocation(declarationSpan.start),
|
||||
declarationEnd: toLocation(textSpanEnd(declarationSpan))
|
||||
...contextSpan && {
|
||||
contextStart: toLocation(contextSpan.start),
|
||||
contextEnd: toLocation(textSpanEnd(contextSpan))
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export interface ProtocolRenameSpanFromSubstring extends ProtocolDeclarationTextSpanFromString {
|
||||
export interface ProtocolRenameSpanFromSubstring extends ProtocolTextSpanWithContextFromString {
|
||||
prefixSuffixText?: {
|
||||
readonly prefixText?: string;
|
||||
readonly suffixText?: string;
|
||||
@ -564,7 +564,7 @@ namespace ts.projectSystem {
|
||||
}
|
||||
export function protocolRenameSpanFromSubstring({ prefixSuffixText, ...rest }: ProtocolRenameSpanFromSubstring): protocol.RenameTextSpan {
|
||||
return {
|
||||
...protocolDeclarationTextSpanFromSubstring(rest),
|
||||
...protocolTextSpanWithContextFromSubstring(rest),
|
||||
...prefixSuffixText
|
||||
};
|
||||
}
|
||||
|
||||
@ -78,10 +78,10 @@ namespace ts.projectSystem {
|
||||
arguments: { file: myConstFile, ...myConstStart }
|
||||
}).response as protocol.RenameResponseBody;
|
||||
|
||||
const locationOfMyConstInLib = protocolDeclarationFileSpanFromSubstring({
|
||||
const locationOfMyConstInLib = protocolFileSpanWithContextFromSubstring({
|
||||
file: containerLib[1],
|
||||
text: "myConst",
|
||||
declarationText: "export const myConst = 30;"
|
||||
contextText: "export const myConst = 30;"
|
||||
});
|
||||
const { file: _, ...renameTextOfMyConstInLib } = locationOfMyConstInLib;
|
||||
assert.deepEqual(response.locs, [
|
||||
@ -191,8 +191,8 @@ fn5();
|
||||
file: dtsPath,
|
||||
start: { line: fn, offset: definition.start.offset + declareSpaceLength },
|
||||
end: { line: fn, offset: definition.end.offset + declareSpaceLength },
|
||||
declarationStart: { line: fn, offset: 1 },
|
||||
declarationEnd: { line: fn, offset: 37 }
|
||||
contextStart: { line: fn, offset: 1 },
|
||||
contextEnd: { line: fn, offset: 37 }
|
||||
}],
|
||||
textSpan
|
||||
},
|
||||
@ -204,20 +204,20 @@ fn5();
|
||||
};
|
||||
}
|
||||
|
||||
function declarationSpan(fn: number): protocol.DeclarationTextSpan {
|
||||
function declarationSpan(fn: number): protocol.TextSpanWithContext {
|
||||
return {
|
||||
start: { line: fn, offset: 17 },
|
||||
end: { line: fn, offset: 20 },
|
||||
declarationStart: { line: fn, offset: 1 },
|
||||
declarationEnd: { line: fn, offset: 26 }
|
||||
contextStart: { line: fn, offset: 1 },
|
||||
contextEnd: { line: fn, offset: 26 }
|
||||
};
|
||||
}
|
||||
function importSpan(fn: number): protocol.DeclarationTextSpan {
|
||||
function importSpan(fn: number): protocol.TextSpanWithContext {
|
||||
return {
|
||||
start: { line: fn + 1, offset: 5 },
|
||||
end: { line: fn + 1, offset: 8 },
|
||||
declarationStart: { line: 1, offset: 1 },
|
||||
declarationEnd: { line: 7, offset: 27 }
|
||||
contextStart: { line: 1, offset: 1 },
|
||||
contextEnd: { line: 7, offset: 27 }
|
||||
};
|
||||
}
|
||||
function usageSpan(fn: number): protocol.TextSpan {
|
||||
@ -226,7 +226,7 @@ fn5();
|
||||
|
||||
function renameFromDependencyTs(fn: number): SessionAction<protocol.RenameRequest, protocol.RenameResponseBody> {
|
||||
const defSpan = declarationSpan(fn);
|
||||
const { declarationStart: _, declarationEnd: _1, ...triggerSpan } = defSpan;
|
||||
const { contextStart: _, contextEnd: _1, ...triggerSpan } = defSpan;
|
||||
return {
|
||||
reqName: "rename",
|
||||
request: {
|
||||
|
||||
@ -20,7 +20,7 @@ namespace ts.projectSystem {
|
||||
protocolRenameSpanFromSubstring({
|
||||
fileText: bTs.content,
|
||||
text: "./a",
|
||||
declarationText: bTs.content
|
||||
contextText: bTs.content
|
||||
})
|
||||
]
|
||||
}],
|
||||
@ -45,7 +45,7 @@ namespace ts.projectSystem {
|
||||
protocolRenameSpanFromSubstring({
|
||||
fileText: bTs.content,
|
||||
text: "./a",
|
||||
declarationText: bTs.content
|
||||
contextText: bTs.content
|
||||
})
|
||||
]
|
||||
}],
|
||||
@ -71,7 +71,7 @@ namespace ts.projectSystem {
|
||||
protocolRenameSpanFromSubstring({
|
||||
fileText: bTs.content,
|
||||
text: "./a",
|
||||
declarationText: bTs.content
|
||||
contextText: bTs.content
|
||||
})
|
||||
]
|
||||
}],
|
||||
@ -103,7 +103,7 @@ namespace ts.projectSystem {
|
||||
protocolRenameSpanFromSubstring({
|
||||
fileText: aTs.content,
|
||||
text: "x",
|
||||
declarationText: "const x = 0;"
|
||||
contextText: "const x = 0;"
|
||||
}),
|
||||
protocolRenameSpanFromSubstring({
|
||||
fileText: aTs.content,
|
||||
@ -135,7 +135,7 @@ namespace ts.projectSystem {
|
||||
protocolRenameSpanFromSubstring({
|
||||
fileText: aTs.content,
|
||||
text: "x",
|
||||
declarationText: "const x = 0;"
|
||||
contextText: "const x = 0;"
|
||||
}),
|
||||
protocolRenameSpanFromSubstring({
|
||||
fileText: aTs.content,
|
||||
@ -169,7 +169,7 @@ namespace ts.projectSystem {
|
||||
protocolRenameSpanFromSubstring({
|
||||
fileText: aTs.content,
|
||||
text: "x",
|
||||
declarationText: "const x = 0;"
|
||||
contextText: "const x = 0;"
|
||||
}),
|
||||
protocolRenameSpanFromSubstring({
|
||||
fileText: aTs.content,
|
||||
@ -210,13 +210,13 @@ namespace ts.projectSystem {
|
||||
protocolRenameSpanFromSubstring({
|
||||
fileText: aTs.content,
|
||||
text: "x",
|
||||
declarationText: "const x = 1;"
|
||||
contextText: "const x = 1;"
|
||||
}),
|
||||
protocolRenameSpanFromSubstring({
|
||||
fileText: aTs.content,
|
||||
text: "x",
|
||||
options: { index: 2 },
|
||||
declarationText: "export { x };",
|
||||
contextText: "export { x };",
|
||||
prefixSuffixText: { suffixText: " as x" }
|
||||
}),
|
||||
],
|
||||
@ -243,7 +243,7 @@ namespace ts.projectSystem {
|
||||
protocolRenameSpanFromSubstring({
|
||||
fileText: bTs.content,
|
||||
text: "x",
|
||||
declarationText: `import { x } from "./a";`
|
||||
contextText: `import { x } from "./a";`
|
||||
}),
|
||||
protocolRenameSpanFromSubstring({
|
||||
fileText: bTs.content,
|
||||
@ -258,13 +258,13 @@ namespace ts.projectSystem {
|
||||
protocolRenameSpanFromSubstring({
|
||||
fileText: aTs.content,
|
||||
text: "x",
|
||||
declarationText: "const x = 1;"
|
||||
contextText: "const x = 1;"
|
||||
}),
|
||||
protocolRenameSpanFromSubstring({
|
||||
fileText: aTs.content,
|
||||
text: "x",
|
||||
options: { index: 2 },
|
||||
declarationText: "export { x };",
|
||||
contextText: "export { x };",
|
||||
}),
|
||||
],
|
||||
},
|
||||
|
||||
@ -61,7 +61,7 @@ namespace ts.projectSystem {
|
||||
protocolRenameSpanFromSubstring({
|
||||
fileText: aFile.content,
|
||||
text: "C",
|
||||
declarationText: `import {C} from "./c/fc";`
|
||||
contextText: `import {C} from "./c/fc";`
|
||||
}),
|
||||
protocolRenameSpanFromSubstring({
|
||||
fileText: aFile.content,
|
||||
@ -72,7 +72,7 @@ namespace ts.projectSystem {
|
||||
const span = protocolRenameSpanFromSubstring({
|
||||
fileText: cFile.content,
|
||||
text: "C",
|
||||
declarationText: "export const C = 8"
|
||||
contextText: "export const C = 8"
|
||||
});
|
||||
const cLocs: protocol.RenameTextSpan[] = [span];
|
||||
assert.deepEqual<protocol.RenameResponseBody | undefined>(response, {
|
||||
|
||||
@ -5172,8 +5172,8 @@ declare namespace ts {
|
||||
* If DocumentSpan.textSpan is the span for name of the declaration,
|
||||
* then this is the span for relevant declaration
|
||||
*/
|
||||
declarationSpan?: TextSpan;
|
||||
originalDeclarationSpan?: TextSpan;
|
||||
contextSpan?: TextSpan;
|
||||
originalContextSpan?: TextSpan;
|
||||
}
|
||||
interface RenameLocation extends DocumentSpan {
|
||||
readonly prefixText?: string;
|
||||
@ -5202,7 +5202,7 @@ declare namespace ts {
|
||||
fileName?: string;
|
||||
isInString?: true;
|
||||
textSpan: TextSpan;
|
||||
declarationSpan?: TextSpan;
|
||||
contextSpan?: TextSpan;
|
||||
kind: HighlightSpanKind;
|
||||
}
|
||||
interface NavigateToItem {
|
||||
@ -6496,21 +6496,21 @@ declare namespace ts.server.protocol {
|
||||
*/
|
||||
file: string;
|
||||
}
|
||||
interface DeclarationTextSpan extends TextSpan {
|
||||
declarationStart?: Location;
|
||||
declarationEnd?: Location;
|
||||
interface TextSpanWithContext extends TextSpan {
|
||||
contextStart?: Location;
|
||||
contextEnd?: Location;
|
||||
}
|
||||
interface DeclarationFileSpan extends FileSpan, DeclarationTextSpan {
|
||||
interface FileSpanWithContext extends FileSpan, TextSpanWithContext {
|
||||
}
|
||||
interface DefinitionInfoAndBoundSpan {
|
||||
definitions: ReadonlyArray<DeclarationFileSpan>;
|
||||
definitions: ReadonlyArray<FileSpanWithContext>;
|
||||
textSpan: TextSpan;
|
||||
}
|
||||
/**
|
||||
* Definition response message. Gives text range for definition.
|
||||
*/
|
||||
interface DefinitionResponse extends Response {
|
||||
body?: DeclarationFileSpan[];
|
||||
body?: FileSpanWithContext[];
|
||||
}
|
||||
interface DefinitionInfoAndBoundSpanReponse extends Response {
|
||||
body?: DefinitionInfoAndBoundSpan;
|
||||
@ -6519,13 +6519,13 @@ declare namespace ts.server.protocol {
|
||||
* Definition response message. Gives text range for definition.
|
||||
*/
|
||||
interface TypeDefinitionResponse extends Response {
|
||||
body?: DeclarationFileSpan[];
|
||||
body?: FileSpanWithContext[];
|
||||
}
|
||||
/**
|
||||
* Implementation response message. Gives text range for implementations.
|
||||
*/
|
||||
interface ImplementationResponse extends Response {
|
||||
body?: DeclarationFileSpan[];
|
||||
body?: FileSpanWithContext[];
|
||||
}
|
||||
/**
|
||||
* Request to get brace completion for a location in the file.
|
||||
@ -6562,7 +6562,7 @@ declare namespace ts.server.protocol {
|
||||
command: CommandTypes.Occurrences;
|
||||
}
|
||||
/** @deprecated */
|
||||
interface OccurrencesResponseItem extends DeclarationFileSpan {
|
||||
interface OccurrencesResponseItem extends FileSpanWithContext {
|
||||
/**
|
||||
* True if the occurrence is a write location, false otherwise.
|
||||
*/
|
||||
@ -6588,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 DeclarationTextSpan {
|
||||
interface HighlightSpan extends TextSpanWithContext {
|
||||
kind: HighlightSpanKind;
|
||||
}
|
||||
/**
|
||||
@ -6618,7 +6618,7 @@ declare namespace ts.server.protocol {
|
||||
interface ReferencesRequest extends FileLocationRequest {
|
||||
command: CommandTypes.References;
|
||||
}
|
||||
interface ReferencesResponseItem extends DeclarationFileSpan {
|
||||
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
|
||||
@ -6733,7 +6733,7 @@ declare namespace ts.server.protocol {
|
||||
/** The text spans in this group */
|
||||
locs: RenameTextSpan[];
|
||||
}
|
||||
interface RenameTextSpan extends DeclarationTextSpan {
|
||||
interface RenameTextSpan extends TextSpanWithContext {
|
||||
readonly prefixText?: string;
|
||||
readonly suffixText?: string;
|
||||
}
|
||||
@ -9090,7 +9090,7 @@ declare namespace ts.server {
|
||||
private mapDefinitionInfo;
|
||||
private static mapToOriginalLocation;
|
||||
private toFileSpan;
|
||||
private toDeclarationFileSpan;
|
||||
private toFileSpanWithContext;
|
||||
private getTypeDefinition;
|
||||
private mapImplementationLocations;
|
||||
private getImplementation;
|
||||
|
||||
@ -5172,8 +5172,8 @@ declare namespace ts {
|
||||
* If DocumentSpan.textSpan is the span for name of the declaration,
|
||||
* then this is the span for relevant declaration
|
||||
*/
|
||||
declarationSpan?: TextSpan;
|
||||
originalDeclarationSpan?: TextSpan;
|
||||
contextSpan?: TextSpan;
|
||||
originalContextSpan?: TextSpan;
|
||||
}
|
||||
interface RenameLocation extends DocumentSpan {
|
||||
readonly prefixText?: string;
|
||||
@ -5202,7 +5202,7 @@ declare namespace ts {
|
||||
fileName?: string;
|
||||
isInString?: true;
|
||||
textSpan: TextSpan;
|
||||
declarationSpan?: TextSpan;
|
||||
contextSpan?: TextSpan;
|
||||
kind: HighlightSpanKind;
|
||||
}
|
||||
interface NavigateToItem {
|
||||
|
||||
@ -4,10 +4,10 @@
|
||||
////declare module "jquery";
|
||||
|
||||
// @Filename: user.ts
|
||||
////[|import {[|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 0 |}x|]} from "jquery";|]
|
||||
////[|import {[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}x|]} from "jquery";|]
|
||||
|
||||
// @Filename: user2.ts
|
||||
////[|import {[|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 2 |}x|]} from "jquery";|]
|
||||
////[|import {[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 2 |}x|]} from "jquery";|]
|
||||
|
||||
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`.
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
////
|
||||
//// }
|
||||
////
|
||||
//// [|public /**/[|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 0 |}start|](){
|
||||
//// [|public /**/[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}start|](){
|
||||
//// return this;
|
||||
//// }|]
|
||||
////
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
// @Filename: fileA.ts
|
||||
//// [|export function [|{| "declarationRangeIndex": 0 |}__foo|]() {
|
||||
//// [|export function [|{| "contextRangeIndex": 0 |}__foo|]() {
|
||||
//// }|]
|
||||
////
|
||||
// @Filename: fileB.ts
|
||||
//// [|import { [|{| "declarationRangeIndex": 2 |}__foo|] as bar } from "./fileA";|]
|
||||
//// [|import { [|{| "contextRangeIndex": 2 |}__foo|] as bar } from "./fileA";|]
|
||||
////
|
||||
//// bar();
|
||||
|
||||
|
||||
@ -2,11 +2,11 @@
|
||||
// @noImplicitReferences: true
|
||||
|
||||
// @Filename: /node_modules/a/index.d.ts
|
||||
////[|import [|{| "name": "useAX", "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 0 |}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, "declarationRangeIndex": 3 |}X|] {
|
||||
////[|export default class /*defAX*/[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 3 |}X|] {
|
||||
//// private x: number;
|
||||
////}|]
|
||||
|
||||
@ -14,11 +14,11 @@
|
||||
////{ "name": "x", "version": "1.2.3" }
|
||||
|
||||
// @Filename: /node_modules/b/index.d.ts
|
||||
////[|import [|{| "name": "useBX", "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 5 |}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, "declarationRangeIndex": 8 |}X|] {
|
||||
////[|export default class /*defBX*/[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 8 |}X|] {
|
||||
//// private x: number;
|
||||
////}|]
|
||||
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
|
||||
// @Filename: /abc.d.ts
|
||||
////declare module "a" {
|
||||
//// [|export const [|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 0 |}x|]: number;|]
|
||||
//// [|export const [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}x|]: number;|]
|
||||
////}
|
||||
|
||||
// @Filename: /b.ts
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
|
||||
// @Filename: /a.d.ts
|
||||
////export as namespace abc;
|
||||
////[|export const [|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 0 |}x|]: number;|]
|
||||
////[|export const [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}x|]: number;|]
|
||||
|
||||
// @Filename: /b.ts
|
||||
////import a from "./a";
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
|
||||
//// class B {}
|
||||
//// function foo() {
|
||||
//// return {[|[|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 0 |}B|]: B|]};
|
||||
//// return {[|[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}B|]: B|]};
|
||||
//// }
|
||||
//// class C extends (foo()).[|B|] {}
|
||||
//// class C1 extends foo().[|B|] {}
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
// @Filename: foo.ts
|
||||
//// export function foo() { return "foo"; }
|
||||
|
||||
//// [|import("[|{| "declarationRangeIndex": 0 |}./foo|]")|]
|
||||
//// [|var x = import("[|{| "declarationRangeIndex": 2 |}./foo|]")|]
|
||||
//// [|import("[|{| "contextRangeIndex": 0 |}./foo|]")|]
|
||||
//// [|var x = import("[|{| "contextRangeIndex": 2 |}./foo|]")|]
|
||||
|
||||
verify.singleReferenceGroup('module "/tests/cases/fourslash/foo"', "./foo");
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
// @Filename: foo.ts
|
||||
//// [|export function [|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 0 |}bar|]() { return "bar"; }|]
|
||||
//// [|export function [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}bar|]() { return "bar"; }|]
|
||||
|
||||
//// var x = import("./foo");
|
||||
//// x.then(foo => {
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
// @Filename: foo.ts
|
||||
////[|export function [|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 0 |}bar|]() { return "bar"; }|]
|
||||
////import('./foo').then(([|{ [|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 2 |}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 [r0Def, r0, r1Def, r1] = test.ranges();
|
||||
verify.referenceGroups(r0, [{ definition: "function bar(): string", ranges: [r0, r1] }]);
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
///<reference path="fourslash.ts" />
|
||||
// @allowJs: true
|
||||
// @Filename: Foo.js
|
||||
/////** @type {function ([|[|{|"isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 0|}new|]: string|], string): string} */
|
||||
/////** @type {function ([|[|{|"isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0|}new|]: string|], string): string} */
|
||||
////var f;
|
||||
|
||||
const [a0Def, a0] = test.ranges();
|
||||
|
||||
@ -2,9 +2,9 @@
|
||||
|
||||
// @Filename: a.ts
|
||||
////export class C {
|
||||
//// [|[|{| "declarationRangeIndex": 0 |}constructor|](n: number);|]
|
||||
//// [|[|{| "declarationRangeIndex": 2 |}constructor|]();|]
|
||||
//// [|[|{| "declarationRangeIndex": 4 |}constructor|](n?: number){}|]
|
||||
//// [|[|{| "contextRangeIndex": 0 |}constructor|](n: number);|]
|
||||
//// [|[|{| "contextRangeIndex": 2 |}constructor|]();|]
|
||||
//// [|[|{| "contextRangeIndex": 4 |}constructor|](n?: number){}|]
|
||||
//// static f() {
|
||||
//// this.f();
|
||||
//// new [|this|]();
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
////class C {
|
||||
//// [|[|{| "declarationRangeIndex": 0 |}constructor|](n: number);|]
|
||||
//// [|[|{| "declarationRangeIndex": 2 |}constructor|](){}|]
|
||||
//// [|[|{| "contextRangeIndex": 0 |}constructor|](n: number);|]
|
||||
//// [|[|{| "contextRangeIndex": 2 |}constructor|](){}|]
|
||||
////}
|
||||
|
||||
verify.singleReferenceGroup("class C", "constructor");
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
// @esModuleInterop: true
|
||||
|
||||
// @Filename: /foo.ts
|
||||
////[|import [|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 0 |}settings|] from "./settings.json";|]
|
||||
////[|import [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}settings|] from "./settings.json";|]
|
||||
////[|settings|];
|
||||
|
||||
// @Filename: /settings.json
|
||||
|
||||
@ -9,12 +9,12 @@
|
||||
|
||||
// @Filename: /node_modules/@types/three/index.d.ts
|
||||
////export * from "./three-core";
|
||||
////[|export as namespace [|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 0 |}THREE|];|]
|
||||
////[|export as namespace [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}THREE|];|]
|
||||
|
||||
// @Filename: /typings/global.d.ts
|
||||
////[|import * as _THREE from '[|{| "declarationRangeIndex": 2 |}three|]';|]
|
||||
////[|import * as _THREE from '[|{| "contextRangeIndex": 2 |}three|]';|]
|
||||
////declare global {
|
||||
//// [|const [|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 4 |}THREE|]: typeof _THREE;|]
|
||||
//// [|const [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 4 |}THREE|]: typeof _THREE;|]
|
||||
////}
|
||||
|
||||
// @Filename: /src/index.ts
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
////[|import { [|{| "declarationRangeIndex": 0 |}ab|] as [|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 0 |}cd|] } from "doesNotExist";|]
|
||||
////[|import { [|{| "contextRangeIndex": 0 |}ab|] as [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}cd|] } from "doesNotExist";|]
|
||||
|
||||
const [r0Def, r0, r1] = test.ranges();
|
||||
verify.referenceGroups(r0, undefined);
|
||||
|
||||
@ -1,12 +1,12 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
// @Filename: /a.ts
|
||||
////export = [|class [|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 0 |}A|] {
|
||||
////export = [|class [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}A|] {
|
||||
//// m() { [|A|]; }
|
||||
////}|];
|
||||
|
||||
// @Filename: /b.ts
|
||||
////[|import [|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 3 |}A|] = require("./a");|]
|
||||
////[|import [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 3 |}A|] = require("./a");|]
|
||||
////[|A|];
|
||||
|
||||
const [r0Def, r0, r1, r2Def, r2, r3] = test.ranges();
|
||||
|
||||
@ -3,10 +3,10 @@
|
||||
// @allowJs: true
|
||||
|
||||
// @Filename: /a.js
|
||||
////module.exports = [|class [|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 0 |}A|] {}|];
|
||||
////module.exports = [|class [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}A|] {}|];
|
||||
|
||||
// @Filename: /b.js
|
||||
////[|import [|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 2 |}A|] = require("./a");|]
|
||||
////[|import [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 2 |}A|] = require("./a");|]
|
||||
////[|A|];
|
||||
|
||||
const [r0Def, r0, r1Def, r1, r2] = test.ranges();
|
||||
|
||||
@ -3,10 +3,10 @@
|
||||
// @allowJs: true
|
||||
|
||||
// @Filename: /a.js
|
||||
////[|exports.[|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 0 |}A|] = class {};|]
|
||||
////[|exports.[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}A|] = class {};|]
|
||||
|
||||
// @Filename: /b.js
|
||||
////[|import { [|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 2 |}A|] } from "./a";|]
|
||||
////[|import { [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 2 |}A|] } from "./a";|]
|
||||
////[|A|];
|
||||
|
||||
const [r0Def, r0, r1Def, r1, r2] = test.ranges();
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
////[|class [|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 0 |}C|] {
|
||||
////[|class [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}C|] {
|
||||
//// static s() {
|
||||
//// [|this|];
|
||||
//// }
|
||||
|
||||
@ -4,10 +4,10 @@
|
||||
|
||||
// @Filename: /a.js
|
||||
////function f() {
|
||||
//// [|this.[|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 0 |}x|] = 0;|]
|
||||
//// [|this.[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}x|] = 0;|]
|
||||
////}
|
||||
////f.prototype.setX = function() {
|
||||
//// [|this.[|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 2 |}x|] = 1;|]
|
||||
//// [|this.[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 2 |}x|] = 1;|]
|
||||
////}
|
||||
////f.prototype.useX = function() { this.[|x|]; }
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
////[|declare class [|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 0 |}C|] {
|
||||
////[|declare class [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}C|] {
|
||||
//// static m(): void;
|
||||
////}|]
|
||||
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
// @Filename: /a.ts
|
||||
////[|export default function [|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 0 |}a|]() {}|]
|
||||
////[|export default function [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}a|]() {}|]
|
||||
|
||||
// @Filename: /b.ts
|
||||
////[|import [|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 2 |}a|], * as ns from "./a";|]
|
||||
////[|import [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 2 |}a|], * as ns from "./a";|]
|
||||
|
||||
const [r0Def, r0, r1Def, r1] = test.ranges();
|
||||
const a: FourSlashInterface.ReferenceGroup = { definition: "function a(): void", ranges: [r0] };
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
// @Filename: /a.ts
|
||||
////[|export [|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 0 |}default|] function [|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 0 |}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,7 +10,7 @@
|
||||
////import { a } from "./b";
|
||||
////a.[|default|]();
|
||||
////
|
||||
////declare const x: { [|[|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 4 |}default|]: number|] };
|
||||
////declare const x: { [|[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 4 |}default|]: number|] };
|
||||
////x.[|default|];
|
||||
|
||||
const [r0Def, r0, r1, r2, r3Def, r3, r4] = test.ranges();
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
////[|const [|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 0 |}x|] = 0;|]
|
||||
////[|const [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}x|] = 0;|]
|
||||
////[|x|];
|
||||
|
||||
const ranges = test.rangesByText().get("x");
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
////interface I<T> {
|
||||
//// [|[|{| "isDefinition": true, "declarationRangeIndex": 0 |}x|]: boolean;|]
|
||||
//// [|[|{| "isDefinition": true, "contextRangeIndex": 0 |}x|]: boolean;|]
|
||||
////}
|
||||
////declare const i: I<number>;
|
||||
////[|const { [|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 2 |}x|] } = i;|]
|
||||
////[|const { [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 2 |}x|] } = i;|]
|
||||
|
||||
const [r0Def, r0, r1Def, r1] = test.ranges();
|
||||
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
////class Test {
|
||||
//// [|get [|{| "isDefinition": true, "isWriteAccess": true, "declarationRangeIndex": 0 |}x|]() { return 0; }|]
|
||||
//// [|get [|{| "isDefinition": true, "isWriteAccess": true, "contextRangeIndex": 0 |}x|]() { return 0; }|]
|
||||
////
|
||||
//// [|set [|{| "isDefinition": true, "isWriteAccess": true, "declarationRangeIndex": 2 |}y|](a: number) {}|]
|
||||
//// [|set [|{| "isDefinition": true, "isWriteAccess": true, "contextRangeIndex": 2 |}y|](a: number) {}|]
|
||||
////}
|
||||
////[|const { [|{| "isDefinition": true, "isWriteAccess": true, "declarationRangeIndex": 4 |}x|], [|{| "isDefinition": true, "isWriteAccess": true, "declarationRangeIndex": 4 |}y|] } = new Test();|]
|
||||
////[|const { [|{| "isDefinition": true, "isWriteAccess": true, "contextRangeIndex": 4 |}x|], [|{| "isDefinition": true, "isWriteAccess": true, "contextRangeIndex": 4 |}y|] } = new Test();|]
|
||||
////[|x|]; [|y|];
|
||||
|
||||
const [x0Def, x0, y0Def, y0, xy1Def, x1, y1, x2, y2] = test.ranges();
|
||||
|
||||
@ -4,11 +4,11 @@
|
||||
|
||||
// @Filename: /a.ts
|
||||
////class C {
|
||||
//// [|get [|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 0 |}g|](): number { return 0; }|]
|
||||
//// [|get [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}g|](): number { return 0; }|]
|
||||
////
|
||||
//// [|set [|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 2 |}s|](value: number) {}|]
|
||||
//// [|set [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 2 |}s|](value: number) {}|]
|
||||
////}
|
||||
////[|const { [|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 4 |}g|], [|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 4 |}s|] } = new C();|]
|
||||
////[|const { [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 4 |}g|], [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 4 |}s|] } = new C();|]
|
||||
|
||||
const [g0Def, g0, s0Def, s0, gs1Def, g1, s1] = test.ranges();
|
||||
verify.quickInfoAt(g0, "(property) C.g: number");
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
////[|enum [|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 0 |}E|] { A }|]
|
||||
////[|enum [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}E|] { A }|]
|
||||
////let e: [|E|].A;
|
||||
|
||||
verify.singleReferenceGroup("enum E", "E");
|
||||
|
||||
@ -3,11 +3,11 @@
|
||||
// `export as namespace` results in global search.
|
||||
|
||||
// @Filename: /node_modules/a/index.d.ts
|
||||
////[|export function [|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 0 |}f|](): void;|]
|
||||
////[|export function [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}f|](): void;|]
|
||||
////export as namespace A;
|
||||
|
||||
// @Filename: /b.ts
|
||||
////[|import { [|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 2 |}f|] } from "a";|]
|
||||
////[|import { [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 2 |}f|] } from "a";|]
|
||||
|
||||
// @Filename: /c.ts
|
||||
////A.[|f|]();
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
// @Filename: /a.ts
|
||||
////[|class [|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 0 |}C|] {}|]
|
||||
////[|export const [|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 2 |}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, "declarationRangeIndex": 5 |}D|] } from "./a";|]
|
||||
////[|import { [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 5 |}D|] } from "./a";|]
|
||||
|
||||
const [C0Def, C0, D0Def, D0, C1, D1Def, D1] = test.ranges();
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
////export default class {
|
||||
//// [|[|{| "declarationRangeIndex": 0 |}constructor|]() {}|]
|
||||
//// [|[|{| "contextRangeIndex": 0 |}constructor|]() {}|]
|
||||
////}
|
||||
|
||||
verify.singleReferenceGroup("class default", "constructor");
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
// @Filename: /a.ts
|
||||
////[|type [|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 0 |}T|] = number;|]
|
||||
////[|[|{| "declarationRangeIndex": 2 |}export|] = [|{| "declarationRangeIndex": 2 |}T|];|]
|
||||
////[|type [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}T|] = number;|]
|
||||
////[|[|{| "contextRangeIndex": 2 |}export|] = [|{| "contextRangeIndex": 2 |}T|];|]
|
||||
|
||||
// @Filename: /b.ts
|
||||
////[|import [|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 5 |}T|] = require("[|{| "declarationRangeIndex": 5 |}./a|]");|]
|
||||
////[|import [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 5 |}T|] = require("[|{| "contextRangeIndex": 5 |}./a|]");|]
|
||||
|
||||
const [r0Def, r0, r12Def, r1, r2, r3Def, r3, r4] = test.ranges();
|
||||
const mod = { definition: 'module "/a"', ranges: [r4, r1] };
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
////{
|
||||
//// [|export const [|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 0 |}x|] = 0;|]
|
||||
//// [|export const [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}x|] = 0;|]
|
||||
//// [|x|];
|
||||
////}
|
||||
|
||||
|
||||
@ -1,15 +1,15 @@
|
||||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
////interface I {
|
||||
//// [|["[|{| "isDefinition": true, "declarationRangeIndex": 0 |}prop1|]"]: () => void;|]
|
||||
//// [|["[|{| "isDefinition": true, "contextRangeIndex": 0 |}prop1|]"]: () => void;|]
|
||||
////}
|
||||
////
|
||||
////class C implements I {
|
||||
//// [|["[|{| "isDefinition": true, "declarationRangeIndex": 2 |}prop1|]"]: any;|]
|
||||
//// [|["[|{| "isDefinition": true, "contextRangeIndex": 2 |}prop1|]"]: any;|]
|
||||
////}
|
||||
////
|
||||
////var x: I = {
|
||||
//// [|["[|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 4 |}prop1|]"]: function () { }|],
|
||||
//// [|["[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 4 |}prop1|]"]: function () { }|],
|
||||
////}
|
||||
|
||||
const [r0Def, r0, r1Def, r1, r2Def, r2] = test.ranges();
|
||||
|
||||
@ -1,15 +1,15 @@
|
||||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
////interface I {
|
||||
//// [|[[|{| "isDefinition": true, "declarationRangeIndex": 0 |}42|]](): void;|]
|
||||
//// [|[[|{| "isDefinition": true, "contextRangeIndex": 0 |}42|]](): void;|]
|
||||
////}
|
||||
////
|
||||
////class C implements I {
|
||||
//// [|[[|{| "isDefinition": true, "declarationRangeIndex": 2 |}42|]]: any;|]
|
||||
//// [|[[|{| "isDefinition": true, "contextRangeIndex": 2 |}42|]]: any;|]
|
||||
////}
|
||||
////
|
||||
////var x: I = {
|
||||
//// [|["[|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 4 |}42|]"]: function () { }|]
|
||||
//// [|["[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 4 |}42|]"]: function () { }|]
|
||||
////}
|
||||
|
||||
const [r0Def, r0, r1Def, r1, r2Def, r2] = test.ranges();
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
// @Filename: a.ts
|
||||
////[|export default function /*def*/[|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 0 |}f|]() {}|]
|
||||
////[|export default function /*def*/[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}f|]() {}|]
|
||||
|
||||
// @Filename: b.ts
|
||||
////[|import [|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 2 |}g|] from "./a";|]
|
||||
////[|import [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 2 |}g|] from "./a";|]
|
||||
////[|/*ref*/g|]();
|
||||
|
||||
// @Filename: c.ts
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
////[|export default class [|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 0 |}DefaultExportedClass|] {
|
||||
////[|export default class [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}DefaultExportedClass|] {
|
||||
////}|]
|
||||
////
|
||||
////var x: [|DefaultExportedClass|];
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
////[|export default function [|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 0 |}DefaultExportedFunction|]() {
|
||||
////[|export default function [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}DefaultExportedFunction|]() {
|
||||
//// return [|DefaultExportedFunction|];
|
||||
////}|]
|
||||
////
|
||||
@ -8,7 +8,7 @@
|
||||
////
|
||||
////var y = [|DefaultExportedFunction|]();
|
||||
////
|
||||
////[|namespace [|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 5 |}DefaultExportedFunction|] {
|
||||
////[|namespace [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 5 |}DefaultExportedFunction|] {
|
||||
////}|]
|
||||
|
||||
|
||||
|
||||
@ -1,16 +1,16 @@
|
||||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
////[|function [|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 0 |}f|]() {
|
||||
////[|function [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}f|]() {
|
||||
//// return 100;
|
||||
////}|]
|
||||
////
|
||||
////[|export default [|{| "declarationRangeIndex": 2 |}f|];|]
|
||||
////[|export default [|{| "contextRangeIndex": 2 |}f|];|]
|
||||
////
|
||||
////var x: typeof [|f|];
|
||||
////
|
||||
////var y = [|f|]();
|
||||
////
|
||||
////[|namespace [|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 6 |}f|] {
|
||||
////[|namespace [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 6 |}f|] {
|
||||
//// var local = 100;
|
||||
////}|]
|
||||
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
// @Filename: /a.ts
|
||||
////[|const [|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 0 |}a|] = 0;|]
|
||||
////[|export [|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 2 |}default|] [|{| "declarationRangeIndex": 2 |}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, "declarationRangeIndex": 5 |}a|] from "./a";|]
|
||||
////[|import [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 5 |}a|] from "./a";|]
|
||||
////[|a|];
|
||||
|
||||
const [r0Def, r0, r1Def, r1, r2, r3Def, r3, r4] = test.ranges();
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
////
|
||||
////var y = new DefaultExportedClass;
|
||||
////
|
||||
////[|namespace [|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 0 |}DefaultExportedClass|] {
|
||||
////[|namespace [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}DefaultExportedClass|] {
|
||||
////}|]
|
||||
|
||||
verify.noErrors();
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
// @Filename: /a.ts
|
||||
////[|export [|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 0 |}default|] function() {}|]
|
||||
////[|export [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}default|] function() {}|]
|
||||
|
||||
// @Filename: /b.ts
|
||||
////[|import [|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 2 |}f|] from "./a";|]
|
||||
////[|import [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 2 |}f|] from "./a";|]
|
||||
|
||||
const [r0Def, r0, r1Def, r1] = test.ranges();
|
||||
verify.referenceGroups(r0, [
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
// @Filename: /a.ts
|
||||
////[|export [|{| "isDefinition": true, "isWriteAccess": true, "declarationRangeIndex": 0 |}default|] 1;|]
|
||||
////[|export [|{| "isDefinition": true, "isWriteAccess": true, "contextRangeIndex": 0 |}default|] 1;|]
|
||||
|
||||
// @Filename: /b.ts
|
||||
////[|import [|{| "isDefinition": true, "isWriteAccess": true, "declarationRangeIndex": 2 |}a|] from "./a";|]
|
||||
////[|import [|{| "isDefinition": true, "isWriteAccess": true, "contextRangeIndex": 2 |}a|] from "./a";|]
|
||||
|
||||
const [r0Def, r0, r1Def, r1] = test.ranges();
|
||||
verify.referenceGroups(r0, [
|
||||
|
||||
@ -1,14 +1,14 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
// @Filename: /export.ts
|
||||
////[|const [|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 0 |}foo|] = 1;|]
|
||||
////[|export default [|{| "declarationRangeIndex": 2 |}foo|];|]
|
||||
////[|const [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}foo|] = 1;|]
|
||||
////[|export default [|{| "contextRangeIndex": 2 |}foo|];|]
|
||||
|
||||
// @Filename: /re-export.ts
|
||||
////[|export { [|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 4 |}default|] } from "./export";|]
|
||||
////[|export { [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 4 |}default|] } from "./export";|]
|
||||
|
||||
// @Filename: /re-export-dep.ts
|
||||
////[|import [|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 6 |}fooDefault|] from "./re-export";|]
|
||||
////[|import [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 6 |}fooDefault|] from "./re-export";|]
|
||||
|
||||
const [r0Def, r0, r1Def, r1, r2Def, r2, r3Def, r3] = test.ranges();
|
||||
verify.referenceGroups([r0, r1], [
|
||||
|
||||
@ -3,14 +3,14 @@
|
||||
// @allowSyntheticDefaultImports: true
|
||||
|
||||
// @Filename: /export.ts
|
||||
////[|const [|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 0 |}foo|] = 1;|]
|
||||
////[|export = [|{| "declarationRangeIndex": 2 |}foo|];|]
|
||||
////[|const [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}foo|] = 1;|]
|
||||
////[|export = [|{| "contextRangeIndex": 2 |}foo|];|]
|
||||
|
||||
// @Filename: /re-export.ts
|
||||
////[|export { [|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 4 |}default|] } from "./export";|]
|
||||
////[|export { [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 4 |}default|] } from "./export";|]
|
||||
|
||||
// @Filename: /re-export-dep.ts
|
||||
////[|import [|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 6 |}fooDefault|] from "./re-export";|]
|
||||
////[|import [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 6 |}fooDefault|] from "./re-export";|]
|
||||
|
||||
verify.noErrors();
|
||||
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
// @Filename: file1.ts
|
||||
////var foo = [|function [|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 0 |}foo|](a = [|foo|](), b = () => [|foo|]) {
|
||||
////var foo = [|function [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}foo|](a = [|foo|](), b = () => [|foo|]) {
|
||||
//// [|foo|]([|foo|], [|foo|]);
|
||||
////}|]
|
||||
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
////interface T { [|[|{| "isDefinition": true, "declarationRangeIndex": 0 |}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, "declarationRangeIndex": 2 |}a|]: ""|] }
|
||||
////const v: V = { [|[|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 4 |}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", "a");
|
||||
|
||||
@ -6,10 +6,10 @@
|
||||
////export const x = 0;
|
||||
|
||||
// @Filename: /b.ts
|
||||
////[|import { x } from "[|{| "declarationRangeIndex": 0 |}./a|]";|]
|
||||
////[|import { x } from "[|{| "contextRangeIndex": 0 |}./a|]";|]
|
||||
|
||||
// @Filename: /c/sub.js
|
||||
////[|const a = require("[|{| "declarationRangeIndex": 2 |}../a|]");|]
|
||||
////[|const a = require("[|{| "contextRangeIndex": 2 |}../a|]");|]
|
||||
|
||||
// @Filename: /d.ts
|
||||
//// /// <reference path="[|./a.ts|]" />
|
||||
|
||||
@ -5,8 +5,8 @@
|
||||
|
||||
// @Filename: /b.ts
|
||||
/////// <reference types="[|foo|]" />
|
||||
////[|import { x } from "[|{| "declarationRangeIndex": 1 |}foo|]";|]
|
||||
////[|declare module "[|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 3 |}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"', "foo");
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
////var x = {
|
||||
//// [|[|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 0 |}property|]: {}|]
|
||||
//// [|[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}property|]: {}|]
|
||||
////};
|
||||
////
|
||||
////x.[|property|];
|
||||
////
|
||||
////[|let {[|{| "declarationRangeIndex": 3 |}property|]: pVar} = x;|]
|
||||
////[|let {[|{| "contextRangeIndex": 3 |}property|]: pVar} = x;|]
|
||||
|
||||
verify.singleReferenceGroup("(property) property: {}", "property");
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
////interface A1 { [|readonly [|{| "isDefinition": true, "declarationRangeIndex": 0 |}a|]: string|] };
|
||||
////interface A2 { [|[|{| "isDefinition": true, "declarationRangeIndex": 2 |}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 };
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
/// <reference path='fourslash.ts'/>
|
||||
////interface Gen {
|
||||
//// x: number
|
||||
//// [|[|{| "isDefinition": true, "declarationRangeIndex": 0 |}parent|]: Gen;|]
|
||||
//// [|[|{| "isDefinition": true, "contextRangeIndex": 0 |}parent|]: Gen;|]
|
||||
//// millenial: string;
|
||||
////}
|
||||
////let t: Gen;
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
//// export function doThing(): string;
|
||||
//// export function doTheOtherThing(): void;
|
||||
|
||||
//// [|export as namespace [|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 0 |}myLib|];|]
|
||||
//// [|export as namespace [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}myLib|];|]
|
||||
|
||||
// @Filename: 1.ts
|
||||
//// /// <reference path="0.d.ts" />
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/// <reference path="fourslash.ts"/>
|
||||
|
||||
////[|var [|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 0 |}Base|] = class { };|]
|
||||
////[|var [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}Base|] = class { };|]
|
||||
////class C extends [|Base|] { }
|
||||
|
||||
verify.singleReferenceGroup("var Base: typeof Base", "Base");
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/// <reference path="fourslash.ts"/>
|
||||
|
||||
////[|interface [|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 0 |}Base|] { }|]
|
||||
////[|interface [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}Base|] { }|]
|
||||
////namespace n {
|
||||
//// var Base = class { };
|
||||
//// interface I extends [|Base|] { }
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
// @Filename: /a.ts
|
||||
////export {};
|
||||
////declare global {
|
||||
//// [|function [|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 0 |}f|](): void;|]
|
||||
//// [|function [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}f|](): void;|]
|
||||
////}
|
||||
|
||||
// @Filename: /b.ts
|
||||
|
||||
@ -1,13 +1,13 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
// @Filename: f.ts
|
||||
////[|export { [|{| "declarationRangeIndex": 0 |}foo|] as [|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 0 |}default|] };|]
|
||||
////[|function /*start*/[|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 3 |}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, "declarationRangeIndex": 5 |}bar|] from "./f";|]
|
||||
////[|import [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 5 |}bar|] from "./f";|]
|
||||
////[|bar|](1, 2);
|
||||
|
||||
verify.noErrors();
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
////import j = N./**/ [|q|];
|
||||
////namespace N { [|export const [|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 1 |}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.rangesByText().get("q") }]);
|
||||
|
||||
@ -5,11 +5,11 @@
|
||||
// @resolveJsonModule: true
|
||||
|
||||
// @Filename: /a.ts
|
||||
////[|import [|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 0 |}j|] = require("[|{| "declarationRangeIndex": 0 |}./j.json|]");|]
|
||||
////[|import [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}j|] = require("[|{| "contextRangeIndex": 0 |}./j.json|]");|]
|
||||
////[|j|];
|
||||
|
||||
// @Filename: /b.js
|
||||
////[|const [|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 4 |}j|] = require("[|{| "declarationRangeIndex": 4 |}./j.json|]");|]
|
||||
////[|const [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 4 |}j|] = require("[|{| "contextRangeIndex": 4 |}./j.json|]");|]
|
||||
////[|j|];
|
||||
|
||||
// @Filename: /j.json
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
// @Filename: f.ts
|
||||
////[|export { [|{| "declarationRangeIndex": 0 |}foo|] as [|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 0 |}foo|] }|]
|
||||
////[|function /*start*/[|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 3 |}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");
|
||||
|
||||
@ -2,21 +2,21 @@
|
||||
|
||||
// @allowSyntheticDefaultimports: true
|
||||
// @Filename: /node_modules/a/index.d.ts
|
||||
////[|declare function [|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 0 |}a|](): void;|]
|
||||
////[|declare namespace [|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 2 |}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 = [|{| "declarationRangeIndex": 4 |}a|];|]
|
||||
////[|export = [|{| "contextRangeIndex": 4 |}a|];|]
|
||||
|
||||
// Import with different name and we find local refs
|
||||
// @Filename: /b.ts
|
||||
////[|import [|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 6 |}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, "declarationRangeIndex": 10 |}a|] from "a";|]
|
||||
////[|import [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 10 |}a|] from "a";|]
|
||||
////[|a|]();
|
||||
////[|a|].x;
|
||||
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
|
||||
// @Filename: /a.js
|
||||
////module.exports = 0;
|
||||
////[|export type [|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 0 |}N|] = number;|]
|
||||
////[|export type [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}N|] = number;|]
|
||||
|
||||
// @Filename: /b.js
|
||||
////type T = import("./a").[|N|];
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
////interface I { [|[|{| "isDefinition": true, "declarationRangeIndex": 0 |}boom|](): void;|] }
|
||||
////interface I { [|[|{| "isDefinition": true, "contextRangeIndex": 0 |}boom|](): void;|] }
|
||||
////new class C implements I {
|
||||
//// [|[|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 2 |}boom|](){}|]
|
||||
//// [|[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 2 |}boom|](){}|]
|
||||
////}
|
||||
|
||||
const [r0Def, r0, r1Def, r1] = test.ranges();
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
////interface I {
|
||||
//// [|[|{| "isDefinition": true, "declarationRangeIndex": 0 |}0|]: number;|]
|
||||
//// [|[|{| "isDefinition": true, "declarationRangeIndex": 2 |}s|]: string;|]
|
||||
//// [|[|{| "isDefinition": true, "contextRangeIndex": 0 |}0|]: number;|]
|
||||
//// [|[|{| "isDefinition": true, "contextRangeIndex": 2 |}s|]: string;|]
|
||||
////}
|
||||
////interface J {
|
||||
//// a: I[[|0|]],
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
//// class class1 extends class1 {
|
||||
//// [|[|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 0 |}doStuff|]() { }|]
|
||||
//// [|[|{| "isDefinition": true, "declarationRangeIndex": 2 |}propName|]: string;|]
|
||||
//// [|[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}doStuff|]() { }|]
|
||||
//// [|[|{| "isDefinition": true, "contextRangeIndex": 2 |}propName|]: string;|]
|
||||
//// }
|
||||
////
|
||||
//// var v: class1;
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
//// interface interface1 extends interface1 {
|
||||
//// [|[|{| "isDefinition": true, "declarationRangeIndex": 0 |}doStuff|](): void;|] // r0
|
||||
//// [|[|{| "isDefinition": true, "declarationRangeIndex": 2 |}propName|]: string;|] // r1
|
||||
//// [|[|{| "isDefinition": true, "contextRangeIndex": 0 |}doStuff|](): void;|] // r0
|
||||
//// [|[|{| "isDefinition": true, "contextRangeIndex": 2 |}propName|]: string;|] // r1
|
||||
//// }
|
||||
////
|
||||
//// var v: interface1;
|
||||
|
||||
@ -1,16 +1,16 @@
|
||||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
//// class class1 extends class1 {
|
||||
//// [|[|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 0 |}doStuff|]() { }|] // r0
|
||||
//// [|[|{| "isDefinition": true, "declarationRangeIndex": 2 |}propName|]: string;|] // r1
|
||||
//// [|[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}doStuff|]() { }|] // r0
|
||||
//// [|[|{| "isDefinition": true, "contextRangeIndex": 2 |}propName|]: string;|] // r1
|
||||
//// }
|
||||
//// interface interface1 extends interface1 {
|
||||
//// [|[|{| "isDefinition": true, "declarationRangeIndex": 4 |}doStuff|](): void;|] // r2
|
||||
//// [|[|{| "isDefinition": true, "declarationRangeIndex": 6 |}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, "declarationRangeIndex": 8 |}doStuff|]() { }|] // r4
|
||||
//// [|[|{| "isDefinition": true, "declarationRangeIndex": 10 |}propName|]: string;|] // r5
|
||||
//// [|[|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 8 |}doStuff|]() { }|] // r4
|
||||
//// [|[|{| "isDefinition": true, "contextRangeIndex": 10 |}propName|]: string;|] // r5
|
||||
//// }
|
||||
////
|
||||
//// var v: class2;
|
||||
|
||||
@ -1,12 +1,12 @@
|
||||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
//// interface C extends D {
|
||||
//// [|[|{| "isDefinition": true, "declarationRangeIndex": 0 |}prop0|]: string;|] // r0
|
||||
//// [|[|{| "isDefinition": true, "declarationRangeIndex": 2 |}prop1|]: number;|] // r1
|
||||
//// [|[|{| "isDefinition": true, "contextRangeIndex": 0 |}prop0|]: string;|] // r0
|
||||
//// [|[|{| "isDefinition": true, "contextRangeIndex": 2 |}prop1|]: number;|] // r1
|
||||
//// }
|
||||
////
|
||||
//// interface D extends C {
|
||||
//// [|[|{| "isDefinition": true, "declarationRangeIndex": 4 |}prop0|]: string;|] // r2
|
||||
//// [|[|{| "isDefinition": true, "contextRangeIndex": 4 |}prop0|]: string;|] // r2
|
||||
//// }
|
||||
////
|
||||
//// var d: D;
|
||||
|
||||
@ -1,12 +1,12 @@
|
||||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
//// class C extends D {
|
||||
//// [|[|{| "isDefinition": true, "declarationRangeIndex": 0 |}prop0|]: string;|] // r0
|
||||
//// [|[|{| "isDefinition": true, "declarationRangeIndex": 2 |}prop1|]: number;|] // r1
|
||||
//// [|[|{| "isDefinition": true, "contextRangeIndex": 0 |}prop0|]: string;|] // r0
|
||||
//// [|[|{| "isDefinition": true, "contextRangeIndex": 2 |}prop1|]: number;|] // r1
|
||||
//// }
|
||||
////
|
||||
//// class D extends C {
|
||||
//// [|[|{| "isDefinition": true, "declarationRangeIndex": 4 |}prop0|]: string;|] // r2
|
||||
//// [|[|{| "isDefinition": true, "contextRangeIndex": 4 |}prop0|]: string;|] // r2
|
||||
//// }
|
||||
////
|
||||
//// var d: D;
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
////[|var [|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 0 |}x|] = 10;|]
|
||||
////[|var [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}x|] = 10;|]
|
||||
////var y = `${ [|x|] } ${ [|x|] }`
|
||||
|
||||
verify.singleReferenceGroup("var x: number", "x");
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
////[|function [|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 0 |}f|](...rest: any[]) { }|]
|
||||
////[|function [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}f|](...rest: any[]) { }|]
|
||||
////[|f|] `${ [|f|] } ${ [|f|] }`
|
||||
|
||||
verify.singleReferenceGroup("function f(...rest: any[]): void", "f");
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
////[|var [|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 0 |}x|] = 0;|]
|
||||
////[|var [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}x|] = 0;|]
|
||||
////
|
||||
////with ({}) {
|
||||
//// var y = x; // Reference of x here should not be picked
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
// @allowJs: true
|
||||
|
||||
// @Filename: /a.js
|
||||
/////** [|@typedef {number} [|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 0 |}T|]|] */
|
||||
/////** [|@typedef {number} [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}T|]|] */
|
||||
////
|
||||
/////**
|
||||
//// * @return {[|T|]}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
////interface T { [|[|{| "isDefinition": true, "declarationRangeIndex": 0 |}a|]: number;|] }
|
||||
////interface T { [|[|{| "isDefinition": true, "contextRangeIndex": 0 |}a|]: number;|] }
|
||||
////type U = { readonly [K in keyof T]?: string };
|
||||
////declare const t: T;
|
||||
////t.[|a|];
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
// @Filename: /node_modules/foo/index.d.ts
|
||||
////[|export type [|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 0 |}T|] = number;|]
|
||||
////[|export type [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}T|] = number;|]
|
||||
|
||||
// @Filename: /a.ts
|
||||
////import * as foo from "foo";
|
||||
|
||||
@ -3,10 +3,10 @@
|
||||
// @allowJs: true
|
||||
|
||||
// @Filename: /a.js
|
||||
////[|const b = require("[|{| "declarationRangeIndex": 0 |}./b|]");|]
|
||||
////[|const b = require("[|{| "contextRangeIndex": 0 |}./b|]");|]
|
||||
|
||||
// @Filename: /b.js
|
||||
////[|[|{| "declarationRangeIndex": 2 |}module|].exports = 0;|]
|
||||
////[|[|{| "contextRangeIndex": 2 |}module|].exports = 0;|]
|
||||
|
||||
const [r0Def, r0, rDef, r1] = test.ranges();
|
||||
verify.singleReferenceGroup('module "/b"', [r0, r1]);
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
// https://github.com/Microsoft/TypeScript/issues/15452
|
||||
|
||||
// @Filename: /a.ts
|
||||
////[|export const [|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 0 |}x|] = 0;|]
|
||||
////[|export const [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 0 |}x|] = 0;|]
|
||||
|
||||
// @Filename: /b.ts
|
||||
////import "./a";
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
////interface I {
|
||||
//// [|[|{| "isDefinition": true, "declarationRangeIndex": 0 |}property1|]: number;|]
|
||||
//// [|[|{| "isDefinition": true, "contextRangeIndex": 0 |}property1|]: number;|]
|
||||
//// property2: string;
|
||||
////}
|
||||
////
|
||||
////var foo: I;
|
||||
////[|var { [|{| "declarationRangeIndex": 2 |}property1|]: prop1 } = foo;|]
|
||||
////[|var { [|{| "contextRangeIndex": 2 |}property1|]: prop1 } = foo;|]
|
||||
|
||||
verify.singleReferenceGroup("(property) I.property1: number", "property1");
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
////interface I {
|
||||
//// [|[|{| "isDefinition": true, "declarationRangeIndex": 0 |}property1|]: number;|]
|
||||
//// [|[|{| "isDefinition": true, "contextRangeIndex": 0 |}property1|]: number;|]
|
||||
//// property2: string;
|
||||
////}
|
||||
////
|
||||
////var foo: I;
|
||||
////[|var { [|{| "declarationRangeIndex": 2 |}property1|]: {} } = foo;|]
|
||||
////[|var { [|{| "contextRangeIndex": 2 |}property1|]: {} } = foo;|]
|
||||
|
||||
verify.singleReferenceGroup("(property) I.property1: number", "property1");
|
||||
|
||||
@ -1,12 +1,12 @@
|
||||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
////interface I {
|
||||
//// [|[|{| "isDefinition": true, "declarationRangeIndex": 0 |}property1|]: number;|]
|
||||
//// [|[|{| "isDefinition": true, "contextRangeIndex": 0 |}property1|]: number;|]
|
||||
//// property2: string;
|
||||
////}
|
||||
////
|
||||
////var foo: I;
|
||||
////[|var [{ [|{| "declarationRangeIndex": 2 |}property1|]: prop1 }, { [|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 2 |}property1|], property2 } ] = [foo, foo];|]
|
||||
////[|var [{ [|{| "contextRangeIndex": 2 |}property1|]: prop1 }, { [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 2 |}property1|], property2 } ] = [foo, foo];|]
|
||||
|
||||
const [r0Def, r0, r1Def, r1, r2] = test.ranges();
|
||||
verify.referenceGroups([r0, r1], [{
|
||||
|
||||
@ -1,12 +1,12 @@
|
||||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
////interface I {
|
||||
//// [|[|{| "isDefinition": true, "declarationRangeIndex": 0 |}property1|]: number;|]
|
||||
//// [|[|{| "isDefinition": true, "contextRangeIndex": 0 |}property1|]: number;|]
|
||||
//// property2: string;
|
||||
////}
|
||||
////
|
||||
////function f([|{ [|{| "declarationRangeIndex": 2 |}property1|]: p1 }: I|],
|
||||
//// [|{ [|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 4 |}property1|] }: I|],
|
||||
////function f([|{ [|{| "contextRangeIndex": 2 |}property1|]: p1 }: I|],
|
||||
//// [|{ [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 4 |}property1|] }: I|],
|
||||
//// { property1: p2 }) {
|
||||
////
|
||||
//// return [|property1|] + 1;
|
||||
|
||||
@ -1,19 +1,19 @@
|
||||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
////interface I {
|
||||
//// [|[|{| "isDefinition": true, "declarationRangeIndex": 0 |}property1|]: number;|]
|
||||
//// [|[|{| "isDefinition": true, "contextRangeIndex": 0 |}property1|]: number;|]
|
||||
//// property2: string;
|
||||
////}
|
||||
////
|
||||
////var elems: I[];
|
||||
////for ([|let { [|{| "declarationRangeIndex": 2 |}property1|]: p } of elems|]) {
|
||||
////for ([|let { [|{| "contextRangeIndex": 2 |}property1|]: p } of elems|]) {
|
||||
////}
|
||||
////for ([|let { [|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 4 |}property1|] } of elems|]) {
|
||||
////for ([|let { [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 4 |}property1|] } of elems|]) {
|
||||
////}
|
||||
////for ([|var { [|{| "declarationRangeIndex": 6 |}property1|]: p1 } of elems|]) {
|
||||
////for ([|var { [|{| "contextRangeIndex": 6 |}property1|]: p1 } of elems|]) {
|
||||
////}
|
||||
////var p2;
|
||||
////for ([|{ [|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 8 |}property1|] : p2 } of elems|]) {
|
||||
////for ([|{ [|{| "isWriteAccess": true, "isDefinition": true, "contextRangeIndex": 8 |}property1|] : p2 } of elems|]) {
|
||||
////}
|
||||
|
||||
const [r0Def, r0, r1Def, r1, r2Def, r2, r3Def, r3, r4Def, r4] = test.ranges();
|
||||
|
||||
@ -2,6 +2,6 @@
|
||||
|
||||
////let p, b;
|
||||
////
|
||||
////p, [|[{ [|{| "isDefinition": true, "declarationRangeIndex": 0 |}a|]: p, b }] = [{ [|[|{| "isWriteAccess": true, "isDefinition": true, "declarationRangeIndex": 2 |}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", "a");
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
////interface Recursive {
|
||||
//// [|[|{| "isDefinition": true, "declarationRangeIndex": 0 |}next|]?: Recursive;|]
|
||||
//// [|[|{| "isDefinition": true, "contextRangeIndex": 0 |}next|]?: Recursive;|]
|
||||
//// value: any;
|
||||
////}
|
||||
////
|
||||
////function f ([|{ [|{| "declarationRangeIndex": 2 |}next|]: { [|{| "declarationRangeIndex": 2 |}next|]: x} }: Recursive|]) {
|
||||
////function f ([|{ [|{| "contextRangeIndex": 2 |}next|]: { [|{| "contextRangeIndex": 2 |}next|]: x} }: Recursive|]) {
|
||||
////}
|
||||
|
||||
verify.singleReferenceGroup("(property) Recursive.next?: Recursive", "next");
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user